blob: 2b130e76d182acf8eb8a5b7e861d6f864c85a76d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "strlib.h"
#include "utils.h"
#include "malloc.h"
//-----------------------------------------------
// string lib.
char* jstrescape (char* pt) {
//copy from here
char *ptr;
int i =0, j=0;
//copy string to temporary
CREATE_A(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';
aFree (ptr);
return &pt[0];
}
char* jstrescapecpy (char* pt,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 &pt[0];
}
int jmemescapecpy (char* pt,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;
}
//-----------------------------------------------------
// Function to suppress control characters in a string.
//-----------------------------------------------------
//int remove_control_chars(char *str) {
int remove_control_chars(unsigned char *str) {
int i;
int change = 0;
for(i = 0; str[i]; i++) {
if (str[i] < 32) {
str[i] = '_';
change = 1;
}
}
return change;
}
|