summaryrefslogtreecommitdiff
path: root/src/login_sql/strlib.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/login_sql/strlib.c')
-rw-r--r--src/login_sql/strlib.c92
1 files changed, 49 insertions, 43 deletions
diff --git a/src/login_sql/strlib.c b/src/login_sql/strlib.c
index 7f6e197..5c87ef6 100644
--- a/src/login_sql/strlib.c
+++ b/src/login_sql/strlib.c
@@ -7,52 +7,58 @@
//-----------------------------------------------
// string lib.
-unsigned char* jstrescape (unsigned char* pt) {
- //copy from here
- unsigned char * ptr;
- int i =0, j=0;
+unsigned char *jstrescape (unsigned char *pt)
+{
+ //copy from here
+ unsigned char *ptr;
+ int i = 0, j = 0;
- //copy string to temporary
- CREATE(ptr, char, J_MAX_MALLOC_SIZE);
- strcpy (ptr,pt);
+ //copy string to temporary
+ CREATE (ptr, char, J_MAX_MALLOC_SIZE);
+ strcpy (ptr, pt);
- while (ptr[i] != '\0') {
- switch (ptr[i]) {
- case '\'':
- pt[j++] = '\\';
- pt[j++] = ptr[i++];
- break;
- case '\\':
- pt[j++] = '\\';
- pt[j++] = ptr[i++];
- break;
- default:
- pt[j++] = ptr[i++];
- }
- }
- pt[j++] = '\0';
- free (ptr);
- return (unsigned char*) &pt[0];
+ while (ptr[i] != '\0')
+ {
+ switch (ptr[i])
+ {
+ case '\'':
+ pt[j++] = '\\';
+ pt[j++] = ptr[i++];
+ break;
+ case '\\':
+ pt[j++] = '\\';
+ pt[j++] = ptr[i++];
+ break;
+ default:
+ pt[j++] = ptr[i++];
+ }
+ }
+ pt[j++] = '\0';
+ free (ptr);
+ return (unsigned char *) &pt[0];
}
-unsigned char* jstrescapecpy (unsigned char* pt,unsigned char* spt) {
- //copy from here
- int i =0, j=0;
+unsigned char *jstrescapecpy (unsigned char *pt, unsigned char *spt)
+{
+ //copy from here
+ int i = 0, j = 0;
- while (spt[i] != '\0') {
- switch (spt[i]) {
- case '\'':
- pt[j++] = '\\';
- pt[j++] = spt[i++];
- break;
- case '\\':
- pt[j++] = '\\';
- pt[j++] = spt[i++];
- break;
- default:
- pt[j++] = spt[i++];
- }
- }
- pt[j++] = '\0';
- return (unsigned char*) &pt[0];
+ while (spt[i] != '\0')
+ {
+ switch (spt[i])
+ {
+ case '\'':
+ pt[j++] = '\\';
+ pt[j++] = spt[i++];
+ break;
+ case '\\':
+ pt[j++] = '\\';
+ pt[j++] = spt[i++];
+ break;
+ default:
+ pt[j++] = spt[i++];
+ }
+ }
+ pt[j++] = '\0';
+ return (unsigned char *) &pt[0];
}