Changeset 95474d7
- Timestamp:
- Jan 3, 2005, 10:34:02 PM (20 years ago)
- Branches:
- master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 15b34fd
- Parents:
- 4e0f545
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
r4e0f545 r95474d7 4 4 Don't crash doing zlocate with bad tickets. [BZ 12] 5 5 Metion the path for the owlconf in intro.txt [BZ 54] 6 Print Better error message if startup fails due to unreadable6 Print better error message if startup fails due to unreadable 7 7 .owlconf [BZ 57] 8 In load-subs: Print an error message if the file is unreadable or 9 doesn't exist, UNLESS load-subs is called with no arguments. In 10 that case only print an error if the file exists but isn't 11 readable. Still prints an error either way if zephyr reports a 12 failure. [BZ 19] 8 13 9 14 2.1.10 -
functions.c
r8232149 r95474d7 854 854 } 855 855 856 857 /* Load zephyr subscriptions from the named 'file' and load zephyr's 858 * default subscriptions as well. An error message is printed if 859 * 'file' can't be opened or if zephyr reports an error in 860 * subscribing. 861 * 862 * If 'file' is NULL, this look for the default filename 863 * $HOME/.zephyr.subs. If the file can not be opened in this case 864 * only, no error message is printed. 865 */ 856 866 void owl_function_loadsubs(char *file) 857 867 { 858 868 int ret, ret2; 859 860 ret=owl_zephyr_loadsubs(file); 869 char *foo; 870 871 if (file==NULL) { 872 ret=owl_zephyr_loadsubs(NULL, 0); 873 } else { 874 ret=owl_zephyr_loadsubs(file, 1); 875 } 861 876 862 877 /* for backwards compatibility for now */ … … 864 879 865 880 if (!owl_context_is_interactive(owl_global_get_context(&g))) return; 866 if (ret==0) { 867 owl_function_makemsg("Subscribed to messages from file."); 881 882 foo=file?file:"file"; 883 if (ret==0 && ret2==0) { 884 if (!file) { 885 owl_function_makemsg("Subscribed to messages."); 886 } else { 887 owl_function_makemsg("Subscribed to messages from %s", file); 888 } 868 889 } else if (ret==-1) { 869 owl_function_error("Could not open file.");890 owl_function_error("Could not read %s", foo); 870 891 } else { 871 owl_function_error("Error subscribing to messages from file.");892 owl_function_error("Error subscribing to messages"); 872 893 } 873 894 } -
owl.c
r4e0f545 r95474d7 373 373 374 374 /* load subscriptions from subs file */ 375 ret2=owl_zephyr_loadsubs(NULL );375 ret2=owl_zephyr_loadsubs(NULL, 0); 376 376 377 377 if (ret || ret2) { -
zephyr.c
r667a1b6 r95474d7 67 67 } 68 68 69 /* return 0 on success 70 * -1 on file error 71 * -2 on subscription error 69 /* Load zephyr subscriptions form 'filename'. If 'filename' is NULL, 70 * the default file $HOME/.zephyr.subs will be used. 71 * 72 * Returns 0 on success. If the file does not exist, return -1 if 73 * 'error_on_nofile' is 1, otherwise return 0. Return -1 if the file 74 * exists but can not be read. Return -2 if there is a failure from 75 * zephyr to load the subscriptions. 72 76 */ 73 int owl_zephyr_loadsubs(char *filename )77 int owl_zephyr_loadsubs(char *filename, int error_on_nofile) 74 78 { 75 79 #ifdef HAVE_LIBZEPHYR … … 88 92 89 93 ret=stat(subsfile, &statbuff); 90 if (ret) return(0); 91 92 ret=0; 94 if (ret) { 95 if (error_on_nofile==1) return(-1); 96 return(0); 97 } 93 98 94 99 ZResetAuthentication(); … … 96 101 count=0; 97 102 file=fopen(subsfile, "r"); 98 if (file) { 99 while ( fgets(buffer, 1024, file)!=NULL ) { 100 if (buffer[0]=='#' || buffer[0]=='\n' || buffer[0]=='\n') continue; 101 102 if (buffer[0]=='-') { 103 start=buffer+1; 104 } else { 105 start=buffer; 106 } 107 108 if (count >= 3000) break; /* also tell the user */ 109 110 /* add it to the list of subs */ 111 if ((tmp=(char *) strtok(start, ",\n\r"))==NULL) continue; 112 subs[count].zsub_class=owl_strdup(tmp); 113 if ((tmp=(char *) strtok(NULL, ",\n\r"))==NULL) continue; 114 subs[count].zsub_classinst=owl_strdup(tmp); 115 if ((tmp=(char *) strtok(NULL, " \t\n\r"))==NULL) continue; 116 subs[count].zsub_recipient=owl_strdup(tmp); 117 118 /* if it started with '-' then add it to the global punt list */ 119 if (buffer[0]=='-') { 120 owl_function_zpunt(subs[count].zsub_class, subs[count].zsub_classinst, subs[count].zsub_recipient, 0); 121 } 122 123 count++; 124 } 125 fclose(file); 126 } else { 127 count=0; 128 ret=-1; 129 } 103 if (!file) return(-1); 104 while ( fgets(buffer, 1024, file)!=NULL ) { 105 if (buffer[0]=='#' || buffer[0]=='\n' || buffer[0]=='\n') continue; 106 107 if (buffer[0]=='-') { 108 start=buffer+1; 109 } else { 110 start=buffer; 111 } 112 113 if (count >= 3000) break; /* also tell the user */ 114 115 /* add it to the list of subs */ 116 if ((tmp=(char *) strtok(start, ",\n\r"))==NULL) continue; 117 subs[count].zsub_class=owl_strdup(tmp); 118 if ((tmp=(char *) strtok(NULL, ",\n\r"))==NULL) continue; 119 subs[count].zsub_classinst=owl_strdup(tmp); 120 if ((tmp=(char *) strtok(NULL, " \t\n\r"))==NULL) continue; 121 subs[count].zsub_recipient=owl_strdup(tmp); 122 123 /* if it started with '-' then add it to the global punt list */ 124 if (buffer[0]=='-') { 125 owl_function_zpunt(subs[count].zsub_class, subs[count].zsub_classinst, subs[count].zsub_recipient, 0); 126 } 127 128 count++; 129 } 130 fclose(file); 130 131 131 132 /* sub without defaults */ 133 ret=0; 132 134 if (ZSubscribeToSansDefaults(subs,count,0) != ZERR_NONE) { 133 135 owl_function_error("Error subscribing to zephyr notifications.");
Note: See TracChangeset
for help on using the changeset viewer.