#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "pi-macros.h"
#include "pi-notepad.h"
Include dependency graph for notepad.c:

Go to the source code of this file.
Functions | |
| void | free_NotePad (NotePad_t *a) |
| int | unpack_NotePad (NotePad_t *notepad, unsigned char *buffer, size_t len) |
| int | pack_NotePad (NotePad_t *notepad, unsigned char *buf, size_t len) |
| int | unpack_NotePadAppInfo (NotePadAppInfo_t *appinfo, unsigned char *record, size_t len) |
| int | pack_NotePadAppInfo (NotePadAppInfo_t *appinfo, unsigned char *record, size_t len) |
| void free_NotePad | ( | NotePad_t * | a | ) |
Definition at line 49 of file notepad.c.
References NotePad::data, NotePad::flags, NotePad::name, NOTEPAD_FLAG_BODY, and NOTEPAD_FLAG_NAME.
Referenced by output_picture().
00050 { 00051 if( a->flags & NOTEPAD_FLAG_NAME ) 00052 { 00053 /* fprintf( stderr, "Freeing name: %s\n", a->name ); */ 00054 free(a->name); 00055 } 00056 00057 if( a->flags & NOTEPAD_FLAG_BODY ) 00058 { 00059 /* fprintf( stderr, "Freeing data\n" ); */ 00060 free(a->data); 00061 } 00062 00063 }
| int pack_NotePad | ( | NotePad_t * | notepad, | |
| unsigned char * | buf, | |||
| size_t | len | |||
| ) |
| int pack_NotePadAppInfo | ( | NotePadAppInfo_t * | appinfo, | |
| unsigned char * | record, | |||
| size_t | len | |||
| ) |
Definition at line 236 of file notepad.c.
References NotePadAppInfo::category, NotePadAppInfo::dirty, pack_CategoryAppInfo(), set_byte, set_short, and NotePadAppInfo::sortByPriority.
00238 { 00239 int i; 00240 unsigned char *start = record; 00241 00242 i = pack_CategoryAppInfo(&appinfo->category, record, len); 00243 if (!record) 00244 return i + 4; 00245 if (!i) 00246 return 0; 00247 record += i; 00248 len -= i; 00249 if (len < 4) 00250 return 0; 00251 set_short(record, appinfo->dirty); 00252 set_byte(record + 2, appinfo->sortByPriority); 00253 set_byte(record + 3, 0); /* gapfill */ 00254 record += 4; 00255 00256 return (record - start); 00257 }
Here is the call graph for this function:

