• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeio/tdeio
 

tdeio/tdeio

tdelficon.cpp
00001 #include "config.h"
00002 #include "tdelficon.h"
00003 
00004 #ifdef HAVE_ALLOCA_H
00005 #include <alloca.h>
00006 #endif
00007 #include <cstring>
00008 
00009 /*
00010  * Obtain an existing icon resource list
00011  */
00012 int get_iconlist(libr_file *file_handle, iconlist *icons)
00013 {
00014     if(icons == NULL)
00015     {
00016         /* Need to be able to return SOMETHING */
00017         return false;
00018     }
00019     /* Obtain the icon resource list */
00020     icons->buffer = libr_malloc(file_handle, ICON_SECTION, &(icons->size));
00021     if(icons->buffer == NULL)
00022         return false;
00023     return true;
00024 }
00025 
00026 /*
00027  * Get the next entry in an icon resource list
00028  */
00029 iconentry *get_nexticon(iconlist *icons, iconentry *last_entry)
00030 {
00031     size_t i;
00032     
00033     /* The icon list is needed both for the data buffer and for a call-specific iconentry instance */ 
00034     if(icons == NULL)
00035         return NULL;
00036     /* If this is the first call (last_entry == NULL) then return the first entry */
00037     if(last_entry == NULL)
00038         icons->entry.offset = sizeof(uint32_t)+sizeof(UUID);
00039     else
00040         icons->entry.offset += icons->entry.entry_size;
00041     /* Check to see if we've run out of entries */
00042     if(icons->entry.offset >= icons->size)
00043         return NULL;
00044     i = icons->entry.offset;
00045     memcpy(&(icons->entry.entry_size), &(icons->buffer[i]), sizeof(uint32_t));
00046     i += sizeof(uint32_t);
00047     icons->entry.type = (libr_icontype_t)icons->buffer[i];
00048     i += sizeof(unsigned char);
00049     switch(icons->entry.type)
00050     {
00051         case LIBR_SVG:
00052             icons->entry.icon_size = 0;
00053             icons->entry.name = &(icons->buffer[i]);
00054             break;
00055         case LIBR_PNG:
00056             memcpy(&(icons->entry.icon_size), &(icons->buffer[i]), sizeof(uint32_t));
00057             i += sizeof(uint32_t);
00058             icons->entry.name = &(icons->buffer[i]);
00059             break;
00060         default:
00061             /* Invalid entry type */
00062             return NULL;
00063     }
00064     return &(icons->entry);
00065 }
00066 
00067 TQString elf_get_resource(libr_file *handle, char *section_name)
00068 {
00069     size_t buffer_size = 0;
00070     char *buffer = NULL;
00071     TQString result;
00072 
00073     /* Get the resource from the ELF binary */
00074     if(!libr_size(handle, section_name, &buffer_size))
00075     {
00076 //      kdWarning() << "failed to obtain ELF resource size: " << libr_errmsg() << endl;
00077         return result;
00078     }
00079     /* Get the resource from the ELF file */
00080     buffer = (char *) malloc(buffer_size+1);
00081     buffer[buffer_size] = 0;
00082     if(!libr_read(handle, section_name, buffer))
00083     {
00084 //      kdWarning() << "failed to obtain ELF resource: " << libr_errmsg() << endl;
00085         goto fail;
00086     }
00087     result = buffer;
00088 
00089 fail:
00090     free(buffer);
00091 
00092     return result;
00093 }

tdeio/tdeio

Skip menu "tdeio/tdeio"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdeio/tdeio

Skip menu "tdeio/tdeio"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeio/tdeio by doxygen 1.7.6.1
This website is maintained by Timothy Pearson.