mirror of /home/gitosis/repositories/libowfat.git
parent
1341bf04de
commit
071df9ee4a
25 changed files with 142 additions and 22 deletions
@ -1,12 +1,18 @@ |
||||
#include <sys/types.h> |
||||
#ifndef __MINGW32__ |
||||
#include <unistd.h> |
||||
#include <sys/socket.h> |
||||
#include <netinet/in.h> |
||||
#endif |
||||
#include "windoze.h" |
||||
#include "socket.h" |
||||
#include "ndelay.h" |
||||
|
||||
int socket_tcp4(void) { |
||||
int s; |
||||
__winsock_init(); |
||||
return winsock2errno(socket(PF_INET,SOCK_STREAM,IPPROTO_TCP)); |
||||
s = winsock2errno(socket(PF_INET,SOCK_STREAM,IPPROTO_TCP)); |
||||
if (s == -1) return -1; |
||||
if (ndelay_on(s) == -1) { close(s); return -1; } |
||||
return s; |
||||
} |
||||
|
@ -1,13 +1,19 @@ |
||||
#include <sys/types.h> |
||||
#ifndef __MINGW32__ |
||||
#include <unistd.h> |
||||
#include <sys/socket.h> |
||||
#include <netinet/in.h> |
||||
#endif |
||||
#include "windoze.h" |
||||
|
||||
#include "socket.h" |
||||
#include "ndelay.h" |
||||
|
||||
int socket_udp4(void) { |
||||
int s; |
||||
__winsock_init(); |
||||
return winsock2errno(socket(PF_INET,SOCK_DGRAM,IPPROTO_UDP)); |
||||
s = winsock2errno(socket(PF_INET,SOCK_DGRAM,IPPROTO_UDP)); |
||||
if (s == -1) return -1; |
||||
if (ndelay_on(s) == -1) { close(s); return -1; } |
||||
return s; |
||||
} |
||||
|
@ -0,0 +1,23 @@ |
||||
#include "fmt.h" |
||||
#include "textcode.h" |
||||
#include "haveinline.h" |
||||
#include "str.h" |
||||
|
||||
unsigned long fmt_ldapescape(char* dest,const char* src,unsigned long len) { |
||||
register const unsigned char* s=(const unsigned char*) src; |
||||
unsigned long written=0,i; |
||||
for (i=0; i<len; ++i) { |
||||
if (s[i]=='*' || s[i]=='(' || s[i]==')' || s[i]==0 || s[i]=='\\') { |
||||
if (dest) { |
||||
dest[written]='\\'; |
||||
dest[written+1]=fmt_tohex(s[i]>>4); |
||||
dest[written+2]=fmt_tohex(s[i]&15); |
||||
} |
||||
written+=3; |
||||
} else { |
||||
if (dest) dest[written]=s[i]; ++written; |
||||
} |
||||
} |
||||
return written; |
||||
} |
||||
|
@ -0,0 +1,24 @@ |
||||
#include "fmt.h" |
||||
#include "textcode.h" |
||||
#include "scan.h" |
||||
|
||||
unsigned long scan_ldapescape(const char *src,char *dest,unsigned long *destlen) { |
||||
register const unsigned char* s=(const unsigned char*) src; |
||||
unsigned long written=0,i; |
||||
for (i=0; s[i]; ++i) { |
||||
if (s[i]=='\\') { |
||||
int j=scan_fromhex(s[i+1]); |
||||
if (j<0) break; |
||||
dest[written]=j<<4; |
||||
j=scan_fromhex(s[i+2]); |
||||
if (j<0) break; |
||||
dest[written]|=j; |
||||
i+=2; |
||||
} else { |
||||
dest[written]=s[i]; |
||||
} |
||||
++written; |
||||
} |
||||
*destlen=written; |
||||
return i; |
||||
} |
Loading…
Reference in new issue