"Fossies" - the Fresh Open Source Software Archive

Member "asp2php-2008-08-13/src/fileupload.c" (13 Aug 2008, 2969 Bytes) of package /linux/www/old/asp2php-2008-08-13.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "fileupload.c" see the Fossies "Dox" file reference documentation.

    1 #include <stdio.h>
    2 #include <stdlib.h>
    3 #include <string.h>
    4 #include <ctype.h>
    5 
    6 #include "globals.h"
    7 #include "functions.h"
    8 
    9 int parse_fileupload()
   10 {
   11 int tokentype;
   12 char token[TOKENSIZE];
   13 char newtoken[LINELENGTH];
   14 char buffer[LINELENGTH];
   15 
   16   autoindent();
   17 
   18   if ((tokentype=gettoken(token))!=TOK_PERIOD)
   19   {
   20     error(token,".","Response");
   21     return 0;
   22   }
   23 
   24   tokentype=gettoken(token);
   25 
   26   if (strcasecmp(token,"write")==0)
   27   {
   28     fprintf(out,"echo ");
   29     tokentype=gettoken(token);
   30     push(token,tokentype);
   31 
   32     if (strcmp(token,"(")==0)
   33     {
   34       strcpy(newtoken,"");
   35       eval_funct(newtoken);
   36       fprintf(out,"%s;",newtoken);
   37     }
   38       else
   39     {
   40       eval_molecule(newtoken);
   41       fprintf(out,"%s;\n",newtoken);
   42     }
   43   } 
   44     else
   45   if (strcasecmp(token,"contenttype")==0)
   46   {
   47     tokentype=gettoken(token);
   48     if (strcmp(token,"=")!=0)
   49     { error(token,"=","ContentType"); }
   50 
   51     fprintf(out,"header(\"Content-type: \".");
   52     eval_molecule(newtoken);
   53     fprintf(out,"%s);\n",newtoken);
   54   }
   55     else
   56   if (strcasecmp(token,"addheader")==0)
   57   {
   58     fprintf(out,"header(");
   59     eval_molecule(newtoken);
   60     fprintf(out,"%s.\": \".",newtoken);
   61     eval_molecule(newtoken);
   62     fprintf(out,"%s);\n",newtoken);
   63   } 
   64     else
   65   if (strcasecmp(token,"expires")==0)
   66   {
   67     fprintf(out,"header(\"Expires: ");
   68     tokentype=gettoken(token);
   69 
   70     if (strcmp(token,"=")!=0)
   71     {  error(token,"=","parse_response"); }
   72 
   73     eval_molecule(newtoken);
   74     fprintf(out,"%s\");\n",newtoken);
   75   } 
   76     else
   77   if (strcasecmp(token,"redirect")==0)
   78   {
   79     fprintf(out,"header(\"Location: \".");
   80     tokentype=gettoken(token);
   81     push(token,tokentype);
   82 
   83     if (strcmp(token,"(")==0)
   84     {
   85       strcpy(newtoken,"");
   86       eval_funct(newtoken);
   87       fprintf(out,"%s);\nexit;\n",newtoken);
   88     }
   89       else
   90     {
   91       eval_molecule(newtoken);
   92       fprintf(out,"%s);\nexit();\n",newtoken);
   93     }
   94   }
   95     else
   96   if (strcasecmp(token,"cookies")==0)
   97   {
   98     sprintf(buffer,"setcookie(");
   99 
  100     tokentype=gettoken(token);
  101     push(token,tokentype);
  102 
  103     if (strcmp(token,"(")==0)
  104     {
  105       strcpy(newtoken,"");
  106       eval_funct(newtoken);
  107       strcat(buffer,newtoken);
  108     }
  109       else
  110     {
  111       eval_molecule(newtoken);
  112       strcat(buffer,newtoken);
  113     }
  114 
  115     tokentype=gettoken(token);
  116     if (strcmp(token,"=")==0)
  117     {
  118       fprintf(out,"%s",buffer);
  119       if (strcmp(token,"(")==0)
  120       {
  121         strcpy(newtoken,"");
  122         eval_funct(newtoken);
  123         fprintf(out,"%s,",newtoken);
  124       }
  125         else
  126       {
  127         eval_molecule(newtoken);
  128         fprintf(out,"%s,",newtoken);
  129       }
  130 
  131       fprintf(out,"0,\"\",\"\",0);\n");
  132     }
  133       else
  134     if (strcmp(token,".")==0)
  135     {
  136       unsupported("Response.Cookie.Something");
  137       comment_out("Unsupported: Response.Cookie.");
  138     }
  139       else
  140     {
  141       error(token,"=","parse_response");
  142     }
  143   }
  144     else
  145   { fprintf(out,"// asp2php says 'huh'?: "); eval_expression(" "); }
  146 
  147   return 0;
  148 }
  149