Changes in / [098376e:209ea94]


Ignore:
Files:
32 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    rb940b91 r43a306c  
    1 1.0.4
    2  * Added a ':show quickstart' command. -geofft
    3  * Allow filters that reference a sub filter more than once non-cyclically. -nelhage
    4  * Make 'version' return 'BarnOwl' not 'Owl'
    5  * Escape interpolated regexes in filters. -andersk
    6  * Various code cleanups. -andersk
    7  * Fix format string injection bugs. -andersk
    8  * Clean up various code warnings. -nelhage
    9  * Replace questionable sprintf(buf, "%s...", buf, ...) pattern. -andersk
    10  * Show IRC /me messages with the conventional * instead of bold. -andersk
    11  * Rip out the openurl function and webbrowser variable. -andersk
    12 
    1311.0.3
    142 * Moved BarnOwl source control to git on github.
  • Makefile.in

    rd4b6b23 r7e78e49  
    55prefix = @prefix@
    66exec_prefix = @exec_prefix@
    7 datarootdir = @datarootdir@
    87datadir = @datadir@/barnowl
    98bindir = @bindir@
     
    5453        $(ATHSTATIC) $(CC) -o $(EXE) owl.o $(OBJS) $(LDFLAGS) $(LIBS)
    5554
    56 tester: $(AUTOGEN) $(OBJS) tester.o libfaim
     55tester: $(AUTOGEN) $(OBJS) tester.o
    5756        $(ATHSTATIC) $(CC) -o tester tester.o $(OBJS) $(LDFLAGS) $(LIBS)
    5857
  • aim.c

    r554a2b8 re3e6cff  
    239239{
    240240  if (message) {
    241     owl_function_error("%s", message);
     241    owl_function_error(message);
    242242  } else {
    243243    owl_function_error("Authentication error on login");
     
    252252  int ret;
    253253
    254   ret=aim_im_sendch1(owl_global_get_aimsess(&g), to, 0, msg);
     254  ret=aim_im_sendch1(owl_global_get_aimsess(&g), to, NULL, msg);
    255255   
    256256  /* I don't know how to check for an error yet */
     
    16981698 
    16991699  /* printf("snac threw error (reason 0x%04x: %s)\n", reason, (reason<msgerrreasonslen)?msgerrreasons[reason]:"unknown"); */
    1700   if (reason<msgerrreasonslen) owl_function_error("%s", msgerrreasons[reason]);
     1700  if (reason<msgerrreasonslen) owl_function_error(msgerrreasons[reason]);
    17011701 
    17021702  return 1;
     
    17151715 
    17161716  /* printf("message to %s bounced (reason 0x%04x: %s)\n", destsn, reason, (reason<msgerrreasonslen)?msgerrreasons[reason]:"unknown"); */
    1717   if (reason<msgerrreasonslen) owl_function_error("%s", msgerrreasons[reason]);
     1717  if (reason<msgerrreasonslen) owl_function_error(msgerrreasons[reason]);
    17181718
    17191719  if (reason==4) {
     
    17361736 
    17371737  /* printf("user information for %s unavailable (reason 0x%04x: %s)\n", destsn, reason, (reason<msgerrreasonslen)?msgerrreasons[reason]:"unknown"); */
    1738   if (reason<msgerrreasonslen) owl_function_error("%s", msgerrreasons[reason]);
     1738  if (reason<msgerrreasonslen) owl_function_error(msgerrreasons[reason]);
    17391739 
    17401740  return 1;
     
    23092309  aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie);
    23102310  return;       
    2311 }
    2312 
    2313 void owl_process_aim()
    2314 {
    2315   if (owl_global_is_doaimevents(&g)) {
    2316     owl_aim_process_events();
    2317 
    2318     if (owl_global_is_aimloggedin(&g)) {
    2319       if (owl_timer_is_expired(owl_global_get_aim_buddyinfo_timer(&g))) {
    2320         /* owl_buddylist_request_idletimes(owl_global_get_buddylist(&g)); */
    2321         owl_timer_reset(owl_global_get_aim_buddyinfo_timer(&g));
    2322       }
    2323     }
    2324   }
    23252311}
    23262312
  • commands.c

    r9b70dd4 r451db9e  
    453453  OWLCMD_VOID("pop-message", owl_command_pop_message, OWL_CTX_RECWIN,
    454454              "pops up a message in a window", "", ""),
     455
     456  OWLCMD_VOID("openurl", owl_command_openurl, OWL_CTX_INTERACTIVE,
     457              "opens up a URL from the current message",
     458              "",
     459              "Uses the 'webbrowser' variable to determine\n"
     460              "which browser to use.  Currently, 'netscape'\n"
     461              "and 'galeon' are supported.\n"),
    455462
    456463  OWLCMD_ARGS("zaway", owl_command_zaway, OWL_CTX_INTERACTIVE,
     
    634641              "show keymap <keymap>\n"
    635642              "show license\n"
    636               "show quickstart\n"
    637643              "show startup\n"
    638644              "show status\n"
     
    10401046void owl_command_version()
    10411047{
    1042   owl_function_makemsg("BarnOwl version %s", OWL_VERSION_STRING);
     1048  char buff[1024];
     1049
     1050  sprintf(buff, "Owl version %s", OWL_VERSION_STRING);
     1051  owl_function_makemsg(buff);
    10431052}
    10441053
     
    14521461    owl_function_aaway_on();
    14531462    owl_function_zaway_on();
    1454     owl_function_makemsg("Away messages set.");
     1463    owl_function_makemsg("Away messages set.", owl_global_get_aaway_msg_default(&g));
    14551464    return NULL;
    14561465  }
     
    16821691  }
    16831692
    1684   owl_function_debugmsg("%s", argv[1]);
     1693  owl_function_debugmsg(argv[1]);
    16851694  return(NULL);
    16861695}
     
    21982207  } else if (!strcmp(argv[1], "license")) {
    21992208    owl_function_show_license();
    2200   } else if (!strcmp(argv[1], "quickstart")) {
    2201     owl_function_show_quickstart();
    22022209  } else if (!strcmp(argv[1], "startup")) {
    22032210    char *filename;
     
    22442251{
    22452252  owl_function_curmsg_to_popwin();
     2253}
     2254
     2255void owl_command_openurl(void)
     2256{
     2257  owl_function_openurl();
    22462258}
    22472259
     
    25682580{
    25692581    buff = skiptokens(buff, 1);
    2570     owl_function_error("%s", buff);
     2582    owl_function_error(buff);
    25712583    return NULL;
    25722584}
     
    25752587{
    25762588    buff = skiptokens(buff, 1);
    2577     owl_function_makemsg("%s", buff);
     2589    owl_function_makemsg(buff);
    25782590    return NULL;
    25792591}
  • examples/owlconf.erik

    r160d3f4 r5d9c664  
    147147    owl::command("set -q rxping on");
    148148    owl::command("set -q typewinsize 5");
     149    if ($ENV{"DISPLAY"} eq ":0.0") {
     150      owl::command("set -q webbrowser galeon");
     151    }
    149152    owl::command("filter me recipient %me% or ( sender %me% and class message and instance personal ) or class mail or type aim");
    150153    owl::command("filter owl instance ^owl.*");
  • examples/owlconf.simple

    r160d3f4 r2b14303  
    9393    # owl::command('set -q view_home all');
    9494
     95
     96    ## Which webbrowser to use to launch URLs with the 'w' key.
     97    # owl::command('set -q webbrowser netscape');
     98    # owl::command('set -q webbrowser galeon');
     99    # owl::command('set -q webbrowser none');
    95100
    96101    ## Default message to send when zaway is on (toggle with 'A')
  • filter.c

    r9711a6e rcdc6ff1  
    33
    44static const char fileIdent[] = "$Id$";
     5
     6#define OWL_FILTER_MAXRECURSE 20
    57
    68int owl_filter_init_fromstring(owl_filter *f, char *name, char *string)
     
    4850  /* Now check for recursion. */
    4951  if (owl_filter_is_toodeep(f)) {
    50     owl_function_error("Filter loop!");
     52    owl_function_error("Filter loop or exceeds recursion depth");
    5153    owl_filter_free(f);
    5254    return(-1);
     
    311313  int numfailed=0;
    312314  owl_message m;
    313   owl_filter f1, f2, f3, f4, f5;
     315  owl_filter f1, f2, f3, f4;
    314316
    315317  owl_list_create(&(g.filterlist));
     
    363365  FAIL_UNLESS("mutual recursion",   owl_filter_init_fromstring(&f4, "f4", "filter f3"));
    364366
    365   /* support referencing a filter several times */
    366   FAIL_UNLESS("DAG", !owl_filter_init_fromstring(&f5, "dag", "filter f1 or filter f1"));
    367 
    368367  return 0;
    369368}
  • filterelement.c

    rf446454 r0504f63  
    279279}
    280280
    281 static int fe_visiting = 0;
    282 static int fe_visited  = 1;
    283 
    284281int owl_filterelement_is_toodeep(owl_filter *f, owl_filterelement *fe)
    285282{
    286   int rv;
     283  int one = 1;
     284  owl_list nodes;
    287285  owl_dict filters;
     286  owl_list_create(&nodes);
    288287  owl_dict_create(&filters);
    289 
    290   owl_dict_insert_element(&filters, f->name, &fe_visiting, owl_dict_noop_free);
    291 
    292   rv = _owl_filterelement_is_toodeep(fe, &filters);
    293 
     288 
     289  owl_list_append_element(&nodes, fe);
     290  owl_dict_insert_element(&filters, f->name, &one, NULL);
     291  while(owl_list_get_size(&nodes)) {
     292    fe = owl_list_get_element(&nodes, 0);
     293    owl_list_remove_element(&nodes, 0);
     294    if(fe->left) owl_list_append_element(&nodes, fe->left);
     295    if(fe->right) owl_list_append_element(&nodes, fe->right);
     296    if(fe->match_message == owl_filterelement_match_filter) {
     297      if(owl_dict_find_element(&filters, fe->field)) return 1;
     298      owl_dict_insert_element(&filters, fe->field, &one, NULL);
     299      f = owl_global_get_filter(&g, fe->field);
     300      if(f) owl_list_append_element(&nodes, f->root);
     301    }
     302  }
     303
     304  owl_list_free_simple(&nodes);
    294305  owl_dict_free_simple(&filters);
    295   return rv;
    296 }
    297 
    298 int _owl_filterelement_is_toodeep(owl_filterelement *fe, owl_dict *seen)
    299 {
    300   int rv = 0;
    301   owl_filter *f;
    302 
    303   if(fe->match_message == owl_filterelement_match_filter) {
    304     int *nval = owl_dict_find_element(seen, fe->field);
    305     if(nval == &fe_visiting) {
    306       return 1;
    307     } else if (nval == NULL) {
    308       f = owl_global_get_filter(&g, fe->field);
    309       owl_dict_insert_element(seen, fe->field, &fe_visiting, owl_dict_noop_free);
    310       if(f) rv = _owl_filterelement_is_toodeep(f->root, seen);
    311       owl_dict_insert_element(seen, fe->field, &fe_visited, owl_dict_noop_free);
    312     }
    313   } else {
    314     if(fe->left)
    315       rv = rv || _owl_filterelement_is_toodeep(fe->left, seen);
    316     if(fe->right)
    317       rv = rv || _owl_filterelement_is_toodeep(fe->right, seen);
    318   }
    319   return rv;
     306  return 0;
    320307}
    321308
  • fmtext.c

    r2aaca94 r6f6330b  
    763763 * If format_fn is specified, passes it the list element value
    764764 * and it will return a string which this needs to free. */
    765 void owl_fmtext_append_list(owl_fmtext *f, owl_list *l, char *join_with, char *(format_fn)(char *))
     765void owl_fmtext_append_list(owl_fmtext *f, owl_list *l, char *join_with, char *(format_fn)(void*))
    766766{
    767767  int i, size;
    768   char *elem;
     768  void *elem;
    769769  char *text;
    770770
  • functions.c

    r9b70dd4 r3f3ee61  
    9999}
    100100
    101 char *owl_function_style_describe(char *name) {
     101char *owl_function_style_describe(void *name) {
    102102  char *desc, *s;
    103103  owl_style *style;
     
    114114}
    115115
    116 char *owl_function_cmd_describe(char *name)
     116char *owl_function_cmd_describe(void *name)
    117117{
    118118  owl_cmd *cmd = owl_cmddict_find(owl_global_get_cmddict(&g), name);
     
    172172}
    173173
    174 void owl_function_show_quickstart()
    175 {
    176     char *message =
    177     "Move between messages with the arrow keys, and press 'r' to reply.\n"
    178     "For more info, press 'h' or visit http://barnowl.mit.edu/\n\n"
    179 #ifdef HAVE_LIBZEPHYR
    180     "@b(Zephyr:)\n"
    181     "To send a message to a user, type ':zwrite @b(username)'. You can also\n"
    182     "press 'z' and then type the username. To subscribe to a class, type\n"
    183     "':sub @b(class)', and then type ':zwrite -c @b(class)' to send.\n\n"
    184 #endif
    185     "@b(AIM:)\n"
    186     "Log in to AIM with ':aimlogin @b(screenname)'. Use ':aimwrite @b(screenname)',\n"
    187     "or 'a' and then the screen name, to send someone a message.\n\n"
    188     ;
    189 
    190     if (owl_perlconfig_is_function("BarnOwl::Hooks::_get_quickstart")) {
    191         char *perlquickstart = owl_perlconfig_execute("BarnOwl::Hooks::_get_quickstart()");
    192         if (perlquickstart) {
    193             char *result = owl_sprintf("%s%s", message, perlquickstart);
    194             owl_function_adminmsg("BarnOwl Quickstart", result);
    195             owl_free(result);
    196             owl_free(perlquickstart);
    197             return;
    198         }
    199     }
    200     owl_function_adminmsg("BarnOwl Quickstart", message);
    201 }
    202 
    203 
    204174/* Create an admin message, append it to the global list of messages
    205175 * and redisplay if necessary.
     
    632602
    633603  if (!found) {
    634     owl_function_makemsg("already at last%s message%s%s%s",
     604    owl_function_makemsg("already at last%s message%s%s",
    635605                         skip_deleted?" non-deleted":"",
    636                          filter?" in ":"", filter?filter:"",
    637                          owl_mainwin_is_curmsg_truncated(owl_global_get_mainwin(&g)) ?
    638                          ", press Enter to scroll" : "");
     606                         filter?" in ":"", filter?filter:"");
    639607    /* if (!skip_deleted) owl_function_beep(); */
    640608  }
     
    10511019  owl_function_debugmsg("Quitting Owl");
    10521020  exit(0);
     1021}
     1022
     1023void owl_function_openurl()
     1024{
     1025  /* visit the first url in the current message */
     1026  owl_message *m;
     1027  owl_view *v;
     1028  char *ptr1, *ptr2, *text, url[LINE], tmpbuff[LINE];
     1029  int webbrowser;
     1030
     1031  webbrowser = owl_global_get_webbrowser(&g);
     1032
     1033  if (webbrowser < 0 || webbrowser == OWL_WEBBROWSER_NONE) {
     1034    owl_function_error("No browser selected");
     1035    return;
     1036  }
     1037
     1038  v=owl_global_get_current_view(&g);
     1039 
     1040  m=owl_view_get_element(v, owl_global_get_curmsg(&g));
     1041
     1042  if (!m || owl_view_get_size(v)==0) {
     1043    owl_function_error("No current message selected");
     1044    return;
     1045  }
     1046
     1047  text=owl_message_get_text(m);
     1048
     1049  /* First look for a good URL */ 
     1050  if ((ptr1=strstr(text, "http://"))!=NULL) {
     1051    ptr2=strpbrk(ptr1, " \n\t");
     1052    if (ptr2) {
     1053      strncpy(url, ptr1, ptr2-ptr1+1);
     1054      url[ptr2-ptr1+1]='\0';
     1055    } else {
     1056      strcpy(url, ptr1);
     1057    }
     1058
     1059    /* if we had <http strip a trailing > */
     1060    if (ptr1>text && ptr1[-1]=='<') {
     1061      if (url[strlen(url)-1]=='>') {
     1062        url[strlen(url)-1]='\0';
     1063      }
     1064    }
     1065  } else if ((ptr1=strstr(text, "https://"))!=NULL) {
     1066    /* Look for an https URL */ 
     1067    ptr2=strpbrk(ptr1, " \n\t");
     1068    if (ptr2) {
     1069      strncpy(url, ptr1, ptr2-ptr1+1);
     1070      url[ptr2-ptr1+1]='\0';
     1071    } else {
     1072      strcpy(url, ptr1);
     1073    }
     1074   
     1075    /* if we had <http strip a trailing > */
     1076    if (ptr1>text && ptr1[-1]=='<') {
     1077      if (url[strlen(url)-1]=='>') {
     1078        url[strlen(url)-1]='\0';
     1079      }
     1080    }
     1081  } else if ((ptr1=strstr(text, "www."))!=NULL) {
     1082    /* if we can't find a real url look for www.something */
     1083    ptr2=strpbrk(ptr1, " \n\t");
     1084    if (ptr2) {
     1085      strncpy(url, ptr1, ptr2-ptr1+1);
     1086      url[ptr2-ptr1+1]='\0';
     1087    } else {
     1088      strcpy(url, ptr1);
     1089    }
     1090  } else {
     1091    owl_function_beep();
     1092    owl_function_error("Could not find URL to open.");
     1093    return;
     1094  }
     1095
     1096  /* Make sure there aren't any quotes or \'s in the url */
     1097  for (ptr1 = url; *ptr1; ptr1++) {
     1098    if (*ptr1 == '"' || *ptr1 == '\\') {
     1099      owl_function_beep();
     1100      owl_function_error("URL contains invalid characters.");
     1101      return;
     1102    }
     1103  }
     1104 
     1105  /* NOTE: There are potentially serious security issues here... */
     1106
     1107  /* open the page */
     1108  owl_function_makemsg("Opening %s", url);
     1109  if (webbrowser == OWL_WEBBROWSER_NETSCAPE) {
     1110    snprintf(tmpbuff, LINE, "netscape -remote \"openURL(%s)\" > /dev/null 2> /dev/null", url);
     1111    system(tmpbuff);
     1112  } else if (webbrowser == OWL_WEBBROWSER_GALEON) {
     1113    snprintf(tmpbuff, LINE, "galeon \"%s\" > /dev/null 2> /dev/null &", url);
     1114    system(tmpbuff);
     1115  } else if (webbrowser == OWL_WEBBROWSER_OPERA) {
     1116    snprintf(tmpbuff, LINE, "opera \"%s\" > /dev/null 2> /dev/null &", url);
     1117    system(tmpbuff);
     1118  }
    10531119}
    10541120
     
    15441610        /* fix this */
    15451611        sprintf(buff, "  Checkd Ath: %i\n", n->z_checked_auth);
    1546         sprintf(buff + strlen(buff), "  Multi notc: %s\n", n->z_multinotice);
    1547         sprintf(buff + strlen(buff), "  Num other : %i\n", n->z_num_other_fields);
    1548         sprintf(buff + strlen(buff), "  Msg Len   : %i\n", n->z_message_len);
     1612        sprintf(buff, "%s  Multi notc: %s\n", buff, n->z_multinotice);
     1613        sprintf(buff, "%s  Num other : %i\n", buff, n->z_num_other_fields);
     1614        sprintf(buff, "%s  Msg Len   : %i\n", buff, n->z_message_len);
    15491615        owl_fmtext_append_normal(&fm, buff);
    15501616       
     
    18561922void owl_function_status()
    18571923{
    1858   char buff[MAXPATHLEN+1];
     1924  char buff[5000];
    18591925  time_t start;
    18601926  int up, days, hours, minutes;
     
    18761942
    18771943  owl_fmtext_append_normal(&fm, "  Current Directory: ");
    1878   if(getcwd(buff, MAXPATHLEN) == NULL) {
    1879     owl_fmtext_append_normal(&fm, "<Error in getcwd>");
    1880   } else {
    1881     owl_fmtext_append_normal(&fm, buff);
    1882   }
     1944  (void) getcwd(buff, MAXPATHLEN);
     1945  owl_fmtext_append_normal(&fm, buff);
    18831946  owl_fmtext_append_normal(&fm, "\n");
    18841947
     
    19892052        return;
    19902053      }
    1991     }
    1992 
    1993     /* then check if it's a question and just bring up the command prompt */
    1994     if (owl_message_is_question(m)) {
    1995       owl_function_start_command("");
    1996       return;
    19972054    }
    19982055
     
    24912548  sprintf(argbuff, "class ^(un)*%s(\\.d)*$", tmpclass);
    24922549  if (tmpinstance) {
    2493     sprintf(argbuff + strlen(argbuff), " and ( instance ^(un)*%s(\\.d)*$ )", tmpinstance);
     2550    sprintf(argbuff, "%s and ( instance ^(un)*%s(\\.d)*$ )", argbuff, tmpinstance);
    24942551  }
    24952552  owl_free(tmpclass);
     
    25202577{
    25212578  owl_filter *f;
    2522   char *argbuff, *longuser, *esclonguser, *shortuser, *filtname;
     2579  char *argbuff, *longuser, *shortuser, *filtname;
    25232580
    25242581  /* stick the local realm on if it's not there */
     
    25272584
    25282585  /* name for the filter */
    2529   filtname=owl_sprintf("user-%s", shortuser);
     2586  filtname=owl_malloc(strlen(shortuser)+20);
     2587  sprintf(filtname, "user-%s", shortuser);
    25302588
    25312589  /* if it already exists then go with it.  This lets users override */
     
    25372595  f=owl_malloc(sizeof(owl_filter));
    25382596
    2539   esclonguser = owl_text_quote(longuser, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    2540 
    2541   argbuff=owl_sprintf("( type ^zephyr$ and filter personal and "
    2542       "( ( direction ^in$ and sender ^%1$s$ ) or ( direction ^out$ and "
    2543       "recipient ^%1$s$ ) ) ) or ( ( class ^login$ ) and ( sender ^%1$s$ ) )",
    2544       esclonguser);
     2597  argbuff=owl_malloc(strlen(longuser)+1000);
     2598  sprintf(argbuff, "( type ^zephyr$ and filter personal and ");
     2599  sprintf(argbuff, "%s ( ( direction ^in$ and sender ^%s$ ) or ( direction ^out$ and recipient ^%s$ ) ) )", argbuff, longuser, longuser);
     2600  sprintf(argbuff, "%s or ( ( class ^login$ ) and ( sender ^%s$ ) )", argbuff, longuser);
    25452601
    25462602  owl_filter_init_fromstring(f, filtname, argbuff);
     
    25522608  owl_free(argbuff);
    25532609  owl_free(longuser);
    2554   owl_free(esclonguser);
    25552610  owl_free(shortuser);
    25562611
     
    25712626
    25722627  /* name for the filter */
    2573   filtname=owl_sprintf("aimuser-%s", user);
     2628  filtname=owl_malloc(strlen(user)+40);
     2629  sprintf(filtname, "aimuser-%s", user);
    25742630
    25752631  /* if it already exists then go with it.  This lets users override */
     
    25832639  escuser = owl_text_quote(user, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    25842640
    2585   argbuff = owl_sprintf(
    2586       "( type ^aim$ and ( ( sender ^%1$s$ and recipient ^%2$s$ ) or "
    2587       "( sender ^%2$s$ and recipient ^%1$s$ ) ) )",
    2588       escuser, owl_global_get_aim_screenname_for_filters(&g));
     2641  argbuff=owl_malloc(1000);
     2642  sprintf(argbuff,
     2643          "( type ^aim$ and ( ( sender ^%s$ and recipient ^%s$ ) or ( sender ^%s$ and recipient ^%s$ ) ) )",
     2644          escuser, owl_global_get_aim_screenname_for_filters(&g),
     2645          owl_global_get_aim_screenname_for_filters(&g), escuser);
    25892646
    25902647  owl_filter_init_fromstring(f, filtname, argbuff);
     
    26032660{
    26042661  owl_filter *f;
    2605   char *argbuff, *filtname, *esctype;
     2662  char *argbuff, *filtname;
    26062663
    26072664  /* name for the filter */
     
    26162673  f=owl_malloc(sizeof(owl_filter));
    26172674
    2618   esctype = owl_text_quote(type, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    2619 
    2620   argbuff = owl_sprintf("type ^%s$", esctype);
     2675  argbuff = owl_sprintf("type ^%s$", type);
    26212676
    26222677  owl_filter_init_fromstring(f, filtname, argbuff);
     
    26272682  /* free stuff */
    26282683  owl_free(argbuff);
    2629   owl_free(esctype);
    26302684
    26312685  return filtname;
     
    29012955    owl_text_tr(quoted, '\'', '.');
    29022956    owl_text_tr(quoted, '"', '.');
    2903     sprintf(buff + strlen(buff), " ^(un)*%s(\\.d)*$", quoted);
     2957    sprintf(buff, "%s ^(un)*%s(\\.d)*$", buff, quoted);
    29042958    owl_free(quoted);
    29052959  }
     
    29112965    owl_text_tr(quoted, '\'', '.');
    29122966    owl_text_tr(quoted, '"', '.');
    2913     sprintf(buff + strlen(buff), " and instance ^(un)*%s(\\.d)*$", quoted);
     2967    sprintf(buff, "%s and instance ^(un)*%s(\\.d)*$", buff, quoted);
    29142968    owl_free(quoted);
    29152969  }
     
    29192973    owl_text_tr(quoted, '\'', '.');
    29202974    owl_text_tr(quoted, '"', '.');
    2921     sprintf(buff + strlen(buff), " and recipient ^%s$", quoted);
     2975    sprintf(buff, "%s and recipient ^%s$", buff, quoted);
    29222976    owl_free(quoted);
    29232977  }
     
    30113065}
    30123066
    3013 char *owl_function_keymap_summary(char *name)
     3067char *owl_function_keymap_summary(void *name)
    30143068{
    30153069  owl_keymap *km
  • global.c

    r5547211b rda466e0  
    139139  g->recwin=newwin(g->recwinlines, cols, 0, 0);
    140140  if (g->recwin==NULL) {
    141     owl_function_debugmsg("_owl_global_setup_windows: newwin returned NULL\n");
     141    owl_function_debugmsg("_owl_global_setup_windows: newwin returned NULL\n", g->recwinlines, cols);
    142142    endwin();
    143143    exit(50);
     
    570570  strcpy(g->startupargs, "");
    571571  for (i=0; i<argc; i++) {
    572     sprintf(g->startupargs + strlen(g->startupargs), "%s ", argv[i]);
     572    sprintf(g->startupargs, "%s%s ", g->startupargs, argv[i]);
    573573  }
    574574  g->startupargs[strlen(g->startupargs)-1]='\0';
  • help.c

    r799b60e r0398d55  
    1818  owl_fmtext_append_normal
    1919    (&fm,
    20      "  If you're new to BarnOwl, the first thing you should type is\n\n"
    21      "    :show quickstart\n\n"
    2220     "  For help on a specific command use 'help <command>'\n"
    2321     "  For information on advanced keys, use 'show keymaps'.\n"
  • keys.c

    r9b70dd4 r3004c9f  
    282282  BIND_CMD("M-r", "reply -e",         "reply to the current message, but allow editing of recipient");
    283283  BIND_CMD("M-R", "reply -e sender",  "reply to sender of the current message, but allow editing of recipient");
     284                 
     285  BIND_CMD("w",   "openurl",          "open a URL using a webbrowser");
    284286
    285287  BIND_CMD("W",   "start-command webzephyr ", "start a webzephyr command");
  • owl.c

    r5b37c063 r5b37c063  
    323323  sprintf(buff,      "Welcome to barnowl version %s.  Press 'h' for on-line help.            \n", OWL_VERSION_STRING);
    324324  strcat(startupmsg, buff);
    325   strcat(startupmsg, "To see a quick introduction, type ':show quickstart'.                  \n");
    326325  strcat(startupmsg, "                                                                       \n");
    327326  strcat(startupmsg, "BarnOwl is free software. Type ':show license' for more                \n");
    328   strcat(startupmsg, "information.                                                     ^ ^   \n");
     327  strcat(startupmsg, "information.                                                           \n");
     328  strcat(startupmsg, "                                                                 ^ ^   \n");
    329329  strcat(startupmsg, "                                                                 OvO   \n");
    330330  strcat(startupmsg, "Please report any bugs or suggestions to bug-barnowl@mit.edu    (   )  \n");
     
    511511      int signum;
    512512      if ((signum = owl_global_get_errsignal_and_clear(&g, &si)) > 0) {
    513         owl_function_error("Got unexpected signal: %d %s  (code: %d band: %ld  errno: %d)",
     513        owl_function_error("Got unexpected signal: %d %s  (code: %d band: %d  errno: %d)",
    514514                           signum, signum==SIGPIPE?"SIGPIPE":"SIG????",
    515515                           si.si_code, si.si_band, si.si_errno);
     
    612612
    613613  return 1;
     614}
     615
     616void owl_process_aim()
     617{
     618  if (owl_global_is_doaimevents(&g)) {
     619    owl_aim_process_events();
     620   
     621    if (owl_global_is_aimloggedin(&g)) {
     622      if (owl_timer_is_expired(owl_global_get_aim_buddyinfo_timer(&g))) {
     623        /* owl_buddylist_request_idletimes(owl_global_get_buddylist(&g)); */
     624        owl_timer_reset(owl_global_get_aim_buddyinfo_timer(&g));
     625      }
     626    }
     627  }
    614628}
    615629
  • owl.h

    rb940b91 r43a306c  
    5252
    5353#ifndef OWL_VERSION_STRING
    54 #define OWL_VERSION_STRING "1.0.4.1"
     54#define OWL_VERSION_STRING "1.0.3"
    5555#endif
    5656
     
    320320
    321321typedef struct _owl_pair {
    322   char *key;
    323   char *value;
     322  void *key;
     323  void *value;
    324324} owl_pair;
    325325
  • pair.c

    rde1c8a5 r160ea47  
    11#include "owl.h"
    22
    3 void owl_pair_create(owl_pair *p, char *key, char *value) {
     3void owl_pair_create(owl_pair *p, void *key, void *value) {
    44  p->key=key;
    55  p->value=value;
    66}
    77
    8 void owl_pair_set_key(owl_pair *p, char *key) {
     8void owl_pair_set_key(owl_pair *p, void *key) {
    99  p->key=key;
    1010}
    1111
    12 void owl_pair_set_value(owl_pair *p, char *value) {
     12void owl_pair_set_value(owl_pair *p, void *value) {
    1313  p->value=value;
    1414}
    1515
    16 char *owl_pair_get_key(owl_pair *p) {
     16void *owl_pair_get_key(owl_pair *p) {
    1717  return(p->key);
    1818}
    1919
    20 char *owl_pair_get_value(owl_pair *p) {
     20void *owl_pair_get_value(owl_pair *p) {
    2121  return(p->value);
    2222}
  • perl/modules/IRC/lib/BarnOwl/Message/IRC.pm

    rf79d6a2 r38a7f22  
    3333        @filter  =
    3434             (qw{( type ^irc$ and filter personal and },
    35               qw{( ( direction ^in$ and sender}, "^\Q$who\E\$",
    36               qw{ ) or ( direction ^out$ and recipient}, "^\Q$who\E\$",
     35              qw{( ( direction ^in$ and sender}, "^$who\$",
     36              qw{ ) or ( direction ^out$ and recipient}, "^$who\$",
    3737              qw{) ) ) });
    3838        BarnOwl::command("filter", "$filter", @filter);
     
    4747            $filter = "irc-$network-channel-$channel-$sender-$1";
    4848            @filter =
    49                  (qw{type ^irc$ and network}, "^\Q$network\E\$",
    50                   qw{and channel}, "^\Q$channel\E\$",
    51                   qw{and ( sender}, "^\Q$sender\E\$",
    52                   qw{or sender}, "^\Q$1\E\$",qq{)});
     49                 (qw{type ^irc$ and network}, "^$network\$",
     50                  qw{and channel}, "^$channel\$",
     51                  qw{and ( sender}, "^$sender\$",
     52                  qw{or sender}, "^$1\$",qq{)});
    5353        } else {
    5454            $filter = "irc-$network-channel-$channel";
    55             @filter = (qw{type ^irc$ and network}, "^\Q$network\E\$",
    56                        qw{and channel}, "^\Q$channel\E\$");
     55            @filter = (qw{type ^irc$ and network}, "^$network\$",
     56                       qw{and channel}, "^$channel\$");
    5757        }
    5858        BarnOwl::command("filter", "$filter", @filter);
  • perl/modules/IRC/lib/BarnOwl/Module/IRC.pm

    r1c014eec r167044b  
    214214    if ($body =~ /^\/me (.*)/) {
    215215        $conn->conn->me($to, $1);
    216         $body = '* '.$conn->nick.' '.$1;
     216        $body = BarnOwl::Style::boldify($conn->nick.' '.$1);
    217217    } else {
    218218        $conn->conn->privmsg($to, $body);
  • perl/modules/Jabber/lib/BarnOwl/Message/Jabber.pm

    r9375f8c r96134cb  
    7070        $filter = "jabber-room-$room";
    7171        BarnOwl::command(qw[filter], $filter,
    72                          qw[type ^jabber$ and room], "^\Q$room\E\$");
     72                         qw[type ^jabber$ and room], "^$room\$");
    7373        return $filter;
    7474    } elsif ($self->login ne 'none') {
     
    8484    my $filter = "jabber-user-$user";
    8585    BarnOwl::command(qw[filter], $filter, qw[type ^jabber$],
    86                      qw[and ( ( direction ^in$ and from], "^\Q$user\E(/.*)?\$",
    87                      qw[) or ( direction ^out$ and to ], "^\Q$user\E(/.*)?\$",
     86                     qw[and ( ( direction ^in$ and from], "^$user",
     87                     qw[) or ( direction ^out$ and to ], "^$user",
    8888                     qw[ ) ) ]);
    8989    return $filter;
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm

    r799b60e re979da9  
    7070        $BarnOwl::Hooks::mainLoop->add("BarnOwl::Module::Jabber::onMainLoop");
    7171        $BarnOwl::Hooks::getBuddyList->add("BarnOwl::Module::Jabber::onGetBuddyList");
    72         $BarnOwl::Hooks::getQuickstart->add("BarnOwl::Module::Jabber::onGetQuickstart");
    7372        $vars{show} = '';
    7473        BarnOwl::new_variable_bool("jabber:show_offline_buddies",
     
    223222}
    224223
    225 sub onGetQuickstart {
    226     return <<'EOF'
    227 @b(Jabber:)
    228 Type ':jabberlogin @b(username@mit.edu)' to log in to Jabber. The command
    229 ':jroster sub @b(somebody@gmail.com)' will request that they let you message
    230 them. Once you get a message saying you are subscribed, you can message
    231 them by typing ':jwrite @b(somebody@gmail.com)' or just 'j @b(somebody)'.
    232 EOF
    233 }
    234 
    235224################################################################################
    236225### Owl Commands
  • perlconfig.c

    r5b37c063 r5b37c063  
    4444  h = newHV();
    4545
    46 #define MSG2H(h,field) (void)hv_store(h, #field, strlen(#field),        \
    47                                       newSVpv(owl_message_get_##field(m),0), 0)
     46#define MSG2H(h,field) hv_store(h, #field, strlen(#field), \
     47                              newSVpv(owl_message_get_##field(m),0), 0)
    4848
    4949  if (owl_message_is_type_zephyr(m)
     
    5959      owl_free(ptr);
    6060    }
    61     (void)hv_store(h, "fields", strlen("fields"), newRV_noinc((SV*)av_zfields), 0);
    62 
    63     (void)hv_store(h, "auth", strlen("auth"),
    64                    newSVpv(owl_zephyr_get_authstr(owl_message_get_notice(m)),0),0);
     61    hv_store(h, "fields", strlen("fields"), newRV_noinc((SV*)av_zfields), 0);
     62
     63    hv_store(h, "auth", strlen("auth"),
     64             newSVpv(owl_zephyr_get_authstr(owl_message_get_notice(m)),0),0);
    6565  }
    6666
     
    6868  for(i=0; i<j; i++) {
    6969    pair=owl_list_get_element(&(m->attributes), i);
    70     (void)hv_store(h, owl_pair_get_key(pair), strlen(owl_pair_get_key(pair)),
    71                    newSVpv(owl_pair_get_value(pair),0),0);
     70    hv_store(h, owl_pair_get_key(pair), strlen(owl_pair_get_key(pair)),
     71             newSVpv(owl_pair_get_value(pair),0),0);
    7272  }
    7373 
     
    8888    MSG2H(h, header);
    8989  }
    90   (void)hv_store(h, "time", strlen("time"), newSVpv(owl_message_get_timestr(m),0),0);
    91   (void)hv_store(h, "id", strlen("id"), newSViv(owl_message_get_id(m)),0);
    92   (void)hv_store(h, "deleted", strlen("deleted"), newSViv(owl_message_is_delete(m)),0);
    93   (void)hv_store(h, "private", strlen("private"), newSViv(owl_message_is_private(m)),0);
    94   (void)hv_store(h, "should_wordwrap",
    95                  strlen("should_wordwrap"), newSViv(
    96                                                     owl_filter_message_match(wrap, m)),0);
     90  hv_store(h, "time", strlen("time"), newSVpv(owl_message_get_timestr(m),0),0);
     91  hv_store(h, "id", strlen("id"), newSViv(owl_message_get_id(m)),0);
     92  hv_store(h, "deleted", strlen("deleted"), newSViv(owl_message_is_delete(m)),0);
     93  hv_store(h, "private", strlen("private"), newSViv(owl_message_is_private(m)),0);
     94  hv_store(h, "should_wordwrap",
     95           strlen("should_wordwrap"), newSViv(
     96                                              owl_filter_message_match(wrap, m)),0);
    9797
    9898  type = owl_message_get_type(m);
     
    102102  blessas = owl_sprintf("BarnOwl::Message::%s", type);
    103103
    104   hr = newRV_noinc((SV*)h);
     104  hr = sv_2mortal(newRV_noinc((SV*)h));
    105105  stash =  gv_stashpv(blessas,0);
    106106  if(!stash) {
     
    182182  dSP ;
    183183  int count;
     184  unsigned int len;
    184185  SV *msgref, *srv;
    185   char *out;
     186  char *out, *preout;
    186187 
    187188  ENTER ;
     
    190191  PUSHMARK(SP) ;
    191192  msgref = owl_perlconfig_message2hashref(m);
    192   XPUSHs(sv_2mortal(msgref));
     193  XPUSHs(msgref);
    193194  PUTBACK ;
    194195 
     
    198199
    199200  if (SvTRUE(ERRSV)) {
    200     owl_function_error("Perl Error: '%s'", SvPV_nolen(ERRSV));
     201    STRLEN n_a;
     202    owl_function_error("Perl Error: '%s'", SvPV(ERRSV, n_a));
    201203    /* and clear the error */
    202204    sv_setsv (ERRSV, &PL_sv_undef);
     
    211213
    212214  if (srv) {
    213     out = owl_strdup(SvPV_nolen(srv));
     215    preout=SvPV(srv, len);
     216    out = owl_malloc(strlen(preout)+1);
     217    strncpy(out, preout, len);
     218    out[len] = '\0';
    214219  } else {
    215220    out = NULL;
     
    230235{
    231236  dSP;
    232   unsigned int count, i;
     237  unsigned int count, len, i;
    233238  SV *msgref, *srv;
    234   char *out;
     239  char *out, *preout;
    235240
    236241  msgref = owl_perlconfig_message2hashref(m);
     
    240245
    241246  PUSHMARK(SP);
    242   XPUSHs(sv_2mortal(msgref));
     247  XPUSHs(msgref);
    243248  for(i=0;i<argc;i++) {
    244249    XPUSHs(sv_2mortal(newSVpv(argv[i], 0)));
     
    256261
    257262  if (SvTRUE(ERRSV)) {
    258     owl_function_error("Error: '%s'", SvPV_nolen(ERRSV));
     263    STRLEN n_a;
     264    owl_function_error("Error: '%s'", SvPV(ERRSV, n_a));
    259265    /* and clear the error */
    260266    sv_setsv (ERRSV, &PL_sv_undef);
     
    264270
    265271  if (srv) {
    266     out = owl_strdup(SvPV_nolen(srv));
     272    preout=SvPV(srv, len);
     273    out = owl_malloc(strlen(preout)+1);
     274    strncpy(out, preout, len);
     275    out[len] = '\0';
    267276  } else {
    268277    out = NULL;
     
    295304  ret=perl_parse(p, owl_perl_xs_init, 2, args, NULL);
    296305  if (ret || SvTRUE(ERRSV)) {
    297     err=owl_strdup(SvPV_nolen(ERRSV));
     306    STRLEN n_a;
     307    err=owl_strdup(SvPV(ERRSV, n_a));
    298308    sv_setsv(ERRSV, &PL_sv_undef);     /* and clear the error */
    299309    return(err);
     
    302312  ret=perl_run(p);
    303313  if (ret || SvTRUE(ERRSV)) {
    304     err=owl_strdup(SvPV_nolen(ERRSV));
     314    STRLEN n_a;
     315    err=owl_strdup(SvPV(ERRSV, n_a));
    305316    sv_setsv(ERRSV, &PL_sv_undef);     /* and clear the error */
    306317    return(err);
     
    331342
    332343  if (SvTRUE(ERRSV)) {
    333     err=owl_strdup(SvPV_nolen(ERRSV));
     344    STRLEN n_a;
     345    err=owl_strdup(SvPV(ERRSV, n_a));
    334346    sv_setsv (ERRSV, &PL_sv_undef);     /* and clear the error */
    335347    return(err);
     
    384396
    385397  if (SvTRUE(ERRSV)) {
    386     owl_function_error("Perl Error: '%s'", SvPV_nolen(ERRSV));
     398    STRLEN n_a;
     399    owl_function_error("Perl Error: '%s'", SvPV(ERRSV, n_a));
    387400    sv_setsv (ERRSV, &PL_sv_undef);     /* and clear the error */
    388401  }
    389402
    390403  preout=SvPV(response, len);
    391   if (len == 0 || preout[len - 1] != '\n')
    392     out = owl_sprintf("%s\n", preout);
    393   else
    394     out = owl_strdup(preout);
     404  /* leave enough space in case we have to add a newline */
     405  out = owl_malloc(strlen(preout)+2);
     406  strncpy(out, preout, len);
     407  out[len] = '\0';
     408  if (!strlen(out) || out[strlen(out)-1]!='\n') {
     409    strcat(out, "\n");
     410  }
    395411
    396412  return(out);
     
    423439  char * ret = NULL;
    424440  SV *rv;
     441  STRLEN n_a;
    425442  dSP;
    426443
     
    441458
    442459  if(SvTRUE(ERRSV)) {
    443     owl_function_error("%s", SvPV_nolen(ERRSV));
     460    owl_function_error("%s", SvPV(ERRSV, n_a));
    444461    (void)POPs;
    445462  } else {
     
    448465    rv = POPs;
    449466    if(SvTRUE(rv)) {
    450       ret = owl_strdup(SvPV_nolen(rv));
     467      ret = owl_strdup(SvPV(rv, n_a));
    451468    }
    452469  }
     
    472489  SV *cb = (SV*)(e->cbdata);
    473490  SV *text;
     491  unsigned int n_a;
    474492  dSP;
    475493
     
    490508
    491509  if(SvTRUE(ERRSV)) {
    492     owl_function_error("%s", SvPV_nolen(ERRSV));
     510    owl_function_error("%s", SvPV(ERRSV, n_a));
    493511  }
    494512
     
    508526  call_pv("BarnOwl::Hooks::_mainloop_hook", G_DISCARD|G_EVAL);
    509527  if(SvTRUE(ERRSV)) {
    510     owl_function_error("%s", SvPV_nolen(ERRSV));
     528    STRLEN n_a;
     529    owl_function_error("%s", SvPV(ERRSV, n_a));
    511530  }
    512531  return;
     
    516535{
    517536  SV *cb = d->pfunc;
     537  unsigned int n_a;
    518538  dSP;
    519539  if(cb == NULL) {
     
    530550
    531551  if(SvTRUE(ERRSV)) {
    532     owl_function_error("%s", SvPV_nolen(ERRSV));
     552    owl_function_error("%s", SvPV(ERRSV, n_a));
    533553  }
    534554
  • perlglue.xs

    r5d2248c r740d5f7  
    2424         * complex argument processing or something, we define a
    2525         * simple version here that takes arguments in as flat a
    26          * manner as possible, to simplify the XS code, put it in
    27          * BarnOwl::Intenal::, and write a perl wrapper in perlwrap.pm
    28          * that munges the arguments as appropriate and calls the
    29          * internal version.
     26         * manner as possible, to simplify the XS code, with a name
     27         * with a trailing `_internal', and write a perl wrapper in
     28         * perlwrap.pm that munges the arguments as appropriate and
     29         * calls the internal version.
    3030         */
    3131
     
    6262getcurmsg()
    6363        CODE:
    64                 RETVAL = owl_perlconfig_curmessage2hashref();
    65         OUTPUT:
    66                 RETVAL
     64                ST(0) = owl_perlconfig_curmessage2hashref();
    6765
    6866int
     
    143141                if (rv) owl_free(rv);
    144142
    145 void queue_message(msg)
    146         SV *msg
    147         PREINIT:
    148                 owl_message *m;
    149         CODE:
    150         {
    151                 if(!SvROK(msg) || SvTYPE(SvRV(msg)) != SVt_PVHV) {
    152                         croak("Usage: BarnOwl::queue_message($message)");
    153                 }
    154 
    155                 m = owl_perlconfig_hashref2message(msg);
    156 
    157                 owl_global_messagequeue_addmsg(&g, m);
    158         }
    159 
    160 void admin_message(header, body)
    161         char *header
    162         char *body
    163         CODE:
    164         {
    165                 owl_function_adminmsg(header, body);           
    166         }
    167 
    168 void start_question(line, callback)
    169         char *line
    170         SV *callback
    171         PREINIT:
    172         CODE:
    173         {
    174                 if(!SV_IS_CODEREF(callback))
    175                         croak("Callback must be a subref");
    176 
    177                 owl_function_start_question(line);
    178 
    179                 SvREFCNT_inc(callback);
    180                 owl_editwin_set_cbdata(owl_global_get_typwin(&g), callback);
    181                 owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback);
    182         }
    183 
    184 void start_password(line, callback)
    185         char *line
    186         SV *callback
    187         PREINIT:
    188         CODE:
    189         {
    190                 if(!SV_IS_CODEREF(callback))
    191                         croak("Callback must be a subref");
    192 
    193                 owl_function_start_password(line);
    194 
    195                 SvREFCNT_inc(callback);
    196                 owl_editwin_set_cbdata(owl_global_get_typwin(&g), callback);
    197                 owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback);
    198         }
    199 
    200 void start_edit_win(line, callback)
    201         char *line
    202         SV *callback
    203         PREINIT:
    204                 owl_editwin * e;
    205                 char buff[1024];
    206         CODE:
    207         {
    208                 if(!SV_IS_CODEREF(callback))
    209                         croak("Callback must be a subref");
    210 
    211                 e = owl_global_get_typwin(&g);
    212                 owl_editwin_new_style(e, OWL_EDITWIN_STYLE_MULTILINE,
    213                                       owl_global_get_msg_history(&g));
    214                 owl_editwin_clear(e);
    215                 owl_editwin_set_dotsend(e);
    216                 snprintf(buff, 1023, "----> %s\n", line);
    217                 owl_editwin_set_locktext(e, buff);
    218 
    219                 owl_global_set_typwin_active(&g);
    220 
    221                 SvREFCNT_inc(callback);
    222                 owl_editwin_set_cbdata(owl_global_get_typwin(&g), callback);
    223                 owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback);
    224         }
    225 
    226 
    227 char *
    228 get_data_dir ()
    229         CODE:
    230                 RETVAL = (char *) owl_get_datadir();
    231         OUTPUT:
    232         RETVAL
    233 
    234 char *
    235 get_config_dir ()
    236         CODE:
    237                 RETVAL = (char *) owl_global_get_confdir(&g);
    238         OUTPUT:
    239         RETVAL 
    240 
    241 void
    242 popless_text(text)
    243         char *text
    244         CODE:
    245         {
    246                 owl_function_popless_text(text);
    247         }
    248 
    249 void
    250 popless_ztext(text)
    251         char *text
    252         CODE:
    253         {
    254                 owl_fmtext fm;
    255                 owl_fmtext_init_null(&fm);
    256                 owl_fmtext_append_ztext(&fm, text);
    257                 owl_function_popless_fmtext(&fm);
    258                 owl_fmtext_free(&fm);
    259         }
    260 
    261 void
    262 error(text)
    263         char *text
    264         CODE:
    265         {
    266                 owl_function_error("%s", text);
    267         }
    268 
    269 void
    270 create_style(name, object)
    271      char *name
    272      SV  *object
    273      PREINIT:
    274                 owl_style *s;
    275      CODE:
    276         {
    277                 s = owl_malloc(sizeof(owl_style));
    278                 owl_style_create_perl(s, name, object);
    279                 owl_global_add_style(&g, s);
    280         }
    281 
    282 int
    283 getnumcolors()
    284         CODE:
    285                 RETVAL = owl_function_get_color_count();
    286         OUTPUT:
    287                 RETVAL
    288 
    289 void
    290 _remove_filter(filterName)
    291         char *filterName
    292         CODE:
    293         {
    294                 /* Don't delete the current view, or the 'all' filter */
    295                 if (strcmp(filterName, owl_view_get_filtname(owl_global_get_current_view(&g)))
    296                     && strcmp(filterName, "all")) {
    297                         owl_global_remove_filter(&g,filterName);
    298                 }
    299         }
    300 
    301 char *
    302 wordwrap(in, cols)
    303         char *in
    304         int cols
    305         PREINIT:
    306                 char *rv = NULL;
    307         CODE:
    308                 rv = owl_text_wordwrap(in, cols);
    309                 RETVAL = rv;   
    310         OUTPUT:
    311                 RETVAL
    312         CLEANUP:
    313                 if (rv) owl_free(rv);
    314 
    315 void
    316 add_dispatch(fd, cb)
    317         int fd
    318         SV * cb
    319         CODE:
    320         SvREFCNT_inc(cb);
    321         owl_select_add_perl_dispatch(fd, cb);
    322 
    323 void
    324 remove_dispatch(fd)
    325         int fd
    326         CODE:
    327         owl_select_remove_perl_dispatch(fd);
    328 
    329 MODULE = BarnOwl                PACKAGE = BarnOwl::Internal
    330 
    331 
    332 void
    333 new_command(name, func, summary, usage, description)
     143void
     144new_command_internal(name, func, summary, usage, description)
    334145        char *name
    335146        SV *func
     
    361172           }
    362173
    363 void
    364 new_variable_string(name, ival, summ, desc)
     174void queue_message(msg)
     175        SV *msg
     176        PREINIT:
     177                owl_message *m;
     178        CODE:
     179        {
     180                if(!SvROK(msg) || SvTYPE(SvRV(msg)) != SVt_PVHV) {
     181                        croak("Usage: BarnOwl::queue_message($message)");
     182                }
     183
     184                m = owl_perlconfig_hashref2message(msg);
     185
     186                owl_global_messagequeue_addmsg(&g, m);
     187        }
     188
     189void admin_message(header, body)
     190        char *header
     191        char *body
     192        CODE:
     193        {
     194                owl_function_adminmsg(header, body);           
     195        }
     196
     197void start_question(line, callback)
     198        char *line
     199        SV *callback
     200        PREINIT:
     201        CODE:
     202        {
     203                if(!SV_IS_CODEREF(callback))
     204                        croak("Callback must be a subref");
     205
     206                owl_function_start_question(line);
     207
     208                SvREFCNT_inc(callback);
     209                owl_editwin_set_cbdata(owl_global_get_typwin(&g), callback);
     210                owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback);
     211        }
     212
     213void start_password(line, callback)
     214        char *line
     215        SV *callback
     216        PREINIT:
     217        CODE:
     218        {
     219                if(!SV_IS_CODEREF(callback))
     220                        croak("Callback must be a subref");
     221
     222                owl_function_start_password(line);
     223
     224                SvREFCNT_inc(callback);
     225                owl_editwin_set_cbdata(owl_global_get_typwin(&g), callback);
     226                owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback);
     227        }
     228
     229void start_edit_win(line, callback)
     230        char *line
     231        SV *callback
     232        PREINIT:
     233                owl_editwin * e;
     234                char buff[1024];
     235        CODE:
     236        {
     237                if(!SV_IS_CODEREF(callback))
     238                        croak("Callback must be a subref");
     239
     240                e = owl_global_get_typwin(&g);
     241                owl_editwin_new_style(e, OWL_EDITWIN_STYLE_MULTILINE,
     242                                      owl_global_get_msg_history(&g));
     243                owl_editwin_clear(e);
     244                owl_editwin_set_dotsend(e);
     245                snprintf(buff, 1023, "----> %s\n", line);
     246                owl_editwin_set_locktext(e, buff);
     247
     248                owl_global_set_typwin_active(&g);
     249
     250                SvREFCNT_inc(callback);
     251                owl_editwin_set_cbdata(owl_global_get_typwin(&g), callback);
     252                owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback);
     253        }
     254
     255
     256char *
     257get_data_dir ()
     258        CODE:
     259                RETVAL = (char *) owl_get_datadir();
     260        OUTPUT:
     261        RETVAL
     262
     263char *
     264get_config_dir ()
     265        CODE:
     266                RETVAL = (char *) owl_global_get_confdir(&g);
     267        OUTPUT:
     268        RETVAL 
     269
     270void
     271popless_text(text)
     272        char *text
     273        CODE:
     274        {
     275                owl_function_popless_text(text);
     276        }
     277
     278void
     279popless_ztext(text)
     280        char *text
     281        CODE:
     282        {
     283                owl_fmtext fm;
     284                owl_fmtext_init_null(&fm);
     285                owl_fmtext_append_ztext(&fm, text);
     286                owl_function_popless_fmtext(&fm);
     287                owl_fmtext_free(&fm);
     288        }
     289
     290void
     291error(text)
     292        char *text
     293        CODE:
     294        {
     295                owl_function_error("%s", text);
     296        }
     297
     298void
     299create_style(name, object)
     300     char *name
     301     SV  *object
     302     PREINIT:
     303                owl_style *s;
     304     CODE:
     305        {
     306                s = owl_malloc(sizeof(owl_style));
     307                owl_style_create_perl(s, name, object);
     308                owl_global_add_style(&g, s);
     309        }
     310
     311int
     312getnumcolors()
     313        CODE:
     314                RETVAL = owl_function_get_color_count();
     315        OUTPUT:
     316                RETVAL
     317
     318void
     319_remove_filter(filterName)
     320        char *filterName
     321        CODE:
     322        {
     323                /* Don't delete the current view, or the 'all' filter */
     324                if (strcmp(filterName, owl_view_get_filtname(owl_global_get_current_view(&g)))
     325                    && strcmp(filterName, "all")) {
     326                        owl_global_remove_filter(&g,filterName);
     327                }
     328        }
     329
     330char *
     331wordwrap(in, cols)
     332        char *in
     333        int cols
     334        PREINIT:
     335                char *rv = NULL;
     336        CODE:
     337                rv = owl_text_wordwrap(in, cols);
     338                RETVAL = rv;   
     339        OUTPUT:
     340                RETVAL
     341        CLEANUP:
     342                if (rv) owl_free(rv);
     343
     344void
     345new_variable_string_internal(name, ival, summ, desc)
    365346        char * name
    366347        char * ival
     
    375356
    376357void
    377 new_variable_int(name, ival, summ, desc)
     358new_variable_int_internal(name, ival, summ, desc)
    378359        char * name
    379360        int ival
     
    388369
    389370void
    390 new_variable_bool(name, ival, summ, desc)
     371new_variable_bool_internal(name, ival, summ, desc)
    391372        char * name
    392373        int ival
     
    399380                                      desc,
    400381                                      ival);
     382
     383void
     384add_dispatch(fd, cb)
     385        int fd
     386        SV * cb
     387        CODE:
     388        SvREFCNT_inc(cb);
     389        owl_select_add_perl_dispatch(fd, cb);
     390
     391void
     392remove_dispatch(fd)
     393        int fd
     394        CODE:
     395        owl_select_remove_perl_dispatch(fd);
  • perlwrap.pm

    r5d2248c r740d5f7  
    242242    );
    243243
    244     BarnOwl::Internal::new_command($name, $func, $args{summary}, $args{usage}, $args{description});
     244    BarnOwl::new_command_internal($name, $func, $args{summary}, $args{usage}, $args{description});
    245245}
    246246
     
    275275
    276276sub new_variable_int {
    277     unshift @_, \&BarnOwl::Internal::new_variable_int, 0;
     277    unshift @_, \&BarnOwl::new_variable_int_internal, 0;
    278278    goto \&_new_variable;
    279279}
    280280
    281281sub new_variable_bool {
    282     unshift @_, \&BarnOwl::Internal::new_variable_bool, 0;
     282    unshift @_, \&BarnOwl::new_variable_bool_internal, 0;
    283283    goto \&_new_variable;
    284284}
    285285
    286286sub new_variable_string {
    287     unshift @_, \&BarnOwl::Internal::new_variable_string, "";
     287    unshift @_, \&BarnOwl::new_variable_string_internal, "";
    288288    goto \&_new_variable;
    289289}
     
    810810displayed in a popup window, with zephyr formatting parsed.
    811811
    812 =item $getQuickstart
    813 
    814 Called by :show quickstart to display 2-5 lines of help on how to
    815 start using the protocol. The result from every function registered
    816 with this hook will be appended and displayed in an admin message,
    817 with zephyr formatting parsed. The format should be
    818 "@b(Protocol:)\nSome text.\nMore text.\n"
    819 
    820812=back
    821813
     
    826818our @EXPORT_OK = qw($startup $shutdown
    827819                    $receiveMessage $newMessage
    828                     $mainLoop $getBuddyList
    829                     $getQuickstart);
     820                    $mainLoop $getBuddyList);
    830821
    831822our %EXPORT_TAGS = (all => [@EXPORT_OK]);
     
    837828our $mainLoop = BarnOwl::Hook->new;
    838829our $getBuddyList = BarnOwl::Hook->new;
    839 our $getQuickstart = BarnOwl::Hook->new;
    840830
    841831# Internal startup/shutdown routines called by the C code
     
    931921}
    932922
    933 sub _get_quickstart {
    934     return join("\n", $getQuickstart->run);
    935 }
    936 
    937923################################################################################
    938924# Built-in perl styles
  • popexec.c

    r44fc93b r1971b59  
    7373    dup2(child_write_fd, 2 /*stderr*/);
    7474    close(child_write_fd);
     75   
     76    while(0) {
     77      write(child_write_fd, "meep\n", 5);
     78      sleep(1);
     79    }
    7580
    7681    argv[0] = "sh";
  • regex.c

    r554a2b8 r8b7466b  
    1313{
    1414  int ret;
    15   char buff1[LINE];
     15  char buff1[LINE], buff2[LINE];
    1616  char *ptr;
    1717 
     
    2929  if (ret) {
    3030    regerror(ret, NULL, buff1, LINE);
    31     owl_function_makemsg("Error in regular expression: %s", buff1);
     31    sprintf(buff2, "Error in regular expression: %s", buff1);
     32    owl_function_makemsg(buff2);
    3233    owl_free(re->string);
    3334    re->string=NULL;
  • tester.c

    r3381399 r1cf3f8d3  
    66
    77owl_global g;
     8
     9void screeninit()
     10{
     11  char buff[1024];
     12 
     13  sprintf(buff, "TERMINFO=%s", TERMINFO);
     14  putenv(buff);
     15
     16  initscr();
     17  start_color();
     18  /* cbreak(); */
     19  raw();
     20  noecho();
     21  intrflush(stdscr,FALSE);
     22  keypad(stdscr,TRUE);
     23  nodelay(stdscr,1);
     24  clear();
     25  refresh();
     26  meta(stdscr, TRUE);
     27}
     28
     29void test1()
     30{
     31  int j;
     32  owl_editwin e;
     33
     34  screeninit();
     35
     36  owl_editwin_init(&e, stdscr, LINES, COLS, OWL_EDITWIN_STYLE_MULTILINE, NULL);
     37  /* owl_editwin_set_locktext(&e, "Here is some locktext:\n");*/
     38  doupdate();
     39  while (1) {
     40    usleep(50);
     41
     42    j=getch();
     43
     44    if (j==ERR) continue;
     45
     46    if (j==3) break;
     47
     48    if (j==27) {
     49      j=getch();
     50      if (j==ERR) continue;
     51      owl_editwin_process_char(&e, j);
     52      doupdate();
     53    } else {
     54      owl_editwin_process_char(&e, j);
     55      doupdate();
     56    }
     57  }
     58  endwin();
     59  printf("Had:\n%s", owl_editwin_get_text(&e));
     60}
     61
     62void test2(char *in)
     63{
     64  owl_fmtext t;
     65
     66  screeninit();
     67
     68  owl_fmtext_init_null(&t);
     69  owl_fmtext_append_ztext(&t, in);
     70  owl_fmtext_curs_waddstr(&t, stdscr);
     71  wrefresh(stdscr);
     72  sleep(5000);
     73  endwin();
     74}
     75
     76void test3()
     77{
     78  ZNotice_t *n;
     79
     80  printf("%i\n", sizeof(n->z_uid.zuid_addr));
     81  /* gethostbyaddr((char *) &(n->z_uid.zuid_addr), sizeof(n->z_uid.zuid_addr), AF_INET); */
     82}
     83
     84void colorinfo()
     85{
     86  char buff[1024];
     87 
     88  screeninit();
     89  sprintf(buff, "Have %i COLOR_PAIRS\n", COLOR_PAIRS);
     90  addstr(buff);
     91  refresh();
     92  sleep(10);
     93  endwin(); 
     94}
     95
     96void test4()
     97{
     98  int j;
     99  char buff[1024];
     100
     101  screeninit();
     102 
     103  while (1) {
     104    usleep(100);
     105
     106    j=getch();
     107
     108    if (j==ERR) continue;
     109
     110    if (j==3) break;
     111    sprintf(buff, "%o\n", j);
     112    addstr(buff);
     113  }
     114  endwin();
     115}
     116
     117void test_keypress()
     118{
     119  int j, rev;
     120  char buff[1024], buff2[64];
     121
     122  screeninit();
     123 
     124  while (1) {
     125    usleep(100);
     126
     127    j=wgetch(stdscr);
     128
     129    if (j==ERR) continue;
     130
     131    if (j==3) break;
     132    if (0 == owl_keypress_tostring(j, 0, buff2, 1000)) {
     133      rev = owl_keypress_fromstring(buff2);
     134      sprintf(buff, "%s : 0x%x 0%o %d %d %s\n", buff2, j, j, j, rev,
     135              (j==rev?"matches":"*** WARNING: Does Not Reverse"));
     136    } else {
     137      sprintf(buff, "UNKNOWN : 0x%x 0%o %d\n", j, j, j);
     138    }
     139      addstr(buff);
     140  }
     141  endwin();
     142}
     143
    8144
    9145#define OWL_DICT_NTESTS  20
     
    19155
    20156  int numfailures=0;
    21   printf("1..%d\n", OWL_UTIL_NTESTS+OWL_DICT_NTESTS+OWL_VARIABLE_NTESTS
    22          +OWL_FILTER_NTESTS+OWL_OBARRAY_NTESTS);
    23   numfailures += owl_util_regtest();
    24   numfailures += owl_dict_regtest();
    25   numfailures += owl_variable_regtest();
    26   numfailures += owl_filter_regtest();
    27   numfailures += owl_obarray_regtest();
    28   if (numfailures) {
     157  if (argc==1 || (argc==2 && 0==strcmp(argv[1],"reg"))) {
     158    printf("1..%d\n", OWL_UTIL_NTESTS+OWL_DICT_NTESTS+OWL_VARIABLE_NTESTS
     159           +OWL_FILTER_NTESTS+OWL_OBARRAY_NTESTS);
     160    numfailures += owl_util_regtest();
     161    numfailures += owl_dict_regtest();
     162    numfailures += owl_variable_regtest();
     163    numfailures += owl_filter_regtest();
     164    numfailures += owl_obarray_regtest();
     165    if (numfailures) {
    29166      fprintf(stderr, "# *** WARNING: %d failures total\n", numfailures);
     167    }
     168    return(numfailures);
     169  } else if (argc==2 && 0==strcmp(argv[1],"test1")) {
     170    test1();
     171  } else if (argc==2 && 0==strcmp(argv[1],"colorinfo")) {
     172    colorinfo();
     173  } else if (argc==2 && 0==strcmp(argv[1],"test4")) {
     174    test4();
     175  } else if (argc==2 && 0==strcmp(argv[1],"keypress")) {
     176    test_keypress();
     177  } else {
     178    fprintf(stderr, "No test specified.  Current options are: reg test1\n");
    30179  }
    31   return(numfailures);
     180  return(0);
    32181}
  • util.c

    r6eaf35b r601733d  
    373373
    374374  if (days>0) {
    375     out=owl_sprintf("%i d %2.2i:%2.2li", days, hours, run);
     375    out=owl_sprintf("%i d %2.2i:%2.2i", days, hours, run);
    376376  } else {
    377     out=owl_sprintf("    %2.2i:%2.2li", hours, run);
     377    out=owl_sprintf("    %2.2i:%2.2i", hours, run);
    378378  }
    379379  return(out);
  • variable.c

    r160d3f4 r451db9e  
    351351               "                 the cursor will be near the center.\n",
    352352               "normal,top,neartop,center,paged,pagedcenter" ),
     353
     354  OWLVAR_ENUM( "webbrowser" /* %OwlVarStub */, OWL_WEBBROWSER_NETSCAPE,
     355               "web browser to use to launch URLs",
     356               "When the 'w' key is pressed, this browser is used\n"
     357               "to display the requested URL.\n",
     358               "none,netscape,galeon,opera" ),
    353359
    354360
     
    10501056  FAIL_UNLESS("get int 7", 9==owl_variable_get_int(&vd,"typewinsize"));
    10511057
     1058  FAIL_UNLESS("get enum", OWL_WEBBROWSER_NETSCAPE==owl_variable_get_int(&vd,"webbrowser"));
     1059  FAIL_UNLESS("get enum as string 1", 0==owl_variable_get_tostring(&vd,"webbrowser", buf, 1024));
     1060  FAIL_UNLESS("get enum as string 2", 0==strcmp(buf,"netscape"));
     1061  FAIL_UNLESS("set enum 1", 0==owl_variable_set_int(&vd,"webbrowser",OWL_WEBBROWSER_GALEON));
     1062  FAIL_UNLESS("get enum 2", OWL_WEBBROWSER_GALEON==owl_variable_get_int(&vd,"webbrowser"));
     1063  FAIL_UNLESS("set enum 1b", -1==owl_variable_set_int(&vd,"webbrowser",-3));
     1064  FAIL_UNLESS("set enum 1b", -1==owl_variable_set_int(&vd,"webbrowser",209));
     1065  FAIL_UNLESS("get enum 2b", OWL_WEBBROWSER_GALEON==owl_variable_get_int(&vd,"webbrowser"));
     1066  FAIL_UNLESS("set enum 3", 0==owl_variable_set_fromstring(&vd,"webbrowser","none",0,0));
     1067  FAIL_UNLESS("get enum 4", OWL_WEBBROWSER_NONE==owl_variable_get_int(&vd,"webbrowser"));
     1068  FAIL_UNLESS("set enum 5", 0==owl_variable_set_fromstring(&vd,"webbrowser","netscape",0,0));
     1069  FAIL_UNLESS("get enum 6", OWL_WEBBROWSER_NETSCAPE==owl_variable_get_int(&vd,"webbrowser"));
     1070  FAIL_UNLESS("set enum 7", -1==owl_variable_set_fromstring(&vd,"webbrowser","xxx",0,0));
     1071  FAIL_UNLESS("set enum 8", -1==owl_variable_set_fromstring(&vd,"webbrowser","",0,0));
     1072  FAIL_UNLESS("set enum 9", -1==owl_variable_set_fromstring(&vd,"webbrowser","netscapey",0,0));
     1073  FAIL_UNLESS("get enum 10", OWL_WEBBROWSER_NETSCAPE==owl_variable_get_int(&vd,"webbrowser"));
     1074
    10521075  owl_variable_dict_newvar_string(&vd, "stringvar", "", "", "testval");
    10531076  FAIL_UNLESS("get new string var", NULL != (v = owl_variable_get(&vd, "stringvar", OWL_VARIABLE_STRING)));
  • wcwidth.c

    r44fc93b r47519e1b  
    6262#include <wchar.h>
    6363
    64 struct interval {               /* noproto */
     64static struct interval {
    6565  int first;
    6666  int last;
  • zcrypt.c

    r5547211b r34509d5  
    375375
    376376    for (i = 0; i < 8; i++) {
    377       sprintf(out + strlen(out), "%c", ((output[i] & 0xf0) >> 4) + BASE_CODE);
    378       sprintf(out + strlen(out), "%c", (output[i] & 0x0f)        + BASE_CODE);
     377      sprintf(out, "%s%c", out, ((output[i] & 0xf0) >> 4) + BASE_CODE);
     378      sprintf(out, "%s%c", out, (output[i] & 0x0f)        + BASE_CODE);
    379379    }
    380380
  • zephyr.c

    r5547211b r451db9e  
    814814    ZGetLocations(&locations,&one);
    815815    myuser=short_zuser(user);
    816     sprintf(out + strlen(out), "%s: %s\t%s\t%s\n", myuser,
     816    sprintf(out, "%s%s: %s\t%s\t%s\n", out, myuser,
    817817            locations.host ? locations.host : "?",
    818818            locations.tty ? locations.tty : "?",
  • zwrite.c

    r5547211b r3f3ee61  
    231231    for (i=0; i<j; i++) {
    232232      if (strcmp(z->realm, "")) {
    233         sprintf(toline + strlen(toline), "%s@%s ", (char *) owl_list_get_element(&(z->recips), i), z->realm);
     233        sprintf(toline, "%s%s@%s ", toline, (char *) owl_list_get_element(&(z->recips), i), z->realm);
    234234      } else {
    235         sprintf(toline + strlen(toline), "%s ", (char *) owl_list_get_element(&(z->recips), i));
     235        sprintf(toline, "%s%s ", toline, (char *) owl_list_get_element(&(z->recips), i));
    236236      }
    237237    }
Note: See TracChangeset for help on using the changeset viewer.