Changeset ec6ff52 for functions.c
- Timestamp:
- Oct 17, 2003, 5:16:25 PM (20 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:
- 836ea3a3
- Parents:
- a053de8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
functions.c
r8a54409 rec6ff52 67 67 v=owl_global_get_current_view(&g); 68 68 if (viewname && strcmp(viewname, owl_view_get_name(v))) { 69 owl_function_ makemsg("No view named '%s'", viewname);69 owl_function_error("No view named '%s'", viewname); 70 70 return; 71 71 } … … 218 218 ret=owl_zwrite_create_from_line(&z, line); 219 219 if (ret) { 220 owl_function_ makemsg("Error in zwrite arugments");220 owl_function_error("Error in zwrite arugments"); 221 221 owl_zwrite_free(&z); 222 222 return; … … 343 343 ret=owl_zcrypt_encrypt(cryptmsg, mymsg, owl_zwrite_get_class(&z), owl_zwrite_get_instance(&z)); 344 344 if (ret) { 345 owl_function_ makemsg("Error in zcrypt, possibly no key found. Message not sent.");345 owl_function_error("Error in zcrypt, possibly no key found. Message not sent."); 346 346 owl_function_beep(); 347 347 owl_free(cryptmsg); … … 379 379 void owl_function_aimwrite(char *to) 380 380 { 381 int ret; 382 381 383 /* send the message */ 382 owl_aim_send_im(to, owl_editwin_get_text(owl_global_get_typwin(&g))); 383 owl_function_makemsg("AIM message sent."); 384 ret=owl_aim_send_im(to, owl_editwin_get_text(owl_global_get_typwin(&g))); 385 if (!ret) { 386 owl_function_makemsg("AIM message sent."); 387 } else { 388 owl_function_error("Could not send AIM message."); 389 } 384 390 385 391 /* display the message as an outgoing message in the receive window */ … … 410 416 f=owl_global_get_filter(&g, filter); 411 417 if (!f) { 412 owl_function_ makemsg("No %s filter defined", filter);418 owl_function_error("No %s filter defined", filter); 413 419 return; 414 420 } … … 434 440 435 441 if (!found) { 436 owl_function_ makemsg("already at last%s message%s%s",442 owl_function_error("already at last%s message%s%s", 437 443 skip_deleted?" non-deleted":"", 438 444 filter?" in ":"", filter?filter:""); … … 460 466 f=owl_global_get_filter(&g, filter); 461 467 if (!f) { 462 owl_function_ makemsg("No %s filter defined", filter);468 owl_function_error("No %s filter defined", filter); 463 469 return; 464 470 } … … 483 489 484 490 if (!found) { 485 owl_function_ makemsg("already at first%s message%s%s",491 owl_function_error("already at first%s message%s%s", 486 492 skip_deleted?" non-deleted":"", 487 493 filter?" in ":"", filter?filter:""); … … 538 544 /* bail if there's no current message */ 539 545 if (owl_view_get_size(v) < 1) { 540 owl_function_ makemsg("No current message to delete");546 owl_function_error("No current message to delete"); 541 547 return; 542 548 } … … 565 571 566 572 if (owl_view_get_size(v) < 1) { 567 owl_function_ makemsg("No current message to undelete");573 owl_function_error("No current message to undelete"); 568 574 return; 569 575 } … … 677 683 } else { 678 684 owl_function_beep(); 679 owl_function_ makemsg("Already full left");685 owl_function_error("Already full left"); 680 686 } 681 687 } … … 697 703 owl_function_makemsg("Subscribed to messages from file."); 698 704 } else if (ret==-1) { 699 owl_function_ makemsg("Could not open file.");705 owl_function_error("Could not open file."); 700 706 } else { 701 owl_function_ makemsg("Error subscribing to messages from file.");707 owl_function_error("Error subscribing to messages from file."); 702 708 } 703 709 } … … 713 719 owl_function_makemsg("Subscribed to login messages from file."); 714 720 } else if (ret==-1) { 715 owl_function_ makemsg("Could not open file for login subscriptions.");721 owl_function_error("Could not open file for login subscriptions."); 716 722 } else { 717 owl_function_ makemsg("Error subscribing to login messages from file.");723 owl_function_error("Error subscribing to login messages from file."); 718 724 } 719 725 } … … 776 782 } 777 783 778 void owl_function_makemsg(char *fmt, ...)779 {780 va_list ap;781 char buff[2048];782 783 if (!owl_global_get_curs_msgwin(&g)) return;784 785 va_start(ap, fmt);786 werase(owl_global_get_curs_msgwin(&g));787 788 vsnprintf(buff, 2048, fmt, ap);789 owl_function_debugmsg("makemsg: %s", buff);790 waddstr(owl_global_get_curs_msgwin(&g), buff);791 wnoutrefresh(owl_global_get_curs_msgwin(&g));792 owl_global_set_needrefresh(&g);793 va_end(ap);794 }795 796 void owl_function_errormsg(char *fmt, ...)797 {798 va_list ap;799 char buff[2048];800 801 if (!owl_global_get_curs_msgwin(&g)) return;802 803 va_start(ap, fmt);804 werase(owl_global_get_curs_msgwin(&g));805 806 vsnprintf(buff, 2048, fmt, ap);807 owl_function_debugmsg("ERROR: %s", buff);808 waddstr(owl_global_get_curs_msgwin(&g), buff);809 waddstr(owl_global_get_curs_msgwin(&g), "ERROR: ");810 wnoutrefresh(owl_global_get_curs_msgwin(&g));811 owl_global_set_needrefresh(&g);812 va_end(ap);813 }814 815 784 void owl_function_openurl() 816 785 { … … 824 793 825 794 if (webbrowser < 0 || webbrowser == OWL_WEBBROWSER_NONE) { 826 owl_function_ makemsg("No browser selected");795 owl_function_error("No browser selected"); 827 796 return; 828 797 } … … 833 802 834 803 if (!m || owl_view_get_size(v)==0) { 835 owl_function_ makemsg("No current message selected");804 owl_function_error("No current message selected"); 836 805 return; 837 806 } … … 882 851 } else { 883 852 owl_function_beep(); 884 owl_function_ makemsg("Could not find URL to open.");853 owl_function_error("Could not find URL to open."); 885 854 return; 886 855 } … … 890 859 if (*ptr1 == '"' || *ptr1 == '\\') { 891 860 owl_function_beep(); 892 owl_function_ makemsg("URL contains invalid characters.");861 owl_function_error("URL contains invalid characters."); 893 862 return; 894 863 } … … 1162 1131 ret=owl_zephyr_sub(class, inst, recip); 1163 1132 if (ret) { 1164 owl_function_ makemsg("Error subscribing.");1133 owl_function_error("Error subscribing."); 1165 1134 } else { 1166 1135 owl_function_makemsg("Subscribed."); … … 1174 1143 ret=owl_zephyr_unsub(class, inst, recip); 1175 1144 if (ret) { 1176 owl_function_ makemsg("Error subscribing.");1145 owl_function_error("Error subscribing."); 1177 1146 } else { 1178 1147 owl_function_makemsg("Unsubscribed."); … … 1278 1247 m=owl_view_get_element(v, owl_global_get_curmsg(&g)); 1279 1248 if (!m || owl_view_get_size(v)==0) { 1280 owl_function_ makemsg("No message selected\n");1249 owl_function_error("No message selected\n"); 1281 1250 return; 1282 1251 } … … 1443 1412 1444 1413 if (!m || owl_view_get_size(v)==0) { 1445 owl_function_ makemsg("No current message");1414 owl_function_error("No current message"); 1446 1415 return; 1447 1416 } … … 1472 1441 /* Bail if the curmsg isn't the last one displayed */ 1473 1442 if (curmsg != owl_mainwin_get_last_msg(owl_global_get_mainwin(&g))) { 1474 owl_function_ makemsg("The entire message is already displayed");1443 owl_function_error("The entire message is already displayed"); 1475 1444 return; 1476 1445 } … … 1478 1447 /* Bail if we're not truncated */ 1479 1448 if (!owl_mainwin_is_curmsg_truncated(owl_global_get_mainwin(&g))) { 1480 owl_function_ makemsg("The entire message is already displayed");1449 owl_function_error("The entire message is already displayed"); 1481 1450 return; 1482 1451 } … … 1647 1616 owl_global_set_needrefresh(&g); 1648 1617 } else { 1649 owl_function_ makemsg("No message with id %d: unable to mark for (un)delete",id);1618 owl_function_error("No message with id %d: unable to mark for (un)delete",id); 1650 1619 } 1651 1620 } … … 1664 1633 f=owl_global_get_filter(&g, "trash"); 1665 1634 if (!f) { 1666 owl_function_ makemsg("No trash filter defined");1635 owl_function_error("No trash filter defined"); 1667 1636 return; 1668 1637 } … … 1787 1756 1788 1757 if (owl_view_get_size(owl_global_get_current_view(&g))==0) { 1789 owl_function_ makemsg("No message selected");1758 owl_function_error("No message selected"); 1790 1759 } else { 1791 1760 char *class, *inst, *to, *cc=NULL; … … 1793 1762 m=owl_view_get_element(owl_global_get_current_view(&g), owl_global_get_curmsg(&g)); 1794 1763 if (!m) { 1795 owl_function_ makemsg("No message selected");1764 owl_function_error("No message selected"); 1796 1765 return; 1797 1766 } … … 1801 1770 if (f) { 1802 1771 if (owl_filter_message_match(f, m)) { 1803 owl_function_ makemsg("Sorry, replies to this message have been disabled by the reply-lockout filter");1772 owl_function_error("Sorry, replies to this message have been disabled by the reply-lockout filter"); 1804 1773 return; 1805 1774 } … … 1808 1777 /* admin */ 1809 1778 if (owl_message_is_type_admin(m)) { 1810 owl_function_ makemsg("You cannot reply to an admin message");1779 owl_function_error("You cannot reply to an admin message"); 1811 1780 return; 1812 1781 } … … 2004 1973 2005 1974 if (argc<2) { 2006 owl_function_ makemsg("Wrong number of arguments to the exec command");1975 owl_function_error("Wrong number of arguments to the exec command"); 2007 1976 return NULL; 2008 1977 } … … 2047 2016 2048 2017 if (argc<2) { 2049 owl_function_ makemsg("Wrong number of arguments to perl command");2018 owl_function_error("Wrong number of arguments to perl command"); 2050 2019 return NULL; 2051 2020 } … … 2093 2062 f=owl_global_get_filter(&g, filtname); 2094 2063 if (!f) { 2095 owl_function_ makemsg("Unknown filter");2064 owl_function_error("Unknown filter %s", filtname); 2096 2065 return; 2097 2066 } … … 2142 2111 f=owl_global_get_filter(&g, filtname); 2143 2112 if (!f) { 2144 owl_function_ makemsg("Unknown filter");2113 owl_function_error("Unknown filter %s", filtname); 2145 2114 return; 2146 2115 } … … 2172 2141 2173 2142 if (argc < 2) { 2174 owl_function_ makemsg("Wrong number of arguments to filter command");2143 owl_function_error("Wrong number of arguments to filter command"); 2175 2144 return; 2176 2145 } … … 2180 2149 /* don't touch the all filter */ 2181 2150 if (!strcmp(argv[1], "all")) { 2182 owl_function_ makemsg("You may not change the 'all' filter.");2151 owl_function_error("You may not change the 'all' filter."); 2183 2152 return; 2184 2153 } … … 2188 2157 f=owl_global_get_filter(&g, argv[1]); 2189 2158 if (!f) { 2190 owl_function_ makemsg("The filter '%s' does not exist.", argv[1]);2159 owl_function_error("The filter '%s' does not exist.", argv[1]); 2191 2160 return; 2192 2161 } … … 2202 2171 if (ret==-1) { 2203 2172 owl_free(f); 2204 owl_function_ makemsg("Invalid filter syntax");2173 owl_function_error("Invalid filter syntax"); 2205 2174 return; 2206 2175 } … … 2262 2231 f=owl_global_get_filter(&g, name); 2263 2232 if (!f) { 2264 owl_function_ makemsg("There is no filter with that name");2233 owl_function_error("There is no filter named %s", name); 2265 2234 return; 2266 2235 } … … 2510 2479 2511 2480 if (!m || owl_view_get_size(v)==0) { 2512 owl_function_ makemsg("No message selected\n");2481 owl_function_error("No message selected\n"); 2513 2482 return(NULL); 2514 2483 } … … 2571 2540 2572 2541 if (!m || owl_view_get_size(v)==0) { 2573 owl_function_ makemsg("No message selected\n");2542 owl_function_error("No message selected\n"); 2574 2543 return; 2575 2544 } … … 2579 2548 || owl_message_is_loginout(m) 2580 2549 || !owl_message_is_type_zephyr(m)) { 2581 owl_function_ makemsg("smartzpunt doesn't support this message type.");2550 owl_function_error("smartzpunt doesn't support this message type."); 2582 2551 return; 2583 2552 } … … 2588 2557 || (!strcasecmp(mclass, "message") && !strcasecmp(minst, "personal")) 2589 2558 || (type && (!minst || !*minst|| *minst==' '))) { 2590 owl_function_ makemsg("smartzpunt can't safely do this for <%s,%s>",2559 owl_function_error("smartzpunt can't safely do this for <%s,%s>", 2591 2560 mclass, minst); 2592 2561 } else { … … 2614 2583 f=owl_global_get_filter(&g, name); 2615 2584 if (!f) { 2616 owl_function_ makemsg("Unknown filter");2585 owl_function_error("Unknown filter"); 2617 2586 return; 2618 2587 } … … 2620 2589 /* don't touch the all filter */ 2621 2590 if (!strcmp(name, "all")) { 2622 owl_function_ makemsg("You may not change the 'all' filter.");2591 owl_function_error("You may not change the 'all' filter."); 2623 2592 return; 2624 2593 } … … 2683 2652 owl_free(buff); 2684 2653 if (ret) { 2685 owl_function_ makemsg("Error creating filter for zpunt");2654 owl_function_error("Error creating filter for zpunt"); 2686 2655 owl_filter_free(f); 2687 2656 return; … … 2716 2685 { 2717 2686 if (!owl_keyhandler_activate(owl_global_get_keyhandler(&g), keymap)) { 2718 owl_function_ makemsg("Unable to activate keymap '%s'", keymap);2687 owl_function_error("Unable to activate keymap '%s'", keymap); 2719 2688 } 2720 2689 } … … 2818 2787 2819 2788 if (viewsize==0) { 2820 owl_function_ makemsg("No messages present");2789 owl_function_error("No messages present"); 2821 2790 return; 2822 2791 } … … 2832 2801 /* bounds check */ 2833 2802 if (start>=viewsize || start<0) { 2834 owl_function_ makemsg("No further matches found");2803 owl_function_error("No further matches found"); 2835 2804 return; 2836 2805 } … … 2856 2825 } 2857 2826 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 2858 owl_function_ makemsg("No matches found");2827 owl_function_error("No matches found"); 2859 2828 } 2860 2829 … … 2918 2887 tmp=owl_global_get_homedir(&g); 2919 2888 if (!tmp) { 2920 owl_function_ makemsg("Could not determine home directory");2889 owl_function_error("Could not determine home directory"); 2921 2890 return; 2922 2891 } … … 2929 2898 f=fopen(ourfile, "r"); 2930 2899 if (!f) { 2931 owl_function_ makemsg("Error opening file %s: %s",2900 owl_function_error("Error opening file %s: %s", 2932 2901 ourfile, 2933 2902 strerror(errno) ? strerror(errno) : ""); … … 2962 2931 ret=ZLocateUser(buff, &numlocs, ZAUTH); 2963 2932 if (ret!=ZERR_NONE) { 2964 owl_function_ makemsg("Error getting location for %s", buff);2933 owl_function_error("Error getting location for %s", buff); 2965 2934 continue; 2966 2935 } … … 3015 2984 file=fopen(filename, "w"); 3016 2985 if (!file) { 3017 owl_function_ makemsg("Error opening file");2986 owl_function_error("Error opening file"); 3018 2987 return; 3019 2988 } … … 3107 3076 file=fopen(filename, "a"); 3108 3077 if (!file) { 3109 owl_function_ makemsg("Error opening startupfile for new command");3078 owl_function_error("Error opening startupfile for new command"); 3110 3079 owl_free(filename); 3111 3080 return; … … 3163 3132 s=owl_global_get_style_by_name(&g, stylename); 3164 3133 if (!s) { 3165 owl_function_ makemsg("No style named %s", stylename);3134 owl_function_error("No style named %s", stylename); 3166 3135 return; 3167 3136 } … … 3170 3139 owl_function_calculate_topmsg(OWL_DIRECTION_DOWNWARDS); 3171 3140 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 3172 3173 3141 } 3174 3142 … … 3191 3159 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 3192 3160 } 3161 3162 void owl_function_error(char *fmt, ...) 3163 { 3164 va_list ap; 3165 char buff[2048], buff2[2048]; 3166 char *date; 3167 time_t now; 3168 3169 now=time(NULL); 3170 date=owl_strdup(ctime(&now)); 3171 date[strlen(date)-1]='\0'; 3172 3173 va_start(ap, fmt); 3174 3175 vsnprintf(buff, 2048, fmt, ap); 3176 sprintf(buff2, "%s %s", date, buff); 3177 owl_function_debugmsg("ERROR: %s", buff); 3178 if (owl_global_get_curs_msgwin(&g)) { 3179 werase(owl_global_get_curs_msgwin(&g)); 3180 waddstr(owl_global_get_curs_msgwin(&g), buff); 3181 wnoutrefresh(owl_global_get_curs_msgwin(&g)); 3182 owl_global_set_needrefresh(&g); 3183 } 3184 owl_errqueue_append_err(owl_global_get_errqueue(&g), buff2); 3185 va_end(ap); 3186 owl_free(date); 3187 } 3188 3189 void owl_function_showerrs() 3190 { 3191 owl_fmtext fm; 3192 3193 owl_fmtext_init_null(&fm); 3194 owl_fmtext_append_normal(&fm, "Errors:\n\n"); 3195 owl_errqueue_to_fmtext(owl_global_get_errqueue(&g), &fm); 3196 owl_function_popless_fmtext(&fm); 3197 } 3198 3199 void owl_function_makemsg(char *fmt, ...) 3200 { 3201 va_list ap; 3202 char buff[2048]; 3203 3204 if (!owl_global_get_curs_msgwin(&g)) return; 3205 3206 va_start(ap, fmt); 3207 werase(owl_global_get_curs_msgwin(&g)); 3208 3209 vsnprintf(buff, 2048, fmt, ap); 3210 owl_function_debugmsg("makemsg: %s", buff); 3211 waddstr(owl_global_get_curs_msgwin(&g), buff); 3212 wnoutrefresh(owl_global_get_curs_msgwin(&g)); 3213 owl_global_set_needrefresh(&g); 3214 va_end(ap); 3215 }
Note: See TracChangeset
for help on using the changeset viewer.