Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    r4367915 r3f3ee61  
    2525  return owl_cmddict_execute(owl_global_get_cmddict(&g),
    2626                             owl_global_get_context(&g), cmdbuff);
     27}
     28
     29char *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);
    2734}
    2835
     
    283290  owl_editwin_set_dotsend(e);
    284291  strcpy(buff, "----> ");
    285   strcat(buff, line);
     292  strncat(buff, line, 1016);
    286293  strcat(buff, "\n");
    287294  owl_editwin_set_locktext(e, buff);
     
    371378  /* create the zwrite and send the message */
    372379  owl_zwrite_create_from_line(&z, line);
     380  owl_zwrite_populate_zsig(&z);
    373381  if (msg) {
    374382    owl_zwrite_set_message(&z, msg);
     
    409417  /* create the zwrite and send the message */
    410418  owl_zwrite_create_from_line(&z, line);
     419  owl_zwrite_populate_zsig(&z);
    411420  if (msg) {
    412421    owl_zwrite_set_message(&z, msg);
     
    415424  mymsg=owl_zwrite_get_message(&z);
    416425#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);
    418435  ret=owl_zcrypt_encrypt(cryptmsg, mymsg, owl_zwrite_get_class(&z), owl_zwrite_get_instance(&z));
    419436  if (ret) {
     
    421438    owl_function_beep();
    422439    owl_free(cryptmsg);
     440    owl_zwrite_free(&z);
    423441    return;
    424442  }
     
    16331651  }
    16341652
    1635   if (owl_message_is_type_aim(m)) {
    1636     owl_fmtext_append_bold(&fm, "\nAIM Specific Information:\n");
    1637   }
    1638 
    16391653  owl_fmtext_append_bold(&fm, "\nOwl Message Attributes:\n");
    16401654  owl_message_attributes_tofmtext(m, &attrfm);
     
    19651979 
    19661980
    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 
    19751981  owl_fmtext_append_normal(&fm, "\nAIM Status:\n");
    19761982  owl_fmtext_append_normal(&fm, "  Logged in: ");
     
    20252031void owl_function_reply(int type, int enter)
    20262032{
    2027   char *buff=NULL, *oldbuff;
     2033  char *buff=NULL;
    20282034  owl_message *m;
    20292035  owl_filter *f;
     
    20322038    owl_function_error("No message selected");
    20332039  } else {
    2034     char *class, *inst, *to, *cc=NULL;
    20352040   
    20362041    m=owl_view_get_element(owl_global_get_current_view(&g), owl_global_get_curmsg(&g));
     
    20492054    }
    20502055
    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;
    21472062    }
    21482063
     
    21512066        return;
    21522067    }
    2153    
     2068
    21542069    if (enter) {
    21552070      owl_history *hist = owl_global_get_cmd_history(&g);
     
    24042319      return;
    24052320    }
    2406     if (owl_util_string_to_color(argv[3])==-1) {
     2321    if (owl_util_string_to_color(argv[3])==OWL_COLOR_INVALID) {
    24072322      owl_function_error("The color '%s' is not available.", argv[3]);
    24082323      return;
     
    24192334      return;
    24202335    }
    2421     if (owl_util_string_to_color(argv[3])==-1) {
     2336    if (owl_util_string_to_color(argv[3])==OWL_COLOR_INVALID) {
    24222337      owl_function_error("The color '%s' is not available.", argv[3]);
    24232338      return;
     
    25272442{
    25282443  owl_filter *f;
    2529   char buff[5000];
     2444  char *buff, *tmp;
    25302445
    25312446  f=owl_global_get_filter(&g, name);
     
    25342449    return;
    25352450  }
    2536   owl_filter_print(f, buff);
     2451  tmp = owl_filter_print(f);
     2452  buff = owl_sprintf("%s: %s", owl_filter_get_name(f), tmp);
    25372453  owl_function_popless_text(buff);
     2454  owl_free(buff);
     2455  owl_free(tmp);
    25382456}
    25392457
     
    25432461  owl_list *fl;
    25442462  char buff[5000];
     2463  char *tmp;
    25452464  owl_fmtext fm;
    25462465  int i, j;
     
    25562475    snprintf(buff, sizeof(buff), "[% 2d] ", i+1);
    25572476    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);
    25592480    owl_fmtext_append_normal(&fm, buff);
    25602481  }
     
    29532874  }
    29542875
    2955   if (owl_util_string_to_color(fgcolor)==-1) {
     2876  if (owl_util_string_to_color(fgcolor)==OWL_COLOR_INVALID) {
    29562877    owl_function_error("No color named '%s' avilable.", fgcolor);
    29572878    return(-1);
     
    29602881
    29612882  if (bgcolor != NULL) {
    2962     if (owl_util_string_to_color(bgcolor)==-1) {
     2883    if (owl_util_string_to_color(bgcolor)==OWL_COLOR_INVALID) {
    29632884      owl_function_error("No color named '%s' avilable.", bgcolor);
    29642885      return(-1);
     
    35123433  FILE *file;
    35133434  char buff[LINE];
     3435  int fail_silent = 0;
    35143436
    35153437  if (!filename) {
     3438    fail_silent = 1;
    35163439    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");
    35213442  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    }
    35233446    return;
    35243447  }
Note: See TracChangeset for help on using the changeset viewer.