summaryrefslogtreecommitdiff
path: root/src/txt-converter/char/strlib.c
diff options
context:
space:
mode:
authorDennis Friis <peavey@placid.dk>2008-04-02 15:09:18 +0000
committerDennis Friis <peavey@placid.dk>2008-04-02 15:09:18 +0000
commit97bb21a79949779df76269b087f3bce7ef8179ee (patch)
tree08b3bdee2f3596581dd8d8f051afd37ee648cee7 /src/txt-converter/char/strlib.c
parentdafdbbe9f1db3e6943003a79a6e23c00da2f2fe1 (diff)
downloadtmwa-97bb21a79949779df76269b087f3bce7ef8179ee.tar.gz
tmwa-97bb21a79949779df76269b087f3bce7ef8179ee.tar.bz2
tmwa-97bb21a79949779df76269b087f3bce7ef8179ee.tar.xz
tmwa-97bb21a79949779df76269b087f3bce7ef8179ee.zip
initial checkin
Diffstat (limited to 'src/txt-converter/char/strlib.c')
-rw-r--r--src/txt-converter/char/strlib.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/txt-converter/char/strlib.c b/src/txt-converter/char/strlib.c
new file mode 100644
index 0000000..60803c1
--- /dev/null
+++ b/src/txt-converter/char/strlib.c
@@ -0,0 +1,66 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "strlib.h"
+
+//-----------------------------------------------
+// string lib.
+unsigned char* jstrescape (unsigned char* pt) {
+ //copy from here
+ unsigned char * ptr;
+ int i =0, j=0;
+
+ //copy string to temporary
+ ptr = malloc(J_MAX_MALLOC_SIZE);
+ strcpy (ptr,pt);
+
+ while (ptr[i] != '\0') {
+ switch (ptr[i]) {
+ 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;
+ 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;
+ default:
+ pt[j++] = spt[i++];
+ }
+ }
+ // copy size is 0 ~ (j-1)
+ return j;
+}