Changeset b2a91b6
- Timestamp:
- Jun 22, 2003, 2:00:25 AM (20 years ago)
- Branches:
- master, barnowl_perlaim, debian, owl, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 73624b4
- Parents:
- 9381782
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
r9381782 rb2a91b6 9 9 Bug fix in using makemsg when no curses window present 10 10 $owl::auth now works 11 Use new function to delete zephyr subs from file 11 12 12 13 2.0.4-pre-1 -
config.h.in
rc269e22 rb2a91b6 52 52 #undef HAVE_DES_KEY_SCHED 53 53 54 #undef HAVE_DES_ECB_ENCRYPT 54 #undef HAVE_DES_ECB_ENCRYPT_PROTO 55 55 56 56 #undef TERMINFO -
zephyr.c
r9381782 rb2a91b6 545 545 { 546 546 #ifdef HAVE_LIBZEPHYR 547 char *line, subsfile[LINE], buff[LINE], *text; 548 char backupfilename[LINE]; 549 FILE *file, *backupfile; 550 int size; 547 char *line, *subsfile; 551 548 552 549 line=owl_zephyr_makesubline(class, inst, recip); 553 554 /* open the subsfile for reading */ 555 if (filename==NULL) { 556 sprintf(subsfile, "%s/%s", owl_global_get_homedir(&g), ".zephyr.subs"); 557 } else { 558 strcpy(subsfile, filename); 559 } 560 file=fopen(subsfile, "r"); 561 if (!file) { 562 owl_function_makemsg("Error opening file %s", subsfile); 563 owl_free(line); 564 return; 565 } 566 567 /* open the backup file for writing */ 568 sprintf(backupfilename, "%s.backup", subsfile); 569 backupfile=fopen(backupfilename, "w"); 570 if (!backupfile) { 571 owl_function_makemsg("Error opening file %s for writing", backupfilename); 572 owl_free(line); 573 return; 574 } 575 576 /* we'll read the entire file into memory, minus the line we don't want and 577 * and at the same time create a backup file */ 578 text=owl_malloc(LINE); 579 strcpy(text, ""); 580 size=LINE; 581 while (fgets(buff, LINE, file)!=NULL) { 582 /* if we don't match the line, add to text */ 583 if (strcasecmp(buff, line)) { 584 size+=LINE; 585 text=owl_realloc(text, size); 586 strcat(text, buff); 587 } 588 589 /* write to backupfile */ 590 fputs(buff, backupfile); 591 } 592 fclose(backupfile); 593 fclose(file); 594 595 /* now open the original subs file for writing and write out the 596 * subs */ 597 file=fopen(subsfile, "w"); 598 if (!file) { 599 owl_function_makemsg("WARNING: Error opening %s to rewrite subscriptions. Use %s to restore", subsfile, backupfilename); 600 owl_function_beep(); 601 owl_free(line); 602 return; 603 } 604 605 fputs(text, file); 606 fclose(file); 550 line[strlen(line)-1]='\0'; 551 552 if (!filename) { 553 subsfile=owl_sprintf("%s/.zephyr.subs", owl_global_get_homedir(&g)); 554 } else { 555 subsfile=owl_strdup(filename); 556 } 557 558 owl_util_file_deleteline(subsfile, line, 1); 559 owl_free(subsfile); 607 560 owl_free(line); 608 609 561 owl_function_makemsg("Subscription removed"); 610 562 #endif 611 563 } 612 564 565 /* caller must free the return */ 613 566 char *owl_zephyr_makesubline(char *class, char *inst, char *recip) 614 567 { 615 /* caller must free the return */616 568 char *out; 617 569
Note: See TracChangeset
for help on using the changeset viewer.