summaryrefslogtreecommitdiff
path: root/src/webserver/parse.c
diff options
context:
space:
mode:
authorcelest <celest@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-03-21 06:06:21 +0000
committercelest <celest@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-03-21 06:06:21 +0000
commit126ce626c0e0ef900a19c1643efe884f95938892 (patch)
tree85553bb7b0be2895c3f75072960814eb86a016ab /src/webserver/parse.c
parent24056776a3d8dfad2e0494136b58f0bbd85f03b3 (diff)
downloadhercules-126ce626c0e0ef900a19c1643efe884f95938892.tar.gz
hercules-126ce626c0e0ef900a19c1643efe884f95938892.tar.bz2
hercules-126ce626c0e0ef900a19c1643efe884f95938892.tar.xz
hercules-126ce626c0e0ef900a19c1643efe884f95938892.zip
* Moved /tool and /webserver to under /src and added 'make tools' and 'make web-server'
* Removed ladmin compiling from 'make sql' git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1261 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/webserver/parse.c')
-rw-r--r--src/webserver/parse.c135
1 files changed, 135 insertions, 0 deletions
diff --git a/src/webserver/parse.c b/src/webserver/parse.c
new file mode 100644
index 000000000..323261c6c
--- /dev/null
+++ b/src/webserver/parse.c
@@ -0,0 +1,135 @@
+#include <stdlib.h>
+
+char filtered_query[2000];
+char rdata[500];
+char param_n[500];
+char param_d[500];
+
+
+char *get_query(char *inquery)
+{
+ memset(filtered_query, 0x0, 2000);
+ sscanf(inquery, "GET %s %[$]", filtered_query);
+ return(filtered_query);
+}
+
+void web_send(int sockin, char *in_data)
+{
+ send(sockin, in_data, strlen(in_data), 0);
+}
+
+
+//THIS IS BAD CODE BE CAREFULL WITH IT!
+//Watch out for buffer overflow...
+//When using please make sure to check the string size.
+
+//Also note:
+//I take no pride in this code, it is a really bad way of doing this...
+char *get_param(char in_string[500], char swhat[500])
+{
+ int i = 0;
+ int marker, iswitch, pint, dint;
+ char flux[500];
+ memset(flux, 0x0, 500);
+
+ //Get the path of out "page"
+ if (swhat == 0)
+ {
+ //while i is not equal to array size
+ while (i != 500)
+ {
+ //if there is a question mark, halt!
+ if (in_string[i] == '?')
+ {
+ i = 499;
+ }
+ else
+ rdata[i] = in_string[i];
+
+ i++;
+ }
+ return rdata;
+ }
+ else //so, we want a param...
+ {
+ //calculate where param begins
+ while (i != 500)
+ {
+ if (in_string[i] == '?')
+ {
+ marker = i + 1;
+ i = 499;
+ }
+ i++;
+ }
+
+ i = 0;
+
+ //keep morons from trying to crash this
+ if ((marker > 500)||(marker < 1))
+ marker = 500;
+
+ while(marker != 500)
+ {
+ if ((in_string[marker] != '&') && (in_string[marker] != '\0'))
+ {
+ flux[i] = in_string[marker];
+ i++;
+ }
+ else
+ {
+
+ //we have a param, now we must dig through it
+
+ //clear temp vars
+ memset(param_n, 0x0, 500);
+ memset(param_d, 0x0, 500);
+ iswitch = 0;
+ pint = 0;
+ dint = 0;
+ i = 0;
+
+ //split result into param_n and param_d
+ while(i != 500)
+ {
+ if ( (flux[i] != '=') && (flux[i] != '\0') )
+ {
+ if (iswitch == 0)
+ {
+ param_n[pint] = flux[i];
+ pint++;
+ }
+ else
+ {
+ param_d[dint] = flux[i];
+ dint++;
+ }
+ }
+ else
+ {
+ iswitch = 1;
+ }
+ if (flux[i] == '\0')
+ i = 499;
+
+ i++;
+ }
+
+ if ( strcmp(param_n, swhat) == 0 )
+ {
+ return param_d;
+ }
+
+ i = 0;
+ }
+
+ if (in_string[marker] == '\0')
+ {
+ marker = 499;
+ }
+ marker++;
+ }
+ return 0;
+ }
+}
+