diff options
author | wizputer <wizputer@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2004-11-27 19:32:30 +0000 |
---|---|---|
committer | wizputer <wizputer@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2004-11-27 19:32:30 +0000 |
commit | 486b4f2a12b41507b67a1a93ae5871b3be447914 (patch) | |
tree | 8196d22d0fce973ac6e53b24735776ba9dcaf77f /src/char_sql/strlib.c | |
parent | ecb15e6101bc1912bb2520151c45ed69af80feb8 (diff) | |
parent | f0da8da932031212f34aa97eff882f72cb69cc2a (diff) | |
download | hercules-486b4f2a12b41507b67a1a93ae5871b3be447914.tar.gz hercules-486b4f2a12b41507b67a1a93ae5871b3be447914.tar.bz2 hercules-486b4f2a12b41507b67a1a93ae5871b3be447914.tar.xz hercules-486b4f2a12b41507b67a1a93ae5871b3be447914.zip |
correct directory structure
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@387 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/char_sql/strlib.c')
-rw-r--r-- | src/char_sql/strlib.c | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/src/char_sql/strlib.c b/src/char_sql/strlib.c new file mode 100644 index 000000000..b113d96f5 --- /dev/null +++ b/src/char_sql/strlib.c @@ -0,0 +1,79 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "strlib.h" +#include "utils.h" + +//----------------------------------------------- +// string lib. +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); + + 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; + + 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]; +} +int jmemescapecpy (unsigned char* pt,unsigned char* spt, int size) { + //copy from here + int i =0, j=0; + + while (i < size) { + switch (spt[i]) { + case '\'': + pt[j++] = '\\'; + pt[j++] = spt[i++]; + break; + case '\\': + pt[j++] = '\\'; + pt[j++] = spt[i++]; + break; + default: + pt[j++] = spt[i++]; + } + } + // copy size is 0 ~ (j-1) + return j; +} |