| int unpack_NotePad | ( | NotePad_t * | notepad, | |
| unsigned char * | buffer, | |||
| size_t | len | |||
| ) |
Definition at line 73 of file notepad.c.
References NotePad::alarmDate, NotePad::body, body::bodyLen, NotePad::changeDate, NotePad::createDate, NotePad::data, body::dataLen, body::dataType, noteDate_t::day, NotePad::flags, get_long, get_short, body::height, noteDate_t::hour, body::l1, noteDate_t::min, noteDate_t::month, NotePad::name, NOTEPAD_FLAG_ALARM, NOTEPAD_FLAG_BODY, NOTEPAD_FLAG_NAME, noteDate_t::s, noteDate_t::sec, strdup(), body::width, and noteDate_t::year.
Referenced by main().
00074 { 00075 unsigned char *start = buffer; 00076 00077 notepad->createDate.sec = (unsigned short int) get_short(buffer); 00078 buffer += 2; 00079 notepad->createDate.min = (unsigned short int) get_short(buffer); 00080 buffer += 2; 00081 notepad->createDate.hour = (unsigned short int) get_short(buffer); 00082 buffer += 2; 00083 notepad->createDate.day = (unsigned short int) get_short(buffer); 00084 buffer += 2; 00085 notepad->createDate.month = (unsigned short int) get_short(buffer); 00086 buffer += 2; 00087 notepad->createDate.year = (unsigned short int) get_short(buffer); 00088 buffer += 2; 00089 00090 notepad->createDate.s = (unsigned short int) get_short(buffer); 00091 buffer += 2; 00092 00093 notepad->changeDate.sec = (unsigned short int) get_short(buffer); 00094 buffer += 2; 00095 notepad->changeDate.min = (unsigned short int) get_short(buffer); 00096 buffer += 2; 00097 notepad->changeDate.hour = (unsigned short int) get_short(buffer); 00098 buffer += 2; 00099 notepad->changeDate.day = (unsigned short int) get_short(buffer); 00100 buffer += 2; 00101 notepad->changeDate.month = (unsigned short int) get_short(buffer); 00102 buffer += 2; 00103 notepad->changeDate.year = (unsigned short int) get_short(buffer); 00104 buffer += 2; 00105 00106 notepad->changeDate.s = (unsigned short int) get_short(buffer); 00107 buffer += 2; 00108 00109 notepad->flags = (unsigned short int) get_short(buffer); 00110 buffer += 2; 00111 00112 /* fprintf( stderr, "flags: 0x%x\n", notepad->flags ); */ 00113 00114 if( notepad->flags & NOTEPAD_FLAG_ALARM ) 00115 { 00116 /* fprintf( stderr, "Getting Alarm\n" ); */ 00117 notepad->alarmDate.sec = (unsigned short int) get_short(buffer); 00118 buffer += 2; 00119 notepad->alarmDate.min = (unsigned short int) get_short(buffer); 00120 buffer += 2; 00121 notepad->alarmDate.hour = (unsigned short int) get_short(buffer); 00122 buffer += 2; 00123 notepad->alarmDate.day = (unsigned short int) get_short(buffer); 00124 buffer += 2; 00125 notepad->alarmDate.month = (unsigned short int) get_short(buffer); 00126 buffer += 2; 00127 notepad->alarmDate.year = (unsigned short int) get_short(buffer); 00128 buffer += 2; 00129 00130 notepad->alarmDate.s = (unsigned short int) get_short(buffer); 00131 buffer += 2; 00132 } 00133 00134 if( notepad->flags & NOTEPAD_FLAG_NAME ) 00135 { 00136 /* fprintf( stderr, "Getting Name\n" ); */ 00137 notepad->name = strdup((char *) buffer); 00138 00139 buffer += strlen( notepad->name ) + 1; 00140 00141 if( (strlen( notepad->name ) + 1)%2 == 1) 00142 buffer++; 00143 00144 } 00145 else 00146 { 00147 notepad->name = NULL; 00148 } 00149 00150 00151 if( notepad->flags & NOTEPAD_FLAG_BODY ) 00152 { 00153 /* fprintf( stderr, "Getting Body\n" ); */ 00154 notepad->body.bodyLen = get_long( buffer ); 00155 buffer += 4; 00156 00157 notepad->body.width = get_long( buffer ); 00158 buffer += 4; 00159 00160 notepad->body.height = get_long( buffer ); 00161 buffer += 4; 00162 00163 notepad->body.l1 = get_long( buffer ); 00164 buffer += 4; 00165 00166 notepad->body.dataType = get_long( buffer ); 00167 buffer += 4; 00168 00169 notepad->body.dataLen = get_long( buffer ); 00170 buffer += 4; 00171 00172 notepad->data = malloc( notepad->body.dataLen ); 00173 00174 if( notepad->data == NULL ) 00175 { 00176 fprintf( stderr, "Body data alloc failed\n" ); 00177 return( 0 ); 00178 } 00179 00180 memcpy( notepad->data, buffer, notepad->body.dataLen ); 00181 00182 } 00183 00184 return ( buffer - start ); /* FIXME: return real length */ 00185 }
Here is the call graph for this function:

| int unpack_NotePadAppInfo | ( | NotePadAppInfo_t * | appinfo, | |
| unsigned char * | record, | |||
| size_t | len | |||
| ) |
Definition at line 208 of file notepad.c.
References NotePadAppInfo::category, NotePadAppInfo::dirty, get_byte, get_short, NotePadAppInfo::sortByPriority, and unpack_CategoryAppInfo().
Referenced by main().
00210 { 00211 int i; 00212 unsigned char *start = record; 00213 00214 i = unpack_CategoryAppInfo( &appinfo->category, record, len ); 00215 if (!i) 00216 return 0; 00217 record += i; 00218 len -= i; 00219 if (len < 4) 00220 return 0; 00221 appinfo->dirty = get_short(record); 00222 record += 2; 00223 appinfo->sortByPriority = get_byte(record); 00224 record += 2; 00225 return (record - start); 00226 }
Here is the call graph for this function:
