Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    r1081d0f r259e60a8  
    3232  char *rv;
    3333  rv=owl_function_command(cmdbuff);
    34   if (rv) g_free(rv);
     34  g_free(rv);
    3535}
    3636
     
    453453
    454454  if (rv || status) {
    455     if(cryptmsg) g_free(cryptmsg);
     455    g_free(cryptmsg);
    456456    g_free(old_msg);
    457457    owl_function_error("Error in zcrypt, possibly no key found.  Message not sent.");
     
    991991  /* execute the commands in shutdown */
    992992  ret = owl_perlconfig_execute("BarnOwl::Hooks::_shutdown();");
    993   if (ret) g_free(ret);
     993  g_free(ret);
    994994
    995995  /* signal our child process, if any */
     
    23472347done:
    23482348  g_free(class);
    2349   if (instance) {
    2350     g_free(instance);
    2351   }
     2349  g_free(instance);
    23522350  return(filtname);
    23532351}
     
    27722770void owl_function_zpunt(const char *class, const char *inst, const char *recip, int direction)
    27732771{
    2774   GString *buf;
     2772  GPtrArray *argv;
    27752773  char *quoted;
    27762774
    2777   buf = g_string_new("");
     2775  argv = g_ptr_array_new();
    27782776  if (!strcmp(class, "*")) {
    2779     g_string_append(buf, "class .*");
     2777    g_ptr_array_add(argv, g_strdup("class"));
     2778    g_ptr_array_add(argv, g_strdup(".*"));
    27802779  } else {
    27812780    quoted=owl_text_quote(class, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    2782     owl_string_appendf_quoted(buf, "class ^(un)*%q(\\.d)*$", quoted);
     2781    g_ptr_array_add(argv, g_strdup("class"));
     2782    g_ptr_array_add(argv, g_strdup_printf("^(un)*%s(\\.d)*$", quoted));
    27832783    g_free(quoted);
    27842784  }
    27852785  if (!strcmp(inst, "*")) {
    2786     g_string_append(buf, " and instance .*");
     2786    g_ptr_array_add(argv, g_strdup("and"));
     2787    g_ptr_array_add(argv, g_strdup("instance"));
     2788    g_ptr_array_add(argv, g_strdup(".*"));
    27872789  } else {
    27882790    quoted=owl_text_quote(inst, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    2789     owl_string_appendf_quoted(buf, " and instance ^(un)*%q(\\.d)*$", quoted);
     2791    g_ptr_array_add(argv, g_strdup("and"));
     2792    g_ptr_array_add(argv, g_strdup("instance"));
     2793    g_ptr_array_add(argv, g_strdup_printf("^(un)*%s(\\.d)*$", quoted));
    27902794    g_free(quoted);
    27912795  }
    27922796  if (!strcmp(recip, "*")) {
    2793     /* g_string_append(buf, ""); */
     2797    /* nothing */
    27942798  } else {
    27952799    if(!strcmp(recip, "%me%")) {
     
    27972801    }
    27982802    quoted=owl_text_quote(recip, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    2799     owl_string_appendf_quoted(buf, " and recipient ^%q$", quoted);
     2803    g_ptr_array_add(argv, g_strdup("and"));
     2804    g_ptr_array_add(argv, g_strdup("recipient"));
     2805    g_ptr_array_add(argv, g_strdup_printf("^%s$", quoted));
    28002806    g_free(quoted);
    28012807  }
    28022808
    2803   owl_function_punt(buf->str, direction);
    2804   g_string_free(buf, true);
    2805 }
    2806 
    2807 void owl_function_punt(const char *filter, int direction)
     2809  owl_function_punt(argv->len, (const char *const*) argv->pdata, direction);
     2810  g_ptr_array_foreach(argv, (GFunc)g_free, NULL);
     2811  g_ptr_array_free(argv, true);
     2812}
     2813
     2814void owl_function_punt(int argc, const char *const *argv, int direction)
    28082815{
    28092816  owl_filter *f;
     
    28132820
    28142821  /* first, create the filter */
    2815   owl_function_debugmsg("About to filter %s", filter);
    2816   f = owl_filter_new_fromstring("punt-filter", filter);
     2822  f = owl_filter_new("punt-filter", argc, argv);
    28172823  if (f == NULL) {
    28182824    owl_function_error("Error creating filter for zpunt");
     
    28412847  }
    28422848
    2843   owl_function_debugmsg("punting");
    2844   /* If we're punting, add the filter to the global punt list */
    2845   if (direction==0) {
     2849  if (direction == 0) {
     2850    owl_function_debugmsg("punting");
     2851    /* If we're punting, add the filter to the global punt list */
    28462852    owl_list_append_element(fl, f);
    2847   }
     2853  } else if (direction == 1) {
     2854    owl_function_makemsg("No matching punt filter");
     2855 }
    28482856}
    28492857
     
    29822990      i--;
    29832991    }
    2984     owl_function_mask_sigint(NULL);
    2985     if(owl_global_is_interrupted(&g)) {
    2986       owl_global_unset_interrupted(&g);
    2987       owl_function_unmask_sigint(NULL);
     2992    if (owl_global_take_interrupt(&g)) {
    29882993      owl_function_makemsg("Search interrupted!");
    29892994      owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    29902995      return;
    29912996    }
    2992     owl_function_unmask_sigint(NULL);
    29932997  }
    29942998  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
     
    30733077          ret=ZLocateUser(zstr(user), &numlocs, ZAUTH);
    30743078
    3075           owl_function_mask_sigint(NULL);
    3076           if(owl_global_is_interrupted(&g)) {
     3079          if (owl_global_take_interrupt(&g)) {
    30773080            interrupted = 1;
    3078             owl_global_unset_interrupted(&g);
    3079             owl_function_unmask_sigint(NULL);
    30803081            owl_function_makemsg("Interrupted!");
    30813082            break;
    30823083          }
    3083 
    3084           owl_function_unmask_sigint(NULL);
    30853084
    30863085          if (ret!=ZERR_NONE) {
     
    32433242  filename=owl_global_get_startupfile(&g);
    32443243
    3245   /* delete earlier copies */
    3246   owl_util_file_deleteline(filename, buff, 1);
     3244  /* delete earlier copies, if the file exists */
     3245  if (g_file_test(filename, G_FILE_TEST_EXISTS))
     3246    owl_util_file_deleteline(filename, buff, 1);
    32473247
    32483248  file=fopen(filename, "a");
     
    34873487}
    34883488
    3489 void owl_function_mask_sigint(sigset_t *oldmask) {
    3490   sigset_t intr;
    3491 
    3492   sigemptyset(&intr);
    3493   sigaddset(&intr, SIGINT);
    3494   sigprocmask(SIG_BLOCK, &intr, oldmask);
    3495 }
    3496 
    3497 void owl_function_unmask_sigint(sigset_t *oldmask) {
    3498   sigset_t intr;
    3499 
    3500   sigemptyset(&intr);
    3501   sigaddset(&intr, SIGINT);
    3502   sigprocmask(SIG_UNBLOCK, &intr, oldmask);
    3503 }
    3504 
    35053489void _owl_function_mark_message(const owl_message *m)
    35063490{
Note: See TracChangeset for help on using the changeset viewer.