Changeset fe7ece2


Ignore:
Timestamp:
Jul 9, 2011, 4:10:45 PM (13 years ago)
Author:
GitHub Merge Button <merge-button@github.com>
Parents:
786a410 (diff), caac19d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:
Merge caac19d40ffaea75410ce13da172590b04dae2b1 into 786a4108f9184d7c73170d373bc2cf80347b6456
Files:
26 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    ra16d7e5 rfe7ece2  
    693693              "current view.\n"),
    694694  OWLCMD_ALIAS("del", "delete"),
     695
     696  OWLCMD_ARGS("delete-and-expunge", owl_command_delete_and_expunge, OWL_CTX_INTERACTIVE,
     697              "delete a message",
     698              "delete-and-expunge [-id msgid] [-q | --quiet]",
     699              "If no message id is specified the current message is deleted.\n"
     700              "Otherwise the message with the given message id is deleted.\n"
     701              "If --quiet is specified, then there is no message displayed on\n"
     702              "success.\n"),
     703  OWLCMD_ALIAS("delx", "delete-and-expunge"),
    695704
    696705  OWLCMD_ARGS("undelete", owl_command_undelete, OWL_CTX_INTERACTIVE,
     
    23542363}
    23552364
     2365char *owl_command_delete_and_expunge(int argc, const char *const *argv, const char *buff)
     2366{
     2367  bool exclaim_success = true;
     2368
     2369  if (argc > 1 && (!strcmp(argv[1], "-q") || !strcmp(argv[1], "--quiet"))) {
     2370    exclaim_success = false;
     2371    argc--;
     2372    argv++;
     2373  } else if (!strcmp(argv[argc - 1], "-q") || !strcmp(argv[argc - 1], "--quiet")) {
     2374    exclaim_success = false;
     2375    argc--;
     2376  }
     2377
     2378  if (argc == 1) {
     2379    owl_function_delete_and_expunge_cur(exclaim_success);
     2380    return NULL;
     2381  }
     2382
     2383  if (argc == 3 && (!strcmp(argv[1], "-id") || !strcmp(argv[1], "--id"))) {
     2384    owl_function_delete_and_expunge_by_id(atoi(argv[2]), exclaim_success);
     2385    return NULL;
     2386  }
     2387
     2388  owl_function_makemsg("Unknown arguments to delete-and-expunge command");
     2389  return NULL;
     2390}
     2391
    23562392char *owl_command_undelete(int argc, const char *const *argv, const char *buff)
    23572393{
  • functions.c

    ra16d7e5 rfe7ece2  
    662662}
    663663
     664void owl_function_delete_and_expunge_message(int n)
     665{
     666  owl_messagelist *ml = owl_global_get_msglist(&g);
     667  owl_view *v = owl_global_get_current_view(&g);
     668  int lastmsgid = owl_function_get_curmsg_id(v);
     669
     670  /* delete and expunge the message */
     671  owl_messagelist_delete_and_expunge_element(ml, n);
     672
     673  owl_function_redisplay_to_nearest(lastmsgid, v);
     674}
     675
     676void owl_function_delete_and_expunge_cur(bool exclaim_success)
     677{
     678  int curmsg;
     679  const owl_view *v = owl_global_get_current_view(&g);
     680
     681  /* bail if there's no current message */
     682  if (owl_view_get_size(v) < 1) {
     683    owl_function_error("No current message to delete");
     684    return;
     685  }
     686
     687  /* delete the current message */
     688  curmsg = owl_global_get_curmsg(&g);
     689  owl_function_delete_and_expunge_message(curmsg);
     690  if (exclaim_success)
     691    owl_function_makemsg("Message deleted and expunged");
     692}
     693
    664694/* if move_after is 1, moves after the delete */
    665695void owl_function_deletecur(int move_after)
     
    721751}
    722752
     753/* returns the current message id, if it exists.  Otherwise returns
     754 * -1 if we are past the end of the message list, and 0 otherwise. */
     755int owl_function_get_curmsg_id(const owl_view *v)
     756{
     757  int curmsg = owl_global_get_curmsg(&g);
     758  const owl_message *m = owl_view_get_element(v, curmsg);
     759  if (m)
     760    return owl_message_get_id(m);
     761  if (curmsg > 0) /* past the end of the message list (probably) */
     762    return -1;
     763  return 0;
     764}
     765
     766/* redisplays the view to the nearest message to the id given.
     767 * if msgid < 0, redisplay to past the end of the message list */
     768void owl_function_redisplay_to_nearest(int msgid, owl_view *v)
     769{
     770  int curmsg;
     771  /* update all views (we only have one right now) */
     772  owl_view_recalculate(v);
     773
     774  /* find where the new position should be */
     775  if (msgid < 0) {
     776    /* If already at the end, blank the screen and move curmsg
     777     * past the end of the messages. */
     778    curmsg = owl_view_get_size(v);
     779    owl_global_set_topmsg(&g, curmsg);
     780    owl_global_set_curmsg(&g, curmsg);
     781  } else {
     782    curmsg = owl_view_get_nearest_to_msgid(v, msgid);
     783    if (curmsg > owl_view_get_size(v) - 1)
     784      curmsg = owl_view_get_size(v) - 1;
     785    if (curmsg < 0)
     786      curmsg = 0;
     787    owl_global_set_curmsg(&g, curmsg);
     788    owl_function_calculate_topmsg(OWL_DIRECTION_NONE);
     789  }
     790  /* if there are no messages set the direction to down in case we
     791   * delete everything upwards */
     792  owl_global_set_direction_downwards(&g);
     793
     794  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
     795}
     796
    723797void owl_function_expunge(void)
    724798{
    725   int curmsg;
    726   const owl_message *m;
    727   owl_messagelist *ml;
    728   owl_view *v;
    729   int lastmsgid=0;
    730 
    731   curmsg=owl_global_get_curmsg(&g);
    732   v=owl_global_get_current_view(&g);
    733   ml=owl_global_get_msglist(&g);
    734 
    735   m=owl_view_get_element(v, curmsg);
    736   if (m) lastmsgid = owl_message_get_id(m);
     799  owl_messagelist *ml = owl_global_get_msglist(&g);
     800  owl_view *v = owl_global_get_current_view(&g);
     801  int lastmsgid = owl_function_get_curmsg_id(v);
    737802
    738803  /* expunge the message list */
    739804  owl_messagelist_expunge(ml);
    740805
    741   /* update all views (we only have one right now) */
    742   owl_view_recalculate(v);
    743 
    744   /* find where the new position should be
    745      (as close as possible to where we last where) */
    746   curmsg = owl_view_get_nearest_to_msgid(v, lastmsgid);
    747   if (curmsg>owl_view_get_size(v)-1) curmsg = owl_view_get_size(v)-1;
    748   if (curmsg<0) curmsg = 0;
    749   owl_global_set_curmsg(&g, curmsg);
    750   owl_function_calculate_topmsg(OWL_DIRECTION_NONE);
    751   /* if there are no messages set the direction to down in case we
    752      delete everything upwards */
    753   owl_global_set_direction_downwards(&g);
     806  owl_function_redisplay_to_nearest(lastmsgid, v);
    754807 
    755808  owl_function_makemsg("Messages expunged");
    756   owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    757809}
    758810
     
    16421694}
    16431695
     1696void owl_function_delete_and_expunge_by_id(int id, bool exclaim_success)
     1697{
     1698  const owl_messagelist *ml = owl_global_get_msglist(&g);
     1699  int msg = owl_messagelist_get_index_by_id(ml, id);
     1700  if (msg < 0) {
     1701    owl_function_error("No message with id %d: unable to delete", id);
     1702  } else {
     1703    owl_function_delete_and_expunge_message(msg);
     1704    if (exclaim_success)
     1705      owl_function_makemsg("Message deleted and expunged");
     1706  }
     1707}
     1708
    16441709/* note: this applies to global message list, not to view.
    16451710 * If flag is 1, deletes.  If flag is 0, undeletes. */
  • messagelist.c

    r901cee9 rfe7ece2  
    3030}
    3131
    32 owl_message *owl_messagelist_get_by_id(const owl_messagelist *ml, int target_id)
     32int owl_messagelist_get_index_by_id(const owl_messagelist *ml, int target_id)
    3333{
    34   /* return the message with id == 'id'.  If it doesn't exist return NULL. */
     34  /* return the message index with id == 'id'.  If it doesn't exist return -1. */
    3535  int first, last, mid, msg_id;
    3636  owl_message *m;
     
    4343    msg_id = owl_message_get_id(m);
    4444    if (msg_id == target_id) {
    45       return(m);
     45      return mid;
    4646    } else if (msg_id < target_id) {
    4747      first = mid + 1;
     
    5050    }
    5151  }
    52   return(NULL);
     52  return -1;
     53}
     54
     55owl_message *owl_messagelist_get_by_id(const owl_messagelist *ml, int target_id)
     56{
     57  /* return the message with id == 'id'.  If it doesn't exist return NULL. */
     58  int n = owl_messagelist_get_index_by_id(ml, target_id);
     59  if (n < 0) return NULL;
     60  return ml->list->pdata[n];
    5361}
    5462
     
    7179  owl_message_unmark_delete(ml->list->pdata[n]);
    7280  return(0);
     81}
     82
     83void owl_messagelist_delete_and_expunge_element(owl_messagelist *ml, int n)
     84{
     85  owl_message_delete(g_ptr_array_remove_index(ml->list, n));
    7386}
    7487
  • perl/lib/BarnOwl.pm

    r785ee77 rfe7ece2  
    105105Enqueue a message in the BarnOwl message list, logging it and
    106106processing it appropriately. C<MESSAGE> should be an instance of
    107 BarnOwl::Message or a subclass.
     107BarnOwl::Message or a subclass.  Returns the queued message.  This
     108is useful for, e.g., deleting a message from the message list.
    108109
    109110=head2 admin_message HEADER BODY
  • perl/lib/BarnOwl/Message.pm

    rd1ae4a4 rcaac19d  
    8181sub short_personal_context { return ""; }
    8282
     83sub delete_and_expunge {
     84    my ($m) = @_;
     85    &BarnOwl::command("delete-and-expunge --quiet --id " . $m->id);
     86}
     87
    8388sub delete {
    8489    my ($m) = @_;
  • perlglue.xs

    rce68f23 rcaac19d  
    143143                g_free(rv);
    144144
    145 void
     145SV *
    146146queue_message(msg)
    147147        SV *msg
     
    157157
    158158                owl_global_messagequeue_addmsg(&g, m);
    159         }
     159
     160                RETVAL = owl_perlconfig_message2hashref(m);
     161        }
     162        OUTPUT:
     163                RETVAL
    160164
    161165void
  • 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*/
  • 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
  • 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/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.