Annotation of parser3/src/targets/cgi/fixopt.C, revision 1.2

1.1       paf         1: /** @file
                      2:        Parser: CGI: fixing command line options decl.
                      3: 
                      4:        Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com)
                      5:        Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
                      6: */
                      7: 
1.2     ! paf         8: static const char* IDENT_FIXOPT_C="$Date: 2002/08/14 11:38:07 $";
1.1       paf         9: 
                     10: #include "pa_config_includes.h"
                     11: 
                     12: #include "pa_common.h"
                     13: #include "pa_exception.h"
                     14: 
                     15: // defines
                     16: 
                     17: #define MAX_ARGV 100
                     18: 
                     19: void fixopt(
                     20:        int beforec, char **beforev, 
                     21:        int& afterc, char **& aafterv) {
                     22: 
1.2     ! paf        23:        static char aftervbuf[MAX_ARGV][MAX_STRING];
1.1       paf        24:        static char *afterv[MAX_ARGV];
                     25:        aafterv=afterv;
                     26:        afterc=0;
                     27: 
1.2     ! paf        28:        if(beforec) {
1.1       paf        29:                afterv[afterc++]=beforev[0]; // do not fix argv[0]
                     30: 
1.2     ! paf        31:                for(int i=1; i<beforec-1; i++) {
        !            32:                        char *buf=aftervbuf[afterc];
        !            33:                        strncpy(buf, beforev[i], MAX_STRING-1); buf[MAX_STRING-1]=0;
        !            34: 
        !            35:                        while(char *one=lsplit(&buf, ' ')) {
        !            36:                                if(afterc==MAX_ARGV-1 /*so not to check later*/)
        !            37:                                        throw Exception(0,
        !            38:                                                0,
        !            39:                                                "too many command line arguments (more then %d)", MAX_ARGV-1);
        !            40:                                afterv[afterc++]=one;                           
        !            41:                        }
1.1       paf        42:                }
1.2     ! paf        43: 
        !            44:                afterv[afterc++]=beforev[beforec-1];
1.1       paf        45:        }
                     46: }

E-mail: