Subversion Repositories Tewi

Rev

Rev 20 | Rev 70 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 20 Rev 21
Line 1... Line 1...
1
/* $Id: string.c 20 2024-09-14 09:59:15Z nishi $ */
1
/* $Id: string.c 21 2024-09-14 12:39:39Z nishi $ */
2
 
2
 
3
#include <string.h>
3
#include <string.h>
4
#include <stdlib.h>
4
#include <stdlib.h>
5
#include <stdbool.h>
5
#include <stdbool.h>
6
#include <stdio.h>
6
#include <stdio.h>
Line 157... Line 157...
157
			free(tmp);
157
			free(tmp);
158
		}
158
		}
159
	}
159
	}
160
	return result;
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
}