Changes in / [caac19d:fe7ece2]


Ignore:
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    r67b959c ra16d7e5  
    5050              "zlog in will send a login notification, zlog out will send a\n"
    5151              "logout notification.  By default a login notification is sent\n"
    52               "when owl is started and a logout notification is sent when owl\n"
     52              "when BarnOwl is started and a logout notification is sent when owl\n"
    5353              "is exited.  This behavior can be changed with the 'startuplogin'\n"
    5454              "and 'shutdownlogout' variables.  If a tty is specified for zlog in\n"
    55               "then the owl variable 'tty' will be set to that string, causing\n"
     55              "then the BarnOwl variable 'tty' will be set to that string, causing\n"
    5656              "it to be used as the zephyr location tty.\n"),
    5757
    5858  OWLCMD_VOID("quit", owl_command_quit, OWL_CTX_ANY,
    59               "exit owl",
     59              "exit BarnOwl",
    6060              "",
    61               "Exit owl and run any shutdown activities."),
     61              "Exit BarnOwl and run any shutdown activities."),
    6262  OWLCMD_ALIAS("exit", "quit"),
    6363  OWLCMD_ALIAS("q",    "quit"),
     
    180180
    181181  OWLCMD_ARGS("startup", owl_command_startup, OWL_CTX_ANY,
    182               "run a command and set it to be run at every Owl startup",
     182              "run a command and set it to be run at every BarnOwl startup",
    183183              "startup <commands> ...",
    184184              "Everything on the command line after the startup command\n"
    185               "is executed as a normal owl command and is also placed in\n"
    186               "a file so that the command is executed every time owl\n"
     185              "is executed as a normal BarnOwl command and is also placed in\n"
     186              "a file so that the command is executed every time BarnOwl\n"
    187187              "is started"),
    188188
    189189  OWLCMD_ARGS("unstartup", owl_command_unstartup, OWL_CTX_ANY,
    190               "remove a command from the list of those to be run at Owl startup",
     190              "remove a command from the list of those to be run at BarnOwl startup",
    191191              "unstartup <commands> ...",
    192192              ""),
    193193
    194194  OWLCMD_VOID("version", owl_command_version, OWL_CTX_ANY,
    195               "print the version of the running owl", "", ""),
     195              "print the version of the running BarnOwl", "", ""),
    196196
    197197  OWLCMD_ARGS("subscribe", owl_command_subscribe, OWL_CTX_ANY,
     
    204204              "only be temporary, i.e., it will not be written to\n"
    205205              "the subscription file and will therefore not be\n"
    206               "present the next time owl is started.\n"),
     206              "present the next time BarnOwl is started.\n"),
    207207  OWLCMD_ALIAS("sub", "subscribe"),
    208208
     
    216216              "only be temporary, i.e., it will not be updated in\n"
    217217              "the subscription file and will therefore not be\n"
    218               "in effect the next time owl is started.\n"),
     218              "in effect the next time BarnOwl is started.\n"),
    219219  OWLCMD_ALIAS("unsub", "unsubscribe"),
    220220
     
    234234
    235235  OWLCMD_ARGS("source", owl_command_source, OWL_CTX_ANY,
    236               "execute owl commands from a file",
     236              "execute BarnOwl commands from a file",
    237237              "source <filename>",
    238               "Execute the owl commands in <filename>.\n"),
     238              "Execute the BarnOwl commands in <filename>.\n"),
    239239
    240240  OWLCMD_ARGS("aim", owl_command_aim, OWL_CTX_INTERACTIVE,
     
    305305 
    306306  OWLCMD_ARGS("help", owl_command_help, OWL_CTX_INTERACTIVE,
    307               "display help on using owl",
     307              "display help on using BarnOwl",
    308308              "help [command]", ""),
    309309
     
    418418
    419419  OWLCMD_VOID("suspend", owl_command_suspend, OWL_CTX_ANY,
    420               "suspend owl", "", ""),
     420              "suspend BarnOwl", "", ""),
    421421
    422422  OWLCMD_ARGS("echo", owl_command_echo, OWL_CTX_ANY,
     
    509509
    510510  OWLCMD_VOID("about", owl_command_about, OWL_CTX_INTERACTIVE,
    511               "print information about owl", "", ""),
     511              "print information about BarnOwl", "", ""),
    512512
    513513  OWLCMD_VOID("status", owl_command_status, OWL_CTX_ANY,
    514               "print status information about the running owl", "", ""),
     514              "print status information about the running BarnOwl", "", ""),
    515515 
    516516  OWLCMD_ARGS("zlocate", owl_command_zlocate, OWL_CTX_INTERACTIVE,
     
    590590              "The other usages listed above are abbreviated forms that simply set\n"
    591591              "the filter of the current view. The -d option allows you to write a\n"
    592               "filter expression that will be dynamically created by owl and then\n"
     592              "filter expression that will be dynamically created by BarnOwl and then\n"
    593593              "applied as the view's filter\n"
    594594              "SEE ALSO: filter, viewclass, viewuser\n"),
     
    676676              "for formatting messages.\n\n"
    677677              "Show variables will list the names of all variables.\n\n"
    678               "Show errors will show a list of errors encountered by Owl.\n\n"
     678              "Show errors will show a list of errors encountered by BarnOwl.\n\n"
    679679              "SEE ALSO: filter, view, alias, bindkey, help\n"),
    680680 
     
    15811581  int  silent=0;
    15821582  int requirebool=0;
     1583  owl_variable *v;
    15831584
    15841585  if (argc == 1) {
     
    16031604    return NULL;
    16041605  }
    1605   owl_variable_set_fromstring(owl_global_get_vardict(&g), var, val, !silent, requirebool);
     1606
     1607  v = owl_variable_get_var(owl_global_get_vardict(&g), var);
     1608  if (v == NULL) {
     1609    if (!silent) owl_function_error("Unknown variable '%s'", var);
     1610  } else if (requirebool && owl_variable_get_type(v) != OWL_VARIABLE_BOOL) {
     1611    if (!silent) owl_function_error("Variable '%s' is not a boolean", var);
     1612  } else {
     1613    owl_variable_set_fromstring(v, val, !silent);
     1614  }
    16061615  return NULL;
    16071616}
     
    16091618char *owl_command_unset(int argc, const char *const *argv, const char *buff)
    16101619{
     1620  owl_variable *v;
    16111621  const char *var, *val;
    16121622  int  silent=0;
     
    16231633    return NULL;
    16241634  }
    1625   owl_variable_set_fromstring(owl_global_get_vardict(&g), var, val, !silent, 1);
     1635
     1636  v = owl_variable_get_var(owl_global_get_vardict(&g), var);
     1637  if (v == NULL) {
     1638    if (!silent) owl_function_error("Unknown variable '%s'", var);
     1639  } else if (owl_variable_get_type(v) != OWL_VARIABLE_BOOL) {
     1640    if (!silent) owl_function_error("Variable '%s' is not a boolean", var);
     1641  } else {
     1642    owl_variable_set_fromstring(v, val, !silent);
     1643  }
    16261644  return NULL;
    16271645}
     
    16311649  const char *var;
    16321650  char *value;
     1651  const owl_variable *v;
    16331652
    16341653  if (argc==1) {
     
    16421661  var=argv[1];
    16431662   
    1644   value = owl_variable_get_tostring(owl_global_get_vardict(&g), var);
    1645   if (value) {
    1646     owl_function_makemsg("%s = '%s'", var, value);
     1663  v = owl_variable_get_var(owl_global_get_vardict(&g), var);
     1664  if (v) {
     1665    value = owl_variable_get_tostring(v);
     1666    if (value == NULL)
     1667      owl_function_makemsg("%s = <null>", var);
     1668    else
     1669      owl_function_makemsg("%s = '%s'", var, value);
    16471670    g_free(value);
    16481671  } else {
     
    25112534  } else if(argc == 2) {
    25122535    /* Handle :unpunt <number> */
    2513     if(unpunt && (i=atoi(argv[1])) !=0) {
     2536    if (unpunt && (i = atoi(argv[1])) > 0) {
    25142537      i--;      /* Accept 1-based indexing */
    25152538      if (i < fl->len) {
     
    25412564}
    25422565
    2543 char *owl_command_getvar(int argc, const char *const *argv, const char *buff)
    2544 {
     2566CALLER_OWN char *owl_command_getvar(int argc, const char *const *argv, const char *buff)
     2567{
     2568  const owl_variable *v;
    25452569  if (argc != 2) {
    25462570    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);
    25472571    return NULL;
    25482572  }
    2549   return owl_variable_get_tostring(owl_global_get_vardict(&g), argv[1]);
     2573  v = owl_variable_get_var(owl_global_get_vardict(&g), argv[1]);
     2574  if (v == NULL) return NULL;
     2575  return owl_variable_get_tostring(v);
    25502576}
    25512577
  • doc/barnowl.1

    rfa1b15b rbad4496  
    1 .TH barnowl 1 "23 Jun 2008"
     1.TH BARNOWL 1 "24 Jun 2011"
    22.SH NAME
    3 barnowl \- tty based zephyr client
     3BarnOwl \- tty\(hybased zephyr client
    44.SH SYNOPSIS
    55.B barnowl
    6 [ \-n
    7 ]
    8 [ \-d
    9 ]
    10 [ \-D
    11 ]
    12 [ \-v
    13 ]
    14 [ \-h
    15 ]
    16 [ \-c
    17 .I configfile
    18 ]
    19 [ \-t
    20 .I tty
    21 ]
    22 [ \-s
    23 .I configdir
    24 ]
     6[\-n]
     7[\-d]
     8[\-D]
     9[\-v]
     10[\-h]
     11[\-c \fICONFIGFILE\fP]
     12[\-t \fITTY\fP]
     13[\-s \fICONFIGDIR\fP]
    2514.br
    2615.SH DESCRIPTION
    2716.B BarnOwl
    28 is a fully integrated tty based instant messaging client.  Currently
    29 it supports AOL Instant Messenger, MIT Zephyr, and Jabber.  It is
    30 curses-based, allows for emacs-style editing of outgoing messages and
    31 uses perl as an extension and configuration language.  BarnOwl will
     17is a fully integrated tty\(hybased instant messaging client.  Currently
     18it supports AOL Instant Messenger, MIT Zephyr, Jabber, IRC, and Twitter.  It is
     19curses\(hybased, allows for emacs\(hystyle editing of outgoing messages, and
     20uses Perl as an extension and configuration language.  \fBBarnOwl\fP will
    3221also run happily without a configuration file.
    3322
    34 Once BarnOwl is started, typing 'h' will display a help screen.
    35 Typing \':\' enters command mode, allowing the user to type a barnowl
     23Once \fBBarnOwl\fP is started, typing \(oqh\(cq will display a help screen.
     24Typing \(oq:\(cq enters command mode, allowing the user to type a \fBBarnOwl\fP
    3625command line.
    3726
    38 .PP
    39 .SH USE
    40 The following command line options are avilable when running barnowl:
     27.SH OPTIONS
     28The following command\-line options are avilable when running \fBBarnOwl\fP:
     29.TP
     30\fB\-n\fP, \fB\-\-no\-subs\fP
     31Do not subscribe to zephyr messages on startup.  By default, \fBBarnOwl\fP
     32subscribes to the default subscriptions and to anything found in
     33\fI~/.zephyr.subs\fP.  When this option is used, no subscriptions are loaded.
    4134
    42 .B \-n
    43 .IP
    44 Do not subscribe to zephyr messages on startup.  By default BarnOwl
    45 subscribes to the default subscriptions and to anything found in
    46 ~/.zephyr.subs.  When this option is used no subscriptions are loaded.
    47 .LP
     35.TP
     36\fB\-c\fP, \fB\-\-config\-file\fP=\fIFILE\fP
     37Specify an alternate config file for \fBBarnOwl\fP to use.  By default,
     38\fBBarnOwl\fP uses \fI~/.barnowlconf\fP if it exists, and \fI~/.owlconf\fP otherwise.
    4839
    49 .B \-c \fIconfigfile\fP
    50 .IP
    51 Specifiy an alternate config file for BarnOwl to use.  By default,
    52 barnowl uses ~/.barnowlconf if it exists, and ~/.owlconf otherwise.
    53 .LP
     40.TP
     41\fB\-s\fP, \fB\-\-config\-dir\fP=\fIDIR\fP
     42Specify an alternate configuration directory.  By default, \fBBarnOwl\fP uses
     43\fI~/.owl/\fP.
    5444
    55 .B \-s \fIconfigdir\fP
    56 .IP
    57 Specify an alternate configuration directory. By default, BarnOwl uses
    58 ~/.owl/.
    59 .LP
     45.TP
     46\fB\-t\fP, \fB\-\-tty\fP=\fITTY\fP
     47Specify the tty name to use for the zephyr location.
    6048
    61 .B \-t \fItty\fP
    62 .IP
    63 Specifiy the tty name to use for the zephyr location.
    64 .LP
     49.TP
     50\fB\-v\fP, \fB\-\-version\fP
     51Print the version number of \fBBarnOwl\fP and exit.
    6552
    66 .B \-v
    67 .IP
    68 Print the version number of barnowl and exit.
    69 .LP
     53.TP
     54\fB\-d\fP, \fB\-\-debug\fP
     55Enable debugging.  By default, debugging information is placed in
     56\fI/var/tmp/barnowl\-debug.PID\fP.
    7057
    71 .B \-d
    72 .IP
    73 Enable debugging.  By default debugging information is placed in
    74 /var/tmp/owldebug.
    75 .LP
     58.TP
     59\fB\-h\fP, \fB\-\-help\fP
     60Print command\(hyline option help.
    7661
    77 .B \-D
    78 .IP
    79 Enable debugging, but first delete any existing debugging file.
    80 .LP
    81 
    82 .B \-h
    83 .IP
    84 Print command line option help.
    85 .LP
    86 
    87 .SH AUTHOR
     62.SH AUTHORS
    8863Written by Nelson Elhage and Alejandro Sedeno at the Massachusetts
    89 Institute of Technology. Based on Owl by James Kretchmar.
     64Institute of Technology.  Based on Owl by James Kretchmar.
    9065
    9166Comments, questions, and bug reports may be mailed to
    92 \fBbug-barnowl@mit.edu\fP.
     67\fBbug\-barnowl@mit.edu\fP.
  • filterelement.c

    rd4927a7 r7756dde  
    104104}
    105105
    106 /* XXX: Our boolea operators short-circuit here. The original owl did
     106/* XXX: Our boolean operators short-circuit here. The original owl did
    107107   not. Do we care?
    108108*/
  • functions.c

    r67b959c ra16d7e5  
    127127
    128128  text=""
    129     "barnowl version " OWL_VERSION_STRING "\n"
     129    "BarnOwl version " OWL_VERSION_STRING "\n"
    130130    "Copyright (c) 2006-2011 The BarnOwl Developers. All rights reserved.\n"
    131131    "Copyright (c) 2004 James Kretchmar. All rights reserved.\n"
     
    144144    "\n"
    145145    "   * Redistributions in any form must be accompanied by information on\n"
    146     "     how to obtain complete source code for the Owl software and any\n"
    147     "     accompanying software that uses the Owl software. The source code\n"
     146    "     how to obtain complete source code for the BarnOwl software and any\n"
     147    "     accompanying software that uses the BarnOwl software. The source code\n"
    148148    "     must either be included in the distribution or be available for no\n"
    149149    "     more than the cost of distribution plus a nominal fee, and must be\n"
     
    10241024  }
    10251025
    1026   owl_function_debugmsg("Quitting Owl");
     1026  owl_function_debugmsg("Quitting BarnOwl");
    10271027  owl_select_quit_loop();
    10281028}
     
    13571357{
    13581358  owl_function_popless_text(
    1359     "This is barnowl version " OWL_VERSION_STRING ".\n\n"
    1360     "barnowl is a fork of the Owl zephyr client, written and\n"
     1359    "This is BarnOwl version " OWL_VERSION_STRING ".\n\n"
     1360    "BarnOwl is a fork of the Owl zephyr client, written and\n"
    13611361    "maintained by Alejandro Sedeno and Nelson Elhage at the\n"
    13621362    "Massachusetts Institute of Technology. \n"
     
    13671367    "The name 'owl' was chosen in reference to the owls in the\n"
    13681368    "Harry Potter novels, who are tasked with carrying messages\n"
    1369     "between Witches and Wizards. The name 'barnowl' was chosen\n"
     1369    "between Witches and Wizards. The name 'BarnOwl' was chosen\n"
    13701370    "because we feel our owls should live closer to our ponies.\n"
    13711371    "\n"
     
    14911491  }
    14921492
    1493   owl_fmtext_append_bold(&fm, "\nOwl Message Attributes:\n");
     1493  owl_fmtext_append_bold(&fm, "\nBarnOwl Message Attributes:\n");
    14941494  owl_message_attributes_tofmtext(m, &attrfm);
    14951495  owl_fmtext_append_fmtext(&fm, &attrfm);
     
    16241624void owl_function_printallvars(void)
    16251625{
     1626  const owl_variable *v;
    16261627  const char *name;
    16271628  char *var;
     
    16371638    if (name && name[0]!='_') {
    16381639      g_string_append_printf(str, "\n%-20s = ", name);
    1639       var = owl_variable_get_tostring(owl_global_get_vardict(&g), name);
     1640      v = owl_variable_get_var(owl_global_get_vardict(&g), name);
     1641      var = owl_variable_get_tostring(v);
    16401642      if (var) {
    1641         g_string_append(str, var);
    1642         g_free(var);
     1643        g_string_append(str, var);
     1644        g_free(var);
     1645      } else {
     1646        g_string_append(str, "<null>");
    16431647      }
    16441648    }
     
    16531657void owl_function_show_variables(void)
    16541658{
     1659  const owl_variable *v;
    16551660  GPtrArray *varnames;
    16561661  owl_fmtext fm; 
     
    16651670    varname = varnames->pdata[i];
    16661671    if (varname && varname[0]!='_') {
    1667       owl_variable_describe(owl_global_get_vardict(&g), varname, &fm);
     1672      v = owl_variable_get_var(owl_global_get_vardict(&g), varname);
     1673      owl_variable_describe(v, &fm);
    16681674    }
    16691675  }
     
    16751681void owl_function_show_variable(const char *name)
    16761682{
     1683  const owl_variable *v;
    16771684  owl_fmtext fm; 
    16781685
    16791686  owl_fmtext_init_null(&fm);
    1680   owl_variable_get_help(owl_global_get_vardict(&g), name, &fm);
     1687  v = owl_variable_get_var(owl_global_get_vardict(&g), name);
     1688  if (v)
     1689    owl_variable_get_help(v, &fm);
     1690  else
     1691    owl_fmtext_append_normal(&fm, "No such variable...\n");
    16811692  owl_function_popless_fmtext(&fm);
    16821693  owl_fmtext_cleanup(&fm);
  • help.c

    rce68f23 ra16d7e5  
    44void owl_help(void)
    55{
     6  const owl_variable *v;
    67  owl_fmtext fm;
    78  const char *varname;
     
    6970     "    w             Open a URL in the current message\n"
    7071     "    C-l           Refresh the screen\n"
    71      "    C-z           Suspend Owl\n"
     72     "    C-z           Suspend BarnOwl\n"
    7273     "    h             Print this help message\n"
    7374     "    : , M-x       Enter command mode\n"
     
    8384  owl_fmtext_append_normal
    8485    (&fm,
    85      "    quit, exit    Exit owl\n"
     86     "    quit, exit    Exit BarnOwl\n"
    8687     "    help          Get help about commands\n"
    87      "    show          Show information about owl (see detailed help)\n"
     88     "    show          Show information about BarnOwl (see detailed help)\n"
    8889     "\n"
    8990     "    zwrite        Send a zephyr\n"
     
    101102     "    set           Set a variable (see list below)\n"
    102103     "    print         Print a variable's value (variables listed below)\n"
    103      "    startup       Set a command to be run at every Owl startup\n"
    104      "    unstartup     Remove a command to be run at every Owl startup\n"
     104     "    startup       Set a command to be run at every BarnOwl startup\n"
     105     "    unstartup     Remove a command to be run at every BarnOwl startup\n"
    105106     "\n"
    106107     "    getsubs       Print a list of current subscriptions\n"
     
    121122     "    dump          Dump messagelist as text to a file\n"
    122123     "\n"
    123      "    about         Print information about owl\n"
    124      "    status        Print status information about the running owl\n"
    125      "    version       Print the version number of owl\n"
     124     "    about         Print information about BarnOwl\n"
     125     "    status        Print status information about the running BarnOwl\n"
     126     "    version       Print the version number of BarnOwl\n"
    126127     "\n");
    127128 
     
    133134    varname = varnames->pdata[i];
    134135    if (varname && varname[0]!='_') {
    135       owl_variable_describe(owl_global_get_vardict(&g), varname, &fm);
     136      v = owl_variable_get_var(owl_global_get_vardict(&g), varname);
     137      owl_variable_describe(v, &fm);
    136138    }
    137139  }
  • m4/ax_check_flag.m4

    rf2a96c0 r82e93c9  
    7272#   exception to the GPL to apply to your modified version as well.
    7373
    74 #serial 2
     74#serial 3
    7575
    7676AC_DEFUN([AX_CHECK_PREPROC_FLAG],
     
    8181  CPPFLAGS="$CPPFLAGS $4 $1"
    8282  AC_PREPROC_IFELSE([AC_LANG_PROGRAM()],
    83     [AS_VAR_SET([CACHEVAR],[yes])],
    84     [AS_VAR_SET([CACHEVAR],[no])])
     83    [AS_VAR_SET(CACHEVAR,[yes])],
     84    [AS_VAR_SET(CACHEVAR,[no])])
    8585  CPPFLAGS=$ax_check_save_flags])
    86 AS_VAR_IF([CACHEVAR], "yes",
     86AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes],
    8787  [m4_default([$2], :)],
    8888  [m4_default([$3], :)])
     
    9797  _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
    9898  AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
    99     [AS_VAR_SET([CACHEVAR],[yes])],
    100     [AS_VAR_SET([CACHEVAR],[no])])
     99    [AS_VAR_SET(CACHEVAR,[yes])],
     100    [AS_VAR_SET(CACHEVAR,[no])])
    101101  _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
    102 AS_VAR_IF([CACHEVAR], "yes",
     102AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes],
    103103  [m4_default([$2], :)],
    104104  [m4_default([$3], :)])
     
    112112  LDFLAGS="$LDFLAGS $4 $1"
    113113  AC_LINK_IFELSE([AC_LANG_PROGRAM()],
    114     [AS_VAR_SET([CACHEVAR],[yes])],
    115     [AS_VAR_SET([CACHEVAR],[no])])
     114    [AS_VAR_SET(CACHEVAR,[yes])],
     115    [AS_VAR_SET(CACHEVAR,[no])])
    116116  LDFLAGS=$ax_check_save_flags])
    117 AS_VAR_IF([CACHEVAR], "yes",
     117AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes],
    118118  [m4_default([$2], :)],
    119119  [m4_default([$3], :)])
     
    124124AC_DEFUN([AX_APPEND_FLAG],
    125125[AC_PREREQ(2.59) dnl for _AC_LANG_PREFIX
    126 AC_REQUIRE([AC_PROG_GREP])
    127 AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[]FLAGS)])dnl
    128 AS_VAR_SET_IF([FLAGS],
    129   [AS_IF([AS_ECHO(" $[]FLAGS ") | $GREP " $1 " 2>&1 >/dev/null],
    130     [AC_RUN_LOG([: FLAGS already contains $1])],
    131     [AC_RUN_LOG([: FLAGS="$FLAGS $1"])
    132     AS_VAR_APPEND([FLAGS], [" $1"])])],
    133   [AS_VAR_SET([FLAGS],[$1])])
     126AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])dnl
     127AS_VAR_SET_IF(FLAGS,
     128  [case " AS_VAR_GET(FLAGS) " in
     129    *" $1 "*)
     130      AC_RUN_LOG([: FLAGS already contains $1])
     131      ;;
     132    *)
     133      AC_RUN_LOG([: FLAGS="$FLAGS $1"])
     134      AS_VAR_SET(FLAGS, ["AS_VAR_GET(FLAGS) $1"])
     135      ;;
     136   esac],
     137  [AS_VAR_SET(FLAGS,["$1"])])
    134138AS_VAR_POPDEF([FLAGS])dnl
    135139])dnl AX_APPEND_FLAG
  • messagelist.c

    r67b959c r901cee9  
    2222void *owl_messagelist_get_element(const owl_messagelist *ml, int n)
    2323{
     24  /* we assume things like owl_view_get_element(v, owl_global_get_curmsg(&g))
     25   * work even when there are no messages in the message list.  So don't
     26   * segfault if someone asks for the zeroth element of an empty list.
     27   */
     28  if (n >= ml->list->len) return NULL;
    2429  return ml->list->pdata[n];
    2530}
  • owl.c

    r2244836 rb8a3e00  
    8989      break;
    9090    case 'v':
    91       printf("This is barnowl version %s\n", OWL_VERSION_STRING);
     91      printf("This is BarnOwl version %s\n", OWL_VERSION_STRING);
    9292      exit(0);
    9393    case 'h':
     
    584584  owl_function_adminmsg("",
    585585    "-----------------------------------------------------------------------\n"
    586     "Welcome to barnowl version " OWL_VERSION_STRING ".\n"
     586    "Welcome to BarnOwl version " OWL_VERSION_STRING ".\n"
    587587    "To see a quick introduction, type ':show quickstart'.                  \n"
    588588    "Press 'h' for on-line help.                                            \n"
  • owl_perl.h

    r06adc25 rb8a3e00  
    1313 * * args   - a code block responsible for pushing args (other than the object)
    1414 * * err    - a string with a %s format specifier to log in case of error
    15  * * fatalp - if true, perl errors terminate barnowl
     15 * * fatalp - if true, perl errors terminate BarnOwl
    1616 * * ret    - a code block executed if the call succeeded
    1717 *
  • perl/lib/BarnOwl.pm

    rcaac19d r785ee77  
    5252The BarnOwl module contains the core of BarnOwl's perl
    5353bindings. Source in this module is also run at startup to bootstrap
    54 barnowl by defining things like the default style.
     54BarnOwl by defining things like the default style.
    5555
    5656=for NOTE
     
    8080=head2 zephyr_getrealm
    8181
    82 Returns the zephyr realm barnowl is running in
     82Returns the zephyr realm BarnOwl is running in
    8383
    8484=head2 zephyr_getsender
    8585
    86 Returns the fully-qualified name of the zephyr sender barnowl is
     86Returns the fully-qualified name of the zephyr sender BarnOwl is
    8787running as, e.g. C<nelhage@ATHENA.MIT.EDU>
    8888
     
    240240=head2 create_style NAME OBJECT
    241241
    242 Creates a new barnowl style with the given NAME defined by the given
     242Creates a new BarnOwl style with the given NAME defined by the given
    243243object. The object must have a C<description> method which returns a
    244244string description of the style, and a and C<format_message> method
     
    571571{
    572572  my $zsig = getvar('zsig');
    573   if (!$zsig) {
    574       if (my $zsigproc = getvar('zsigproc')) {
     573  if (!defined($zsig) || $zsig eq '') {
     574      my $zsigproc = getvar('zsigproc');
     575      if (defined($zsigproc) && $zsigproc ne '') {
    575576          $zsig = `$zsigproc`;
    576577      } elsif (!defined($zsig = get_zephyr_variable('zwrite-signature'))) {
  • perl/lib/BarnOwl/Hooks.pm

    r3aa0522 rb8a3e00  
    146146}
    147147
    148 # These are the internal hooks called by the barnowl C code, which
     148# These are the internal hooks called by the BarnOwl C code, which
    149149# take care of dispatching to the appropriate perl hooks, and deal
    150150# with compatibility by calling the old, fixed-name hooks.
  • perl/lib/Module/Install/BarnOwl.pm

    r3519d06 rb8a3e00  
    88=head1 DESCRIPTION
    99
    10 Module::Install::BarnOwl is a M::I module to help building barnowl
     10Module::Install::BarnOwl is a M::I module to help building BarnOwl
    1111modules,
    1212
     
    2828
    2929As well as make rules to generate Jabber.par, and to put some
    30 additional barnowl-specific information into META.yml
     30additional BarnOwl-specific information into META.yml
    3131
    3232=cut
  • perl/modules/IRC/lib/BarnOwl/Module/IRC.pm

    r5c6d661 rb8a3e00  
    1010=head1 DESCRIPTION
    1111
    12 This module implements IRC support for barnowl.
     12This module implements IRC support for BarnOwl.
    1313
    1414=cut
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm

    rc8d9f84 rb8a3e00  
    1010=head1 DESCRIPTION
    1111
    12 This module implements Jabber support for barnowl.
     12This module implements Jabber support for BarnOwl.
    1313
    1414=cut
     
    3636        if($IO::Socket::SSL::VERSION eq "0.97") {
    3737            BarnOwl::error("You are using IO::Socket:SSL 0.97, which \n" .
    38                            "contains bugs causing it not to work with barnowl's\n" .
     38                           "contains bugs causing it not to work with BarnOwl's\n" .
    3939                           "Jabber support. We recommend updating to the latest\n" .
    4040                           "IO::Socket::SSL from CPAN. \n");
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber/ConnectionManager.pm

    r2cca044 rb8a3e00  
    88=head1 DESCRIPTION
    99
    10 A class to keep track of all the active connection in the barnowl
    11 jabber module
     10A class to keep track of all the active connection in the BarnOwl
     11Jabber module
    1212
    1313=cut
  • perl/modules/Twitter/README

    r8c6e2c1 rb8a3e00  
    118118    the sender. Has no effect if poll_for_tweets is false.
    119119
    120 * oauth_key, oauth_secret (strings, default barnowl's consumer credentials)
     120* oauth_key, oauth_secret (strings, default BarnOwl's consumer credentials)
    121121    These are the OAuth consumer key and secret to use to negotiate an
    122122    OAuth connection to Twitter. These credentials must be enabled for
  • perl/modules/Twitter/lib/BarnOwl/Module/Twitter.pm

    rf6e1262 rb8a3e00  
    193193
    194194sub poll_messages {
    195     # If we are reloaded into a barnowl with the old
     195    # If we are reloaded into a BarnOwl with the old
    196196    # BarnOwl::Module::Twitter loaded, it still has a main loop hook
    197197    # that will call this function every second. If we just delete it,
  • runtests.sh

    r5aa33fd r786a410  
    55export BARNOWL_BIN_DIR="$SRCDIR/"
    66
    7 HARNESS_PERL=./tester exec prove t/
     7HARNESS_PERL=./tester exec prove --failures t/
  • scripts/do-release

    r74312ad rb8a3e00  
    99    cat >&2 <<EOF
    1010Usage: $0 [options]
    11 Generate a barnowl release tarball.
     11Generate a BarnOwl release tarball.
    1212
    1313OPTIONS:
     
    3737else
    3838    VERS=$(perl -ne 'print $1 if m{^AC_INIT\(\[[^\]]+\],\s*\[([^\]]+)\]}' configure.ac) \
    39         || die "Unable to parse barnowl version"
     39        || die "Unable to parse BarnOwl version"
    4040fi
    4141TAG=barnowl-$VERS
  • scripts/locker-build

    r4f5e38f r401752a  
    119119    $MAKE -j$CPUS all || die "make failed"
    120120
     121    $MAKE check || die "Unit tests failed"
     122
    121123    if [ -n "$DRYRUN" ]; then
    122124        echo "Build completed; Dropping to a shell..."
  • stubgen.pl

    rfd03b12 rca54fd6  
    1414    if ($vartype =~ /^BOOL/) {
    1515        print "void owl_global_set_${altvarname}_on(owl_global *g) {\n";
    16         print "  owl_variable_set_bool_on(&g->vars, \"$varname\");\n}\n";
     16        print "  owl_variable_set_bool_on(owl_variable_get_var(&g->vars, \"$varname\"));\n}\n";
    1717        print "void owl_global_set_${altvarname}_off(owl_global *g) {\n";
    18         print "  owl_variable_set_bool_off(&g->vars, \"$varname\");\n}\n";
     18        print "  owl_variable_set_bool_off(owl_variable_get_var(&g->vars, \"$varname\"));\n}\n";
    1919        print "int owl_global_is_$altvarname(const owl_global *g) {\n";
    20         print "  return owl_variable_get_bool(&g->vars, \"$varname\");\n}\n";
     20        print "  return owl_variable_get_bool(owl_variable_get_var(&g->vars, \"$varname\"));\n}\n";
    2121    } elsif ($vartype =~ /^PATH/ or $vartype =~ /^STRING/) {
    2222        print "void owl_global_set_$altvarname(owl_global *g, const char *text) {\n";
    23         print "  owl_variable_set_string(&g->vars, \"$varname\", text);\n}\n";
     23        print "  owl_variable_set_string(owl_variable_get_var(&g->vars, \"$varname\"), text);\n}\n";
    2424        print "const char *owl_global_get_$altvarname(const owl_global *g) {\n";
    25         print "  return owl_variable_get_string(&g->vars, \"$varname\");\n}\n";
     25        print "  return owl_variable_get_string(owl_variable_get_var(&g->vars, \"$varname\"));\n}\n";
    2626    } elsif ($vartype =~ /^INT/ or $vartype =~ /^ENUM/) {
    2727        print "void owl_global_set_$altvarname(owl_global *g, int n) {\n";
    28         print "  owl_variable_set_int(&g->vars, \"$varname\", n);\n}\n";
     28        print "  owl_variable_set_int(owl_variable_get_var(&g->vars, \"$varname\"), n);\n}\n";
    2929        print "int owl_global_get_$altvarname(const owl_global *g) {\n";
    30         print "  return owl_variable_get_int(&g->vars, \"$varname\");\n}\n";
     30        print "  return owl_variable_get_int(owl_variable_get_var(&g->vars, \"$varname\"));\n}\n";
    3131    }
    3232    }
  • tester.c

    r25891a8 r14c9e05  
    44#undef WINDOW
    55
     6#include <errno.h>
    67#include <unistd.h>
     8#include <pwd.h>
     9#include <stdio.h>
    710#include <stdlib.h>
     11#include <string.h>
     12#include <sys/types.h>
    813
    914#undef instr
     
    124129#define FAIL_UNLESS(desc,pred) do { int __pred = (pred);                \
    125130    numtests++;                                                         \
    126     printf("%s %s", (__pred)?"ok":(numfailed++,"not ok"), desc);        \
     131    printf("%s %d %s", (__pred) ? "ok" : (numfailed++, "not ok"), numtests, desc); \
    127132    if(!(__pred)) printf("\t(%s:%d)", __FILE__, __LINE__); printf("%c", '\n'); } while(0)
    128133
     
    131136{
    132137  int numfailed=0;
     138  const char *home;
     139  char *s, *path;
     140  struct passwd *pw;
    133141
    134142  printf("# BEGIN testing owl_util\n");
     
    225233  g_string_free(g, true);
    226234
     235
     236  s = owl_util_baseclass("barnowl");
     237  FAIL_UNLESS("baseclass barnowl", !strcmp("barnowl", s));
     238  g_free(s);
     239  s = owl_util_baseclass("unbarnowl");
     240  FAIL_UNLESS("baseclass unbarnowl", !strcmp("barnowl", s));
     241  g_free(s);
     242  s = owl_util_baseclass("unununbarnowl.d.d");
     243  FAIL_UNLESS("baseclass unununbarnowl.d.d", !strcmp("barnowl", s));
     244  g_free(s);
     245  s = owl_util_baseclass("ununun.d.d");
     246  FAIL_UNLESS("baseclass ununun.d.d", !strcmp("", s));
     247  g_free(s);
     248  s = owl_util_baseclass("d.d.d.d");
     249  FAIL_UNLESS("baseclass d.d.d.d", !strcmp("d", s));
     250  g_free(s);
     251  s = owl_util_baseclass("n.d.d.d");
     252  FAIL_UNLESS("baseclass n.d.d.d", !strcmp("n", s));
     253  g_free(s);
     254  s = owl_util_baseclass("ununun.");
     255  FAIL_UNLESS("baseclass ununun.", !strcmp(".", s));
     256  g_free(s);
     257  s = owl_util_baseclass("unununu");
     258  FAIL_UNLESS("baseclass unununu", !strcmp("u", s));
     259  g_free(s);
     260
     261
     262  s = owl_util_makepath("foo/bar");
     263  FAIL_UNLESS("makepath foo/bar", !strcmp("foo/bar", s));
     264  g_free(s);
     265  s = owl_util_makepath("//foo///bar");
     266  FAIL_UNLESS("makepath //foo///bar", !strcmp("/foo/bar", s));
     267  g_free(s);
     268  s = owl_util_makepath("foo/~//bar/");
     269  FAIL_UNLESS("makepath foo/~//bar/", !strcmp("foo/~/bar/", s));
     270  g_free(s);
     271  s = owl_util_makepath("~thisuserhadreallybetternotexist/foobar/");
     272  FAIL_UNLESS("makepath ~thisuserhadreallybetternotexist/foobar/",
     273              !strcmp("~thisuserhadreallybetternotexist/foobar/", s));
     274  g_free(s);
     275
     276  errno = 0;
     277  pw = getpwuid(getuid());
     278  if (pw) {
     279    home = pw->pw_dir;
     280  } else {
     281    /* Just make some noise so we notice. */
     282    home = "<WHAT>";
     283    fprintf(stderr, "getpwuid: %s", errno ? strerror(errno) : "No such user");
     284  }
     285  s = owl_util_makepath("~");
     286  FAIL_UNLESS("makepath ~", !strcmp(home, s));
     287  g_free(s);
     288
     289  path = g_strconcat(home, "/foo/bar/baz", NULL);
     290  s = owl_util_makepath("~///foo/bar//baz");
     291  FAIL_UNLESS("makepath ~///foo/bar//baz", !strcmp(path, s));
     292  g_free(s);
     293  g_free(path);
     294
     295  errno = 0;
     296  pw = getpwnam("root");
     297  if (pw) {
     298    home = pw->pw_dir;
     299  } else {
     300    /* Just make some noise so we notice. */
     301    home = "<WHAT>";
     302    fprintf(stderr, "getpwnam: %s", errno ? strerror(errno) : "No such user");
     303  }
     304
     305  s = owl_util_makepath("~root");
     306  FAIL_UNLESS("makepath ~root", !strcmp(home, s));
     307  g_free(s);
     308
     309  path = g_strconcat(home, "/foo/bar/baz", NULL);
     310  s = owl_util_makepath("~root///foo/bar//baz");
     311  FAIL_UNLESS("makepath ~root///foo/bar//baz", !strcmp(path, s));
     312  g_free(s);
     313  g_free(path);
     314
    227315  /* if (numfailed) printf("*** WARNING: failures encountered with owl_util\n"); */
    228316  printf("# END testing owl_util (%d failures)\n", numfailed);
     
    276364int owl_variable_regtest(void) {
    277365  owl_vardict vd;
     366  owl_variable *var;
    278367  int numfailed=0;
    279368  char *value;
     
    283372  FAIL_UNLESS("setup", 0==owl_variable_dict_setup(&vd));
    284373
    285   FAIL_UNLESS("get bool", 0==owl_variable_get_bool(&vd,"rxping"));
    286   FAIL_UNLESS("get bool (no such)", -1==owl_variable_get_bool(&vd,"mumble"));
     374  FAIL_UNLESS("get bool var", NULL != (var = owl_variable_get_var(&vd, "rxping")));
     375  FAIL_UNLESS("get bool", 0 == owl_variable_get_bool(var));
     376  FAIL_UNLESS("get bool (no such)", NULL == owl_variable_get_var(&vd, "mumble"));
    287377  FAIL_UNLESS("get bool as string",
    288               !strcmp((value = owl_variable_get_tostring(&vd,"rxping")), "off"));
     378              !strcmp((value = owl_variable_get_tostring(var)), "off"));
    289379  g_free(value);
    290   FAIL_UNLESS("set bool 1", 0==owl_variable_set_bool_on(&vd,"rxping"));
    291   FAIL_UNLESS("get bool 2", 1==owl_variable_get_bool(&vd,"rxping"));
    292   FAIL_UNLESS("set bool 3", 0==owl_variable_set_fromstring(&vd,"rxping","off",0,0));
    293   FAIL_UNLESS("get bool 4", 0==owl_variable_get_bool(&vd,"rxping"));
    294   FAIL_UNLESS("set bool 5", -1==owl_variable_set_fromstring(&vd,"rxping","xxx",0,0));
    295   FAIL_UNLESS("get bool 6", 0==owl_variable_get_bool(&vd,"rxping"));
    296 
    297 
    298   FAIL_UNLESS("get string", 0==strcmp("~/zlog/people", owl_variable_get_string(&vd,"logpath")));
    299   FAIL_UNLESS("set string 7", 0==owl_variable_set_string(&vd,"logpath","whee"));
    300   FAIL_UNLESS("get string", 0==strcmp("whee", owl_variable_get_string(&vd,"logpath")));
    301 
    302   FAIL_UNLESS("get int", 8==owl_variable_get_int(&vd,"typewinsize"));
    303   FAIL_UNLESS("get int (no such)", -1==owl_variable_get_int(&vd,"mmble"));
     380  FAIL_UNLESS("set bool 1", 0 == owl_variable_set_bool_on(var));
     381  FAIL_UNLESS("get bool 2", 1 == owl_variable_get_bool(var));
     382  FAIL_UNLESS("set bool 3", 0 == owl_variable_set_fromstring(var, "off", 0));
     383  FAIL_UNLESS("get bool 4", 0 == owl_variable_get_bool(var));
     384  FAIL_UNLESS("set bool 5", -1 == owl_variable_set_fromstring(var, "xxx", 0));
     385  FAIL_UNLESS("get bool 6", 0 == owl_variable_get_bool(var));
     386
     387
     388  FAIL_UNLESS("get string var", NULL != (var = owl_variable_get_var(&vd, "logpath")));
     389  FAIL_UNLESS("get string", 0 == strcmp("~/zlog/people", owl_variable_get_string(var)));
     390  FAIL_UNLESS("set string 7", 0 == owl_variable_set_string(var, "whee"));
     391  FAIL_UNLESS("get string", !strcmp("whee", owl_variable_get_string(var)));
     392
     393  FAIL_UNLESS("get int var", NULL != (var = owl_variable_get_var(&vd, "typewinsize")));
     394  FAIL_UNLESS("get int", 8 == owl_variable_get_int(var));
     395  FAIL_UNLESS("get int (no such)", NULL == owl_variable_get_var(&vd, "mumble"));
    304396  FAIL_UNLESS("get int as string",
    305               !strcmp((value = owl_variable_get_tostring(&vd,"typewinsize")), "8"));
     397              !strcmp((value = owl_variable_get_tostring(var)), "8"));
    306398  g_free(value);
    307   FAIL_UNLESS("set int 1", 0==owl_variable_set_int(&vd,"typewinsize",12));
    308   FAIL_UNLESS("get int 2", 12==owl_variable_get_int(&vd,"typewinsize"));
    309   FAIL_UNLESS("set int 1b", -1==owl_variable_set_int(&vd,"typewinsize",-3));
    310   FAIL_UNLESS("get int 2b", 12==owl_variable_get_int(&vd,"typewinsize"));
    311   FAIL_UNLESS("set int 3", 0==owl_variable_set_fromstring(&vd,"typewinsize","9",0,0));
    312   FAIL_UNLESS("get int 4", 9==owl_variable_get_int(&vd,"typewinsize"));
    313   FAIL_UNLESS("set int 5", -1==owl_variable_set_fromstring(&vd,"typewinsize","xxx",0,0));
    314   FAIL_UNLESS("set int 6", -1==owl_variable_set_fromstring(&vd,"typewinsize","",0,0));
    315   FAIL_UNLESS("get int 7", 9==owl_variable_get_int(&vd,"typewinsize"));
     399  FAIL_UNLESS("set int 1", 0 == owl_variable_set_int(var, 12));
     400  FAIL_UNLESS("get int 2", 12 == owl_variable_get_int(var));
     401  FAIL_UNLESS("set int 1b", -1 == owl_variable_set_int(var, -3));
     402  FAIL_UNLESS("get int 2b", 12 == owl_variable_get_int(var));
     403  FAIL_UNLESS("set int 3", 0 == owl_variable_set_fromstring(var, "9", 0));
     404  FAIL_UNLESS("get int 4", 9 == owl_variable_get_int(var));
     405  FAIL_UNLESS("set int 5", -1 == owl_variable_set_fromstring(var, "xxx", 0));
     406  FAIL_UNLESS("set int 6", -1 == owl_variable_set_fromstring(var, "", 0));
     407  FAIL_UNLESS("get int 7", 9 == owl_variable_get_int(var));
    316408
    317409  owl_variable_dict_newvar_string(&vd, "stringvar", "", "", "testval");
    318   FAIL_UNLESS("get new string var", NULL != (v = owl_variable_get(&vd, "stringvar", OWL_VARIABLE_STRING)));
    319   FAIL_UNLESS("get new string val", !strcmp("testval", owl_variable_get_string(&vd, "stringvar")));
    320   owl_variable_set_string(&vd, "stringvar", "new val");
    321   FAIL_UNLESS("update string val", !strcmp("new val", owl_variable_get_string(&vd, "stringvar")));
     410  FAIL_UNLESS("get new string var", NULL != (var = owl_variable_get_var(&vd, "stringvar")));
     411  FAIL_UNLESS("get new string var", NULL != (v = owl_variable_get(var)));
     412  FAIL_UNLESS("get new string val", !strcmp("testval", owl_variable_get_string(var)));
     413  owl_variable_set_string(var, "new val");
     414  FAIL_UNLESS("update string val", !strcmp("new val", owl_variable_get_string(var)));
    322415
    323416  owl_variable_dict_newvar_int(&vd, "intvar", "", "", 47);
    324   FAIL_UNLESS("get new int var", NULL != (v = owl_variable_get(&vd, "intvar", OWL_VARIABLE_INT)));
    325   FAIL_UNLESS("get new int val", 47 == owl_variable_get_int(&vd, "intvar"));
    326   owl_variable_set_int(&vd, "intvar", 17);
    327   FAIL_UNLESS("update bool val", 17 == owl_variable_get_int(&vd, "intvar"));
     417  FAIL_UNLESS("get new int var", NULL != (var = owl_variable_get_var(&vd, "intvar")));
     418  FAIL_UNLESS("get new int var", NULL != (v = owl_variable_get(var)));
     419  FAIL_UNLESS("get new int val", 47 == owl_variable_get_int(var));
     420  owl_variable_set_int(var, 17);
     421  FAIL_UNLESS("update int val", 17 == owl_variable_get_int(var));
    328422
    329423  owl_variable_dict_newvar_bool(&vd, "boolvar", "", "", 1);
    330   FAIL_UNLESS("get new bool var", NULL != (v = owl_variable_get(&vd, "boolvar", OWL_VARIABLE_BOOL)));
    331   FAIL_UNLESS("get new bool val", owl_variable_get_bool(&vd, "boolvar"));
    332   owl_variable_set_bool_off(&vd, "boolvar");
    333   FAIL_UNLESS("update string val", !owl_variable_get_bool(&vd, "boolvar"));
     424  FAIL_UNLESS("get new bool var", NULL != (var = owl_variable_get_var(&vd, "boolvar")));
     425  FAIL_UNLESS("get new bool var", NULL != (v = owl_variable_get(var)));
     426  FAIL_UNLESS("get new bool val", owl_variable_get_bool(var));
     427  owl_variable_set_bool_off(var);
     428  FAIL_UNLESS("update bool val", !owl_variable_get_bool(var));
     429
     430  owl_variable_dict_newvar_string(&vd, "nullstringvar", "", "", NULL);
     431  FAIL_UNLESS("get new string (NULL) var", NULL != (var = owl_variable_get_var(&vd, "nullstringvar")));
     432  FAIL_UNLESS("get string (NULL)", NULL == (value = owl_variable_get_tostring(var)));
     433  g_free(value);
     434  var = owl_variable_get_var(&vd, "zsigproc");
     435  FAIL_UNLESS("get string (NULL) 2", NULL == (value = owl_variable_get_tostring(var)));
     436  g_free(value);
    334437
    335438  owl_variable_dict_cleanup(&vd);
  • util.c

    r3cdd6d2 rc0c48d14  
    3737CALLER_OWN char *owl_util_makepath(const char *in)
    3838{
    39   int i, j, x;
    40   char *out, user[MAXPATHLEN];
    41   struct passwd *pw;
    42 
    43   out=g_new(char, MAXPATHLEN+1);
    44   out[0]='\0';
    45   j=strlen(in);
    46   x=0;
    47   for (i=0; i<j; i++) {
    48     if (in[i]=='~') {
    49       if ( (i==(j-1)) ||          /* last character */
    50            (in[i+1]=='/') ) {     /* ~/ */
    51         /* use my homedir */
    52         pw=getpwuid(getuid());
    53         if (!pw) {
    54           out[x]=in[i];
    55         } else {
    56           out[x]='\0';
    57           strcat(out, pw->pw_dir);
    58           x+=strlen(pw->pw_dir);
    59         }
    60       } else {
    61         /* another user homedir */
    62         int a, b;
    63         b=0;
    64         for (a=i+1; i<j; a++) {
    65           if (in[a]==' ' || in[a]=='/') {
    66             break;
    67           } else {
    68             user[b]=in[a];
    69             i++;
    70             b++;
    71           }
    72         }
    73         user[b]='\0';
    74         pw=getpwnam(user);
    75         if (!pw) {
    76           out[x]=in[i];
    77         } else {
    78           out[x]='\0';
    79           strcat(out, pw->pw_dir);
    80           x+=strlen(pw->pw_dir);
    81         }
    82       }
    83     } else if (in[i]=='/') {
    84       /* check for a double / */
    85       if (i<(j-1) && (in[i+1]=='/')) {
    86         /* do nothing */
    87       } else {
    88         out[x]=in[i];
    89         x++;
    90       }
     39  char *out;
     40  int i, j;
     41  if (in[0] == '~') {
     42    /* Attempt tilde-expansion of the first component. Get the
     43       tilde-prefix, which goes up to the next slash. */
     44    struct passwd *pw;
     45    const char *end = strchr(in + 1, '/');
     46    if (end == NULL)
     47      end = in + strlen(in);
     48
     49    if (end == in + 1) {
     50      /* My home directory. */
     51      pw = getpwuid(getuid());
    9152    } else {
    92       out[x]=in[i];
    93       x++;
    94     }
    95   }
    96   out[x]='\0';
    97   return(out);
     53      /* Someone else's home directory. */
     54      char *user = g_strndup(in + 1, end - (in + 1));
     55      pw = getpwnam(user);
     56      g_free(user);
     57    }
     58
     59    /* Patch together a new path. Replace the ~ and tilde-prefix with
     60       the homedir. */
     61    if (pw) {
     62      out = g_strconcat(pw->pw_dir, end, NULL);
     63    } else {
     64      out = g_strdup(in);
     65    }
     66  } else {
     67      out = g_strdup(in);
     68  }
     69
     70  /* And a quick pass to remove duplicate slashes. */
     71  for (i = j = 0; out[i] != '\0'; i++) {
     72    if (out[i] != '/' || i == 0 || out[i-1] != '/')
     73      out[j++] = out[i];
     74  }
     75  out[j] = '\0';
     76  return out;
    9877}
    9978
     
    221200/*
    222201 * Appends 'tmpl' to 'buf', replacing any instances of '%q' with arguments from
    223  * the varargs provided, quoting them to be safe for placing in a barnowl
     202 * the varargs provided, quoting them to be safe for placing in a BarnOwl
    224203 * command line.
    225204 */
  • variable.c

    rce68f23 ra16d7e5  
    7070
    7171  OWLVAR_BOOL( "startuplogin" /* %OwlVarStub */, 1,
    72                "send a login message when owl starts", "" ),
     72               "send a login message when BarnOwl starts", "" ),
    7373
    7474  OWLVAR_BOOL( "shutdownlogout" /* %OwlVarStub */, 1,
    75                "send a logout message when owl exits", "" ),
     75               "send a logout message when BarnOwl exits", "" ),
    7676
    7777  OWLVAR_BOOL( "rxping" /* %OwlVarStub */, 0,
     
    137137  OWLVAR_BOOL_FULL( "pseudologins" /* %OwlVarStub */, 0,
    138138                    "Enable zephyr pseudo logins",
    139                     "When this is enabled, Owl will periodically check the zephyr\n"
     139                    "When this is enabled, BarnOwl will periodically check the zephyr\n"
    140140                    "location of users in your .anyone file.  If a user is present\n"
    141141                    "but sent no login message, or a user is not present that sent no\n"
     
    145145  OWLVAR_BOOL( "ignorelogins" /* %OwlVarStub */, 0,
    146146               "Enable printing of login notifications",
    147                "When this is enabled, Owl will print login and logout notifications\n"
    148                "for AIM, zephyr, or other protocols.  If disabled Owl will not print\n"
     147               "When this is enabled, BarnOwl will print login and logout notifications\n"
     148               "for AIM, zephyr, or other protocols.  If disabled BarnOwl will not print\n"
    149149               "login or logout notifications.\n"),
    150150
     
    160160  OWLVAR_BOOL( "loglogins" /* %OwlVarStub */, 0,
    161161               "Enable logging of login notifications",
    162                "When this is enabled, Owl will login login and logout notifications\n"
     162               "When this is enabled, BarnOwl will log login and logout notifications\n"
    163163               "for AIM, zephyr, or other protocols.  If disabled Owl will not print\n"
    164164               "login or logout notifications.\n"),
     
    201201  OWLVAR_PATH( "newmsgproc" /* %OwlVarStub:newmsgproc */, NULL,
    202202               "name of a program to run when new messages are present",
    203                "The named program will be run when owl receives new\n"
     203               "The named program will be run when BarnOwl receives new\n"
    204204               "messages.  It will not be run again until the first\n"
    205205               "instance exits"),
     
    229229                 "string to append to the end of the sepbar",
    230230                 "The sepbar is the bar separating the top and bottom\n"
    231                  "of the owl screen.  Any string specified here will\n"
     231                 "of the BarnOwl screen.  Any string specified here will\n"
    232232                 "be displayed on the right of the sepbar\n"),
    233233
     
    265265
    266266  OWLVAR_STRING( "alert_action" /* %OwlVarStub */, "nop",
    267                  "owl command to execute for alert actions",
     267                 "BarnOwl command to execute for alert actions",
    268268                 "" ),
    269269
     
    276276                 "Styles may be created with the 'style' command.\n"
    277277                 "Some built-in styles include:\n"
    278                  "   default  - the default owl formatting\n"
     278                 "   default  - the default BarnOwl formatting\n"
    279279                 "   oneline  - one line per-message\n"
    280280                 "   perl     - legacy perl interface\n"
     
    333333               "cursor moves between messages being displayed.\n"
    334334               "The following modes are supported:\n\n"
    335                "   normal      - This is the owl default.  Scrolling happens\n"
     335               "   normal      - This is the BarnOwl default.  Scrolling happens\n"
    336336               "                 when it needs to, and an attempt is made to\n"
    337337               "                 keep the current message roughly near\n"
     
    662662}
    663663
    664 void owl_variable_dict_newvar_string(owl_vardict * vd, const char *name, const char *summ, const char * desc, const char * initval) {
    665   owl_variable *old = owl_variable_get_var(vd, name, OWL_VARIABLE_STRING);
    666   if(old) {
     664void owl_variable_dict_newvar_string(owl_vardict *vd, const char *name, const char *summ, const char *desc, const char *initval)
     665{
     666  owl_variable *old = owl_variable_get_var(vd, name);
     667  if (old && owl_variable_get_type(old) == OWL_VARIABLE_STRING) {
    667668    owl_variable_update(old, summ, desc);
    668669    g_free(old->pval_default);
     
    671672    owl_variable * var = owl_variable_newvar(name, summ, desc);
    672673    var->type = OWL_VARIABLE_STRING;
     674    var->validsettings = "<string>";
    673675    var->pval_default = g_strdup(initval);
    674676    var->set_fn = owl_variable_string_set_default;
     
    682684}
    683685
    684 void owl_variable_dict_newvar_int(owl_vardict * vd, const char *name, const char *summ, const char * desc, int initval) {
    685   owl_variable *old = owl_variable_get_var(vd, name, OWL_VARIABLE_INT);
    686   if(old) {
     686void owl_variable_dict_newvar_int(owl_vardict *vd, const char *name, const char *summ, const char *desc, int initval)
     687{
     688  owl_variable *old = owl_variable_get_var(vd, name);
     689  if (old && owl_variable_get_type(old) == OWL_VARIABLE_INT) {
    687690    owl_variable_update(old, summ, desc);
    688691    old->ival_default = initval;
     
    690693    owl_variable * var = owl_variable_newvar(name, summ, desc);
    691694    var->type = OWL_VARIABLE_INT;
     695    var->validsettings = "<int>";
    692696    var->ival_default = initval;
    693697    var->validate_fn = owl_variable_int_validate_default;
     
    703707}
    704708
    705 void owl_variable_dict_newvar_bool(owl_vardict * vd, const char *name, const char *summ, const char * desc, int initval) {
    706   owl_variable *old = owl_variable_get_var(vd, name, OWL_VARIABLE_BOOL);
    707   if(old) {
     709void owl_variable_dict_newvar_bool(owl_vardict *vd, const char *name, const char *summ, const char *desc, bool initval)
     710{
     711  owl_variable *old = owl_variable_get_var(vd, name);
     712  if (old && owl_variable_get_type(old) == OWL_VARIABLE_BOOL) {
    708713    owl_variable_update(old, summ, desc);
    709714    old->ival_default = initval;
     
    711716    owl_variable * var = owl_variable_newvar(name, summ, desc);
    712717    var->type = OWL_VARIABLE_BOOL;
     718    var->validsettings = "on,off";
    713719    var->ival_default = initval;
    714720    var->validate_fn = owl_variable_bool_validate_default;
     
    750756
    751757
     758const char *owl_variable_get_name(const owl_variable *v)
     759{
     760  return v->name;
     761}
     762
    752763const char *owl_variable_get_description(const owl_variable *v) {
    753764  return v->description;
     
    759770
    760771const char *owl_variable_get_validsettings(const owl_variable *v) {
    761   if (v->validsettings) {
    762     return v->validsettings;
    763   } else {
    764     return "";
    765   }
     772  return v->validsettings;
     773}
     774
     775int owl_variable_get_type(const owl_variable *v)
     776{
     777  return v->type;
    766778}
    767779
     
    769781
    770782/* returns 0 on success, prints a status msg if msg is true */
    771 int owl_variable_set_fromstring(owl_vardict *d, const char *name, const char *value, int msg, int requirebool) {
    772   owl_variable *v;
     783int owl_variable_set_fromstring(owl_variable *v, const char *value, int msg) {
    773784  char *tostring;
    774   if (!name) return(-1);
    775   v = owl_dict_find_element(d, name);
    776   if (v == NULL) {
    777     if (msg) owl_function_error("Unknown variable %s", name);
     785  if (!v->set_fromstring_fn) {
     786    if (msg) owl_function_error("Variable %s is read-only", owl_variable_get_name(v));
     787    return -1;   
     788  }
     789  if (0 != v->set_fromstring_fn(v, value)) {
     790    if (msg) owl_function_error("Unable to set %s (must be %s)", owl_variable_get_name(v),
     791                                owl_variable_get_validsettings(v));
    778792    return -1;
    779793  }
    780   if (!v->set_fromstring_fn) {
    781     if (msg) owl_function_error("Variable %s is read-only", name);
    782     return -1;   
    783   }
    784   if (requirebool && v->type!=OWL_VARIABLE_BOOL) {
    785     if (msg) owl_function_error("Variable %s is not a boolean", name);
    786     return -1;   
    787   }
    788   if (0 != v->set_fromstring_fn(v, value)) {
    789     if (msg) owl_function_error("Unable to set %s (must be %s)", name,
    790                                   owl_variable_get_validsettings(v));
    791     return -1;
    792   }
    793   if (msg && v->get_tostring_fn) {
     794  if (msg) {
    794795    tostring = v->get_tostring_fn(v, v->get_fn(v));
    795     owl_function_makemsg("%s = '%s'", name, tostring);
     796    if (tostring)
     797      owl_function_makemsg("%s = '%s'", owl_variable_get_name(v), tostring);
     798    else
     799      owl_function_makemsg("%s = <null>", owl_variable_get_name(v));
    796800    g_free(tostring);
    797801  }   
     
    799803}
    800804 
    801 int owl_variable_set_string(owl_vardict *d, const char *name, const char *newval) {
    802   owl_variable *v;
    803   if (!name) return(-1);
    804   v = owl_dict_find_element(d, name);
    805   if (v == NULL || !v->set_fn) return(-1);
    806   if (v->type!=OWL_VARIABLE_STRING) return(-1);
     805int owl_variable_set_string(owl_variable *v, const char *newval)
     806{
     807  if (v->type != OWL_VARIABLE_STRING) return -1;
    807808  return v->set_fn(v, newval);
    808809}
    809810 
    810 int owl_variable_set_int(owl_vardict *d, const char *name, int newval) {
    811   owl_variable *v;
    812   if (!name) return(-1);
    813   v = owl_dict_find_element(d, name);
    814   if (v == NULL || !v->set_fn) return(-1);
    815   if (v->type!=OWL_VARIABLE_INT && v->type!=OWL_VARIABLE_BOOL) return(-1);
     811int owl_variable_set_int(owl_variable *v, int newval)
     812{
     813  if (v->type != OWL_VARIABLE_INT && v->type != OWL_VARIABLE_BOOL) return -1;
    816814  return v->set_fn(v, &newval);
    817815}
    818816 
    819 int owl_variable_set_bool_on(owl_vardict *d, const char *name) {
    820   return owl_variable_set_int(d,name,1);
    821 }
    822 
    823 int owl_variable_set_bool_off(owl_vardict *d, const char *name) {
    824   return owl_variable_set_int(d,name,0);
    825 }
    826 
    827 CALLER_OWN char *owl_variable_get_tostring(const owl_vardict *d, const char *name)
    828 {
    829   owl_variable *v;
    830   if (!name) return NULL;
    831   v = owl_dict_find_element(d, name);
    832   if (v == NULL || !v->get_tostring_fn) return NULL;
     817int owl_variable_set_bool_on(owl_variable *v)
     818{
     819  if (v->type != OWL_VARIABLE_BOOL) return -1;
     820  return owl_variable_set_int(v, true);
     821}
     822
     823int owl_variable_set_bool_off(owl_variable *v)
     824{
     825  if (v->type != OWL_VARIABLE_BOOL) return -1;
     826  return owl_variable_set_int(v, false);
     827}
     828
     829CALLER_OWN char *owl_variable_get_tostring(const owl_variable *v)
     830{
    833831  return v->get_tostring_fn(v, v->get_fn(v));
    834832}
    835833
    836 CALLER_OWN char *owl_variable_get_default_tostring(const owl_vardict *d, const char *name)
    837 {
    838   owl_variable *v;
    839   if (!name) return NULL;
    840   v = owl_dict_find_element(d, name);
    841   if (v == NULL || !v->get_tostring_fn) return NULL;
     834CALLER_OWN char *owl_variable_get_default_tostring(const owl_variable *v)
     835{
    842836  if (v->type == OWL_VARIABLE_INT || v->type == OWL_VARIABLE_BOOL) {
    843837    return v->get_tostring_fn(v, &(v->ival_default));
     
    847841}
    848842
    849 owl_variable *owl_variable_get_var(const owl_vardict *d, const char *name, int require_type) {
    850   owl_variable *v;
    851   if (!name) return(NULL);
    852   v = owl_dict_find_element(d, name);
    853   if (v == NULL || !v->get_fn || v->type != require_type) return(NULL);
    854   return v;
     843owl_variable *owl_variable_get_var(const owl_vardict *d, const char *name)
     844{
     845  return owl_dict_find_element(d, name);
    855846}
    856847
    857848/* returns a reference */
    858 const void *owl_variable_get(const owl_vardict *d, const char *name, int require_type) {
    859   owl_variable *v = owl_variable_get_var(d, name, require_type);
    860   if(v == NULL) return NULL;
     849const void *owl_variable_get(const owl_variable *v)
     850{
    861851  return v->get_fn(v);
    862852}
    863853
     854const char *owl_variable_get_string(const owl_variable *v)
     855{
     856  if (owl_variable_get_type(v) != OWL_VARIABLE_STRING) {
     857    owl_function_error("Variable '%s' is not a string.", owl_variable_get_name(v));
     858    return NULL;
     859  }
     860  return owl_variable_get(v);
     861}
     862
    864863/* returns a reference */
    865 const char *owl_variable_get_string(const owl_vardict *d, const char *name) {
    866   return owl_variable_get(d,name, OWL_VARIABLE_STRING);
    867 }
    868 
    869 /* returns a reference */
    870 const void *owl_variable_get_other(const owl_vardict *d, const char *name) {
    871   return owl_variable_get(d,name, OWL_VARIABLE_OTHER);
    872 }
    873 
    874 int owl_variable_get_int(const owl_vardict *d, const char *name) {
    875   const int *pi;
    876   pi = owl_variable_get(d,name,OWL_VARIABLE_INT);
    877   if (!pi) return(-1);
    878   return(*pi);
    879 }
    880 
    881 int owl_variable_get_bool(const owl_vardict *d, const char *name) {
    882   const int *pi;
    883   pi = owl_variable_get(d,name,OWL_VARIABLE_BOOL);
    884   if (!pi) return(-1);
    885   return(*pi);
    886 }
    887 
    888 void owl_variable_describe(const owl_vardict *d, const char *name, owl_fmtext *fm) {
     864const void *owl_variable_get_other(const owl_variable *v)
     865{
     866  if (owl_variable_get_type(v) != OWL_VARIABLE_OTHER) {
     867    owl_function_error("Variable '%s' is not type other.", owl_variable_get_name(v));
     868    return NULL;
     869  }
     870  return owl_variable_get(v);
     871}
     872
     873int owl_variable_get_int(const owl_variable *v)
     874{
     875  if (owl_variable_get_type(v) != OWL_VARIABLE_INT) {
     876    owl_function_error("Variable '%s' is an int.", owl_variable_get_name(v));
     877    return -1;
     878  }
     879  const int *pi = owl_variable_get(v);
     880  if (!pi) return -1;
     881  return *pi;
     882}
     883
     884int owl_variable_get_bool(const owl_variable *v)
     885{
     886  if (owl_variable_get_type(v) != OWL_VARIABLE_BOOL) {
     887    owl_function_error("Variable '%s' is a boolean.", owl_variable_get_name(v));
     888    return -1;
     889  }
     890  const int *pi = owl_variable_get(v);
     891  if (!pi) return -1;
     892  return *pi;
     893}
     894
     895void owl_variable_describe(const owl_variable *v, owl_fmtext *fm)
     896{
     897  char *tostring = owl_variable_get_default_tostring(v);
    889898  char *default_buf;
    890   owl_variable *v;
    891 
    892   if (!name
    893       || (v = owl_dict_find_element(d, name)) == NULL
    894       || !v->get_fn) {
    895     owl_fmtext_appendf_normal(fm, "     No such variable '%s'\n", name);
    896     return;
    897   }
    898   if (v->type == OWL_VARIABLE_INT || v->type == OWL_VARIABLE_BOOL) {
    899     default_buf = v->get_tostring_fn(v, &(v->ival_default));
    900   } else {
    901     default_buf = v->get_tostring_fn(v, v->pval_default);
    902   }
    903   owl_fmtext_appendf_normal(fm, OWL_TABSTR "%-20s - %s (default: '%s')\n",
    904                             v->name,
    905                             owl_variable_get_summary(v), default_buf);
     899
     900  if (tostring)
     901    default_buf = g_strdup_printf("'%s'", tostring);
     902  else
     903    default_buf = g_strdup("<null>");
     904  owl_fmtext_appendf_normal(fm, OWL_TABSTR "%-20s - %s (default: %s)\n",
     905                            owl_variable_get_name(v),
     906                            owl_variable_get_summary(v), default_buf);
    906907  g_free(default_buf);
    907 }
    908 
    909 void owl_variable_get_help(const owl_vardict *d, const char *name, owl_fmtext *fm) {
     908  g_free(tostring);
     909}
     910
     911void owl_variable_get_help(const owl_variable *v, owl_fmtext *fm) {
    910912  char *tostring;
    911   owl_variable *v;
    912 
    913   if (!name
    914       || (v = owl_dict_find_element(d, name)) == NULL
    915       || !v->get_fn) {
    916     owl_fmtext_append_normal(fm, "No such variable...\n");
    917     return;
    918   }
    919913
    920914  owl_fmtext_append_bold(fm, "OWL VARIABLE\n\n");
    921915  owl_fmtext_append_normal(fm, OWL_TABSTR);
    922   owl_fmtext_append_normal(fm, name);
     916  owl_fmtext_append_normal(fm, owl_variable_get_name(v));
    923917  owl_fmtext_append_normal(fm, " - ");
    924   owl_fmtext_append_normal(fm, v->summary);
     918  owl_fmtext_append_normal(fm, owl_variable_get_summary(v));
    925919  owl_fmtext_append_normal(fm, "\n\n");
    926920
    927921  owl_fmtext_append_normal(fm, "Current:        ");
    928   tostring = owl_variable_get_tostring(d, name);
    929   owl_fmtext_append_normal(fm, tostring);
     922  tostring = owl_variable_get_tostring(v);
     923  owl_fmtext_append_normal(fm, (tostring ? tostring : "<null>"));
    930924  g_free(tostring);
    931925  owl_fmtext_append_normal(fm, "\n\n");
    932926
    933927
    934   if (v->type == OWL_VARIABLE_INT || v->type == OWL_VARIABLE_BOOL) {
    935     tostring = v->get_tostring_fn(v, &(v->ival_default));
    936   } else {
    937     tostring = v->get_tostring_fn(v, v->pval_default);
    938   }
     928  tostring = owl_variable_get_default_tostring(v);
    939929  owl_fmtext_append_normal(fm, "Default:        ");
    940   owl_fmtext_append_normal(fm, tostring);
     930  owl_fmtext_append_normal(fm, (tostring ? tostring : "<null>"));
    941931  owl_fmtext_append_normal(fm, "\n\n");
    942932
     
    998988{
    999989  if (val == NULL) {
    1000     return g_strdup("<null>");
     990    return NULL;
    1001991  } else if (*(const int*)val == 0) {
    1002992    return g_strdup("off");
     
    10341024{
    10351025  if (val == NULL) {
    1036     return g_strdup("<null>");
     1026    return NULL;
    10371027  } else {
    10381028    return g_strdup_printf("%d", *(const int*)val);
     
    10781068
    10791069  if (val == NULL) {
    1080     return g_strdup("<null>");
     1070    return NULL;
    10811071  }
    10821072  enums = g_strsplit_set(v->validsettings, ",", 0);
     
    11141104CALLER_OWN char *owl_variable_string_get_tostring_default(const owl_variable *v, const void *val)
    11151105{
    1116   if (val == NULL) {
    1117     return g_strdup("<null>");
    1118   } else {
    1119     return g_strdup((const char*)val);
    1120   }
    1121 }
    1122 
     1106  return g_strdup((const char*)val);
     1107}
     1108
Note: See TracChangeset for help on using the changeset viewer.