Changeset 42abb10
- 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
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
r425c013 r42abb10 3 3 'zlog in' will now take an optional thrid argument to set the 4 4 'tty' variable before setting the zlocation 5 There is now a 'zlist' command that acts like 'znol -l' 6 'l' is bound to 'zlist' 5 7 6 8 1.2.3 -
commands.c
r425c013 r42abb10 185 185 "display help on using owl", 186 186 "help [command]", ""), 187 188 OWLCMD_ARGS("zlist", owl_command_zlist, OWL_CTX_INTERACTIVE, 189 "List users logged in", 190 "znol [-f file]", 191 "Print a znol-style listing of users logged in"), 187 192 188 193 OWLCMD_VOID("recv:shiftleft", owl_command_shift_left, OWL_CTX_INTERACTIVE, … … 717 722 owl_function_help_for_command(argv[1]); 718 723 return NULL; 724 } 725 726 char *owl_command_zlist(int argc, char **argv) { 727 int elapsed=0, timesort=0; 728 char *file=NULL; 729 730 argc--; 731 argv++; 732 while (argc) { 733 if (!strcmp(argv[0], "-e")) { 734 elapsed=1; 735 argc--; 736 argv++; 737 } else if (!strcmp(argv[0], "-t")) { 738 timesort=1; 739 argc--; 740 argv++; 741 } else if (!strcmp(argv[0], "-f")) { 742 if (argc==1) { 743 owl_function_makemsg("zlist: -f needs an argument"); 744 return(NULL); 745 } 746 file=argv[1]; 747 argc-=2; 748 argv+=2; 749 } else { 750 owl_function_makemsg("zlist: unknown argument"); 751 return(NULL); 752 } 753 } 754 owl_function_zlist(file, elapsed, timesort); 755 return(NULL); 719 756 } 720 757 -
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 } -
keys.c
r67103d4 r42abb10 240 240 241 241 BIND_CMD("i", "info", ""); 242 BIND_CMD("l", "zlist", ""); 242 243 BIND_CMD("M", "pop-message", ""); 243 244 BIND_CMD("T", "delete trash", "mark all 'trash' messages for deletion"); -
util.c
r5145235 r42abb10 148 148 } 149 149 150 /* skips n tokens and returns where that would be.151 * TODO: handle quotes more sanely. */152 150 char *skiptokens(char *buff, int n) { 151 /* skips n tokens and returns where that would be. 152 * TODO: handle quotes more sanely. */ 153 153 154 int inquotes=0; 154 155 while (*buff && n>0) { … … 288 289 289 290 char *stristr(char *a, char *b) { 291 /* exactly like strstr but it's case insensitive */ 290 292 char *x, *y, *ret; 291 293 … … 306 308 } 307 309 308 /* Caller must free response.309 Takes in strings which are space-separated lists of tokens310 and returns a single string containing no token more than once.311 If prohibit is non-null, no token may start with a character312 in prohibit.313 */314 310 char *owl_util_uniq(char *A, char *B, char *prohibit) { 311 /* Caller must free response. 312 Takes in strings which are space-separated lists of tokens 313 and returns a single string containing no token more than once. 314 If prohibit is non-null, no token may start with a character 315 in prohibit. 316 */ 317 315 318 char *cat, **tok; 316 319 int toklen, i, j, first=1; … … 338 341 } 339 342 340 341 342 /* returns if a string is only whitespace */343 343 int only_whitespace(char *s) { 344 /* returns if a string is only whitespace */ 345 344 346 int i; 345 347 for (i=0; s[i]; i++) { … … 349 351 } 350 352 353 /* hooks for doing memory allocation et. al. in owl */ 354 351 355 void *owl_malloc(size_t size) { 352 356 return(malloc(size)); … … 365 369 } 366 370 367 /* allocates memory and returns the string or null.368 * caller must free the string.369 * from Linux sprintf man page.370 */371 371 char *owl_sprintf(const char *fmt, ...) { 372 /* allocates memory and returns the string or null. 373 * caller must free the string. 374 * from Linux sprintf man page. 375 */ 376 372 377 int n, size = 100; 373 378 char *p; 374 379 va_list ap; 375 if ((p = owl_malloc (size)) == NULL) 376 return NULL; 380 if ((p = owl_malloc (size)) == NULL) return (NULL); 377 381 while (1) { 378 382 /* Try to print in the allocated space. */ … … 427 431 } 428 432 429 /* Caller must free returned string.430 * Returns a string with any occurances of 'from' replaced with 'to'.431 * Does not currently handle backslash quoting, but may in the future.432 */433 433 char *owl_util_substitute(char *in, char *from, char *to) { 434 /* Caller must free returned string. 435 * Returns a string with any occurances of 'from' replaced with 'to'. 436 * Does not currently handle backslash quoting, but may in the future. 437 */ 438 434 439 char *out; 435 440 int outlen, tolen, fromlen, inpos=0, outpos=0;
Note: See TracChangeset
for help on using the changeset viewer.