Changeset 21 in Main for trunk/Common
- Timestamp:
- Sep 14, 2024, 9:39:39 PM (2 months ago)
- Location:
- trunk/Common
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/Makefile
r6 r21 6 6 .SUFFIXES: .c .o 7 7 8 OBJS = string.o log.o 8 OBJS = string.o log.o dir.o 9 9 10 10 all: common.a -
trunk/Common/cm_string.h
r20 r21 8 8 int cm_hex(const char* str, int len); 9 9 char* cm_html_escape(const char* str); 10 char* cm_url_escape(const char* str); 10 11 char* cm_strcat(const char* a, const char* b); 11 12 char* cm_strcat3(const char* a, const char* b, const char* c); -
trunk/Common/string.c
r20 r21 160 160 return result; 161 161 } 162 163 char* cm_url_escape(const char* str) { 164 int i; 165 char* result = malloc(1); 166 result[0] = 0; 167 char cbuf[2]; 168 cbuf[1] = 0; 169 for(i = 0; str[i] != 0; i++) { 170 cbuf[0] = str[i]; 171 if('!' <= str[i] && str[i] <= '@' && str[i] != '.' && str[i] != '-' && str[i] != '/' && !('0' <= str[i] && str[i] <= '9')) { 172 char code[4]; 173 sprintf(code, "%%%02X", str[i]); 174 char* tmp = result; 175 result = cm_strcat(tmp, code); 176 free(tmp); 177 } else { 178 char* tmp = result; 179 result = cm_strcat(tmp, cbuf); 180 free(tmp); 181 } 182 } 183 return result; 184 }
Note:
See TracChangeset
for help on using the changeset viewer.