Changeset aa5f725 for functions.c
- Timestamp:
- Jun 3, 2003, 3:40:28 PM (21 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:
- fd93b41
- Parents:
- 651560f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
functions.c
r3abf28b raa5f725 125 125 } 126 126 127 voidowl_function_make_outgoing_aim(char *body, char *to)127 int owl_function_make_outgoing_aim(char *body, char *to) 128 128 { 129 129 owl_message *m; 130 130 int followlast; 131 132 133 if (!owl_global_is_aimloggedin(&g)) { 134 return(-1); 135 } 131 136 132 137 followlast=owl_global_should_followlast(&g); … … 149 154 wnoutrefresh(owl_global_get_curs_recwin(&g)); 150 155 owl_global_set_needrefresh(&g); 156 return(0); 151 157 } 152 158 … … 2689 2695 } 2690 2696 2691 /* popup a znol listing. If file is NULL use the default .anyone */ 2692 /* this doesn't obey 'elapsed' or 'timesort' yet */ 2693 void owl_function_zlist(char *file, int elapsed, int timesort) 2697 /* Popup a buddylisting. If file is NULL use the default .anyone */ 2698 void owl_function_buddylist(int aim, int zephyr, char *file) 2694 2699 { 2695 2700 char *ourfile, *tmp, buff[LINE], *line; 2696 2701 FILE *f; 2697 int numlocs, ret, i ;2702 int numlocs, ret, i, j; 2698 2703 ZLocations_t location[200]; 2699 2704 owl_fmtext fm; 2700 2701 if (file==NULL) { 2702 tmp=owl_global_get_homedir(&g); 2703 if (!tmp) { 2704 owl_function_makemsg("Could not determine home directory"); 2705 owl_buddylist *b; 2706 2707 owl_fmtext_init_null(&fm); 2708 2709 if (aim && owl_global_is_aimloggedin(&g)) { 2710 b=owl_global_get_buddylist(&g); 2711 2712 owl_fmtext_append_bold(&fm, "AIM users logged in:\n"); 2713 j=owl_buddylist_get_size(b); 2714 for (i=0; i<j; i++) { 2715 owl_fmtext_append_normal(&fm, " "); 2716 owl_fmtext_append_normal(&fm, owl_buddylist_get_buddy(b, i)); 2717 owl_fmtext_append_normal(&fm, "\n"); 2718 } 2719 } 2720 2721 if (zephyr) { 2722 if (file==NULL) { 2723 tmp=owl_global_get_homedir(&g); 2724 if (!tmp) { 2725 owl_function_makemsg("Could not determine home directory"); 2726 return; 2727 } 2728 ourfile=owl_malloc(strlen(tmp)+50); 2729 sprintf(ourfile, "%s/.anyone", owl_global_get_homedir(&g)); 2730 } else { 2731 ourfile=owl_strdup(file); 2732 } 2733 2734 f=fopen(ourfile, "r"); 2735 if (!f) { 2736 owl_function_makemsg("Error opening file %s: %s", 2737 ourfile, 2738 strerror(errno) ? strerror(errno) : ""); 2705 2739 return; 2706 2740 } 2707 ourfile=owl_malloc(strlen(tmp)+50);2708 sprintf(ourfile, "%s/.anyone", owl_global_get_homedir(&g));2709 } else {2710 ourfile=owl_strdup(file);2711 }2712 2713 f=fopen(ourfile, "r");2714 if (!f) {2715 owl_function_makemsg("Error opening file %s: %s",2716 ourfile,2717 strerror(errno) ? strerror(errno) : "");2718 return;2719 }2720 2721 owl_fmtext_init_null(&fm);2722 2741 2723 while (fgets(buff, LINE, f)!=NULL) { 2724 /* ignore comments, blank lines etc. */ 2725 if (buff[0]=='#') continue; 2726 if (buff[0]=='\n') continue; 2727 if (buff[0]=='\0') continue; 2728 2729 /* strip the \n */ 2730 buff[strlen(buff)-1]='\0'; 2731 2732 /* ingore from # on */ 2733 tmp=strchr(buff, '#'); 2734 if (tmp) tmp[0]='\0'; 2735 2736 /* ingore from SPC */ 2737 tmp=strchr(buff, ' '); 2738 if (tmp) tmp[0]='\0'; 2739 2740 /* stick on the local realm. */ 2741 if (!strchr(buff, '@')) { 2742 strcat(buff, "@"); 2743 strcat(buff, ZGetRealm()); 2744 } 2745 2746 ret=ZLocateUser(buff, &numlocs, ZAUTH); 2747 if (ret!=ZERR_NONE) { 2748 owl_function_makemsg("Error getting location for %s", buff); 2749 continue; 2750 } 2751 2752 numlocs=200; 2753 ret=ZGetLocations(location, &numlocs); 2754 if (ret==0) { 2755 for (i=0; i<numlocs; i++) { 2756 line=malloc(strlen(location[i].host)+strlen(location[i].time)+strlen(location[i].tty)+100); 2757 tmp=short_zuser(buff); 2758 sprintf(line, "%-10.10s %-24.24s %-12.12s %20.20s\n", 2759 tmp, 2760 location[i].host, 2761 location[i].tty, 2762 location[i].time); 2763 owl_fmtext_append_normal(&fm, line); 2764 owl_free(tmp); 2742 owl_fmtext_append_bold(&fm, "Zephyr users logged in:\n"); 2743 2744 while (fgets(buff, LINE, f)!=NULL) { 2745 /* ignore comments, blank lines etc. */ 2746 if (buff[0]=='#') continue; 2747 if (buff[0]=='\n') continue; 2748 if (buff[0]=='\0') continue; 2749 2750 /* strip the \n */ 2751 buff[strlen(buff)-1]='\0'; 2752 2753 /* ingore from # on */ 2754 tmp=strchr(buff, '#'); 2755 if (tmp) tmp[0]='\0'; 2756 2757 /* ingore from SPC */ 2758 tmp=strchr(buff, ' '); 2759 if (tmp) tmp[0]='\0'; 2760 2761 /* stick on the local realm. */ 2762 if (!strchr(buff, '@')) { 2763 strcat(buff, "@"); 2764 strcat(buff, ZGetRealm()); 2765 2765 } 2766 if (numlocs>=200) { 2767 owl_fmtext_append_normal(&fm, "Too many locations found for this user, truncating.\n"); 2766 2767 ret=ZLocateUser(buff, &numlocs, ZAUTH); 2768 if (ret!=ZERR_NONE) { 2769 owl_function_makemsg("Error getting location for %s", buff); 2770 continue; 2768 2771 } 2769 } 2770 } 2771 fclose(f); 2772 2772 2773 numlocs=200; 2774 ret=ZGetLocations(location, &numlocs); 2775 if (ret==0) { 2776 for (i=0; i<numlocs; i++) { 2777 line=malloc(strlen(location[i].host)+strlen(location[i].time)+strlen(location[i].tty)+100); 2778 tmp=short_zuser(buff); 2779 sprintf(line, " %-10.10s %-24.24s %-12.12s %20.20s\n", 2780 tmp, 2781 location[i].host, 2782 location[i].tty, 2783 location[i].time); 2784 owl_fmtext_append_normal(&fm, line); 2785 owl_free(tmp); 2786 } 2787 if (numlocs>=200) { 2788 owl_fmtext_append_normal(&fm, " Too many locations found for this user, truncating.\n"); 2789 } 2790 } 2791 } 2792 fclose(f); 2793 owl_free(ourfile); 2794 } 2795 2773 2796 owl_function_popless_fmtext(&fm); 2774 2797 owl_fmtext_free(&fm); 2775 2776 owl_free(ourfile);2777 2798 } 2778 2799
Note: See TracChangeset
for help on using the changeset viewer.