summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/plugins/calendar.c57
1 files changed, 29 insertions, 28 deletions
diff --git a/apps/plugins/calendar.c b/apps/plugins/calendar.c
index a7762589d6..3748ac5dae 100644
--- a/apps/plugins/calendar.c
+++ b/apps/plugins/calendar.c
@@ -117,7 +117,7 @@ static void draw_calendar(struct shown *shown)
117{ 117{
118 int w,h; 118 int w,h;
119 int ws,row,pos,days_per_month,j; 119 int ws,row,pos,days_per_month,j;
120 char buffer[7]; 120 char buffer[9];
121 char *Monthname[] = { 121 char *Monthname[] = {
122 "Jan", 122 "Jan",
123 "Feb", 123 "Feb",
@@ -144,9 +144,9 @@ static void draw_calendar(struct shown *shown)
144 for (j = 0; j < days_per_month;) 144 for (j = 0; j < days_per_month;)
145 { 145 {
146 if ( (day_has_memo[++j]) || (wday_has_memo[pos]) ) 146 if ( (day_has_memo[++j]) || (wday_has_memo[pos]) )
147 rb->snprintf(buffer,3,"%02d.", j); 147 rb->snprintf(buffer,4,"%02d.", j);
148 else 148 else
149 rb->snprintf(buffer,3,"%02d", j); 149 rb->snprintf(buffer,4,"%02d", j);
150 rb->lcd_putsxy(ws, (row * h) + 5 ,buffer); 150 rb->lcd_putsxy(ws, (row * h) + 5 ,buffer);
151 if (shown->mday == j) 151 if (shown->mday == j)
152 { 152 {
@@ -164,7 +164,7 @@ static void draw_calendar(struct shown *shown)
164 } 164 }
165 rb->lcd_drawline(60,LCD_HEIGHT-h-3,60,LCD_HEIGHT-1); 165 rb->lcd_drawline(60,LCD_HEIGHT-h-3,60,LCD_HEIGHT-1);
166 rb->lcd_drawline(60,LCD_HEIGHT-h-3,LCD_WIDTH-1,LCD_HEIGHT-h-3); 166 rb->lcd_drawline(60,LCD_HEIGHT-h-3,LCD_WIDTH-1,LCD_HEIGHT-h-3);
167 rb->snprintf(buffer,8,"%s %04d",Monthname[shown->mon-1],shown->year); 167 rb->snprintf(buffer,9,"%s %04d",Monthname[shown->mon-1],shown->year);
168 rb->lcd_putsxy(62,(LCD_HEIGHT-h-1),buffer); 168 rb->lcd_putsxy(62,(LCD_HEIGHT-h-1),buffer);
169 shown->lastday = pos; 169 shown->lastday = pos;
170 rb->lcd_update(); 170 rb->lcd_update();
@@ -185,13 +185,14 @@ struct memo {
185static int pointer_array[MAX_MEMOS_IN_A_MONTH]; 185static int pointer_array[MAX_MEMOS_IN_A_MONTH];
186static int memos_in_memory = 0; 186static int memos_in_memory = 0;
187static int memos_in_shown_memory = 0; 187static int memos_in_shown_memory = 0;
188
188static void load_memo(struct shown *shown) 189static void load_memo(struct shown *shown)
189{ 190{
190 int i, k, fp; 191 int i, k, fp;
191 bool exit = false; 192 bool exit = false;
192 char temp_memo0[0]; 193 char temp_memo1[2];
193 char temp_memo1[1]; 194 char temp_memo2[3];
194 char temp_memo3[3]; 195 char temp_memo4[5];
195 for (k = 0; k < memos_in_memory; k++) 196 for (k = 0; k < memos_in_memory; k++)
196 { 197 {
197 memos[k].day = 0; 198 memos[k].day = 0;
@@ -218,16 +219,16 @@ static void load_memo(struct shown *shown)
218 { 219 {
219 memos[memos_in_memory].file_pointer_start = rb->lseek(fp, 0, 220 memos[memos_in_memory].file_pointer_start = rb->lseek(fp, 0,
220 SEEK_CUR); 221 SEEK_CUR);
221 if (rb->read(fp, temp_memo1, 2) == 2) 222 if (rb->read(fp, temp_memo2, 2) == 2)
222 memos[memos_in_memory].day = rb->atoi(&temp_memo1[0]); 223 memos[memos_in_memory].day = rb->atoi(&temp_memo2[0]);
223 else 224 else
224 memos[memos_in_memory].day = 0; 225 memos[memos_in_memory].day = 0;
225 if (rb->read(fp, temp_memo1, 2) == 2) 226 if (rb->read(fp, temp_memo2, 2) == 2)
226 memos[memos_in_memory].month = rb->atoi(&temp_memo1[0]); 227 memos[memos_in_memory].month = rb->atoi(&temp_memo2[0]);
227 else 228 else
228 memos[memos_in_memory].month = 0; 229 memos[memos_in_memory].month = 0;
229 if (rb->read(fp, temp_memo3, 4) == 4) 230 if (rb->read(fp, temp_memo4, 4) == 4)
230 memos[memos_in_memory].year = rb->atoi(&temp_memo3[0]); 231 memos[memos_in_memory].year = rb->atoi(&temp_memo4[0]);
231 else 232 else
232 memos[memos_in_memory].year = 0; 233 memos[memos_in_memory].year = 0;
233 /* as the year returned is sometimes yearmonth, ie if yr should = 234 /* as the year returned is sometimes yearmonth, ie if yr should =
@@ -236,17 +237,17 @@ static void load_memo(struct shown *shown)
236 memos[memos_in_memory].year = (memos[memos_in_memory].year - 237 memos[memos_in_memory].year = (memos[memos_in_memory].year -
237 memos[memos_in_memory].month) / 238 memos[memos_in_memory].month) /
238 100; 239 100;
239 if (rb->read(fp, temp_memo0, 1) == 1) 240 if (rb->read(fp, temp_memo1, 1) == 1)
240 memos[memos_in_memory].wday = rb->atoi(&temp_memo0[0]); 241 memos[memos_in_memory].wday = rb->atoi(&temp_memo1[0]);
241 else 242 else
242 memos[memos_in_memory].wday = 0; 243 memos[memos_in_memory].wday = 0;
243 if (rb->read(fp, temp_memo0, 1) == 1) 244 if (rb->read(fp, temp_memo1, 1) == 1)
244 memos[memos_in_memory].type = rb->atoi(&temp_memo0[0]); 245 memos[memos_in_memory].type = rb->atoi(&temp_memo1[0]);
245 else 246 else
246 memos[memos_in_memory].type = 0; 247 memos[memos_in_memory].type = 0;
247 for (k = 0; k <= count; k++) 248 for (k = 0; k <= count; k++)
248 { 249 {
249 if (rb->read(fp, temp_memo0, 1) == 1) 250 if (rb->read(fp, temp_memo1, 1) == 1)
250 { 251 {
251 if ( 252 if (
252 (memos[memos_in_memory].type < 2) 253 (memos[memos_in_memory].type < 2)
@@ -266,7 +267,7 @@ static void load_memo(struct shown *shown)
266 ) 267 )
267 ) 268 )
268 { 269 {
269 if (temp_memo0[0] == '\n') 270 if (temp_memo1[0] == '\n')
270 { 271 {
271 if (memos[memos_in_memory].type > 0) 272 if (memos[memos_in_memory].type > 0)
272 day_has_memo[memos[memos_in_memory].day] = 273 day_has_memo[memos[memos_in_memory].day] =
@@ -277,11 +278,11 @@ static void load_memo(struct shown *shown)
277 memos[memos_in_memory++].file_pointer_end = 278 memos[memos_in_memory++].file_pointer_end =
278 rb->lseek(fp, 0, SEEK_CUR); 279 rb->lseek(fp, 0, SEEK_CUR);
279 } 280 }
280 else if ( (temp_memo0[0] != '\r') && 281 else if ( (temp_memo1[0] != '\r') &&
281 (temp_memo0[0] != '\t') ) 282 (temp_memo1[0] != '\t') )
282 memos[memos_in_memory].message[k] = temp_memo0[0]; 283 memos[memos_in_memory].message[k] = temp_memo1[0];
283 } 284 }
284 if (temp_memo0[0] == '\n') 285 if (temp_memo1[0] == '\n')
285 break; 286 break;
286 } 287 }
287 else 288 else
@@ -320,15 +321,15 @@ static bool save_memo(int changed, bool new_mod, struct shown *shown)
320 } 321 }
321 if (new_mod) 322 if (new_mod)
322 { 323 {
323 rb->snprintf(temp, 2, "%02d", memos[changed].day); 324 rb->snprintf(temp, 3, "%02d", memos[changed].day);
324 rb->write(fq,temp,2); 325 rb->write(fq,temp,2);
325 rb->snprintf(temp, 2, "%02d", memos[changed].month); 326 rb->snprintf(temp, 3, "%02d", memos[changed].month);
326 rb->write(fq,temp,2); 327 rb->write(fq,temp,2);
327 rb->snprintf(temp, 4, "%04d", memos[changed].year); 328 rb->snprintf(temp, 5, "%04d", memos[changed].year);
328 rb->write(fq,temp,4); 329 rb->write(fq,temp,4);
329 rb->snprintf(temp, 1, "%01d", memos[changed].wday); 330 rb->snprintf(temp, 2, "%01d", memos[changed].wday);
330 rb->write(fq,temp,1); 331 rb->write(fq,temp,1);
331 rb->snprintf(temp, 1, "%01d", memos[changed].type); 332 rb->snprintf(temp, 2, "%01d", memos[changed].type);
332 rb->write(fq,temp,1); 333 rb->write(fq,temp,1);
333 rb->snprintf(temp, rb->strlen(memos[changed].message)+1, 334 rb->snprintf(temp, rb->strlen(memos[changed].message)+1,
334 "%s\n", memos[changed].message); 335 "%s\n", memos[changed].message);