make socket_(tc|ud)p[46] actually return non-blocking sockets as

documented (Richard Lyons)
This commit is contained in:
leitner
2006-05-18 06:02:43 +00:00
parent db2ab20d9f
commit d361d81c64
25 changed files with 142 additions and 22 deletions

23
textcode/fmt_ldapescape.c Normal file
View File

@@ -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;
}

View File

@@ -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;
}