Annotation of parser3/src/types/pa_vfile.C, revision 1.11

1.5       paf         1: /** @file
                      2:        Parser: file object.
1.3       paf         3: 
1.1       paf         4:        Copyright(c) 2001 ArtLebedev Group(http://www.artlebedev.com)
1.3       paf         5: 
1.1       paf         6:        Author: Alexander Petrosyan <paf@design.ru>(http://design.ru/paf)
                      7: 
1.11    ! paf         8:        $Id: pa_vfile.C,v 1.10 2001/04/03 06:23:07 paf Exp $
1.1       paf         9: */
                     10: 
1.6       paf        11: #include "pa_config_includes.h"
1.3       paf        12: #include <memory.h>
1.1       paf        13: #include "pa_vfile.h"
                     14: #include "pa_vstring.h"
1.3       paf        15: #include "pa_vint.h"
1.1       paf        16: 
1.8       paf        17: void VFile::set(const void *avalue_ptr, size_t avalue_size,
1.9       paf        18:                                const char *afile_name,
                     19:                                const String *mime_type) {
1.8       paf        20:        fvalue_ptr=avalue_ptr;
                     21:        fvalue_size=avalue_size;
                     22: 
1.10      paf        23:        ffields.clear();
1.3       paf        24:        // $name
1.10      paf        25:        if(afile_name) {
                     26:                char *lfile_name=(char *)malloc(strlen(afile_name)+1);
                     27:                strcpy(lfile_name, afile_name);
                     28:                if(char *after_slash=rsplit(lfile_name, '\\'))
                     29:                        lfile_name=after_slash;
                     30:                if(char *after_slash=rsplit(lfile_name, '/'))
                     31:                        lfile_name=after_slash;
                     32:                ffields.put(*name_name, NEW VString(*NEW String(pool(), lfile_name, true)));
                     33:        }
1.3       paf        34:        // $size
1.10      paf        35:        ffields.put(*size_name, NEW VInt(pool(), fvalue_size));
1.3       paf        36:        // $text
                     37:        String& text=*NEW String(pool());
                     38:        char *premature_zero_pos=(char *)memchr(fvalue_ptr, 0, fvalue_size);
                     39:        if(premature_zero_pos!=fvalue_ptr)
1.8       paf        40:                text.APPEND_TAINTED((char *)fvalue_ptr, 
1.7       paf        41:                        premature_zero_pos?premature_zero_pos-(char *)fvalue_ptr:fvalue_size, 
                     42:                        "user <input type=file>", 0);
1.10      paf        43:        ffields.put(*text_name, NEW VString(text));
1.9       paf        44:        // $mime-type
                     45:        if(mime_type)
1.10      paf        46:                ffields.put(*vfile_mime_type_name, NEW VString(*mime_type));
1.3       paf        47: }

E-mail: