make socket_(tc|ud)p[46] actually return non-blocking sockets as
documented (Richard Lyons)
This commit is contained in:
23
textcode/fmt_ldapescape.c
Normal file
23
textcode/fmt_ldapescape.c
Normal 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;
|
||||
}
|
||||
|
||||
24
textcode/scan_ldapescape.c
Normal file
24
textcode/scan_ldapescape.c
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user