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

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.9     ! paf         8:        $Id: pa_vfile.C,v 1.8 2001/03/28 13:21:32 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: 
                     23:        fields.clear();
1.3       paf        24:        // $name
                     25:        char *lfile_name=(char *)malloc(strlen(afile_name)+1);
                     26:        strcpy(lfile_name, afile_name);
                     27:        if(char *after_slash=rsplit(lfile_name, '\\'))
                     28:                lfile_name=after_slash;
                     29:        if(char *after_slash=rsplit(lfile_name, '/'))
                     30:                lfile_name=after_slash;
                     31:        fields.put(*name_name, NEW VString(*NEW String(pool(), lfile_name, true)));
                     32:        // $size
                     33:        fields.put(*size_name, NEW VInt(pool(), fvalue_size));
                     34:        // $text
                     35:        String& text=*NEW String(pool());
                     36:        char *premature_zero_pos=(char *)memchr(fvalue_ptr, 0, fvalue_size);
                     37:        if(premature_zero_pos!=fvalue_ptr)
1.8       paf        38:                text.APPEND_TAINTED((char *)fvalue_ptr, 
1.7       paf        39:                        premature_zero_pos?premature_zero_pos-(char *)fvalue_ptr:fvalue_size, 
                     40:                        "user <input type=file>", 0);
1.3       paf        41:        fields.put(*text_name, NEW VString(text));
1.9     ! paf        42:        // $mime-type
        !            43:        if(mime_type)
        !            44:                fields.put(*vfile_mime_type_name, NEW VString(*mime_type));
1.3       paf        45: }
1.8       paf        46: 

E-mail: