Changeset 765fa34
- Timestamp:
- Mar 29, 2009, 5:06:44 PM (14 years ago)
- Branches:
- owl
- Children:
- 9b9e2d9c
- Parents:
- e01449c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
zephyr.c
re01449c r765fa34 717 717 char *owl_zephyr_makesubline(char *class, char *inst, char *recip) 718 718 { 719 char *out; 720 721 out=owl_malloc(strlen(class)+strlen(inst)+strlen(recip)+30); 722 sprintf(out, "%s,%s,%s\n", class, inst, !strcmp(recip, "") ? "*" : recip); 723 return(out); 724 } 725 719 return(owl_sprintf("%s,%s,%s\n", class, inst, !strcmp(recip, "") ? "*" : recip)); 720 } 726 721 727 722 void owl_zephyr_zlog_in(void) … … 753 748 ret=ZSetLocation(eset); 754 749 if (ret != ZERR_NONE) { 755 /* 756 char buff[LINE]; 757 sprintf(buff, "Error setting location: %s", error_message(ret)); 758 owl_function_makemsg(buff); 759 */ 750 /* owl_function_makemsg("Error setting location: %s", error_message(ret)); */ 760 751 } 761 752 #endif … … 770 761 ret=ZUnsetLocation(); 771 762 if (ret != ZERR_NONE) { 772 /* 773 char buff[LINE]; 774 sprintf(buff, "Error unsetting location: %s", error_message(ret)); 775 owl_function_makemsg(buff); 776 */ 763 /* owl_function_makemsg("Error unsetting location: %s", error_message(ret)); */ 777 764 } 778 765 #endif … … 835 822 #ifdef HAVE_LIBZEPHYR 836 823 int ret, num, i, one; 824 int buffsize; 837 825 ZSubscription_t sub; 838 char *out , *tmpbuff;826 char *out; 839 827 one=1; 840 828 … … 842 830 if (ret==ZERR_TOOMANYSUBS) { 843 831 return(owl_strdup("Zephyr: too many subscriptions\n")); 844 } else if (ret ) {832 } else if (ret || (num <= 0)) { 845 833 return(owl_strdup("Zephyr: error retriving subscriptions\n")); 846 834 } 847 835 848 out=owl_malloc(num*500);849 tmpbuff=owl_malloc(num*500);836 buffsize = (num + 1) * 50; 837 out=owl_malloc(buffsize); 850 838 strcpy(out, ""); 851 839 for (i=0; i<num; i++) { 852 840 if ((ret = ZGetSubscriptions(&sub, &one)) != ZERR_NONE) { 853 841 owl_free(out); 854 owl_free(tmpbuff);855 842 ZFlushSubscriptions(); 856 843 out=owl_strdup("Error while getting subscriptions\n"); 857 844 return(out); 858 845 } else { 859 sprintf(tmpbuff, "<%s,%s,%s>\n%s", sub.zsub_class, sub.zsub_classinst, sub.zsub_recipient, out); 846 int tmpbufflen; 847 char *tmpbuff; 848 tmpbuff = owl_sprintf("<%s,%s,%s>\n%s", sub.zsub_class, sub.zsub_classinst, sub.zsub_recipient, out); 849 tmpbufflen = strlen(tmpbuff) + 1; 850 if (tmpbufflen > buffsize) { 851 char *out2; 852 buffsize = tmpbufflen * 2; 853 out2 = owl_realloc(out, buffsize); 854 if (out2 == NULL) { 855 owl_free(out); 856 owl_free(tmpbuff); 857 ZFlushSubscriptions(); 858 out=owl_strdup("Realloc error while getting subscriptions\n"); 859 return(out); 860 } 861 out = out2; 862 } 860 863 strcpy(out, tmpbuff); 861 }862 }863 864 owl_free(tmpbuff); 864 owl_free(tmpbuff); 865 } 866 } 867 865 868 ZFlushSubscriptions(); 866 869 return(out);
Note: See TracChangeset
for help on using the changeset viewer.