Lines 1-13
Link Here
|
1 |
--- mstore/mstore.c.orig Mon Mar 27 06:07:12 2000 |
1 |
--- mstore/mstore.c.orig Mon Mar 27 06:07:12 2000 |
2 |
+++ mstore/mstore.c Tue Dec 11 08:56:58 2001 |
2 |
+++ mstore/mstore.c Sun Jan 20 13:36:14 2002 |
3 |
@@ -1,4 +1,4 @@ |
3 |
@@ -1,31 +1,39 @@ |
4 |
-/* $Id: mstore.c,v 1.11 2000/03/27 04:07:12 zircote Exp $ */ |
4 |
-/* $Id: mstore.c,v 1.11 2000/03/27 04:07:12 zircote Exp $ */ |
5 |
+/* $Id: mstore.c,v 1.21 2001/05/07 17:37:10 chuck Exp $ */ |
5 |
+/* $Id: mstore.c,v 1.22 2001/12/25 02:41:44 chuck Exp $ */ |
6 |
|
6 |
|
7 |
#include <stdlib.h> |
7 |
#include <stdlib.h> |
8 |
#include <string.h> |
8 |
#include <string.h> |
9 |
@@ -6,26 +6,33 @@ |
9 |
#include <errno.h> |
10 |
#include <pwd.h> |
10 |
#include <pwd.h> |
|
|
11 |
+#include <sys/time.h> |
11 |
#include <unistd.h> |
12 |
#include <unistd.h> |
12 |
#include <crypt.h> |
13 |
#include <crypt.h> |
13 |
+ |
14 |
+ |
Lines 43-49
Link Here
|
43 |
static bool mstore_search_range( CALSTREAM *stream, |
44 |
static bool mstore_search_range( CALSTREAM *stream, |
44 |
const datetime_t *start, |
45 |
const datetime_t *start, |
45 |
const datetime_t *end); |
46 |
const datetime_t *end); |
46 |
@@ -44,12 +51,18 @@ |
47 |
@@ -44,12 +52,18 @@ |
47 |
unsigned long id); |
48 |
unsigned long id); |
48 |
static bool mstore_store( CALSTREAM *stream, |
49 |
static bool mstore_store( CALSTREAM *stream, |
49 |
const CALEVENT *modified_event); |
50 |
const CALEVENT *modified_event); |
Lines 62-68
Link Here
|
62 |
mstore_search_range, |
63 |
mstore_search_range, |
63 |
mstore_search_alarm, |
64 |
mstore_search_alarm, |
64 |
mstore_fetch, |
65 |
mstore_fetch, |
65 |
@@ -57,6 +70,8 @@ |
66 |
@@ -57,6 +71,8 @@ |
66 |
mstore_remove, |
67 |
mstore_remove, |
67 |
mstore_snooze, |
68 |
mstore_snooze, |
68 |
mstore_store, |
69 |
mstore_store, |
Lines 71-77
Link Here
|
71 |
}; |
72 |
}; |
72 |
|
73 |
|
73 |
|
74 |
|
74 |
@@ -88,13 +103,98 @@ |
75 |
@@ -88,13 +104,98 @@ |
75 |
} |
76 |
} |
76 |
|
77 |
|
77 |
|
78 |
|
Lines 171-177
Link Here
|
171 |
if(!mpasswd) |
172 |
if(!mpasswd) |
172 |
{ |
173 |
{ |
173 |
printf("Error! couldn't open mpasswd file!\n"); |
174 |
printf("Error! couldn't open mpasswd file!\n"); |
174 |
@@ -123,36 +223,31 @@ |
175 |
@@ -123,36 +224,31 @@ |
175 |
} |
176 |
} |
176 |
fclose(mpasswd); |
177 |
fclose(mpasswd); |
177 |
return false; |
178 |
return false; |
Lines 233-239
Link Here
|
233 |
} |
234 |
} |
234 |
|
235 |
|
235 |
|
236 |
|
236 |
@@ -161,8 +256,6 @@ |
237 |
@@ -161,8 +257,6 @@ |
237 |
{ |
238 |
{ |
238 |
if (!addr->proto || strcasecmp(addr->proto, "mstore")) |
239 |
if (!addr->proto || strcasecmp(addr->proto, "mstore")) |
239 |
return false; |
240 |
return false; |
Lines 242-248
Link Here
|
242 |
return true; |
243 |
return true; |
243 |
} |
244 |
} |
244 |
|
245 |
|
245 |
@@ -197,10 +290,18 @@ |
246 |
@@ -197,10 +291,18 @@ |
246 |
} |
247 |
} |
247 |
|
248 |
|
248 |
cc_login(&username, &password); |
249 |
cc_login(&username, &password); |
Lines 263-269
Link Here
|
263 |
} |
264 |
} |
264 |
|
265 |
|
265 |
if (!reopen) { |
266 |
if (!reopen) { |
266 |
@@ -212,13 +313,23 @@ |
267 |
@@ -212,13 +314,23 @@ |
267 |
|
268 |
|
268 |
if (options & CAL_LOGIN) { |
269 |
if (options & CAL_LOGIN) { |
269 |
/* Copy login_userbuf, folder. */ |
270 |
/* Copy login_userbuf, folder. */ |
Lines 289-295
Link Here
|
289 |
|
290 |
|
290 |
/* Set up folder_user */ |
291 |
/* Set up folder_user */ |
291 |
if(addr->host) |
292 |
if(addr->host) |
292 |
@@ -229,8 +340,13 @@ |
293 |
@@ -229,8 +341,13 @@ |
293 |
DATA->login_user=DATA->login_userbuf; |
294 |
DATA->login_user=DATA->login_userbuf; |
294 |
if (addr->user) { |
295 |
if (addr->user) { |
295 |
/* Copy and split folder_userbuf */ |
296 |
/* Copy and split folder_userbuf */ |
Lines 304-310
Link Here
|
304 |
/* Check for identical folder/login users. */ |
305 |
/* Check for identical folder/login users. */ |
305 |
DATA->folder_user=DATA->folder_userbuf; |
306 |
DATA->folder_user=DATA->folder_userbuf; |
306 |
if ( !strcmp(DATA->login_user, DATA->folder_user)) |
307 |
if ( !strcmp(DATA->login_user, DATA->folder_user)) |
307 |
@@ -246,7 +362,6 @@ |
308 |
@@ -246,7 +363,6 @@ |
308 |
DATA->folder_user = DATA->login_user; |
309 |
DATA->folder_user = DATA->login_user; |
309 |
} |
310 |
} |
310 |
|
311 |
|
Lines 312-318
Link Here
|
312 |
return stream; |
313 |
return stream; |
313 |
fail: |
314 |
fail: |
314 |
mstore_freestream(stream); |
315 |
mstore_freestream(stream); |
315 |
@@ -270,6 +385,36 @@ |
316 |
@@ -270,6 +386,36 @@ |
316 |
} |
317 |
} |
317 |
|
318 |
|
318 |
|
319 |
|
Lines 349-365
Link Here
|
349 |
CALEVENT *read_event(FILE *calfile) |
350 |
CALEVENT *read_event(FILE *calfile) |
350 |
{ |
351 |
{ |
351 |
char line[100]; |
352 |
char line[100]; |
352 |
@@ -277,7 +422,8 @@ |
353 |
@@ -334,79 +480,75 @@ |
353 |
int size; |
|
|
354 |
CALEVENT *event; |
355 |
|
356 |
- fgets(line, sizeof(line), calfile); |
357 |
+ if (fgets(line, sizeof(line), calfile) == NULL) |
358 |
+ return NULL; |
359 |
if (sscanf(line, "%d", &size) != 1) |
360 |
return NULL; |
361 |
buf = malloc(size + 2); |
362 |
@@ -334,17 +480,18 @@ |
363 |
datetime_t _end = DT_INIT; |
354 |
datetime_t _end = DT_INIT; |
364 |
FILE *calfile; |
355 |
FILE *calfile; |
365 |
char userpath[1000]; |
356 |
char userpath[1000]; |
Lines 378-398
Link Here
|
378 |
rewind(calfile); |
369 |
rewind(calfile); |
379 |
|
370 |
|
380 |
if (start) { |
371 |
if (start) { |
381 |
if (!dt_hasdate(start)) |
372 |
- if (!dt_hasdate(start)) |
382 |
+//LM:should this be _start = NULL? and again below for end? |
373 |
- start = NULL; |
383 |
start = NULL; |
374 |
- else { |
384 |
else { |
375 |
- dt_setdate(&_start, |
385 |
dt_setdate(&_start, |
376 |
- start->year, start->mon, start->mday); |
386 |
@@ -358,7 +505,7 @@ |
377 |
- } |
387 |
dt_setdate(&_end, end->year, end->mon, end->mday); |
378 |
+ if (!dt_hasdate(start)) { |
|
|
379 |
+ // LM:should this be _start = NULL? and again below for end? |
380 |
+ start = NULL; |
381 |
+ } else { |
382 |
+ dt_setdate(&_start, |
383 |
+ start->year, start->mon, start->mday); |
384 |
+ } |
388 |
} |
385 |
} |
389 |
|
386 |
if (end) { |
|
|
387 |
- if (!dt_hasdate(end)) |
388 |
- end = NULL; |
389 |
- else |
390 |
- dt_setdate(&_end, end->year, end->mon, end->mday); |
391 |
- } |
392 |
- |
390 |
- while((event=read_event(calfile))) { |
393 |
- while((event=read_event(calfile))) { |
391 |
+ while((event = read_event(calfile))) { |
394 |
- datetime_t clamp = DT_INIT; |
392 |
datetime_t clamp = DT_INIT; |
395 |
- |
|
|
396 |
- if (!start) |
397 |
- dt_setdate(&clamp, 1, JANUARY, 1); |
398 |
- else { |
399 |
- dt_setdate(&clamp, |
400 |
- _start.year, _start.mon, _start.mday); |
401 |
- } |
402 |
+ if (!dt_hasdate(end)) |
403 |
+ end = NULL; |
404 |
+ else |
405 |
+ dt_setdate(&_end, end->year, end->mon, end->mday); |
406 |
+ } |
407 |
+ |
408 |
+ while ((event = read_event(calfile))) { |
409 |
+ datetime_t clamp = DT_INIT; |
410 |
+ |
411 |
+ if (!start) { |
412 |
+ dt_setdate(&clamp, 1, JANUARY, 1); |
413 |
+ } else { |
414 |
+ dt_setdate(&clamp, |
415 |
+ _start.year, _start.mon, _start.mday); |
416 |
+ } |
417 |
|
418 |
- calevent_next_recurrence(event, &clamp, stream->startofweek); |
419 |
- if ( dt_hasdate(&clamp) && |
420 |
- !(end && dt_compare(&clamp, &_end) > 0)) |
421 |
- { |
422 |
- cc_searched(event->id); |
423 |
- } |
424 |
+ calevent_next_recurrence(event, &clamp, stream->startofweek); |
425 |
+ if (dt_hasdate(&clamp) && |
426 |
+ !(end && dt_compare(&clamp, &_end) > 0)) { |
427 |
+ cc_searched(event->id); |
428 |
+ } |
429 |
|
430 |
- calevent_free(event); |
431 |
+ calevent_free(event); |
432 |
} |
433 |
- fclose(calfile); |
434 |
- return true; |
435 |
+ fclose(calfile); |
436 |
+ return true; |
437 |
} |
438 |
|
393 |
|
439 |
|
394 |
if (!start) |
|
|
395 |
@@ -385,28 +532,24 @@ |
396 |
bool |
440 |
bool |
397 |
mstore_search_alarm(CALSTREAM *stream, const datetime_t *when) |
441 |
mstore_search_alarm(CALSTREAM *stream, const datetime_t *when) |
398 |
{ |
442 |
{ |
Lines 409-416
Link Here
|
409 |
- if(!calfile) |
453 |
- if(!calfile) |
410 |
- { |
454 |
- { |
411 |
+ snprintf(userpath, 900, "%s/%s", DATA->base_path, DATA->folder_user); |
455 |
+ snprintf(userpath, 900, "%s/%s", DATA->base_path, DATA->folder_user); |
412 |
+ calfile=fopen (userpath, "a+"); |
456 |
+ calfile = fopen (userpath, "a+"); |
413 |
+ if(!calfile) { |
457 |
+ if (!calfile) { |
414 |
printf("Error! couldn't open calendar file!\n"); |
458 |
printf("Error! couldn't open calendar file!\n"); |
415 |
exit(1); |
459 |
exit(1); |
416 |
- } |
460 |
- } |
Lines 431-437
Link Here
|
431 |
} |
475 |
} |
432 |
calevent_free(event); |
476 |
calevent_free(event); |
433 |
} |
477 |
} |
434 |
@@ -422,13 +565,12 @@ |
478 |
@@ -422,13 +564,12 @@ |
435 |
FILE *calfile; |
479 |
FILE *calfile; |
436 |
char userpath[1000]; |
480 |
char userpath[1000]; |
437 |
|
481 |
|
Lines 449-467
Link Here
|
449 |
rewind(calfile); |
493 |
rewind(calfile); |
450 |
while((event=read_event(calfile))) { |
494 |
while((event=read_event(calfile))) { |
451 |
if(event->id==id) { |
495 |
if(event->id==id) { |
452 |
@@ -459,8 +601,11 @@ |
496 |
@@ -445,43 +586,45 @@ |
453 |
if (strcasecmp(addr->folder, "INBOX")) |
497 |
|
454 |
return false; |
498 |
|
|
|
499 |
bool |
500 |
-mstore_append( CALSTREAM *stream, const CALADDR *addr, |
501 |
- unsigned long *id, const CALEVENT *event) |
502 |
+mstore_append(CALSTREAM *stream, const CALADDR *addr, |
503 |
+ unsigned long *id, const CALEVENT *event) |
504 |
{ |
505 |
- CALEVENT myevent; |
506 |
- FILE *calfile; |
507 |
- char userpath[1000]; |
508 |
+ CALEVENT myevent; |
509 |
+ FILE *calfile; |
510 |
+ char userpath[1000]; |
511 |
+ |
512 |
+ if (addr->host) { |
513 |
+ return false; |
514 |
+ } |
515 |
+ if (addr->user) { |
516 |
+ return false; |
517 |
+ } |
518 |
+ if (strcasecmp(addr->folder, "INBOX")) { |
519 |
+ return false; |
520 |
+ } |
521 |
|
522 |
- if (addr->host) |
523 |
- return false; |
524 |
- if (addr->user) |
525 |
- return false; |
526 |
- if (strcasecmp(addr->folder, "INBOX")) |
527 |
- return false; |
528 |
+ if (!dt_hasdate(&event->start)) { |
529 |
+ return false; |
530 |
+ } |
531 |
|
532 |
- if (DATA->folder_userbuf) |
533 |
- return false; |
534 |
- if (!dt_hasdate(&event->start)) |
535 |
- return false; |
536 |
+ snprintf(userpath, 900, "%s/%s", DATA->base_path, DATA->folder_user); |
537 |
+ calfile = fopen(userpath, "a"); |
538 |
+ if (!calfile) { |
539 |
+ printf("Error! couldn't open calendar file %s\n",userpath); |
540 |
+ perror("mstore_append"); |
541 |
+ return false; |
542 |
+ } |
543 |
|
544 |
- snprintf(userpath,900,"%s/%s",DATA->base_path,DATA->folder_user); |
545 |
- calfile=fopen (userpath,"a"); |
546 |
- if(!calfile) |
547 |
- { |
548 |
- printf("Error! couldn't open calendar file %s\n",userpath); |
549 |
- perror("mstore_append"); |
550 |
- return false; |
551 |
- } |
552 |
- |
553 |
- myevent = *event; |
554 |
- myevent.id = time(NULL); |
555 |
- write_event(calfile, &myevent); |
556 |
+ myevent = *event; |
557 |
+ myevent.id = time(NULL); |
558 |
+ |
559 |
+ write_event(calfile, &myevent); |
560 |
|
561 |
- fclose(calfile); |
562 |
+ fclose(calfile); |
563 |
|
564 |
- *id = myevent.id; |
565 |
+ *id = myevent.id; |
566 |
|
567 |
- return true; |
568 |
+ return true; |
569 |
} |
455 |
|
570 |
|
456 |
+ /* comment this out so that we can share calendars |
|
|
457 |
if (DATA->folder_userbuf) |
458 |
return false; |
459 |
+ */ |
460 |
+ |
461 |
if (!dt_hasdate(&event->start)) |
462 |
return false; |
463 |
|
571 |
|
464 |
@@ -609,3 +754,15 @@ |
572 |
@@ -609,3 +752,15 @@ |
465 |
return true; |
573 |
return true; |
466 |
} |
574 |
} |