Changeset 42abb10 for functions.c
- Timestamp:
- Sep 16, 2002, 2:51:33 PM (22 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:
- af2ca19
- Parents:
- 425c013
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
functions.c
r56330ff r42abb10 2391 2391 return(plaintext); 2392 2392 } 2393 2394 /* popup a znol listing. If file is NULL use the default .anyone */ 2395 /* this doesn't obey 'elapsed' or 'timesort' yet */ 2396 void owl_function_zlist(char *file, int elapsed, int timesort) { 2397 char *ourfile, *tmp, buff[LINE], *line; 2398 FILE *f; 2399 int numlocs, ret, i; 2400 ZLocations_t location[200]; 2401 owl_fmtext fm; 2402 2403 if (file==NULL) { 2404 tmp=owl_global_get_homedir(&g); 2405 if (!tmp) { 2406 owl_function_makemsg("Could not determine home directory"); 2407 return; 2408 } 2409 ourfile=owl_malloc(strlen(tmp)+50); 2410 sprintf(ourfile, "%s/.anyone", owl_global_get_homedir(&g)); 2411 } else { 2412 ourfile=owl_strdup(file); 2413 } 2414 2415 f=fopen(ourfile, "r"); 2416 if (!f) { 2417 owl_function_makemsg("Error opening file %s", ourfile); 2418 return; 2419 } 2420 2421 owl_fmtext_init_null(&fm); 2422 2423 while (fgets(buff, LINE, f)!=NULL) { 2424 /* ignore comments, blank lines etc. */ 2425 if (buff[0]=='#') continue; 2426 if (buff[0]=='\n') continue; 2427 if (buff[0]=='\0') continue; 2428 2429 /* strip the \n */ 2430 buff[strlen(buff)-1]='\0'; 2431 2432 /* ingore from # on */ 2433 tmp=strchr(buff, '#'); 2434 if (tmp) tmp[0]='\0'; 2435 2436 /* ingore from SPC */ 2437 tmp=strchr(buff, ' '); 2438 if (tmp) tmp[0]='\0'; 2439 2440 /* stick on the local realm. */ 2441 if (!strchr(buff, '@')) { 2442 strcat(buff, "@"); 2443 strcat(buff, ZGetRealm()); 2444 } 2445 2446 ret=ZLocateUser(buff, &numlocs, ZAUTH); 2447 if (ret!=ZERR_NONE) { 2448 owl_function_makemsg("Error getting location for %s", buff); 2449 continue; 2450 } 2451 2452 numlocs=200; 2453 ret=ZGetLocations(location, &numlocs); 2454 if (ret==0) { 2455 for (i=0; i<numlocs; i++) { 2456 line=malloc(strlen(location[i].host)+strlen(location[i].time)+strlen(location[i].tty)+100); 2457 tmp=short_zuser(buff); 2458 sprintf(line, "%-10.10s %-24.24s %-12.12s %20.20s\n", 2459 tmp, 2460 location[i].host, 2461 location[i].tty, 2462 location[i].time); 2463 owl_fmtext_append_normal(&fm, line); 2464 owl_free(tmp); 2465 } 2466 if (numlocs>=200) { 2467 owl_fmtext_append_normal(&fm, "Too many locations found for this user, truncating.\n"); 2468 } 2469 } 2470 } 2471 fclose(f); 2472 2473 owl_function_popless_fmtext(&fm); 2474 owl_fmtext_free(&fm); 2475 2476 owl_free(ourfile); 2477 }
Note: See TracChangeset
for help on using the changeset viewer.