|
|
| version 1.37, 2001/09/01 14:47:11 | version 1.41, 2001/09/13 14:10:54 |
|---|---|
| Line 219 void measure(Pool& pool, const String& f | Line 219 void measure(Pool& pool, const String& f |
| "can not determine image type - no file name extension"); | "can not determine image type - no file name extension"); |
| } | } |
| /// used by image: _measure / read_mem | #ifndef DOXYGEN |
| struct Read_mem_info { | struct Read_mem_info { |
| unsigned char *ptr; | unsigned char *ptr; |
| unsigned char *eof; | unsigned char *eof; |
| }; | }; |
| #endif | |
| static size_t read_mem(void*& buf, size_t limit, void *info) { | static size_t read_mem(void*& buf, size_t limit, void *info) { |
| Read_mem_info& rmi=*static_cast<Read_mem_info *>(info); | Read_mem_info& rmi=*static_cast<Read_mem_info *>(info); |
| buf=rmi.ptr; | buf=rmi.ptr; |
| Line 232 static size_t read_mem(void*& buf, size_ | Line 233 static size_t read_mem(void*& buf, size_ |
| return read_size; | return read_size; |
| } | } |
| /// used by image: _measure / read_disk | #ifndef DOXYGEN |
| struct Read_disk_info { | struct Read_disk_info { |
| const String *file_spec; | const String *file_spec; |
| size_t offset; | size_t offset; |
| }; | }; |
| #endif | |
| static size_t read_disk(void*& buf, size_t limit, void *info) { | static size_t read_disk(void*& buf, size_t limit, void *info) { |
| Read_disk_info& rdi=*static_cast<Read_disk_info *>(info); | Read_disk_info& rdi=*static_cast<Read_disk_info *>(info); |
| Pool& pool=rdi.file_spec->pool(); | Pool& pool=rdi.file_spec->pool(); |
| Line 283 static void _measure(Request& r, const S | Line 285 static void _measure(Request& r, const S |
| static_cast<VImage *>(r.self)->set(file_name, width, height); | static_cast<VImage *>(r.self)->set(file_name, width, height); |
| } | } |
| /// used by image: _html / append_attrib_pair | #ifndef DOXYGEN |
| struct Attrib_info { | struct Attrib_info { |
| String *tag; ///< html tag being constructed | String *tag; ///< html tag being constructed |
| Hash *skip; ///< tag attributes not to append to tag string [to skip] | Hash *skip; ///< tag attributes not to append to tag string [to skip] |
| }; | }; |
| #endif | |
| static void append_attrib_pair(const Hash::Key& key, Hash::Val *val, void *info) { | static void append_attrib_pair(const Hash::Key& key, Hash::Val *val, void *info) { |
| Attrib_info& ai=*static_cast<Attrib_info *>(info); | Attrib_info& ai=*static_cast<Attrib_info *>(info); |
| Line 309 static void _html(Request& r, const Stri | Line 312 static void _html(Request& r, const Stri |
| const Hash& fields=static_cast<VImage *>(r.self)->fields(); | const Hash& fields=static_cast<VImage *>(r.self)->fields(); |
| Hash *attribs=0; | Hash *attribs=0; |
| if(params->size()) | if(params->size()) { |
| if(attribs=params->get(0).get_hash()) { | Value &vattribs=params->get(0); |
| Attrib_info attrib_info={&tag, 0}; | if(vattribs.is_defined()) // allow 'void' |
| attribs->for_each(append_attrib_pair, &attrib_info); | if(Hash *attribs=vattribs.get_hash()) { |
| } else | Attrib_info attrib_info={&tag, 0}; |
| PTHROW(0, 0, | attribs->for_each(append_attrib_pair, &attrib_info); |
| &method_name, | } else |
| "attributes must be must be hash"); | PTHROW(0, 0, |
| &method_name, | |
| "attributes must be hash"); | |
| } | |
| Attrib_info attrib_info={&tag, attribs}; | Attrib_info attrib_info={&tag, attribs}; |
| fields.for_each(append_attrib_pair, &attrib_info); | fields.for_each(append_attrib_pair, &attrib_info); |
| Line 387 static void _gif(Request& r, const Strin | Line 393 static void _gif(Request& r, const Strin |
| String out(pool); image->Gif(out); | String out(pool); image->Gif(out); |
| VFile& vfile=*new(pool) VFile(pool); | VFile& vfile=*new(pool) VFile(pool); |
| String& image_gif=*new(pool) String(pool, "image/gif"); | Value *content_type=new(pool) VString(*new(pool) String(pool, "image/gif")); |
| vfile.set(false/*not tainted*/, | vfile.set(false/*not tainted*/, |
| out.cstr(String::UL_AS_IS), out.size(), 0, &image_gif); | out.cstr(String::UL_AS_IS), out.size(), 0, content_type); |
| r.write_no_lang(vfile); | r.write_no_lang(vfile); |
| } | } |
| Line 544 static void _polybar(Request& r, const S | Line 550 static void _polybar(Request& r, const S |
| class Font : public Pooled { | class Font : public Pooled { |
| public: | public: |
| const static int kerning; | const static int letter_spacing; |
| int height; ///< Font heigth | int height; ///< Font heigth |
| int monospace; ///< Default char width | int monospace; ///< Default char width |
| int spacebarspace; ///< spacebar width | int spacebarspace; ///< spacebar width |
| Line 598 public: | Line 604 public: |
| if(cstr) for(; *cstr; cstr++) { | if(cstr) for(; *cstr; cstr++) { |
| int index=index_of(*cstr); | int index=index_of(*cstr); |
| index_display(image, x, y, index); | index_display(image, x, y, index); |
| x+=kerning + (monospace ? monospace : index_width(index)); | x+=letter_spacing + (monospace ? monospace : index_width(index)); |
| } | } |
| } | } |
| }; | }; |
| const int Font::kerning=1; | const int Font::letter_spacing=1; |
| static void _font(Request& r, const String& method_name, MethodParams *params) { | static void _font(Request& r, const String& method_name, MethodParams *params) { |
| Pool& pool=r.pool(); | Pool& pool=r.pool(); |