static void _owl_fmtext_realloc(owl_fmtext *f, int newlen) { if(newlen + 1 > f->bufflen) { f->textbuff = owl_realloc(f->textbuff, newlen + 1); f->bufflen = newlen+1; } }
void _owl_fmtext_realloc(owl_fmtext *f, int newlen) /*noproto*/ { if(newlen + 1 > f->bufflen) { f->textbuff = owl_realloc(f->textbuff, newlen + 1); f->bufflen = newlen+1; } }
int owl_zephyr_loadloginsubs(char *filename) { #ifdef HAVE_LIBZEPHYR FILE *file; ZSubscription_t *subs; int numSubs = 100; char subsfile[1024], buffer[1024]; int count, ret; struct stat statbuff; subs = owl_malloc(numSubs * sizeof(ZSubscription_t)); if (filename==NULL) { sprintf(subsfile, "%s/%s", owl_global_get_homedir(&g), ".anyone"); } else { strcpy(subsfile, filename); } ret=stat(subsfile, &statbuff); if (ret) return(0); ret=0; ZResetAuthentication(); count=0; file=fopen(subsfile, "r"); if (file) { while ( fgets(buffer, 1024, file)!=NULL ) { if (buffer[0]=='#' || buffer[0]=='\n' || buffer[0]=='\n') continue; if (count == numSubs) { numSubs *= 2; subs = owl_realloc(subs, numSubs * sizeof(ZSubscription_t)); } buffer[strlen(buffer)-1]='\0'; subs[count].zsub_class=owl_strdup("login"); subs[count].zsub_recipient=owl_strdup("*"); if (strchr(buffer, '@')) { subs[count].zsub_classinst=owl_strdup(buffer); } else { subs[count].zsub_classinst=owl_sprintf("%s@%s", buffer, ZGetRealm()); } count++; } fclose(file); } else { count=0; ret=-1; } ret = owl_zephyr_loadsubs_helper(subs, count); return(ret); #else return(0); #endif }
/* Load zephyr subscriptions from 'filename'. If 'filename' is NULL, * the default file $HOME/.zephyr.subs will be used. * * Returns 0 on success. If the file does not exist, return -1 if * 'error_on_nofile' is 1, otherwise return 0. Return -1 if the file * exists but can not be read. Return -2 if there is a failure from * zephyr to load the subscriptions. */ int owl_zephyr_loadsubs(char *filename, int error_on_nofile) { #ifdef HAVE_LIBZEPHYR FILE *file; char *tmp, *start; char buffer[1024], subsfile[1024]; ZSubscription_t *subs; int subSize = 1024; int count, ret; struct stat statbuff; subs = owl_malloc(sizeof(ZSubscription_t) * subSize); if (filename==NULL) { sprintf(subsfile, "%s/%s", owl_global_get_homedir(&g), ".zephyr.subs"); } else { strcpy(subsfile, filename); } ret=stat(subsfile, &statbuff); if (ret) { if (error_on_nofile==1) return(-1); return(0); } ZResetAuthentication(); count=0; file=fopen(subsfile, "r"); if (!file) return(-1); while ( fgets(buffer, 1024, file)!=NULL ) { if (buffer[0]=='#' || buffer[0]=='\n' || buffer[0]=='\n') continue; if (buffer[0]=='-') { start=buffer+1; } else { start=buffer; } if (count >= subSize) { subSize *= 2; subs = owl_realloc(subs, sizeof(ZSubscription_t) * subSize); } /* add it to the list of subs */ if ((tmp=(char *) strtok(start, ",\n\r"))==NULL) continue; subs[count].zsub_class=owl_strdup(tmp); if ((tmp=(char *) strtok(NULL, ",\n\r"))==NULL) continue; subs[count].zsub_classinst=owl_strdup(tmp); if ((tmp=(char *) strtok(NULL, " \t\n\r"))==NULL) continue; subs[count].zsub_recipient=owl_strdup(tmp); /* if it started with '-' then add it to the global punt list, and * remove it from the list of subs. */ if (buffer[0]=='-') { owl_function_zpunt(subs[count].zsub_class, subs[count].zsub_classinst, subs[count].zsub_recipient, 0); owl_free(subs[count].zsub_class); owl_free(subs[count].zsub_classinst); owl_free(subs[count].zsub_recipient); } else { count++; } } fclose(file); ret = owl_zephyr_loadsubs_helper(subs, count); return(ret); #else return(0); #endif }