Changeset a0a5179 for functions.c


Ignore:
Timestamp:
Nov 19, 2003, 11:19:03 PM (20 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
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:
f1645da
Parents:
52f3507
Message:
blist works for AIM even if the zephyr .anyone can't be read
AIM Buddy debugging
File:
1 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    rcee1f25 ra0a5179  
    30003000  owl_fmtext_init_null(&fm);
    30013001
     3002  /* AIM first */
    30023003  if (aim && owl_global_is_aimloggedin(&g)) {
    30033004    bl=owl_global_get_buddylist(&g);
     
    30143015        timestr=owl_strdup("");
    30153016      }
    3016       foo=owl_sprintf("  %-20.20s %-12.12s\n",
    3017                       owl_buddy_get_name(b),
    3018                       timestr);
     3017      foo=owl_sprintf("  %-20.20s %-12.12s\n", owl_buddy_get_name(b), timestr);
    30193018      owl_fmtext_append_normal(&fm, foo);
    30203019      owl_free(timestr);
     
    30273026    if (file==NULL) {
    30283027      tmp=owl_global_get_homedir(&g);
    3029       if (!tmp) {
    3030         owl_function_error("Could not determine home directory");
    3031         return;
    3032       }
    3033       ourfile=owl_malloc(strlen(tmp)+50);
    3034       sprintf(ourfile, "%s/.anyone", owl_global_get_homedir(&g));
     3028      ourfile=owl_sprintf("%s/.anyone", owl_global_get_homedir(&g));
    30353029    } else {
    30363030      ourfile=owl_strdup(file);
    30373031    }
    3038    
     3032
     3033    owl_fmtext_append_bold(&fm, "Zephyr users logged in:\n");
    30393034    f=fopen(ourfile, "r");
    30403035    if (!f) {
    3041       owl_function_error("Error opening file %s: %s",
    3042                            ourfile,
    3043                            strerror(errno) ? strerror(errno) : "");
    3044       return;
    3045     }
    3046 
    3047     owl_fmtext_append_bold(&fm, "Zephyr users logged in:\n");
    3048    
    3049     while (fgets(buff, LINE, f)!=NULL) {
    3050       /* ignore comments, blank lines etc. */
    3051       if (buff[0]=='#') continue;
    3052       if (buff[0]=='\n') continue;
    3053       if (buff[0]=='\0') continue;
    3054      
    3055       /* strip the \n */
    3056       buff[strlen(buff)-1]='\0';
    3057      
    3058       /* ingore from # on */
    3059       tmp=strchr(buff, '#');
    3060       if (tmp) tmp[0]='\0';
    3061      
    3062       /* ingore from SPC */
    3063       tmp=strchr(buff, ' ');
    3064       if (tmp) tmp[0]='\0';
    3065      
    3066       /* stick on the local realm. */
    3067       if (!strchr(buff, '@')) {
    3068         strcat(buff, "@");
    3069         strcat(buff, ZGetRealm());
    3070       }
    3071      
    3072       ret=ZLocateUser(buff, &numlocs, ZAUTH);
    3073       if (ret!=ZERR_NONE) {
    3074         owl_function_error("Error getting location for %s", buff);
    3075         continue;
    3076       }
    3077      
    3078       numlocs=200;
    3079       ret=ZGetLocations(location, &numlocs);
    3080       if (ret==0) {
    3081         for (i=0; i<numlocs; i++) {
    3082           line=malloc(strlen(location[i].host)+strlen(location[i].time)+strlen(location[i].tty)+100);
    3083           tmp=short_zuser(buff);
    3084           sprintf(line, "  %-10.10s %-24.24s %-12.12s  %20.20s\n",
    3085                   tmp,
    3086                   location[i].host,
    3087                   location[i].tty,
    3088                   location[i].time);
    3089           owl_fmtext_append_normal(&fm, line);
    3090           owl_free(tmp);
     3036      owl_fmtext_append_normal(&fm, "  Error opening file ");
     3037      owl_fmtext_append_normal(&fm, ourfile);
     3038      owl_fmtext_append_normal(&fm, "\n");
     3039      owl_function_error("Error opening file %s: %s", ourfile, strerror(errno) ? strerror(errno) : "");
     3040    } else {
     3041      while (fgets(buff, LINE, f)!=NULL) {
     3042        /* ignore comments, blank lines etc. */
     3043        if (buff[0]=='#') continue;
     3044        if (buff[0]=='\n') continue;
     3045        if (buff[0]=='\0') continue;
     3046       
     3047        /* strip the \n */
     3048        buff[strlen(buff)-1]='\0';
     3049       
     3050        /* ingore from # on */
     3051        tmp=strchr(buff, '#');
     3052        if (tmp) tmp[0]='\0';
     3053       
     3054        /* ingore from SPC */
     3055        tmp=strchr(buff, ' ');
     3056        if (tmp) tmp[0]='\0';
     3057       
     3058        /* stick on the local realm. */
     3059        if (!strchr(buff, '@')) {
     3060          strcat(buff, "@");
     3061          strcat(buff, ZGetRealm());
    30913062        }
    3092         if (numlocs>=200) {
    3093           owl_fmtext_append_normal(&fm, "  Too many locations found for this user, truncating.\n");
     3063       
     3064        ret=ZLocateUser(buff, &numlocs, ZAUTH);
     3065        if (ret!=ZERR_NONE) {
     3066          owl_function_error("Error getting location for %s", buff);
     3067          continue;
     3068        }
     3069       
     3070        numlocs=200;
     3071        ret=ZGetLocations(location, &numlocs);
     3072        if (ret==0) {
     3073          for (i=0; i<numlocs; i++) {
     3074            line=malloc(strlen(location[i].host)+strlen(location[i].time)+strlen(location[i].tty)+100);
     3075            tmp=short_zuser(buff);
     3076            sprintf(line, "  %-10.10s %-24.24s %-12.12s  %20.20s\n",
     3077                    tmp,
     3078                    location[i].host,
     3079                    location[i].tty,
     3080                    location[i].time);
     3081            owl_fmtext_append_normal(&fm, line);
     3082            owl_free(tmp);
     3083          }
     3084          if (numlocs>=200) {
     3085            owl_fmtext_append_normal(&fm, "  Too many locations found for this user, truncating.\n");
     3086          }
    30943087        }
    30953088      }
    3096     }
    3097     fclose(f);
     3089      fclose(f);
     3090    }
    30983091    owl_free(ourfile);
    30993092  }
Note: See TracChangeset for help on using the changeset viewer.