- Timestamp:
- Mar 7, 2009, 7:04:55 PM (16 years ago)
- Branches:
- master, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- a5e7ed6
- Parents:
- 0cff2b4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
zephyr.c
r0cff2b4 rd21efbc 192 192 } 193 193 194 owl_free(subs); 195 194 196 return ret; 195 197 } … … 242 244 243 245 if (count >= subSize) { 244 ZSubscription_t* newsubs; 245 newsubs = owl_realloc(subs, sizeof(ZSubscription_t) * subSize * 2); 246 if (NULL == newsubs) { 247 /* If realloc fails, load what we've got, clear, and continue */ 248 ret = owl_zephyr_loadsubs_helper(subs, count); 249 if (ret != 0) { 250 fclose(file); 251 return(ret); 252 } 253 count=0; 254 } 255 else { 256 subs = newsubs; 257 subSize *= 2; 258 } 246 subSize *= 2; 247 subs = owl_realloc(subs, sizeof(ZSubscription_t) * subSize); 259 248 } 260 249 … … 282 271 283 272 owl_zephyr_loadsubs_helper(subs, count); 284 owl_free(subs);285 273 return(ret); 286 274 #else … … 308 296 #ifdef HAVE_LIBZEPHYR 309 297 FILE *file; 310 ZSubscription_t subs[3001]; 298 ZSubscription_t *subs; 299 int numSubs = 100; 311 300 char subsfile[1024], buffer[1024]; 312 int count, ret , i;301 int count, ret; 313 302 struct stat statbuff; 303 304 subs = owl_malloc(numSubs * sizeof(ZSubscription_t)); 314 305 315 306 if (filename==NULL) { … … 325 316 326 317 ZResetAuthentication(); 327 /* need to redo this to do chunks, not just bag out after 3000 */328 318 count=0; 329 319 file=fopen(subsfile, "r"); … … 332 322 if (buffer[0]=='#' || buffer[0]=='\n' || buffer[0]=='\n') continue; 333 323 334 if (count >= 3000) break; /* also tell the user */ 324 if (count == numSubs) { 325 numSubs *= 2; 326 subs = owl_realloc(subs, numSubs * sizeof(ZSubscription_t)); 327 } 335 328 336 329 buffer[strlen(buffer)-1]='\0'; 337 subs[count].zsub_class= "login";338 subs[count].zsub_recipient= "*";330 subs[count].zsub_class=owl_strdup("login"); 331 subs[count].zsub_recipient=owl_strdup("*"); 339 332 if (strchr(buffer, '@')) { 340 333 subs[count].zsub_classinst=owl_strdup(buffer); 341 334 } else { 342 335 subs[count].zsub_classinst=owl_sprintf("%s@%s", buffer, ZGetRealm()); 343 336 } 344 337 … … 351 344 } 352 345 353 /* sub with defaults */ 354 if (ZSubscribeToSansDefaults(subs,count,0) != ZERR_NONE) { 355 owl_function_error("Error subscribing to zephyr notifications."); 356 ret=-2; 357 } 358 359 /* free stuff */ 360 for (i=0; i<count; i++) { 361 owl_free(subs[i].zsub_classinst); 362 } 346 ret = owl_zephyr_loadsubs_helper(subs, count); 363 347 364 348 return(ret);
Note: See TracChangeset
for help on using the changeset viewer.