Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    r259e60a8 r1081d0f  
    3232  char *rv;
    3333  rv=owl_function_command(cmdbuff);
    34   g_free(rv);
     34  if (rv) g_free(rv);
    3535}
    3636
     
    453453
    454454  if (rv || status) {
    455     g_free(cryptmsg);
     455    if(cryptmsg) 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   g_free(ret);
     993  if (ret) g_free(ret);
    994994
    995995  /* signal our child process, if any */
     
    23472347done:
    23482348  g_free(class);
    2349   g_free(instance);
     2349  if (instance) {
     2350    g_free(instance);
     2351  }
    23502352  return(filtname);
    23512353}
     
    27702772void owl_function_zpunt(const char *class, const char *inst, const char *recip, int direction)
    27712773{
    2772   GPtrArray *argv;
     2774  GString *buf;
    27732775  char *quoted;
    27742776
    2775   argv = g_ptr_array_new();
     2777  buf = g_string_new("");
    27762778  if (!strcmp(class, "*")) {
    2777     g_ptr_array_add(argv, g_strdup("class"));
    2778     g_ptr_array_add(argv, g_strdup(".*"));
     2779    g_string_append(buf, "class .*");
    27792780  } else {
    27802781    quoted=owl_text_quote(class, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    2781     g_ptr_array_add(argv, g_strdup("class"));
    2782     g_ptr_array_add(argv, g_strdup_printf("^(un)*%s(\\.d)*$", quoted));
     2782    owl_string_appendf_quoted(buf, "class ^(un)*%q(\\.d)*$", quoted);
    27832783    g_free(quoted);
    27842784  }
    27852785  if (!strcmp(inst, "*")) {
    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(".*"));
     2786    g_string_append(buf, " and instance .*");
    27892787  } else {
    27902788    quoted=owl_text_quote(inst, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    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));
     2789    owl_string_appendf_quoted(buf, " and instance ^(un)*%q(\\.d)*$", quoted);
    27942790    g_free(quoted);
    27952791  }
    27962792  if (!strcmp(recip, "*")) {
    2797     /* nothing */
     2793    /* g_string_append(buf, ""); */
    27982794  } else {
    27992795    if(!strcmp(recip, "%me%")) {
     
    28012797    }
    28022798    quoted=owl_text_quote(recip, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    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));
     2799    owl_string_appendf_quoted(buf, " and recipient ^%q$", quoted);
    28062800    g_free(quoted);
    28072801  }
    28082802
    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 
    2814 void owl_function_punt(int argc, const char *const *argv, int direction)
     2803  owl_function_punt(buf->str, direction);
     2804  g_string_free(buf, true);
     2805}
     2806
     2807void owl_function_punt(const char *filter, int direction)
    28152808{
    28162809  owl_filter *f;
     
    28202813
    28212814  /* first, create the filter */
    2822   f = owl_filter_new("punt-filter", argc, argv);
     2815  owl_function_debugmsg("About to filter %s", filter);
     2816  f = owl_filter_new_fromstring("punt-filter", filter);
    28232817  if (f == NULL) {
    28242818    owl_function_error("Error creating filter for zpunt");
     
    28472841  }
    28482842
    2849   if (direction == 0) {
    2850     owl_function_debugmsg("punting");
    2851     /* If we're punting, add the filter to the global punt list */
     2843  owl_function_debugmsg("punting");
     2844  /* If we're punting, add the filter to the global punt list */
     2845  if (direction==0) {
    28522846    owl_list_append_element(fl, f);
    2853   } else if (direction == 1) {
    2854     owl_function_makemsg("No matching punt filter");
    2855  }
     2847  }
    28562848}
    28572849
     
    29902982      i--;
    29912983    }
    2992     if (owl_global_take_interrupt(&g)) {
     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);
    29932988      owl_function_makemsg("Search interrupted!");
    29942989      owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    29952990      return;
    29962991    }
     2992    owl_function_unmask_sigint(NULL);
    29972993  }
    29982994  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
     
    30773073          ret=ZLocateUser(zstr(user), &numlocs, ZAUTH);
    30783074
    3079           if (owl_global_take_interrupt(&g)) {
     3075          owl_function_mask_sigint(NULL);
     3076          if(owl_global_is_interrupted(&g)) {
    30803077            interrupted = 1;
     3078            owl_global_unset_interrupted(&g);
     3079            owl_function_unmask_sigint(NULL);
    30813080            owl_function_makemsg("Interrupted!");
    30823081            break;
    30833082          }
     3083
     3084          owl_function_unmask_sigint(NULL);
    30843085
    30853086          if (ret!=ZERR_NONE) {
     
    32423243  filename=owl_global_get_startupfile(&g);
    32433244
    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);
     3245  /* delete earlier copies */
     3246  owl_util_file_deleteline(filename, buff, 1);
    32473247
    32483248  file=fopen(filename, "a");
     
    34873487}
    34883488
     3489void 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
     3497void 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
    34893505void _owl_function_mark_message(const owl_message *m)
    34903506{
Note: See TracChangeset for help on using the changeset viewer.