Changes in functions.c [4367915:3f3ee61]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
functions.c
r4367915 r3f3ee61 25 25 return owl_cmddict_execute(owl_global_get_cmddict(&g), 26 26 owl_global_get_context(&g), cmdbuff); 27 } 28 29 char *owl_function_command_argv(char **argv, int argc) 30 { 31 return owl_cmddict_execute_argv(owl_global_get_cmddict(&g), 32 owl_global_get_context(&g), 33 argv, argc); 27 34 } 28 35 … … 283 290 owl_editwin_set_dotsend(e); 284 291 strcpy(buff, "----> "); 285 str cat(buff, line);292 strncat(buff, line, 1016); 286 293 strcat(buff, "\n"); 287 294 owl_editwin_set_locktext(e, buff); … … 371 378 /* create the zwrite and send the message */ 372 379 owl_zwrite_create_from_line(&z, line); 380 owl_zwrite_populate_zsig(&z); 373 381 if (msg) { 374 382 owl_zwrite_set_message(&z, msg); … … 409 417 /* create the zwrite and send the message */ 410 418 owl_zwrite_create_from_line(&z, line); 419 owl_zwrite_populate_zsig(&z); 411 420 if (msg) { 412 421 owl_zwrite_set_message(&z, msg); … … 415 424 mymsg=owl_zwrite_get_message(&z); 416 425 #ifdef OWL_ENABLE_ZCRYPT 417 cryptmsg=owl_malloc(strlen(mymsg)*4); 426 /* Allocate enough space for the crypted message. For each byte of 427 * the message, the encoded cyphertext will have two bytes. Block 428 * size is 8 bytes of input, or 16 bytes of output, so make sure we 429 * have at least one block worth of space allocated. If the message 430 * is empty, no blocks are sent, but we still allocate one 431 * block. The additional 16 bytes also provide space for the null 432 * terminator, as we will never use all of it for cyphertext. 433 */ 434 cryptmsg=owl_malloc((strlen(mymsg)*2)+16); 418 435 ret=owl_zcrypt_encrypt(cryptmsg, mymsg, owl_zwrite_get_class(&z), owl_zwrite_get_instance(&z)); 419 436 if (ret) { … … 421 438 owl_function_beep(); 422 439 owl_free(cryptmsg); 440 owl_zwrite_free(&z); 423 441 return; 424 442 } … … 1633 1651 } 1634 1652 1635 if (owl_message_is_type_aim(m)) {1636 owl_fmtext_append_bold(&fm, "\nAIM Specific Information:\n");1637 }1638 1639 1653 owl_fmtext_append_bold(&fm, "\nOwl Message Attributes:\n"); 1640 1654 owl_message_attributes_tofmtext(m, &attrfm); … … 1965 1979 1966 1980 1967 owl_fmtext_append_normal(&fm, "\nMemory Usage:\n");1968 owl_fmtext_append_normal(&fm, " Not currently available.\n");1969 /*1970 sprintf(buff, "%sMemory Malloced: %i\n", buff, owl_global_get_malloced(&g));1971 sprintf(buff, "%sMemory Freed: %i\n", buff, owl_global_get_freed(&g));1972 sprintf(buff, "%sMemory In Use: %i\n", buff, owl_global_get_meminuse(&g));1973 */1974 1975 1981 owl_fmtext_append_normal(&fm, "\nAIM Status:\n"); 1976 1982 owl_fmtext_append_normal(&fm, " Logged in: "); … … 2025 2031 void owl_function_reply(int type, int enter) 2026 2032 { 2027 char *buff=NULL , *oldbuff;2033 char *buff=NULL; 2028 2034 owl_message *m; 2029 2035 owl_filter *f; … … 2032 2038 owl_function_error("No message selected"); 2033 2039 } else { 2034 char *class, *inst, *to, *cc=NULL;2035 2040 2036 2041 m=owl_view_get_element(owl_global_get_current_view(&g), owl_global_get_curmsg(&g)); … … 2049 2054 } 2050 2055 2051 /* loopback */ 2052 if (owl_message_is_type_loopback(m)) { 2053 owl_function_loopwrite_setup(); 2054 return; 2055 } 2056 2057 /* zephyr */ 2058 if (owl_message_is_type_zephyr(m)) { 2059 /* if it's a zephyr we sent, send it out the same way again */ 2060 if (owl_message_is_direction_out(m)) { 2061 buff = owl_strdup(owl_message_get_zwriteline(m)); 2062 } else { 2063 2064 /* Special case a personal reply to a webzephyr user on a class */ 2065 if ((type==1) && !strcasecmp(owl_message_get_opcode(m), OWL_WEBZEPHYR_OPCODE)) { 2066 class=OWL_WEBZEPHYR_CLASS; 2067 inst=owl_message_get_sender(m); 2068 to=OWL_WEBZEPHYR_PRINCIPAL; 2069 } else if (!strcasecmp(owl_message_get_class(m), OWL_WEBZEPHYR_CLASS) && owl_message_is_loginout(m)) { 2070 /* Special case LOGIN/LOGOUT notifications on class "webzephyr" */ 2071 class=OWL_WEBZEPHYR_CLASS; 2072 inst=owl_message_get_instance(m); 2073 to=OWL_WEBZEPHYR_PRINCIPAL; 2074 } else if (owl_message_is_loginout(m)) { 2075 /* Normal LOGIN/LOGOUT messages */ 2076 class="MESSAGE"; 2077 inst="PERSONAL"; 2078 to=owl_message_get_sender(m); 2079 } else if (type==1) { 2080 /* Personal reply */ 2081 class="MESSAGE"; 2082 inst="PERSONAL"; 2083 to=owl_message_get_sender(m); 2084 } else { 2085 /* General reply */ 2086 class=owl_message_get_class(m); 2087 inst=owl_message_get_instance(m); 2088 to=owl_message_get_recipient(m); 2089 cc=owl_message_get_cc_without_recipient(m); 2090 if (!strcmp(to, "") || !strcmp(to, "*")) { 2091 to=""; 2092 } else if (to[0]=='@') { 2093 /* leave it, to get the realm */ 2094 } else { 2095 to=owl_message_get_sender(m); 2096 } 2097 } 2098 2099 /* create the command line */ 2100 if (!strcasecmp(owl_message_get_opcode(m), "CRYPT")) { 2101 buff=owl_strdup("zcrypt"); 2102 } else { 2103 buff = owl_strdup("zwrite"); 2104 } 2105 if (strcasecmp(class, "message")) { 2106 buff = owl_sprintf("%s -c %s%s%s", oldbuff=buff, owl_getquoting(class), class, owl_getquoting(class)); 2107 owl_free(oldbuff); 2108 } 2109 if (strcasecmp(inst, "personal")) { 2110 buff = owl_sprintf("%s -i %s%s%s", oldbuff=buff, owl_getquoting(inst), inst, owl_getquoting(inst)); 2111 owl_free(oldbuff); 2112 } 2113 if (*to != '\0') { 2114 char *tmp, *oldtmp, *tmp2; 2115 tmp=short_zuser(to); 2116 if (cc) { 2117 tmp = owl_util_uniq(oldtmp=tmp, cc, "-"); 2118 owl_free(oldtmp); 2119 buff = owl_sprintf("%s -C %s", oldbuff=buff, tmp); 2120 owl_free(oldbuff); 2121 } else { 2122 if (owl_global_is_smartstrip(&g)) { 2123 tmp2=tmp; 2124 tmp=owl_zephyr_smartstripped_user(tmp2); 2125 owl_free(tmp2); 2126 } 2127 buff = owl_sprintf("%s %s", oldbuff=buff, tmp); 2128 owl_free(oldbuff); 2129 } 2130 owl_free(tmp); 2131 } 2132 if (cc) owl_free(cc); 2133 } 2134 } else if (owl_message_is_type_aim(m)) { 2135 /* aim */ 2136 if (owl_message_is_direction_out(m)) { 2137 buff=owl_sprintf("aimwrite %s", owl_message_get_recipient(m)); 2138 } else { 2139 buff=owl_sprintf("aimwrite %s", owl_message_get_sender(m)); 2140 } 2141 } else { 2142 char *cmd; 2143 if((type==0 && (cmd=owl_message_get_attribute_value(m, "replycmd"))) 2144 || (type==1 && (cmd=owl_message_get_attribute_value(m, "replysendercmd")))) { 2145 buff = owl_strdup(cmd); 2146 } 2056 char *cmd; 2057 if((type == 0 && 2058 (cmd=owl_perlconfig_message_call_method(m, "replycmd", 0, NULL))) || 2059 (type == 1 && 2060 (cmd=owl_perlconfig_message_call_method(m, "replysendercmd", 0, NULL)))) { 2061 buff = cmd; 2147 2062 } 2148 2063 … … 2151 2066 return; 2152 2067 } 2153 2068 2154 2069 if (enter) { 2155 2070 owl_history *hist = owl_global_get_cmd_history(&g); … … 2404 2319 return; 2405 2320 } 2406 if (owl_util_string_to_color(argv[3])== -1) {2321 if (owl_util_string_to_color(argv[3])==OWL_COLOR_INVALID) { 2407 2322 owl_function_error("The color '%s' is not available.", argv[3]); 2408 2323 return; … … 2419 2334 return; 2420 2335 } 2421 if (owl_util_string_to_color(argv[3])== -1) {2336 if (owl_util_string_to_color(argv[3])==OWL_COLOR_INVALID) { 2422 2337 owl_function_error("The color '%s' is not available.", argv[3]); 2423 2338 return; … … 2527 2442 { 2528 2443 owl_filter *f; 2529 char buff[5000];2444 char *buff, *tmp; 2530 2445 2531 2446 f=owl_global_get_filter(&g, name); … … 2534 2449 return; 2535 2450 } 2536 owl_filter_print(f, buff); 2451 tmp = owl_filter_print(f); 2452 buff = owl_sprintf("%s: %s", owl_filter_get_name(f), tmp); 2537 2453 owl_function_popless_text(buff); 2454 owl_free(buff); 2455 owl_free(tmp); 2538 2456 } 2539 2457 … … 2543 2461 owl_list *fl; 2544 2462 char buff[5000]; 2463 char *tmp; 2545 2464 owl_fmtext fm; 2546 2465 int i, j; … … 2556 2475 snprintf(buff, sizeof(buff), "[% 2d] ", i+1); 2557 2476 owl_fmtext_append_normal(&fm, buff); 2558 owl_filter_print(f, buff); 2477 tmp = owl_filter_print(f); 2478 owl_fmtext_append_normal(&fm, tmp); 2479 owl_free(tmp); 2559 2480 owl_fmtext_append_normal(&fm, buff); 2560 2481 } … … 2953 2874 } 2954 2875 2955 if (owl_util_string_to_color(fgcolor)== -1) {2876 if (owl_util_string_to_color(fgcolor)==OWL_COLOR_INVALID) { 2956 2877 owl_function_error("No color named '%s' avilable.", fgcolor); 2957 2878 return(-1); … … 2960 2881 2961 2882 if (bgcolor != NULL) { 2962 if (owl_util_string_to_color(bgcolor)== -1) {2883 if (owl_util_string_to_color(bgcolor)==OWL_COLOR_INVALID) { 2963 2884 owl_function_error("No color named '%s' avilable.", bgcolor); 2964 2885 return(-1); … … 3512 3433 FILE *file; 3513 3434 char buff[LINE]; 3435 int fail_silent = 0; 3514 3436 3515 3437 if (!filename) { 3438 fail_silent = 1; 3516 3439 filename=owl_global_get_startupfile(&g); 3517 file=fopen(filename, "r"); 3518 } else { 3519 file=fopen(filename, "r"); 3520 } 3440 } 3441 file=fopen(filename, "r"); 3521 3442 if (!file) { 3522 owl_function_error("Error opening file: %s", filename); 3443 if (!fail_silent) { 3444 owl_function_error("Error opening file: %s", filename); 3445 } 3523 3446 return; 3524 3447 }
Note: See TracChangeset
for help on using the changeset viewer.