git.asbjorn.biz
/
swftools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
more transparency stack tweaking
[swftools.git]
/
lib
/
modules
/
swfcgi.c
diff --git
a/lib/modules/swfcgi.c
b/lib/modules/swfcgi.c
index
67f6881
..
aa86e49
100644
(file)
--- a/
lib/modules/swfcgi.c
+++ b/
lib/modules/swfcgi.c
@@
-9,16
+9,29
@@
Copyright (c) 2001 Rainer Böhme <rfxswf@reflex-studio.de>
Copyright (c) 2001 Rainer Böhme <rfxswf@reflex-studio.de>
- This file is distributed under the GPL, see file COPYING for details
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
-*/
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include "../rfxswf.h"
#define ishex(x) (((x) >= '0' && (x) <= '9') || ((x) >= 'a' && (x) <= 'f') || ((x) >= 'A' && (x) <= 'F'))
#define PREFIX "WWW_"
#define ishex(x) (((x) >= '0' && (x) <= '9') || ((x) >= 'a' && (x) <= 'f') || ((x) >= 'A' && (x) <= 'F'))
#define PREFIX "WWW_"
-static int htoi(unsigned char * s)
+static int swf_htoi(unsigned char * s)
{ int value;
char c;
{ int value;
char c;
@@
-33,14
+46,14
@@
static int htoi(unsigned char * s)
return (value);
}
return (value);
}
-static void url_unescape(unsigned char * s)
+static void swf_url_unescape(unsigned char * s)
{ unsigned char *dest = s;
while (s[0])
{ if (s[0] == '+') dest[0] = ' ';
else
{ if (s[0] == '%' && ishex(s[1]) && ishex(s[2]))
{ unsigned char *dest = s;
while (s[0])
{ if (s[0] == '+') dest[0] = ' ';
else
{ if (s[0] == '%' && ishex(s[1]) && ishex(s[2]))
- { dest[0] = (unsigned char) htoi(s + 1);
+ { dest[0] = (unsigned char) swf_htoi(s + 1);
s += 2;
}
else dest[0] = s[0];
s += 2;
}
else dest[0] = s[0];
@@
-50,24
+63,24
@@
static void url_unescape(unsigned char * s)
dest[0] = 0;
}
dest[0] = 0;
}
-static void cgienv(unsigned char * var)
+static void swf_cgienv(unsigned char * var)
{ unsigned char *buf, *c, *s, *t, *oldval = NULL, *newval;
int despace = 0, got_cr = 0;
// fprintf(stderr,"%s\n",var);
{ unsigned char *buf, *c, *s, *t, *oldval = NULL, *newval;
int despace = 0, got_cr = 0;
// fprintf(stderr,"%s\n",var);
- url_unescape(var);
+ swf_url_unescape(var);
// fprintf(stderr,"%s\n",var);
// fprintf(stderr,"%s\n",var);
- buf = (unsigned char*)malloc(strlen(var) + sizeof(PREFIX) + 2);
+ buf = (unsigned char*)rfx_alloc(strlen((const char*)var) + sizeof(PREFIX) + 2);
if (!buf) return;
if (!buf) return;
- strcpy(buf, PREFIX);
+ strcpy((char*)buf, (const char*)PREFIX);
if (var[0] == '_')
if (var[0] == '_')
- { strcpy(&buf[sizeof(PREFIX)-1], &var[1]);
+ { strcpy((char*)&buf[sizeof(PREFIX)-1], (const char*)&var[1]);
despace = 1;
}
despace = 1;
}
- else strcpy(&buf[sizeof(PREFIX)-1], var);
+ else strcpy((char*)&buf[sizeof(PREFIX)-1], (const char*)var);
for (c = buf; c[0] ; c++)
{ if (c[0] == '.') c[0] = '_';
for (c = buf; c[0] ; c++)
{ if (c[0] == '.') c[0] = '_';
@@
-96,37
+109,37
@@
static void cgienv(unsigned char * var)
t[1] = 0;
}
t[1] = 0;
}
- if ((oldval = getenv(buf)))
- { newval = (unsigned char*)malloc(strlen(oldval) + strlen(buf) + strlen(&c[1]) + 3);
+ if ((oldval = (unsigned char*)getenv((const char*)buf)))
+ { newval = (unsigned char*)rfx_alloc(strlen((const char*)oldval) + strlen((const char *)buf) + strlen((const char*)&c[1]) + 3);
if (!newval) return;
c[0] = '=';
if (!newval) return;
c[0] = '=';
- sprintf(newval, "%s#%s", buf, oldval);
+ sprintf((char*)newval, "%s#%s", buf, oldval);
c[0] = 0;
c[0] = 0;
- oldval -= strlen(buf) + 1; // skip past VAR=
+ oldval -= strlen((const char*)buf) + 1; // skip past VAR=
}
else
{ c[0] = '=';
newval = buf;
}
}
else
{ c[0] = '=';
newval = buf;
}
- putenv(newval);
+ putenv((char *)newval);
if (oldval)
if (oldval)
- { free(oldval);
- free(buf);
+ { rfx_free(oldval);
+ rfx_free(buf);
}
}
}
}
-static void scanquery(char * q)
+static void swf_scanquery(char * q)
{ char *next = q;
if (!q) return;
while (next)
{ next = strchr(q, '&');
if (next) next[0] = 0;
{ char *next = q;
if (!q) return;
while (next)
{ next = strchr(q, '&');
if (next) next[0] = 0;
- cgienv(q);
+ swf_cgienv((unsigned char*)q);
if (next)
{ next[0] = '&';
q = next+1;
if (next)
{ next[0] = '&';
q = next+1;
@@
-134,7
+147,7
@@
static void scanquery(char * q)
}
}
}
}
-char * postread()
+char * swf_postread()
{ char * buf = NULL;
int size = 0, sofar = 0, got;
{ char * buf = NULL;
int size = 0, sofar = 0, got;
@@
-145,7
+158,7
@@
char * postread()
if (!buf) return NULL;
size = atoi(buf);
if (!buf) return NULL;
size = atoi(buf);
- buf = (unsigned char*)malloc(size + 1);
+ buf = (char*)rfx_alloc(size + 1);
if (buf)
{ do
{ got = fread(buf + sofar, 1, size - sofar, stdin);
if (buf)
{ do
{ got = fread(buf + sofar, 1, size - sofar, stdin);
@@
-157,23
+170,24
@@
char * postread()
return buf;
}
return buf;
}
-void uncgi()
+void swf_uncgi()
{ char *query, *dupquery, *method;
query = getenv("QUERY_STRING");
if ((query) && strlen(query))
{ dupquery = strdup(query);
{ char *query, *dupquery, *method;
query = getenv("QUERY_STRING");
if ((query) && strlen(query))
{ dupquery = strdup(query);
- scanquery(dupquery);
- free(dupquery);
+ swf_scanquery(dupquery);
+ rfx_free(dupquery);
}
method = getenv("REQUEST_METHOD");
if ((method) && ! strcmp(method, "POST"))
}
method = getenv("REQUEST_METHOD");
if ((method) && ! strcmp(method, "POST"))
- { query = postread();
- if ((query)&&(query[0]!=0)) scanquery(query);
- free(query);
+ { query = swf_postread();
+ if ((query)&&(query[0]!=0)) swf_scanquery(query);
+ rfx_free(query);
}
}
#undef ishex
}
}
#undef ishex
+#undef PREFIX