Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    r3939268 r34509d5  
    580580
    581581  if (i>owl_view_get_size(v)-1) i=owl_view_get_size(v)-1;
    582   if (i<0) i=0;
    583582
    584583  if (!found) {
     
    849848{
    850849  int ret, ret2;
    851   char *foo, *path;
     850  char *foo;
    852851
    853852  if (file==NULL) {
    854853    ret=owl_zephyr_loadsubs(NULL, 0);
    855854  } else {
    856     path = owl_util_makepath(file);
    857     ret=owl_zephyr_loadsubs(path, 1);
    858     free(path);
     855    ret=owl_zephyr_loadsubs(file, 1);
    859856  }
    860857
     
    20602057      /* if it's a zephyr we sent, send it out the same way again */
    20612058      if (owl_message_is_direction_out(m)) {
    2062           buff = owl_strdup(owl_message_get_zwriteline(m));
     2059        owl_function_zwrite_setup(owl_message_get_zwriteline(m));
     2060        owl_global_set_buffercommand(&g, owl_message_get_zwriteline(m));
     2061        return;
     2062      }
     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);
    20632084      } else {
    2064 
    2065         /* Special case a personal reply to a webzephyr user on a class */
    2066         if ((type==1) && !strcasecmp(owl_message_get_opcode(m), OWL_WEBZEPHYR_OPCODE)) {
    2067           class=OWL_WEBZEPHYR_CLASS;
    2068           inst=owl_message_get_sender(m);
    2069           to=OWL_WEBZEPHYR_PRINCIPAL;
    2070         } else if (!strcasecmp(owl_message_get_class(m), OWL_WEBZEPHYR_CLASS) && owl_message_is_loginout(m)) {
    2071           /* Special case LOGIN/LOGOUT notifications on class "webzephyr" */
    2072           class=OWL_WEBZEPHYR_CLASS;
    2073           inst=owl_message_get_instance(m);
    2074           to=OWL_WEBZEPHYR_PRINCIPAL;
    2075         } else if (owl_message_is_loginout(m)) {
    2076           /* Normal LOGIN/LOGOUT messages */
    2077           class="MESSAGE";
    2078           inst="PERSONAL";
    2079           to=owl_message_get_sender(m);
    2080         } else if (type==1) {
    2081           /* Personal reply */
    2082           class="MESSAGE";
    2083           inst="PERSONAL";
    2084           to=owl_message_get_sender(m);
    2085         } else {
    2086           /* General reply */
    2087           class=owl_message_get_class(m);
    2088           inst=owl_message_get_instance(m);
    2089           to=owl_message_get_recipient(m);
    2090           cc=owl_message_get_cc_without_recipient(m);
    2091           if (!strcmp(to, "") || !strcmp(to, "*")) {
    2092             to="";
    2093           } else if (to[0]=='@') {
    2094             /* leave it, to get the realm */
    2095           } else {
    2096             to=owl_message_get_sender(m);
    2097           }
    2098         }
    2099 
    2100         /* create the command line */
    2101         if (!strcasecmp(owl_message_get_opcode(m), "CRYPT")) {
    2102           buff=owl_strdup("zcrypt");
    2103         } else {
    2104           buff = owl_strdup("zwrite");
    2105         }
    2106         if (strcasecmp(class, "message")) {
    2107           buff = owl_sprintf("%s -c %s%s%s", oldbuff=buff, owl_getquoting(class), class, owl_getquoting(class));
    2108           owl_free(oldbuff);
    2109         }
    2110         if (strcasecmp(inst, "personal")) {
    2111           buff = owl_sprintf("%s -i %s%s%s", oldbuff=buff, owl_getquoting(inst), inst, owl_getquoting(inst));
    2112           owl_free(oldbuff);
    2113         }
    2114         if (*to != '\0') {
    2115           char *tmp, *oldtmp, *tmp2;
    2116           tmp=short_zuser(to);
    2117           if (cc) {
    2118             tmp = owl_util_uniq(oldtmp=tmp, cc, "-");
    2119             owl_free(oldtmp);
    2120             buff = owl_sprintf("%s -C %s", oldbuff=buff, tmp);
    2121             owl_free(oldbuff);
    2122           } else {
    2123             if (owl_global_is_smartstrip(&g)) {
    2124               tmp2=tmp;
    2125               tmp=owl_zephyr_smartstripped_user(tmp2);
    2126               owl_free(tmp2);
    2127             }
    2128             buff = owl_sprintf("%s %s", oldbuff=buff, tmp);
    2129             owl_free(oldbuff);
    2130           }
    2131           owl_free(tmp);
    2132         }
    2133         if (cc) owl_free(cc);
     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        }
    21342097      }
     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);
    21352133    } else if (owl_message_is_type_aim(m)) {
    21362134      /* aim */
     
    25592557  for (i=0; i<j; i++) {
    25602558    f=owl_list_get_element(fl, i);
    2561     snprintf(buff, sizeof(buff), "[% 2d] ", i+1);
    2562     owl_fmtext_append_normal(&fm, buff);
    25632559    owl_filter_print(f, buff);
    25642560    owl_fmtext_append_normal(&fm, buff);
     
    26262622  sprintf(argbuff, "class ^(un)*%s(\\.d)*$", tmpclass);
    26272623  if (tmpinstance) {
    2628     sprintf(argbuff, "%s and ( instance ^(un)*%s(\\.d)*$ )", argbuff, tmpinstance);
     2624    sprintf(argbuff, "%s and ( instance ^%s(\\.d)*$ )", argbuff, tmpinstance);
    26292625  }
    26302626  owl_free(tmpclass);
     
    26742670
    26752671  argbuff=owl_malloc(strlen(longuser)+1000);
    2676   sprintf(argbuff, "( type ^zephyr$ and filter personal and ");
     2672  sprintf(argbuff, "( type ^zephyr$ and ( class ^message$ and instance ^personal$ and ");
    26772673  sprintf(argbuff, "%s ( ( direction ^in$ and sender ^%s$ ) or ( direction ^out$ and recipient ^%s$ ) ) )", argbuff, longuser, longuser);
    2678   sprintf(argbuff, "%s or ( ( class ^login$ ) and ( sender ^%s$ ) )", argbuff, longuser);
     2674  sprintf(argbuff, "%s or ( ( class ^login$ ) and ( sender ^%s$ ) ) )", argbuff, longuser);
    26792675
    26802676  owl_filter_init_fromstring(f, filtname, argbuff);
     
    28042800  owl_message *m;
    28052801  char *zperson, *filtname=NULL;
    2806   char *argv[1];
    28072802 
    28082803  v=owl_global_get_current_view(&g);
     
    28362831  /* narrow personal and login messages to the sender or recip as appropriate */
    28372832  if (owl_message_is_type_zephyr(m)) {
    2838     if (owl_message_is_personal(m) || owl_message_is_loginout(m)) {
     2833    if (owl_message_is_private(m) || owl_message_is_loginout(m)) {
    28392834      if (owl_message_is_direction_in(m)) {
    28402835        zperson=short_zuser(owl_message_get_sender(m));
     
    28632858
    28642859  /* pass it off to perl */
     2860  char *argv[1];
    28652861  if(type) {
    28662862    argv[0] = "-i";
     
    30203016void owl_function_zpunt(char *class, char *inst, char *recip, int direction)
    30213017{
     3018  owl_filter *f;
     3019  owl_list *fl;
    30223020  char *buff;
    30233021  char *quoted;
    3024 
    3025   buff=malloc(strlen(class)+strlen(inst)+strlen(recip)+100);
     3022  int ret, i, j;
     3023
     3024  fl=owl_global_get_puntlist(&g);
     3025
     3026  /* first, create the filter */
     3027  f=owl_malloc(sizeof(owl_filter));
     3028  buff=owl_malloc(strlen(class)+strlen(inst)+strlen(recip)+100);
    30263029  strcpy(buff, "class");
    30273030  if (!strcmp(class, "*")) {
     
    30533056    owl_free(quoted);
    30543057  }
    3055 
    3056   owl_function_punt(buff, direction);
     3058 
     3059  owl_function_debugmsg("About to filter %s", buff);
     3060  ret=owl_filter_init_fromstring(f, "punt-filter", buff);
    30573061  owl_free(buff);
    3058 }
    3059 
    3060 void owl_function_punt(char *filter, int direction)
    3061 {
    3062   owl_filter *f;
    3063   owl_list *fl;
    3064   int ret, i, j;
    3065   fl=owl_global_get_puntlist(&g);
    3066 
    3067   /* first, create the filter */
    3068   f=malloc(sizeof(owl_filter));
    3069 
    3070   owl_function_debugmsg("About to filter %s", filter);
    3071   ret=owl_filter_init_fromstring(f, "punt-filter", filter);
    30723062  if (ret) {
    30733063    owl_function_error("Error creating filter for zpunt");
     
    30803070  for (i=0; i<j; i++) {
    30813071    if (owl_filter_equiv(f, owl_list_get_element(fl, i))) {
    3082       owl_function_debugmsg("found an equivalent punt filter");
    30833072      /* if we're punting, then just silently bow out on this duplicate */
    30843073      if (direction==0) {
     
    30913080        owl_filter_free(owl_list_get_element(fl, i));
    30923081        owl_list_remove_element(fl, i);
    3093         owl_filter_free(f);
    30943082        return;
    30953083      }
     
    30973085  }
    30983086
    3099   owl_function_debugmsg("punting");
    31003087  /* If we're punting, add the filter to the global punt list */
    31013088  if (direction==0) {
     
    33273314          if (ret==0) {
    33283315            for (x=0; x<numlocs; x++) {
    3329               line=malloc(strlen(location[x].host)+strlen(location[x].time)+strlen(location[x].tty)+100);
     3316              line=owl_malloc(strlen(location[x].host)+strlen(location[x].time)+strlen(location[x].tty)+100);
    33303317              tmp=short_zuser(user);
    33313318              sprintf(line, "  %-10.10s %-24.24s %-12.12s  %20.20s\n",
     
    34333420          _exit(127);
    34343421        }
    3435         parsed=realloc(parsed, sizeof(*parsed) * (myargc+1));
     3422        parsed=owl_realloc(parsed, sizeof(*parsed) * (myargc+1));
    34363423        parsed[myargc] = NULL;
    34373424       
     
    34743461  char *filename;
    34753462
    3476   filename=owl_global_get_startupfile(&g);
     3463  filename=owl_sprintf("%s/%s", owl_global_get_homedir(&g), OWL_STARTUP_FILE);
    34773464  file=fopen(filename, "a");
    34783465  if (!file) {
    34793466    owl_function_error("Error opening startupfile for new command");
     3467    owl_free(filename);
    34803468    return;
    34813469  }
     
    34833471  /* delete earlier copies */
    34843472  owl_util_file_deleteline(filename, buff, 1);
     3473  owl_free(filename);
    34853474
    34863475  /* add this line */
     
    34943483{
    34953484  char *filename;
    3496   filename=owl_global_get_startupfile(&g);
     3485  filename=owl_sprintf("%s/%s", owl_global_get_homedir(&g), OWL_STARTUP_FILE);
    34973486  owl_util_file_deleteline(filename, buff, 1);
     3487  owl_free(filename);
    34983488}
    34993489
     
    35073497
    35083498  if (!filename) {
    3509     filename=owl_global_get_startupfile(&g);
     3499    filename=owl_sprintf("%s/%s", owl_global_get_homedir(&g), OWL_STARTUP_FILE);
    35103500    file=fopen(filename, "r");
     3501    owl_free(filename);
    35113502  } else {
    35123503    file=fopen(filename, "r");
Note: See TracChangeset for help on using the changeset viewer.