Remove fmemopen

This commit is contained in:
Neale Pickett 2012-05-10 12:08:41 -06:00
parent d63e957ee3
commit 9f2749512f
2 changed files with 11 additions and 14 deletions

12
eris.c
View File

@ -550,10 +550,11 @@ handle_request()
/* Interpret path into fspath. */ /* Interpret path into fspath. */
path = p - 1; path = p - 1;
{ {
FILE *f = fmemopen(fspath, sizeof fspath, "w"); char *fsp = fspath;
char *query_string = NULL; char *query_string = NULL;
fprintf(f, "./"); *(fsp++) = '.';
*(fsp++) = '/';
for (; *p != ' '; p += 1) { for (; *p != ' '; p += 1) {
if (! query_string) { if (! query_string) {
char c = *p; char c = *p;
@ -584,11 +585,12 @@ handle_request()
break; break;
} }
fputc(c, f); if (fsp - fspath + 1 < sizeof fspath) {
*(fsp++) = c;
}
} }
} }
fputc(0, f); *fsp = 0;
fclose(f);
*(p++) = 0; /* NULL-terminate path */ *(p++) = 0; /* NULL-terminate path */

View File

@ -116,15 +116,10 @@ void
url_esc(FILE *f, char *s) url_esc(FILE *f, char *s)
{ {
for (; *s; s += 1) { for (; *s; s += 1) {
switch (*s) { if ((*s == '%') || (*s == 127) || (*s < 31)) {
case '%': fprintf(f, "%%%02x", *s);
case 127: } else {
case -127 ... 31: fputc(*s, f);
fprintf(f, "%%%02x", *s);
break;
default:
fputc(*s, f);
break;
} }
} }
} }