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

Go to the source code of this file.
Functions | |
| void | free_Memo (Memo_t *memo) |
| int | unpack_Memo (Memo_t *memo, const pi_buffer_t *record, memoType type) |
| int | pack_Memo (const Memo_t *memo, pi_buffer_t *record, memoType type) |
| int | unpack_MemoAppInfo (struct MemoAppInfo *appinfo, const unsigned char *record, size_t len) |
| int | pack_MemoAppInfo (const MemoAppInfo_t *appinfo, unsigned char *record, size_t len) |
| void free_Memo | ( | Memo_t * | memo | ) |
Definition at line 42 of file memo.c.
References Memo::text.
Referenced by memos(), and MemoUnpackCmd().
00043 { 00044 if (memo->text != NULL) { 00045 free(memo->text); 00046 memo->text = NULL; 00047 } 00048 }
| int pack_Memo | ( | const Memo_t * | memo, | |
| pi_buffer_t * | record, | |||
| memoType | type | |||
| ) |
Definition at line 87 of file memo.c.
References pi_buffer_t::data, memo_v1, pi_buffer_expect(), Memo::text, and pi_buffer_t::used.
00088 { 00089 size_t destlen = (memo->text ? strlen(memo->text) : 0) + 1; 00090 00091 if (type != memo_v1) 00092 /* Don't support anything else yet */ 00093 return -1; 00094 if (record == NULL) 00095 return -1; 00096 00097 pi_buffer_expect(record, destlen); 00098 record->used = destlen; 00099 00100 if (memo->text) 00101 strcpy((char *) record->data, memo->text); 00102 else 00103 record->data[0] = 0; 00104 00105 return 0; 00106 }
Here is the call graph for this function:

| int pack_MemoAppInfo | ( | const MemoAppInfo_t * | appinfo, | |
| unsigned char * | record, | |||
| size_t | len | |||
| ) |
Definition at line 156 of file memo.c.
References MemoAppInfo::category, pack_CategoryAppInfo(), set_byte, set_short, and MemoAppInfo::sortByAlpha.
00157 { 00158 int i; 00159 unsigned char *start = record; 00160 00161 i = pack_CategoryAppInfo(&appinfo->category, record, len); 00162 if (!record) 00163 return i + 4; 00164 if (i == 0) /* category pack failed */ 00165 return 0; 00166 record += i; 00167 len -= i; 00168 if (len < 4) 00169 return (record - start); 00170 set_short(record, 0); /* gapfill new for 2.0 */ 00171 record += 2; 00172 set_byte(record, appinfo->sortByAlpha); /* new for 2.0 */ 00173 record++; 00174 set_byte(record, 0); /* gapfill new for 2.0 */ 00175 record++; 00176 00177 return (record - start); 00178 }
Here is the call graph for this function:

| int unpack_Memo | ( | Memo_t * | memo, | |
| const pi_buffer_t * | record, | |||
| memoType | type | |||
| ) |
Definition at line 63 of file memo.c.
References pi_buffer_t::data, memo_v1, strdup(), Memo::text, and pi_buffer_t::used.
Referenced by main(), memos(), MemoUnpackCmd(), and test_memo().
00064 { 00065 if (type != memo_v1) 00066 /* Don't support anything else yet */ 00067 return -1; 00068 if (record == NULL || record->data == NULL || record->used < 1) 00069 return -1; 00070 memo->text = strdup((char *) record->data); 00071 return 0; 00072 }
Here is the call graph for this function:

| int unpack_MemoAppInfo | ( | struct MemoAppInfo * | appinfo, | |
| const unsigned char * | record, | |||
| size_t | len | |||
| ) |
Definition at line 121 of file memo.c.
References MemoAppInfo::category, get_byte, memo_v1, MemoAppInfo::sortByAlpha, MemoAppInfo::type, and unpack_CategoryAppInfo().
Referenced by main(), and test_memo().
00123 { 00124 int i = unpack_CategoryAppInfo(&appinfo->category, record, len); 00125 unsigned char *start = record; 00126 00127 appinfo->type = memo_v1; 00128 00129 if (!i) 00130 return i; 00131 record += i; 00132 len -= i; 00133 if (len >= 4) { 00134 record += 2; 00135 appinfo->sortByAlpha = get_byte(record); 00136 record += 2; 00137 } else { 00138 appinfo->sortByAlpha = 0; 00139 } 00140 return (record - start); 00141 }
Here is the call graph for this function:
