Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    r4fd211f 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 */
     
    14081408#ifdef HAVE_LIBZEPHYR
    14091409    if (owl_message_is_direction_in(m)) {
    1410       char *ptr, tmpbuff[1024];
    1411       int i, j, fields, len;
     1410      char *tmpbuff;
     1411      int i, fields;
    14121412
    14131413      n=owl_message_get_notice(m);
     
    14531453        owl_fmtext_appendf_normal(&fm, "  Fields    : %i\n", fields);
    14541454
    1455         for (i=0; i<fields; i++) {
    1456           ptr=owl_zephyr_get_field_as_utf8(n, i+1);
    1457           len=strlen(ptr);
    1458           if (len<30) {
    1459             strncpy(tmpbuff, ptr, len);
    1460             tmpbuff[len]='\0';
    1461           } else {
    1462             strncpy(tmpbuff, ptr, 30);
    1463             tmpbuff[30]='\0';
    1464             strcat(tmpbuff, "...");
    1465           }
    1466           g_free(ptr);
    1467 
    1468           for (j=0; j<strlen(tmpbuff); j++) {
    1469             if (tmpbuff[j]=='\n') tmpbuff[j]='~';
    1470             if (tmpbuff[j]=='\r') tmpbuff[j]='!';
    1471           }
    1472 
    1473           owl_fmtext_appendf_normal(&fm, "  Field %i   : %s\n", i+1, tmpbuff);
     1455        for (i = 0; i < fields; i++) {
     1456          tmpbuff = owl_zephyr_get_field_as_utf8(n, i + 1);
     1457
     1458          g_strdelimit(tmpbuff, "\n", '~');
     1459          g_strdelimit(tmpbuff, "\r", '!');
     1460
     1461          owl_fmtext_appendf_normal(&fm, "  Field %i   : %s\n", i + 1, tmpbuff);
     1462          g_free(tmpbuff);
    14741463        }
    14751464        owl_fmtext_appendf_normal(&fm, "  Default Fm: %s\n", n->z_default_format);
     
    18171806          owl_global_get_cols(&g));
    18181807
    1819   if (owl_global_get_hascolors(&g)) {
     1808  if (has_colors()) {
    18201809    owl_fmtext_append_normal(&fm, "Color: Yes\n");
    1821     owl_fmtext_appendf_normal(&fm, "Number of color pairs: %i\n", owl_global_get_colorpairs(&g));
     1810    owl_fmtext_appendf_normal(&fm, "Number of color pairs: %i\n", owl_util_get_colorpairs());
    18221811    owl_fmtext_appendf_normal(&fm, "Can change colors: %s\n", can_change_color() ? "yes" : "no");
    18231812  } else {
     
    22262215    f = fl->data;
    22272216    owl_fmtext_append_normal(&fm, "   ");
    2228     if (owl_global_get_hascolors(&g)) {
    2229       owl_fmtext_append_normal_color(&fm, owl_filter_get_name(f), owl_filter_get_fgcolor(f), owl_filter_get_bgcolor(f));
    2230     } else {
    2231       owl_fmtext_append_normal(&fm, owl_filter_get_name(f));
    2232     }
     2217    owl_fmtext_append_normal_color(&fm, owl_filter_get_name(f),
     2218                                   owl_filter_get_fgcolor(f),
     2219                                   owl_filter_get_bgcolor(f));
    22332220    owl_fmtext_append_normal(&fm, "\n");
    22342221  }
     
    23602347done:
    23612348  g_free(class);
    2362   if (instance) {
    2363     g_free(instance);
    2364   }
     2349  g_free(instance);
    23652350  return(filtname);
    23662351}
     
    25232508
    25242509  filtname = g_strdup_printf("conversation-%s", ccs);
    2525   owl_text_tr(filtname, ' ', '-');
     2510  g_strdelimit(filtname, " ", '-');
    25262511
    25272512  if (owl_global_get_filter(&g, filtname)) {
     
    27852770void owl_function_zpunt(const char *class, const char *inst, const char *recip, int direction)
    27862771{
    2787   GString *buf;
     2772  GPtrArray *argv;
    27882773  char *quoted;
    27892774
    2790   buf = g_string_new("");
     2775  argv = g_ptr_array_new();
    27912776  if (!strcmp(class, "*")) {
    2792     g_string_append(buf, "class .*");
     2777    g_ptr_array_add(argv, g_strdup("class"));
     2778    g_ptr_array_add(argv, g_strdup(".*"));
    27932779  } else {
    27942780    quoted=owl_text_quote(class, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    2795     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));
    27962783    g_free(quoted);
    27972784  }
    27982785  if (!strcmp(inst, "*")) {
    2799     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(".*"));
    28002789  } else {
    28012790    quoted=owl_text_quote(inst, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    2802     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));
    28032794    g_free(quoted);
    28042795  }
    28052796  if (!strcmp(recip, "*")) {
    2806     /* g_string_append(buf, ""); */
     2797    /* nothing */
    28072798  } else {
    28082799    if(!strcmp(recip, "%me%")) {
     
    28102801    }
    28112802    quoted=owl_text_quote(recip, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    2812     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));
    28132806    g_free(quoted);
    28142807  }
    28152808
    2816   owl_function_punt(buf->str, direction);
    2817   g_string_free(buf, true);
    2818 }
    2819 
    2820 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)
    28212815{
    28222816  owl_filter *f;
     
    28262820
    28272821  /* first, create the filter */
    2828   owl_function_debugmsg("About to filter %s", filter);
    2829   f = owl_filter_new_fromstring("punt-filter", filter);
     2822  f = owl_filter_new("punt-filter", argc, argv);
    28302823  if (f == NULL) {
    28312824    owl_function_error("Error creating filter for zpunt");
     
    28542847  }
    28552848
    2856   owl_function_debugmsg("punting");
    2857   /* If we're punting, add the filter to the global punt list */
    2858   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 */
    28592852    owl_list_append_element(fl, f);
    2860   }
     2853  } else if (direction == 1) {
     2854    owl_function_makemsg("No matching punt filter");
     2855 }
    28612856}
    28622857
     
    29952990      i--;
    29962991    }
    2997     owl_function_mask_sigint(NULL);
    2998     if(owl_global_is_interrupted(&g)) {
    2999       owl_global_unset_interrupted(&g);
    3000       owl_function_unmask_sigint(NULL);
     2992    if (owl_global_take_interrupt(&g)) {
    30012993      owl_function_makemsg("Search interrupted!");
    30022994      owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    30032995      return;
    30042996    }
    3005     owl_function_unmask_sigint(NULL);
    30062997  }
    30072998  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
     
    30863077          ret=ZLocateUser(zstr(user), &numlocs, ZAUTH);
    30873078
    3088           owl_function_mask_sigint(NULL);
    3089           if(owl_global_is_interrupted(&g)) {
     3079          if (owl_global_take_interrupt(&g)) {
    30903080            interrupted = 1;
    3091             owl_global_unset_interrupted(&g);
    3092             owl_function_unmask_sigint(NULL);
    30933081            owl_function_makemsg("Interrupted!");
    30943082            break;
    30953083          }
    3096 
    3097           owl_function_unmask_sigint(NULL);
    30983084
    30993085          if (ret!=ZERR_NONE) {
     
    32563242  filename=owl_global_get_startupfile(&g);
    32573243
    3258   /* delete earlier copies */
    3259   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);
    32603247
    32613248  file=fopen(filename, "a");
     
    35003487}
    35013488
    3502 void owl_function_mask_sigint(sigset_t *oldmask) {
    3503   sigset_t intr;
    3504 
    3505   sigemptyset(&intr);
    3506   sigaddset(&intr, SIGINT);
    3507   sigprocmask(SIG_BLOCK, &intr, oldmask);
    3508 }
    3509 
    3510 void owl_function_unmask_sigint(sigset_t *oldmask) {
    3511   sigset_t intr;
    3512 
    3513   sigemptyset(&intr);
    3514   sigaddset(&intr, SIGINT);
    3515   sigprocmask(SIG_UNBLOCK, &intr, oldmask);
    3516 }
    3517 
    35183489void _owl_function_mark_message(const owl_message *m)
    35193490{
Note: See TracChangeset for help on using the changeset viewer.