Annotation of parser3/src/types/pa_vfile.C, revision 1.5
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.5 ! paf 8: $Id: pa_vfile.C,v 1.4 2001/03/19 21:39:37 paf Exp $
1.1 paf 9: */
10:
11: #include <string.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.3 paf 17: VFile::VFile(Pool& apool,
18: const char *avalue_ptr, size_t avalue_size,
1.4 paf 19: const char *afile_name) : VStateless_object(apool, *file_class),
1.3 paf 20:
21: fvalue_ptr(avalue_ptr),
22: fvalue_size(avalue_size),
23: fields(apool) {
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)
38: text.APPEND(fvalue_ptr,
39: premature_zero_pos?premature_zero_pos-fvalue_ptr:fvalue_size,
40: "<input type=file>", 0);
41: fields.put(*text_name, NEW VString(text));
42: }
E-mail: