Changeset e1d3607


Ignore:
Timestamp:
Jun 25, 2011, 7:22:24 AM (13 years ago)
Author:
GitHub Merge Button <merge-button@github.com>
Parents:
25891a8 (diff), d9fbfd8 (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 d9fbfd831d2af947f279310e5d92ba2dc15591af into 25891a81c52b4a7460682ef7a3773e6774e73e27
Files:
1 added
2 deleted
53 edited

Legend:

Unmodified
Added
Removed
  • doc/barnowl.1

    rfa1b15b rd9fbfd8  
    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.
  • functions.c

    rce68f23 re1d3607  
    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"
     
    13051305{
    13061306  owl_function_popless_text(
    1307     "This is barnowl version " OWL_VERSION_STRING ".\n\n"
    1308     "barnowl is a fork of the Owl zephyr client, written and\n"
     1307    "This is BarnOwl version " OWL_VERSION_STRING ".\n\n"
     1308    "BarnOwl is a fork of the Owl zephyr client, written and\n"
    13091309    "maintained by Alejandro Sedeno and Nelson Elhage at the\n"
    13101310    "Massachusetts Institute of Technology. \n"
     
    13151315    "The name 'owl' was chosen in reference to the owls in the\n"
    13161316    "Harry Potter novels, who are tasked with carrying messages\n"
    1317     "between Witches and Wizards. The name 'barnowl' was chosen\n"
     1317    "between Witches and Wizards. The name 'BarnOwl' was chosen\n"
    13181318    "because we feel our owls should live closer to our ponies.\n"
    13191319    "\n"
  • owl.c

    r2244836 r413c910  
    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 r413c910  
    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

    rbcde7926 r413c910  
    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
     
    239239=head2 create_style NAME OBJECT
    240240
    241 Creates a new barnowl style with the given NAME defined by the given
     241Creates a new BarnOwl style with the given NAME defined by the given
    242242object. The object must have a C<description> method which returns a
    243243string description of the style, and a and C<format_message> method
  • perl/lib/BarnOwl/Hooks.pm

    r3aa0522 r413c910  
    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 r413c910  
    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 r413c910  
    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 r413c910  
    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 r413c910  
    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 r413c910  
    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 r413c910  
    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,
  • scripts/do-release

    r74312ad r413c910  
    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
  • util.c

    r3cdd6d2 re1d3607  
    221221/*
    222222 * 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
     223 * the varargs provided, quoting them to be safe for placing in a BarnOwl
    224224 * command line.
    225225 */
  • Makefile.am

    r4f746f8 rc266281  
    3838           $(GIT_FLAGS)
    3939
    40 CODELIST_SRCS=list.c message.c mainwin.c popwin.c zephyr.c messagelist.c \
     40CODELIST_SRCS=message.c mainwin.c popwin.c zephyr.c messagelist.c \
    4141     commands.c global.c text.c fmtext.c editwin.c util.c logging.c \
    4242     perlconfig.c keys.c functions.c zwrite.c viewwin.c help.c filter.c \
  • aim.c

    rd427f08 re4524da  
    437437
    438438/* caller must free the return */
    439 G_GNUC_WARN_UNUSED_RESULT char *owl_aim_normalize_screenname(const char *in)
     439CALLER_OWN char *owl_aim_normalize_screenname(const char *in)
    440440{
    441441  char *out;
     
    14391439  const char *address, *SNs;
    14401440  int num, i;
    1441   owl_list list;
     1441  GPtrArray *list;
    14421442 
    14431443  va_start(ap, fr);
     
    14471447  va_end(ap);
    14481448
    1449   owl_list_create(&list);
     1449  list = g_ptr_array_new();
    14501450 
    14511451  owl_function_debugmsg("faimtest_parse_searchreply: E-Mail Search Results for %s: ", address);
    14521452  for (i=0; i<num; i++) {
    14531453    owl_function_debugmsg("  %s", &SNs[i*(MAXSNLEN+1)]);
    1454     owl_list_append_element(&list, (void *)&SNs[i*(MAXSNLEN+1)]);
    1455   }
    1456   owl_function_aimsearch_results(address, &list);
    1457   owl_list_cleanup(&list, NULL);
    1458   return(1);
     1454    g_ptr_array_add(list, (void *)&SNs[i*(MAXSNLEN+1)]);
     1455  }
     1456  owl_function_aimsearch_results(address, list);
     1457  g_ptr_array_free(list, true);
     1458  return 1;
    14591459}
    14601460
  • buddylist.c

    r96828e4 r3cdd6d2  
    33void owl_buddylist_init(owl_buddylist *bl)
    44{
    5   owl_list_create(&(bl->buddies));
     5  bl->buddies = g_ptr_array_new();
    66}
    77
     
    1414 
    1515  owl_buddy_create(b, OWL_PROTOCOL_AIM, screenname);
    16   owl_list_append_element(&(bl->buddies), b);
     16  g_ptr_array_add(bl->buddies, b);
    1717}
    1818
     
    2121int owl_buddylist_remove_aim_buddy(owl_buddylist *bl, const char *name)
    2222{
    23   int i, j;
     23  int i;
    2424  owl_buddy *b;
    2525
    26   j=owl_list_get_size(&(bl->buddies));
    27   for (i=0; i<j; i++) {
    28     b=owl_list_get_element(&(bl->buddies), i);
     26  for (i = 0; i < bl->buddies->len; i++) {
     27    b = bl->buddies->pdata[i];
    2928    if (!strcasecmp(name, owl_buddy_get_name(b)) && owl_buddy_is_proto_aim(b)) {
    30       owl_list_remove_element(&(bl->buddies), i);
    31       owl_buddy_delete(b);
     29      owl_buddy_delete(g_ptr_array_remove_index(bl->buddies, i));
    3230      return(0);
    3331    }
     
    8785int owl_buddylist_get_size(const owl_buddylist *bl)
    8886{
    89   return(owl_list_get_size(&(bl->buddies)));
     87  return bl->buddies->len;
    9088}
    9189
     
    9795  if (index>(owl_buddylist_get_size(bl)-1)) return(NULL);
    9896
    99   return(owl_list_get_element(&(bl->buddies), index));
     97  return bl->buddies->pdata[index];
    10098}
    10199
     
    105103owl_buddy *owl_buddylist_get_aim_buddy(const owl_buddylist *bl, const char *name)
    106104{
    107   int i, j;
     105  int i;
    108106  owl_buddy *b;
    109107
    110   j=owl_list_get_size(&(bl->buddies));
    111   for (i=0; i<j; i++) {
    112     b=owl_list_get_element(&(bl->buddies), i);
     108  for (i = 0; i < bl->buddies->len; i++) {
     109    b = bl->buddies->pdata[i];
    113110    if (!strcasecmp(name, owl_buddy_get_name(b))) return(b);
    114111  }
     
    131128void owl_buddylist_clear(owl_buddylist *bl)
    132129{
    133   owl_list_cleanup(&(bl->buddies), (void (*)(void *))owl_buddy_delete);
    134   owl_list_create(&(bl->buddies));
     130  g_ptr_array_foreach(bl->buddies, (GFunc)owl_buddy_delete, NULL);
     131  g_ptr_array_set_size(bl->buddies, 0);
    135132}
    136133
    137134void owl_buddylist_cleanup(owl_buddylist *bl)
    138135{
    139   owl_list_cleanup(&(bl->buddies), (void (*)(void *))owl_buddy_delete);
     136  owl_ptr_array_free(bl->buddies, (GDestroyNotify)owl_buddy_delete);
    140137}
  • cmd.c

    rd427f08 rce68f23  
    2828}
    2929
    30 void owl_cmddict_get_names(const owl_cmddict *d, owl_list *l) {
    31   owl_dict_get_keys(d, l);
     30GPtrArray *owl_cmddict_get_names(const owl_cmddict *d) {
     31  return owl_dict_get_keys(d);
    3232}
    3333
     
    5656
    5757/* caller must free the return */
    58 G_GNUC_WARN_UNUSED_RESULT char *_owl_cmddict_execute(const owl_cmddict *cd, const owl_context *ctx, const char *const *argv, int argc, const char *buff)
     58CALLER_OWN char *_owl_cmddict_execute(const owl_cmddict *cd, const owl_context *ctx, const char *const *argv, int argc, const char *buff)
    5959{
    6060  char *retval = NULL;
     
    7373
    7474/* caller must free the return */
    75 G_GNUC_WARN_UNUSED_RESULT char *owl_cmddict_execute(const owl_cmddict *cd, const owl_context *ctx, const char *cmdbuff)
     75CALLER_OWN char *owl_cmddict_execute(const owl_cmddict *cd, const owl_context *ctx, const char *cmdbuff)
    7676{
    7777  char **argv;
     
    9797
    9898/* caller must free the return */
    99 G_GNUC_WARN_UNUSED_RESULT char *owl_cmddict_execute_argv(const owl_cmddict *cd, const owl_context *ctx, const char *const *argv, int argc)
     99CALLER_OWN char *owl_cmddict_execute_argv(const owl_cmddict *cd, const owl_context *ctx, const char *const *argv, int argc)
    100100{
    101101  char *buff;
     
    154154
    155155/* caller must free the result */
    156 G_GNUC_WARN_UNUSED_RESULT char *owl_cmd_execute(const owl_cmd *cmd, const owl_cmddict *cd, const owl_context *ctx, int argc, const char *const *argv, const char *cmdbuff)
     156CALLER_OWN char *owl_cmd_execute(const owl_cmd *cmd, const owl_cmddict *cd, const owl_context *ctx, int argc, const char *const *argv, const char *cmdbuff)
    157157{
    158158  static int alias_recurse_depth = 0;
     
    228228
    229229/* returns a summary line describing this keymap.  the caller must free. */
    230 G_GNUC_WARN_UNUSED_RESULT char *owl_cmd_describe(const owl_cmd *cmd)
     230CALLER_OWN char *owl_cmd_describe(const owl_cmd *cmd)
    231231{
    232232  if (!cmd || !cmd->name || !cmd->summary) return NULL;
  • commands.c

    rd427f08 re6d7e4e  
    13731373}
    13741374
    1375 G_GNUC_WARN_UNUSED_RESULT char *owl_command_smartfilter(int argc, const char *const *argv, const char *buff)
     1375CALLER_OWN char *owl_command_smartfilter(int argc, const char *const *argv, const char *buff)
    13761376{
    13771377  char *filtname = NULL;
     
    14131413}
    14141414
    1415 G_GNUC_WARN_UNUSED_RESULT char *owl_command_get_shift(int argc, const char *const *argv, const char *buff)
     1415CALLER_OWN char *owl_command_get_shift(int argc, const char *const *argv, const char *buff)
    14161416{
    14171417  if(argc != 1)
     
    16441644
    16451645
    1646 G_GNUC_WARN_UNUSED_RESULT char *owl_command_exec(int argc, const char *const *argv, const char *buff)
     1646CALLER_OWN char *owl_command_exec(int argc, const char *const *argv, const char *buff)
    16471647{
    16481648  return owl_function_exec(argc, argv, buff, OWL_OUTPUT_RETURN);
    16491649}
    16501650
    1651 G_GNUC_WARN_UNUSED_RESULT char *owl_command_pexec(int argc, const char *const *argv, const char *buff)
     1651CALLER_OWN char *owl_command_pexec(int argc, const char *const *argv, const char *buff)
    16521652{
    16531653  return owl_function_exec(argc, argv, buff, OWL_OUTPUT_POPUP);
    16541654}
    16551655
    1656 G_GNUC_WARN_UNUSED_RESULT char *owl_command_aexec(int argc, const char *const *argv, const char *buff)
     1656CALLER_OWN char *owl_command_aexec(int argc, const char *const *argv, const char *buff)
    16571657{
    16581658  return owl_function_exec(argc, argv, buff, OWL_OUTPUT_ADMINMSG);
    16591659}
    16601660
    1661 G_GNUC_WARN_UNUSED_RESULT char *owl_command_perl(int argc, const char *const *argv, const char *buff)
     1661CALLER_OWN char *owl_command_perl(int argc, const char *const *argv, const char *buff)
    16621662{
    16631663  return owl_function_perl(argc, argv, buff, OWL_OUTPUT_RETURN);
    16641664}
    16651665
    1666 G_GNUC_WARN_UNUSED_RESULT char *owl_command_pperl(int argc, const char *const *argv, const char *buff)
     1666CALLER_OWN char *owl_command_pperl(int argc, const char *const *argv, const char *buff)
    16671667{
    16681668  return owl_function_perl(argc, argv, buff, OWL_OUTPUT_POPUP);
    16691669}
    16701670
    1671 G_GNUC_WARN_UNUSED_RESULT char *owl_command_aperl(int argc, const char *const *argv, const char *buff)
     1671CALLER_OWN char *owl_command_aperl(int argc, const char *const *argv, const char *buff)
    16721672{
    16731673  return owl_function_perl(argc, argv, buff, OWL_OUTPUT_ADMINMSG);
    16741674}
    16751675
    1676 G_GNUC_WARN_UNUSED_RESULT char *owl_command_multi(int argc, const char *const *argv, const char *buff)
     1676CALLER_OWN char *owl_command_multi(int argc, const char *const *argv, const char *buff)
    16771677{
    16781678  char *lastrv = NULL, *newbuff;
     
    24672467void owl_command_punt_unpunt(int argc, const char *const * argv, const char *buff, int unpunt)
    24682468{
    2469   owl_list * fl;
    2470   owl_filter * f;
     2469  GPtrArray * fl;
    24712470  int i;
    24722471
     
    24782477    if(unpunt && (i=atoi(argv[1])) !=0) {
    24792478      i--;      /* Accept 1-based indexing */
    2480       if(i < owl_list_get_size(fl)) {
    2481         f = owl_list_get_element(fl, i);
    2482         owl_list_remove_element(fl, i);
    2483         owl_filter_delete(f);
     2479      if (i < fl->len) {
     2480        owl_filter_delete(g_ptr_array_remove_index(fl, i));
    24842481        return;
    24852482      } else {
     
    25942591}
    25952592
    2596 G_GNUC_WARN_UNUSED_RESULT char *owl_command_getstyle(int argc, const char *const *argv, const char *buff)
     2593CALLER_OWN char *owl_command_getstyle(int argc, const char *const *argv, const char *buff)
    25972594{
    25982595  const char *stylename;
     
    26322629  ptr = skiptokens(buff, 1);
    26332630  hist = owl_global_get_cmd_history(&g);
    2634   owl_history_store(hist, ptr);
    2635   owl_history_reset(hist);
     2631  owl_history_store(hist, ptr, false);
    26362632  /* owl_function_makemsg("History '%s' stored successfully", ptr+1); */
    26372633  return NULL;
    26382634}
    26392635
    2640 G_GNUC_WARN_UNUSED_RESULT char *owl_command_with_history(int argc, const char *const *argv, const char *buff)
     2636CALLER_OWN char *owl_command_with_history(int argc, const char *const *argv, const char *buff)
    26412637{
    26422638  owl_history *hist;
     
    26552651
    26562652  hist = owl_global_get_cmd_history(&g);
    2657   owl_history_store(hist, ptr);
    2658   owl_history_reset(hist);
     2653  owl_history_store(hist, ptr, false);
    26592654  return owl_function_command(ptr);
    26602655}
     
    27392734
    27402735  hist = owl_editwin_get_history(e);
    2741   if (hist) {
    2742     owl_history_store(hist, owl_editwin_get_text(e));
    2743     owl_history_reset(hist);
    2744   }
     2736  if (hist)
     2737    owl_history_store(hist, owl_editwin_get_text(e), false);
    27452738
    27462739  owl_global_pop_context(&g);
     
    27552748  if (!hist)
    27562749    return;
    2757   if (!owl_history_is_touched(hist)) {
    2758     owl_history_store(hist, owl_editwin_get_text(e));
    2759     owl_history_set_partial(hist);
    2760   }
     2750  if (!owl_history_is_touched(hist))
     2751    owl_history_store(hist, owl_editwin_get_text(e), true);
    27612752  ptr=owl_history_get_prev(hist);
    27622753  if (ptr) {
     
    27962787  owl_history *hist=owl_editwin_get_history(e);
    27972788
    2798   if (hist) {
    2799     owl_history_store(hist, owl_editwin_get_text(e));
    2800     owl_history_reset(hist);
    2801   }
     2789  if (hist)
     2790    owl_history_store(hist, owl_editwin_get_text(e), false);
    28022791
    28032792  /* Take a reference to the editwin, so that it survives the pop
  • configure.ac

    r4f746f8 rf2a96c0  
    1717
    1818AS_IF([test "x$with_stack_protector" != xno],
    19   [AX_C_CHECK_FLAG([-fstack-protector],[],[],
     19  [AX_CHECK_COMPILE_FLAG([-fstack-protector],
    2020    [AM_CFLAGS="$AM_CFLAGS -fstack-protector"],
    2121    [if test "x$with_stack_protector" != xcheck; then
     
    129129
    130130AX_CFLAGS_WARN_ALL([AM_CFLAGS])
    131 AX_C_CHECK_FLAG([-Wstrict-prototypes],[],[],[AM_CFLAGS="$AM_CFLAGS -Wstrict-prototypes"])
    132 AX_C_CHECK_FLAG([-Wwrite-strings],[],[],[AM_CFLAGS="$AM_CFLAGS -Wwrite-strings"])
     131AX_APPEND_COMPILE_FLAGS([-Wstrict-prototypes -Wwrite-strings],[AM_CFLAGS])
    133132
    134133dnl Shut gcc up about zero-length format strings; the warning's apparently for
    135134dnl efficiency reasons, which is bogus for custom functions.
    136 AX_C_CHECK_FLAG([-Wno-format-zero-length],[],[],[AM_CFLAGS="$AM_CFLAGS -Wno-format-zero-length"])
     135AX_APPEND_COMPILE_FLAGS([-Wno-format-zero-length],[AM_CFLAGS])
    137136
    138 m4_foreach([myflag],
    139   [[-Wno-pointer-sign],[-Wno-empty-body],[-Wno-unused-value]],
    140   [AX_C_CHECK_FLAG([myflag],[],[],[LIBFAIM_CFLAGS="$LIBFAIM_CFLAGS myflag"])])
     137AX_APPEND_COMPILE_FLAGS([-Wno-pointer-sign -Wno-empty-body -Wno-unused-value],[LIBFAIM_CFLAGS])
    141138
    142139AM_CONDITIONAL([ENABLE_ZCRYPT], [test "$HAVE_DES_STRING_TO_KEY" && dnl
  • context.c

    rd427f08 r6829afc  
    66
    77/* TODO: dependency from owl_context -> owl_window is annoying. */
    8 G_GNUC_WARN_UNUSED_RESULT owl_context *owl_context_new(int mode, void *data, const char *keymap, owl_window *cursor)
     8CALLER_OWN owl_context *owl_context_new(int mode, void *data, const char *keymap, owl_window *cursor)
    99{
    1010  owl_context *c;
  • dict.c

    rd427f08 rce68f23  
    5656}
    5757
    58 /* Appends dictionary keys to a list.  Duplicates the keys,
    59  * so they will need to be freed by the caller. */
    60 void owl_dict_get_keys(const owl_dict *d, owl_list *l) {
     58/* Returns a GPtrArray of dictionary keys. Duplicates the keys, so
     59 * they will need to be freed by the caller with g_free. */
     60CALLER_OWN GPtrArray *owl_dict_get_keys(const owl_dict *d) {
     61  GPtrArray *keys = g_ptr_array_sized_new(d->size);
    6162  int i;
    62   for (i=0; i<d->size; i++) {
    63     owl_list_append_element(l, g_strdup(d->els[i].k));
     63  for (i = 0; i < d->size; i++) {
     64    g_ptr_array_add(keys, g_strdup(d->els[i].k));
    6465  }
     66  return keys;
    6567}
    6668
     
    107109/* Doesn't free the value of the element, but does
    108110 * return it so the caller can free it. */
    109 G_GNUC_WARN_UNUSED_RESULT void *owl_dict_remove_element(owl_dict *d, const char *k)
     111CALLER_OWN void *owl_dict_remove_element(owl_dict *d, const char *k)
    110112{
    111113  int i;
  • editcontext.c

    rd427f08 r6829afc  
    88}
    99
    10 G_GNUC_WARN_UNUSED_RESULT owl_context *owl_editcontext_new(int mode, owl_editwin *e, const char *keymap, void (*deactivate_cb)(owl_context*), void *cbdata)
     10CALLER_OWN owl_context *owl_editcontext_new(int mode, owl_editwin *e, const char *keymap, void (*deactivate_cb)(owl_context*), void *cbdata)
    1111{
    1212  owl_context *ctx = owl_context_new(mode, owl_editwin_ref(e), keymap,
  • editwin.c

    rd427f08 r6829afc  
    6161static const char *oe_copy_buf(owl_editwin *e, const char *buf, int len);
    6262static int oe_copy_region(owl_editwin *e);
    63 static G_GNUC_WARN_UNUSED_RESULT char *oe_chunk(owl_editwin *e, int start, int end);
     63static CALLER_OWN char *oe_chunk(owl_editwin *e, int start, int end);
    6464static void oe_destroy_cbdata(owl_editwin *e);
    6565static void oe_dirty(owl_editwin *e);
     
    7070#define WHITESPACE " \n\t"
    7171
    72 static G_GNUC_WARN_UNUSED_RESULT owl_editwin *owl_editwin_allocate(void)
     72static CALLER_OWN owl_editwin *owl_editwin_allocate(void)
    7373{
    7474  owl_editwin *e = g_new0(owl_editwin, 1);
     
    142142}
    143143
    144 G_GNUC_WARN_UNUSED_RESULT owl_editwin *owl_editwin_new(owl_window *win, int winlines, int wincols, int style, owl_history *hist)
     144CALLER_OWN owl_editwin *owl_editwin_new(owl_window *win, int winlines, int wincols, int style, owl_history *hist)
    145145{
    146146  owl_editwin *e = owl_editwin_allocate();
     
    13691369}
    13701370
    1371 G_GNUC_WARN_UNUSED_RESULT char *owl_editwin_get_region(owl_editwin *e)
     1371CALLER_OWN char *owl_editwin_get_region(owl_editwin *e)
    13721372{
    13731373  int start, end;
     
    13881388}
    13891389
    1390 static G_GNUC_WARN_UNUSED_RESULT char *oe_chunk(owl_editwin *e, int start, int end)
     1390static CALLER_OWN char *oe_chunk(owl_editwin *e, int start, int end)
    13911391{
    13921392  char *p;
  • errqueue.c

    rd4927a7 reb897c6  
    33void owl_errqueue_init(owl_errqueue *eq)
    44{
    5   owl_list_create(&(eq->errlist));
     5  eq->errlist = g_ptr_array_new();
    66}
    77
    88void owl_errqueue_append_err(owl_errqueue *eq, const char *msg)
    99{
    10   owl_list_append_element(&(eq->errlist), g_strdup(msg));
     10  g_ptr_array_add(eq->errlist, g_strdup(msg));
    1111}
    1212
     
    1414void owl_errqueue_to_fmtext(const owl_errqueue *eq, owl_fmtext *fm)
    1515{
    16   int i, j;
    17 
    18   j=owl_list_get_size(&(eq->errlist));
    19   for (i=0; i<j; i++) {
    20     owl_fmtext_append_normal(fm, owl_list_get_element(&(eq->errlist), i));
     16  int i;
     17  for (i = 0; i < eq->errlist->len; i++) {
     18    owl_fmtext_append_normal(fm, eq->errlist->pdata[i]);
    2119    owl_fmtext_append_normal(fm, "\n");
    2220  }
  • filter.c

    rd427f08 r2560529  
    200200
    201201
    202 char G_GNUC_WARN_UNUSED_RESULT *owl_filter_print(const owl_filter *f)
     202CALLER_OWN char *owl_filter_print(const owl_filter *f)
    203203{
    204204  GString *out = g_string_new("");
  • fmtext.c

    rd427f08 r2560529  
    171171 * freeing the return
    172172 */
    173 char G_GNUC_WARN_UNUSED_RESULT *owl_fmtext_print_plain(const owl_fmtext *f)
     173CALLER_OWN char *owl_fmtext_print_plain(const owl_fmtext *f)
    174174{
    175175  return owl_strip_format_chars(f->buff->str);
     
    755755 * If format_fn is specified, passes it the list element value
    756756 * and it will return a string which this needs to free. */
    757 void owl_fmtext_append_list(owl_fmtext *f, const owl_list *l, const char *join_with, char *(format_fn)(const char *))
    758 {
    759   int i, size;
     757void owl_fmtext_append_list(owl_fmtext *f, const GPtrArray *l, const char *join_with, char *(format_fn)(const char *))
     758{
     759  int i;
    760760  const char *elem;
    761761  char *text;
    762762
    763   size = owl_list_get_size(l);
    764   for (i=0; i<size; i++) {
    765     elem = owl_list_get_element(l,i);
     763  for (i = 0; i < l->len; i++) {
     764    elem = l->pdata[i];
    766765    if (elem && format_fn) {
    767766      text = format_fn(elem);
     
    773772      owl_fmtext_append_normal(f, elem);
    774773    }
    775     if ((i < size-1) && join_with) {
     774    if ((i < l->len - 1) && join_with) {
    776775      owl_fmtext_append_normal(f, join_with);
    777776    }
  • global.c

    rd427f08 r2560529  
    4747  owl_dict_create(&(g->filters));
    4848  g->filterlist = NULL;
    49   owl_list_create(&(g->puntlist));
     49  g->puntlist = g_ptr_array_new();
    5050  g->messagequeue = g_queue_new();
    5151  owl_dict_create(&(g->styledict));
     
    6565  owl_history_init(&(g->msghist));
    6666  owl_history_init(&(g->cmdhist));
    67   owl_history_set_norepeats(&(g->cmdhist));
    6867  g->nextmsgid=0;
    6968
     
    173172/* Pops the current context from the context stack and returns it. Caller is
    174173 * responsible for freeing. */
    175 G_GNUC_WARN_UNUSED_RESULT owl_context *owl_global_pop_context_no_delete(owl_global *g)
     174CALLER_OWN owl_context *owl_global_pop_context_no_delete(owl_global *g)
    176175{
    177176  owl_context *c;
     
    580579/* puntlist */
    581580
    582 owl_list *owl_global_get_puntlist(owl_global *g) {
    583   return(&(g->puntlist));
     581GPtrArray *owl_global_get_puntlist(owl_global *g) {
     582  return g->puntlist;
    584583}
    585584
    586585int owl_global_message_is_puntable(owl_global *g, const owl_message *m) {
    587   const owl_list *pl;
    588   int i, j;
    589 
    590   pl=owl_global_get_puntlist(g);
    591   j=owl_list_get_size(pl);
    592   for (i=0; i<j; i++) {
    593     if (owl_filter_message_match(owl_list_get_element(pl, i), m)) return(1);
    594   }
    595   return(0);
     586  const GPtrArray *pl;
     587  int i;
     588
     589  pl = owl_global_get_puntlist(g);
     590  for (i = 0; i < pl->len; i++) {
     591    if (owl_filter_message_match(pl->pdata[i], m)) return 1;
     592  }
     593  return 0;
    596594}
    597595
     
    726724 * necessary.
    727725 */
    728 owl_message G_GNUC_WARN_UNUSED_RESULT *owl_global_messagequeue_popmsg(owl_global *g)
     726CALLER_OWN owl_message *owl_global_messagequeue_popmsg(owl_global *g)
    729727{
    730728  owl_message *out;
     
    755753}
    756754
    757 void owl_global_get_style_names(const owl_global *g, owl_list *l) {
    758   owl_dict_get_keys(&(g->styledict), l);
     755CALLER_OWN GPtrArray *owl_global_get_style_names(const owl_global *g)
     756{
     757  return owl_dict_get_keys(&g->styledict);
    759758}
    760759
  • help.c

    rf25df21 rce68f23  
    66  owl_fmtext fm;
    77  const char *varname;
    8   owl_list varnames;
    9   int i, numvarnames;
     8  GPtrArray *varnames;
     9  int i;
    1010
    1111  owl_fmtext_init_null(&fm);
     
    129129  owl_fmtext_append_bold(&fm,
    130130                         "Variables:\n");
    131   owl_list_create(&varnames);
    132   owl_variable_dict_get_names(owl_global_get_vardict(&g), &varnames);
    133   numvarnames = owl_list_get_size(&varnames);
    134   for (i=0; i<numvarnames; i++) {
    135     varname = owl_list_get_element(&varnames, i);
     131  varnames = owl_variable_dict_get_names(owl_global_get_vardict(&g));
     132  for (i = 0; i < varnames->len; i++) {
     133    varname = varnames->pdata[i];
    136134    if (varname && varname[0]!='_') {
    137135      owl_variable_describe(owl_global_get_vardict(&g), varname, &fm);
    138136    }
    139137  }
    140   owl_list_cleanup(&varnames, g_free);
     138  owl_ptr_array_free(varnames, g_free);
    141139
    142140  owl_fmtext_append_normal(&fm, "\n");
  • history.c

    rd4927a7 r25891a8  
    33void owl_history_init(owl_history *h)
    44{
    5   owl_list_create(&(h->hist));
    6   h->cur=0;                     /* current position in history */
    7   h->touched=0;                 /* whether we've gone into history */
    8   h->partial=0;                 /* is the 0th element is partially composed? */
    9   h->repeats=1;                 /* by default we'll allow repeat entries */
     5  g_queue_init(&h->hist);
     6  h->cur = h->hist.tail;        /* current position in history */
     7  h->partial = false;           /* is the 0th element is partially composed? */
    108}
    119
    12 void owl_history_set_norepeats(owl_history *h)
     10void owl_history_cleanup(owl_history *h)
    1311{
    14   h->repeats=0;
     12  g_queue_foreach(&h->hist, (GFunc)g_free, NULL);
     13  g_queue_clear(&h->hist);
    1514}
    1615
    1716const char *owl_history_get_prev(owl_history *h)
    1817{
     18  if (!h) return NULL;
    1919
    20   if (!h) return NULL;
    21   h->touched=1;
     20  if (h->cur == NULL || g_list_previous(h->cur) == NULL) return NULL;
    2221
    23   if (owl_list_get_size(&(h->hist))==0) return(NULL);
    24 
    25   if (h->cur == owl_list_get_size(&(h->hist))-1) {
    26     return(NULL);
    27   }
    28 
    29   h->cur++;
    30 
    31   return(owl_list_get_element(&(h->hist), h->cur));
     22  h->cur = g_list_previous(h->cur);
     23  return h->cur->data;
    3224}
    3325
     
    3527{
    3628  if (!h) return NULL;
    37   if (owl_list_get_size(&(h->hist))==0) return(NULL);
    38   if (h->cur==0) {
    39     return(NULL);
    40   }
    4129
    42   h->cur--;
    43   return(owl_list_get_element(&(h->hist), h->cur));
     30  if (h->cur == NULL || g_list_next(h->cur) == NULL) return NULL;
     31
     32  h->cur = g_list_next(h->cur);
     33  return h->cur->data;
    4434}
    4535
    46 void owl_history_store(owl_history *h, const char *line)
     36void owl_history_store(owl_history *h, const char *line, bool partial)
    4737{
    48   int size;
     38  if (!h) return;
    4939
    50   if (!h) return;
    51   size=owl_list_get_size(&(h->hist));
     40  owl_history_reset(h);
    5241
    53   /* if partial is set, remove the first entry first */
    54   if (h->partial) {
    55     g_free(owl_list_get_element(&(h->hist), 0));
    56     owl_list_remove_element(&(h->hist), 0);
    57   }
    58 
    59   /* if repeats are disallowed, check if the line is the same as the last */
    60   if (owl_list_get_size(&(h->hist))>0) {
    61     if (!strcmp(line, owl_list_get_element(&(h->hist), 0))) return;
    62   }
     42  /* check if the line is the same as the last */
     43  if (!partial && !g_queue_is_empty(&h->hist) &&
     44      strcmp(line, g_queue_peek_tail(&h->hist)) == 0)
     45    return;
    6346
    6447  /* if we've reached the max history size, pop off the last element */
    65   if (size>OWL_HISTORYSIZE) {
    66     g_free(owl_list_get_element(&(h->hist), size-1));
    67     owl_list_remove_element(&(h->hist), size-1);
    68   }
     48  if (g_queue_get_length(&h->hist) >= OWL_HISTORYSIZE)
     49    g_free(g_queue_pop_head(&h->hist));
    6950
    7051  /* add the new line */
    71   owl_list_prepend_element(&(h->hist), g_strdup(line));
    72 }
    73 
    74 void owl_history_set_partial(owl_history *h)
    75 {
    76   if (!h) return;
    77   h->partial=1;
     52  g_queue_push_tail(&h->hist, g_strdup(line));
     53  h->partial = partial;
     54  h->cur = h->hist.tail;
    7855}
    7956
     
    8158{
    8259  if (!h) return;
    83   h->cur=0;
    84   h->touched=0;
    85   h->partial=0;
     60
     61  /* if partial is set, remove the first entry first */
     62  if (h->partial) {
     63    g_free(g_queue_pop_tail(&h->hist));
     64    h->partial = false;
     65  }
     66
     67  h->cur = h->hist.tail;
    8668}
    8769
     
    8971{
    9072  if (!h) return(0);
    91   if (h->touched) return(1);
    92   return(0);
     73  return h->cur != NULL && g_list_next(h->cur) != NULL;
    9374}
  • keybinding.c

    rd427f08 r6829afc  
    1414
    1515/* sets up a new keybinding for a command */
    16 G_GNUC_WARN_UNUSED_RESULT owl_keybinding *owl_keybinding_new(const char *keyseq, const char *command, void (*function_fn)(void), const char *desc)
     16CALLER_OWN owl_keybinding *owl_keybinding_new(const char *keyseq, const char *command, void (*function_fn)(void), const char *desc)
    1717{
    1818  owl_keybinding *kb = g_new(owl_keybinding, 1);
     
    8585}
    8686
    87 G_GNUC_WARN_UNUSED_RESULT char *owl_keybinding_stack_tostring(int *j, int len)
     87CALLER_OWN char *owl_keybinding_stack_tostring(int *j, int len)
    8888{
    8989  GString *string;
     
    100100}
    101101
    102 G_GNUC_WARN_UNUSED_RESULT char *owl_keybinding_tostring(const owl_keybinding *kb)
     102CALLER_OWN char *owl_keybinding_tostring(const owl_keybinding *kb)
    103103{
    104104  return owl_keybinding_stack_tostring(kb->keys, kb->len);
  • keymap.c

    rd427f08 rce68f23  
    1111  km->name = g_strdup(name);
    1212  km->desc = g_strdup(desc);
    13   owl_list_create(&km->bindings);
     13  km->bindings = g_ptr_array_new();
    1414  km->parent = NULL;
    1515  km->default_fn = default_fn;
     
    2424  g_free(km->name);
    2525  g_free(km->desc);
    26   owl_list_cleanup(&km->bindings, (void (*)(void *))owl_keybinding_delete);
     26  owl_ptr_array_free(km->bindings, (GDestroyNotify)owl_keybinding_delete);
    2727}
    2828
     
    3535int owl_keymap_create_binding(owl_keymap *km, const char *keyseq, const char *command, void (*function_fn)(void), const char *desc)
    3636{
    37   owl_keybinding *kb, *curkb;
     37  owl_keybinding *kb;
    3838  int i;
    3939
     
    4444   * otherwise just add this one.
    4545   */
    46   for (i = owl_list_get_size(&km->bindings)-1; i>=0; i--) {
    47     curkb = owl_list_get_element(&km->bindings, i);
    48     if (owl_keybinding_equal(curkb, kb)) {
    49       owl_list_remove_element(&km->bindings, i);
    50       owl_keybinding_delete(curkb);
    51     }
    52   }
    53   owl_list_append_element(&km->bindings, kb);
     46  for (i = km->bindings->len-1; i >= 0; i--) {
     47    if (owl_keybinding_equal(km->bindings->pdata[i], kb)) {
     48      owl_keybinding_delete(g_ptr_array_remove_index(km->bindings, i));
     49    }
     50  }
     51  g_ptr_array_add(km->bindings, kb);
    5452  return 0;
    5553}
     
    5856int owl_keymap_remove_binding(owl_keymap *km, const char *keyseq)
    5957{
    60   owl_keybinding *kb, *curkb;
     58  owl_keybinding *kb;
    6159  int i;
    6260
     
    6563    return -1;
    6664
    67   for (i = owl_list_get_size(&km->bindings)-1; i >= 0; i--) {
    68     curkb = owl_list_get_element(&km->bindings, i);
    69     if (owl_keybinding_equal(curkb, kb)) {
    70       owl_list_remove_element(&km->bindings, i);
    71       owl_keybinding_delete(curkb);
     65  for (i = km->bindings->len-1; i >= 0; i--) {
     66    if (owl_keybinding_equal(km->bindings->pdata[i], kb)) {
     67      owl_keybinding_delete(g_ptr_array_remove_index(km->bindings, i));
    7268      owl_keybinding_delete(kb);
    7369      return(0);
     
    8076
    8177/* returns a summary line describing this keymap.  the caller must free. */
    82 G_GNUC_WARN_UNUSED_RESULT char *owl_keymap_summary(const owl_keymap *km)
     78CALLER_OWN char *owl_keymap_summary(const owl_keymap *km)
    8379{
    8480  if (!km || !km->name || !km->desc) return NULL;
     
    139135static void _owl_keymap_format_bindings(const owl_keymap *km, owl_fmtext *fm)
    140136{
    141   int i, nbindings;
     137  int i;
    142138  const owl_keybinding *kb;
    143139 
    144   nbindings = owl_list_get_size(&km->bindings);
    145   for (i=0; i<nbindings; i++) {
     140  for (i = 0; i < km->bindings->len; i++) {
    146141    char *kbstr;
    147142    const owl_cmd *cmd;
    148143    const char *tmpdesc, *desc = "";
    149144
    150     kb = owl_list_get_element(&km->bindings, i);
     145    kb = km->bindings->pdata[i];
    151146    kbstr = owl_keybinding_tostring(kb);
    152147    owl_fmtext_append_normal(fm, OWL_TABSTR);
     
    214209}
    215210
    216 void owl_keyhandler_get_keymap_names(const owl_keyhandler *kh, owl_list *l)
    217 {
    218   owl_dict_get_keys(&kh->keymaps, l);
     211CALLER_OWN GPtrArray *owl_keyhandler_get_keymap_names(const owl_keyhandler *kh)
     212{
     213  return owl_dict_get_keys(&kh->keymaps);
    219214}
    220215
     
    274269   * keyhandler and keymap apart.  */
    275270  for (km=kh->active; km; km=km->parent) {
    276     for (i=owl_list_get_size(&km->bindings)-1; i>=0; i--) {
    277       kb = owl_list_get_element(&km->bindings, i);
     271    for (i = km->bindings->len-1; i >= 0; i--) {
     272      kb = km->bindings->pdata[i];
    278273      match = owl_keybinding_match(kb, kh);
    279274      if (match == 1) {         /* subset match */
  • keypress.c

    rd427f08 r2560529  
    129129/* OWL_META is definied in owl.h */
    130130
    131 char G_GNUC_WARN_UNUSED_RESULT *owl_keypress_tostring(int j, int esc)
     131CALLER_OWN char *owl_keypress_tostring(int j, int esc)
    132132{
    133133  GString *kb;
  • logging.c

    rd427f08 r6829afc  
    8080}
    8181
    82 G_GNUC_WARN_UNUSED_RESULT char *owl_log_zephyr(const owl_message *m)
     82CALLER_OWN char *owl_log_zephyr(const owl_message *m)
    8383{
    8484    char *tmp = NULL;
     
    104104}
    105105
    106 G_GNUC_WARN_UNUSED_RESULT char *owl_log_aim(const owl_message *m)
     106CALLER_OWN char *owl_log_aim(const owl_message *m)
    107107{
    108108    GString *buffer = NULL;
     
    122122}
    123123
    124 G_GNUC_WARN_UNUSED_RESULT char *owl_log_jabber(const owl_message *m)
     124CALLER_OWN char *owl_log_jabber(const owl_message *m)
    125125{
    126126    GString *buffer = NULL;
     
    135135}
    136136
    137 G_GNUC_WARN_UNUSED_RESULT char *owl_log_generic(const owl_message *m)
     137CALLER_OWN char *owl_log_generic(const owl_message *m)
    138138{
    139139    GString *buffer;
  • m4/ax_cflags_warn_all.m4

    r8073852 r378ede7  
    11# ===========================================================================
    2 #           http://autoconf-archive.cryp.to/ax_cflags_warn_all.html
     2#    http://www.gnu.org/software/autoconf-archive/ax_cflags_warn_all.html
    33# ===========================================================================
    44#
    55# SYNOPSIS
    66#
    7 #   AX_CFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])]
     7#   AX_CFLAGS_WARN_ALL   [(shellvar [,default, [A/NA]])]
     8#   AX_CXXFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])]
     9#   AX_FCFLAGS_WARN_ALL  [(shellvar [,default, [A/NA]])]
    810#
    911# DESCRIPTION
    1012#
    1113#   Try to find a compiler option that enables most reasonable warnings.
    12 #   This macro is directly derived from VL_PROG_CC_WARNINGS which is split
    13 #   up into two AX_CFLAGS_WARN_ALL and AX_CFLAGS_WARN_ALL_ANSI
    1414#
    15 #   For the GNU CC compiler it will be -Wall (and -ansi -pedantic) The
    16 #   result is added to the shellvar being CFLAGS by default.
     15#   For the GNU compiler it will be -Wall (and -ansi -pedantic) The result
     16#   is added to the shellvar being CFLAGS, CXXFLAGS, or FCFLAGS by default.
    1717#
    18 #   Currently this macro knows about GCC, Solaris C compiler, Digital Unix C
    19 #   compiler, C for AIX Compiler, HP-UX C compiler, IRIX C compiler, NEC
    20 #   SX-5 (Super-UX 10) C compiler, and Cray J90 (Unicos 10.0.0.8) C
    21 #   compiler.
     18#   Currently this macro knows about the GCC, Solaris, Digital Unix, AIX,
     19#   HP-UX, IRIX, NEC SX-5 (Super-UX 10), Cray J90 (Unicos 10.0.0.8), and
     20#   Intel compilers.  For a given compiler, the Fortran flags are much more
     21#   experimental than their C equivalents.
    2222#
    23 #    - $1 shell-variable-to-add-to : CFLAGS
     23#    - $1 shell-variable-to-add-to : CFLAGS, CXXFLAGS, or FCFLAGS
    2424#    - $2 add-value-if-not-found : nothing
    2525#    - $3 action-if-found : add value to shellvariable
     
    2929#
    3030#   Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
     31#   Copyright (c) 2010 Rhys Ulerich <rhys.ulerich@gmail.com>
    3132#
    3233#   This program is free software; you can redistribute it and/or modify it
    3334#   under the terms of the GNU General Public License as published by the
    34 #   Free Software Foundation; either version 2 of the License, or (at your
     35#   Free Software Foundation; either version 3 of the License, or (at your
    3536#   option) any later version.
    3637#
     
    5657#   exception to the GPL to apply to your modified version as well.
    5758
     59#serial 10
     60
    5861AC_DEFUN([AX_CFLAGS_WARN_ALL],[dnl
    5962AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl
     
    6164AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings],
    6265VAR,[VAR="no, unknown"
    63  AC_LANG_SAVE
    64  AC_LANG_C
     66 AC_LANG_PUSH([C])
    6567 ac_save_[]FLAGS="$[]FLAGS"
    6668for ac_arg dnl
     
    7577   #
    7678do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
    77    AC_TRY_COMPILE([],[return 0;],
    78    [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
     79   AC_COMPILE_IFELSE([AC_LANG_PROGRAM],
     80                     [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
    7981done
    8082 FLAGS="$ac_save_[]FLAGS"
    81  AC_LANG_RESTORE
     83 AC_LANG_POP([C])
    8284])
    8385case ".$VAR" in
     
    101103AC_DEFUN([AX_CXXFLAGS_WARN_ALL],[dnl
    102104AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl
    103 AS_VAR_PUSHDEF([VAR],[ac_cv_cxxflags_warn_all])dnl
     105AS_VAR_PUSHDEF([VAR],[ax_cv_cxxflags_warn_all])dnl
    104106AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings],
    105107VAR,[VAR="no, unknown"
    106  AC_LANG_SAVE
    107  AC_LANG_CPLUSPLUS
     108 AC_LANG_PUSH([C++])
    108109 ac_save_[]FLAGS="$[]FLAGS"
    109110for ac_arg dnl
     
    118119   #
    119120do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
    120    AC_TRY_COMPILE([],[return 0;],
    121    [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
     121   AC_COMPILE_IFELSE([AC_LANG_PROGRAM],
     122                     [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
    122123done
    123124 FLAGS="$ac_save_[]FLAGS"
    124  AC_LANG_RESTORE
     125 AC_LANG_POP([C++])
     126])
     127case ".$VAR" in
     128     .ok|.ok,*) m4_ifvaln($3,$3) ;;
     129   .|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[
     130        AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])
     131                      m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])]) ;;
     132   *) m4_ifvaln($3,$3,[
     133   if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
     134   then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
     135   else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
     136                      m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
     137   fi ]) ;;
     138esac
     139AS_VAR_POPDEF([VAR])dnl
     140AS_VAR_POPDEF([FLAGS])dnl
     141])
     142
     143dnl the only difference - the LANG selection... and the default FLAGS
     144
     145AC_DEFUN([AX_FCFLAGS_WARN_ALL],[dnl
     146AS_VAR_PUSHDEF([FLAGS],[FCFLAGS])dnl
     147AS_VAR_PUSHDEF([VAR],[ax_cv_fcflags_warn_all])dnl
     148AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings],
     149VAR,[VAR="no, unknown"
     150 AC_LANG_PUSH([Fortran])
     151 ac_save_[]FLAGS="$[]FLAGS"
     152for ac_arg dnl
     153in "-warn all  % -warn all"   dnl Intel
     154   "-pedantic  % -Wall"       dnl GCC
     155   "-xstrconst % -v"          dnl Solaris C
     156   "-std1      % -verbose -w0 -warnprotos" dnl Digital Unix
     157   "-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX
     158   "-ansi -ansiE % -fullwarn" dnl IRIX
     159   "+ESlit     % +w1"         dnl HP-UX C
     160   "-Xc        % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10)
     161   "-h conform % -h msglevel 2" dnl Cray C (Unicos)
     162   #
     163do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
     164   AC_COMPILE_IFELSE([AC_LANG_PROGRAM],
     165                     [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
     166done
     167 FLAGS="$ac_save_[]FLAGS"
     168 AC_LANG_POP([Fortran])
    125169])
    126170case ".$VAR" in
     
    148192dnl   like -Woption or -Xoption as they think of it is a pass-through
    149193dnl   to later compile stages or something. The "%" is used as a
    150 dnl   delimimiter. A non-option comment can be given after "%%" marks
     194dnl   delimiter. A non-option comment can be given after "%%" marks
    151195dnl   which will be shown but not added to the respective C/CXXFLAGS.
  • m4/ax_prog_perl_modules.m4

    r2d3ed95 r378ede7  
    11# ===========================================================================
    2 #      http://www.nongnu.org/autoconf-archive/ax_prog_perl_modules.html
     2#   http://www.gnu.org/software/autoconf-archive/ax_prog_perl_modules.html
    33# ===========================================================================
    44#
     
    3333#   warranty.
    3434
    35 #serial 6
     35#serial 7
    3636
    3737AU_ALIAS([AC_PROG_PERL_MODULES], [AX_PROG_PERL_MODULES])
  • m4/pkg.m4

    r8073852 r650fb2c  
    11# pkg.m4 - Macros to locate and utilise pkg-config.            -*- Autoconf -*-
     2# serial 1 (pkg-config-0.24)
    23#
    34# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
     
    2627AC_DEFUN([PKG_PROG_PKG_CONFIG],
    2728[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
    28 m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
    29 AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl
     29m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
     30m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
     31AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
     32AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
     33AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
     34
    3035if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
    3136        AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
     
    4045                PKG_CONFIG=""
    4146        fi
    42                
    4347fi[]dnl
    4448])# PKG_PROG_PKG_CONFIG
     
    4953# to PKG_CHECK_MODULES(), but does not set variables or print errors.
    5054#
    51 #
    52 # Similar to PKG_CHECK_MODULES, make sure that the first instance of
    53 # this or PKG_CHECK_MODULES is called, or make sure to call
    54 # PKG_CHECK_EXISTS manually
     55# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
     56# only at the first occurence in configure.ac, so if the first place
     57# it's called might be skipped (such as if it is within an "if", you
     58# have to call PKG_CHECK_EXISTS manually
    5559# --------------------------------------------------------------
    5660AC_DEFUN([PKG_CHECK_EXISTS],
     
    5862if test -n "$PKG_CONFIG" && \
    5963    AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
    60   m4_ifval([$2], [$2], [:])
     64  m4_default([$2], [:])
    6165m4_ifvaln([$3], [else
    6266  $3])dnl
    6367fi])
    6468
    65 
    6669# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
    6770# ---------------------------------------------
    6871m4_define([_PKG_CONFIG],
    69 [if test -n "$PKG_CONFIG"; then
    70     if test -n "$$1"; then
    71         pkg_cv_[]$1="$$1"
    72     else
    73         PKG_CHECK_EXISTS([$3],
    74                          [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
    75                          [pkg_failed=yes])
    76     fi
    77 else
    78         pkg_failed=untried
     72[if test -n "$$1"; then
     73    pkg_cv_[]$1="$$1"
     74 elif test -n "$PKG_CONFIG"; then
     75    PKG_CHECK_EXISTS([$3],
     76                     [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
     77                      test "x$?" != "x0" && pkg_failed=yes ],
     78                     [pkg_failed=yes])
     79 else
     80    pkg_failed=untried
    7981fi[]dnl
    8082])# _PKG_CONFIG
     
    118120
    119121if test $pkg_failed = yes; then
     122        AC_MSG_RESULT([no])
    120123        _PKG_SHORT_ERRORS_SUPPORTED
    121124        if test $_pkg_short_errors_supported = yes; then
    122                 $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"`
     125                $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
    123126        else
    124                 $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
     127                $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
    125128        fi
    126129        # Put the nasty error message in config.log where it belongs
    127130        echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
    128131
    129         ifelse([$4], , [AC_MSG_ERROR(dnl
     132        m4_default([$4], [AC_MSG_ERROR(
    130133[Package requirements ($2) were not met:
    131134
     
    135138installed software in a non-standard prefix.
    136139
    137 _PKG_TEXT
    138 ])],
    139                 [AC_MSG_RESULT([no])
    140                 $4])
     140_PKG_TEXT])[]dnl
     141        ])
    141142elif test $pkg_failed = untried; then
    142         ifelse([$4], , [AC_MSG_FAILURE(dnl
     143        AC_MSG_RESULT([no])
     144        m4_default([$4], [AC_MSG_FAILURE(
    143145[The pkg-config script could not be found or is too old.  Make sure it
    144146is in your PATH or set the PKG_CONFIG environment variable to the full
     
    147149_PKG_TEXT
    148150
    149 To get pkg-config, see <http://pkg-config.freedesktop.org/>.])],
    150                 [$4])
     151To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
     152        ])
    151153else
    152154        $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
    153155        $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
    154156        AC_MSG_RESULT([yes])
    155         ifelse([$3], , :, [$3])
     157        $3
    156158fi[]dnl
    157159])# PKG_CHECK_MODULES
  • message.c

    rd427f08 rf9df2f0  
    4343
    4444  owl_message_set_hostname(m, "");
    45   owl_list_create(&(m->attributes));
     45  m->attributes = g_ptr_array_new();
    4646 
    4747  /* save the time */
     
    5858void owl_message_set_attribute(owl_message *m, const char *attrname, const char *attrvalue)
    5959{
    60   int i, j;
     60  int i;
    6161  owl_pair *p = NULL, *pair = NULL;
    6262
     
    6464
    6565  /* look for an existing pair with this key, */
    66   j=owl_list_get_size(&(m->attributes));
    67   for (i=0; i<j; i++) {
    68     p=owl_list_get_element(&(m->attributes), i);
     66  for (i = 0; i < m->attributes->len; i++) {
     67    p = m->attributes->pdata[i];
    6968    if (owl_pair_get_key(p) == attrname) {
    7069      g_free(owl_pair_get_value(p));
     
    7776    pair = g_new(owl_pair, 1);
    7877    owl_pair_create(pair, attrname, NULL);
    79     owl_list_append_element(&(m->attributes), pair);
     78    g_ptr_array_add(m->attributes, pair);
    8079  }
    8180  owl_pair_set_value(pair, owl_validate_or_convert(attrvalue));
     
    8786const char *owl_message_get_attribute_value(const owl_message *m, const char *attrname)
    8887{
    89   int i, j;
     88  int i;
    9089  owl_pair *p;
    9190  GQuark quark;
     
    9796  attrname = g_quark_to_string(quark);
    9897
    99   j=owl_list_get_size(&(m->attributes));
    100   for (i=0; i<j; i++) {
    101     p=owl_list_get_element(&(m->attributes), i);
     98  for (i = 0; i < m->attributes->len; i++) {
     99    p = m->attributes->pdata[i];
    102100    if (owl_pair_get_key(p) == attrname) {
    103101      return(owl_pair_get_value(p));
     
    118116 */
    119117void owl_message_attributes_tofmtext(const owl_message *m, owl_fmtext *fm) {
    120   int i, j;
     118  int i;
    121119  owl_pair *p;
    122120  char *buff, *tmpbuff;
     
    124122  owl_fmtext_init_null(fm);
    125123
    126   j=owl_list_get_size(&(m->attributes));
    127   for (i=0; i<j; i++) {
    128     p=owl_list_get_element(&(m->attributes), i);
     124  for (i = 0; i < m->attributes->len; i++) {
     125    p = m->attributes->pdata[i];
    129126
    130127    tmpbuff = g_strdup(owl_pair_get_value(p));
     
    580577
    581578/* caller must free return value. */
    582 G_GNUC_WARN_UNUSED_RESULT char *owl_message_get_cc(const owl_message *m)
     579CALLER_OWN char *owl_message_get_cc(const owl_message *m)
    583580{
    584581  const char *cur;
     
    597594
    598595/* caller must free return value */
    599 G_GNUC_WARN_UNUSED_RESULT GList *owl_message_get_cc_without_recipient(const owl_message *m)
     596CALLER_OWN GList *owl_message_get_cc_without_recipient(const owl_message *m)
    600597{
    601598  char *cc, *shortuser, *recip;
     
    10041001void owl_message_cleanup(owl_message *m)
    10051002{
    1006   int i, j;
     1003  int i;
    10071004  owl_pair *p;
    10081005#ifdef HAVE_LIBZEPHYR   
     
    10141011
    10151012  /* free all the attributes */
    1016   j=owl_list_get_size(&(m->attributes));
    1017   for (i=0; i<j; i++) {
    1018     p=owl_list_get_element(&(m->attributes), i);
     1013  for (i = 0; i < m->attributes->len; i++) {
     1014    p = m->attributes->pdata[i];
    10191015    g_free(owl_pair_get_value(p));
    10201016    g_free(p);
    10211017  }
    10221018
    1023   owl_list_cleanup(&(m->attributes), NULL);
     1019  g_ptr_array_free(m->attributes, true);
    10241020 
    10251021  owl_message_invalidate_format(m);
  • messagelist.c

    rd427f08 rfc8a87a  
    33#include <string.h>
    44
    5 int owl_messagelist_create(owl_messagelist *ml)
     5void owl_messagelist_create(owl_messagelist *ml)
    66{
    7   owl_list_create(&(ml->list));
    8   return(0);
     7  ml->list = g_ptr_array_new();
     8}
     9
     10void owl_messagelist_cleanup(owl_messagelist *ml, bool free_messages)
     11{
     12  if (free_messages)
     13    g_ptr_array_foreach(ml->list, (GFunc)owl_message_delete, NULL);
     14  g_ptr_array_free(ml->list, true);
    915}
    1016
    1117int owl_messagelist_get_size(const owl_messagelist *ml)
    1218{
    13   return(owl_list_get_size(&(ml->list)));
     19  return ml->list->len;
    1420}
    1521
    1622void *owl_messagelist_get_element(const owl_messagelist *ml, int n)
    1723{
    18   return(owl_list_get_element(&(ml->list), n));
     24  return ml->list->pdata[n];
    1925}
    2026
     
    2632
    2733  first = 0;
    28   last = owl_list_get_size(&(ml->list)) - 1;
     34  last = ml->list->len - 1;
    2935  while (first <= last) {
    3036    mid = (first + last) / 2;
    31     m = owl_list_get_element(&(ml->list), mid);
     37    m = ml->list->pdata[mid];
    3238    msg_id = owl_message_get_id(m);
    3339    if (msg_id == target_id) {
     
    4450void owl_messagelist_append_element(owl_messagelist *ml, void *element)
    4551{
    46   owl_list_append_element(&ml->list, element);
     52  g_ptr_array_add(ml->list, element);
    4753}
    4854
     
    5157{
    5258  /* mark a message as deleted */
    53   owl_message_mark_delete(owl_list_get_element(&(ml->list), n));
     59  owl_message_mark_delete(ml->list->pdata[n]);
    5460  return(0);
    5561}
     
    5864{
    5965  /* mark a message as deleted */
    60   owl_message_unmark_delete(owl_list_get_element(&(ml->list), n));
     66  owl_message_unmark_delete(ml->list->pdata[n]);
    6167  return(0);
    6268}
     
    6571{
    6672  /* expunge deleted messages */
    67   int i, j;
    68   owl_list newlist;
     73  int i;
     74  GPtrArray *newlist;
    6975  owl_message *m;
    7076
    71   owl_list_create(&newlist);
     77  newlist = g_ptr_array_new();
    7278  /*create a new list without messages marked as deleted */
    73   j=owl_list_get_size(&(ml->list));
    74   for (i=0; i<j; i++) {
    75     m=owl_list_get_element(&(ml->list), i);
     79  for (i = 0; i < ml->list->len; i++) {
     80    m = ml->list->pdata[i];
    7681    if (owl_message_is_delete(m)) {
    7782      owl_message_delete(m);
    7883    } else {
    79       owl_list_append_element(&newlist, m);
     84      g_ptr_array_add(newlist, m);
    8085    }
    8186  }
    8287
    8388  /* free the old list */
    84   owl_list_cleanup(&(ml->list), NULL);
     89  g_ptr_array_free(ml->list, true);
    8590
    8691  /* copy the new list to the old list */
     
    9297void owl_messagelist_invalidate_formats(const owl_messagelist *ml)
    9398{
    94   int i, j;
     99  int i;
    95100  owl_message *m;
    96101
    97   j=owl_list_get_size(&(ml->list));
    98   for (i=0; i<j; i++) {
    99     m=owl_list_get_element(&(ml->list), i);
     102  for (i = 0; i < ml->list->len; i++) {
     103    m = ml->list->pdata[i];
    100104    owl_message_invalidate_format(m);
    101105  }
  • owl.h

    rd427f08 r2560529  
    199199#define OWL_ENABLE_ZCRYPT 1
    200200#endif
     201
     202/* Annotate functions in which the caller owns the return value and is
     203 * responsible for ensuring it is freed. */
     204#define CALLER_OWN G_GNUC_WARN_UNUSED_RESULT
    201205
    202206#define OWL_META(key) ((key)|010000)
     
    251255                                 * WARNING:  this approach is hard to make
    252256                                 * thread-safe... */
    253   char G_GNUC_WARN_UNUSED_RESULT *(*get_tostring_fn)(const struct _owl_variable *v, const void *val);
     257  CALLER_OWN char *(*get_tostring_fn)(const struct _owl_variable *v, const void *val);
    254258                                /* converts val to a string;
    255259                                 * caller must free the result */
     
    266270  GString *buff;
    267271} owl_fmtext;
    268 
    269 typedef struct _owl_list {
    270   int size;
    271   int avail;
    272   void **list;
    273 } owl_list;
    274272
    275273typedef struct _owl_dict_el {
     
    313311 
    314312  /* These don't take any context */
    315   char G_GNUC_WARN_UNUSED_RESULT *(*cmd_args_fn)(int argc, const char *const *argv, const char *buff);
     313  CALLER_OWN char *(*cmd_args_fn)(int argc, const char *const *argv, const char *buff);
    316314                                /* takes argv and the full command as buff.
    317315                                 * caller must free return value if !NULL */
     
    320318
    321319  /* The following also take the active context if it's valid */
    322   char G_GNUC_WARN_UNUSED_RESULT *(*cmd_ctxargs_fn)(void *ctx, int argc, const char *const *argv, const char *buff);
     320  CALLER_OWN char *(*cmd_ctxargs_fn)(void *ctx, int argc, const char *const *argv, const char *buff);
    323321                                /* takes argv and the full command as buff.
    324322                                 * caller must free return value if !NULL */
     
    338336  char *zsig;
    339337  char *message;
    340   owl_list recips;
     338  GPtrArray *recips;
    341339  int cc;
    342340  int noping;
     
    359357  int delete;
    360358  const char *hostname;
    361   owl_list attributes;            /* this is a list of pairs */
     359  GPtrArray *attributes;          /* this is a list of pairs */
    362360  char *timestr;
    363361  time_t time;
     
    418416
    419417typedef struct _owl_messagelist {
    420   owl_list list;
     418  GPtrArray *list;
    421419} owl_messagelist;
    422420
     
    455453
    456454typedef struct _owl_history {
    457   owl_list hist;
    458   int cur;
    459   int touched;
    460   int partial;
    461   int repeats;
     455  GQueue hist;
     456  GList *cur;
     457  bool partial;
    462458} owl_history;
    463459
     
    483479  char     *name;               /* name of keymap */
    484480  char     *desc;               /* description */
    485   owl_list  bindings;           /* key bindings */
     481  GPtrArray *bindings;          /* key bindings */
    486482  const struct _owl_keymap *parent;     /* parent */
    487483  void (*default_fn)(owl_input j);      /* default action (takes a keypress) */
     
    506502
    507503typedef struct _owl_buddylist {
    508   owl_list buddies;
     504  GPtrArray *buddies;
    509505} owl_buddylist;
    510506
    511507typedef struct _owl_zbuddylist {
    512   owl_list zusers;
     508  GPtrArray *zusers;
    513509} owl_zbuddylist;
    514510
    515511typedef struct _owl_errqueue {
    516   owl_list errlist;
     512  GPtrArray *errlist;
    517513} owl_errqueue;
    518514
     
    540536  owl_dict filters;
    541537  GList *filterlist;
    542   owl_list puntlist;
     538  GPtrArray *puntlist;
    543539  owl_vardict vars;
    544540  owl_cmddict cmds;
  • perlconfig.c

    rd427f08 rce68f23  
    2323
    2424
    25 G_GNUC_WARN_UNUSED_RESULT SV *owl_new_sv(const char * str)
     25CALLER_OWN SV *owl_new_sv(const char * str)
    2626{
    2727  SV *ret = newSVpv(str, 0);
     
    3636}
    3737
    38 G_GNUC_WARN_UNUSED_RESULT AV *owl_new_av(const owl_list *l, SV *(*to_sv)(const void *))
     38CALLER_OWN AV *owl_new_av(const GPtrArray *l, SV *(*to_sv)(const void *))
    3939{
    4040  AV *ret;
     
    4444  ret = newAV();
    4545
    46   for (i = 0; i < owl_list_get_size(l); i++) {
    47     element = owl_list_get_element(l, i);
     46  for (i = 0; i < l->len; i++) {
     47    element = l->pdata[i];
    4848    av_push(ret, to_sv(element));
    4949  }
     
    5252}
    5353
    54 G_GNUC_WARN_UNUSED_RESULT HV *owl_new_hv(const owl_dict *d, SV *(*to_sv)(const void *))
     54CALLER_OWN HV *owl_new_hv(const owl_dict *d, SV *(*to_sv)(const void *))
    5555{
    5656  HV *ret;
    57   owl_list l;
     57  GPtrArray *keys;
    5858  const char *key;
    5959  void *element;
     
    6363
    6464  /* TODO: add an iterator-like interface to owl_dict */
    65   owl_list_create(&l);
    66   owl_dict_get_keys(d, &l);
    67   for (i = 0; i < owl_list_get_size(&l); i++) {
    68     key = owl_list_get_element(&l, i);
     65  keys = owl_dict_get_keys(d);
     66  for (i = 0; i < keys->len; i++) {
     67    key = keys->pdata[i];
    6968    element = owl_dict_find_element(d, key);
    7069    (void)hv_store(ret, key, strlen(key), to_sv(element), 0);
    7170  }
    72   owl_list_cleanup(&l, g_free);
     71  owl_ptr_array_free(keys, g_free);
    7372
    7473  return ret;
    7574}
    7675
    77 G_GNUC_WARN_UNUSED_RESULT SV *owl_perlconfig_message2hashref(const owl_message *m)
     76CALLER_OWN SV *owl_perlconfig_message2hashref(const owl_message *m)
    7877{
    7978  HV *h, *stash;
     
    115114  }
    116115
    117   j=owl_list_get_size(&(m->attributes));
    118   for(i=0; i<j; i++) {
    119     pair=owl_list_get_element(&(m->attributes), i);
     116  for (i = 0; i < m->attributes->len; i++) {
     117    pair = m->attributes->pdata[i];
    120118    (void)hv_store(h, owl_pair_get_key(pair), strlen(owl_pair_get_key(pair)),
    121119                   owl_new_sv(owl_pair_get_value(pair)),0);
     
    165163}
    166164
    167 G_GNUC_WARN_UNUSED_RESULT SV *owl_perlconfig_curmessage2hashref(void)
     165CALLER_OWN SV *owl_perlconfig_curmessage2hashref(void)
    168166{
    169167  int curmsg;
     
    183181   This has been somewhat addressed, but is still not lossless.
    184182 */
    185 G_GNUC_WARN_UNUSED_RESULT owl_message *owl_perlconfig_hashref2message(SV *msg)
     183CALLER_OWN owl_message *owl_perlconfig_hashref2message(SV *msg)
    186184{
    187185  owl_message * m;
     
    251249/* Calls in a scalar context, passing it a hash reference.
    252250   If return value is non-null, caller must free. */
    253 G_GNUC_WARN_UNUSED_RESULT char *owl_perlconfig_call_with_message(const char *subname, const owl_message *m)
     251CALLER_OWN char *owl_perlconfig_call_with_message(const char *subname, const owl_message *m)
    254252{
    255253  dSP ;
     
    300298   If the return value is non-null, the caller must free it.
    301299 */
    302 G_GNUC_WARN_UNUSED_RESULT char *owl_perlconfig_message_call_method(const owl_message *m, const char *method, int argc, const char **argv)
     300CALLER_OWN char *owl_perlconfig_message_call_method(const owl_message *m, const char *method, int argc, const char **argv)
    303301{
    304302  dSP;
     
    350348
    351349/* caller must free result, if not NULL */
    352 G_GNUC_WARN_UNUSED_RESULT char *owl_perlconfig_initperl(const char *file, int *Pargc, char ***Pargv, char ***Penv)
     350CALLER_OWN char *owl_perlconfig_initperl(const char *file, int *Pargc, char ***Pargv, char ***Penv)
    353351{
    354352  int ret;
     
    436434
    437435/* caller is responsible for freeing returned string */
    438 G_GNUC_WARN_UNUSED_RESULT char *owl_perlconfig_execute(const char *line)
     436CALLER_OWN char *owl_perlconfig_execute(const char *line)
    439437{
    440438  STRLEN len;
     
    506504
    507505/* caller must free the result */
    508 G_GNUC_WARN_UNUSED_RESULT char *owl_perlconfig_perlcmd(const owl_cmd *cmd, int argc, const char *const *argv)
     506CALLER_OWN char *owl_perlconfig_perlcmd(const owl_cmd *cmd, int argc, const char *const *argv)
    509507{
    510508  int i, count;
  • perlglue.xs

    rbcde7926 rce68f23  
    329329all_filters()
    330330        PREINIT:
    331                 owl_list fl;
    332         CODE:
    333         {
    334                 owl_list_create(&fl);
    335                 owl_dict_get_keys(&g.filters, &fl);
    336                 RETVAL = owl_new_av(&fl, (SV*(*)(const void*))owl_new_sv);
     331                GPtrArray *fl;
     332        CODE:
     333        {
     334                fl = owl_dict_get_keys(&g.filters);
     335                RETVAL = owl_new_av(fl, (SV*(*)(const void*))owl_new_sv);
    337336                sv_2mortal((SV*)RETVAL);
    338                 owl_list_cleanup(&fl, g_free);
     337                owl_ptr_array_free(fl, g_free);
    339338        }
    340339        OUTPUT:
     
    344343all_styles()
    345344        PREINIT:
    346                 owl_list l;
    347         CODE:
    348         {
    349                 owl_list_create(&l);
    350                 owl_global_get_style_names(&g, &l);
    351                 RETVAL = owl_new_av(&l, (SV*(*)(const void*))owl_new_sv);
     345                GPtrArray *l;
     346        CODE:
     347        {
     348                l = owl_global_get_style_names(&g);
     349                RETVAL = owl_new_av(l, (SV*(*)(const void*))owl_new_sv);
    352350                sv_2mortal((SV*)RETVAL);
    353351        }
     
    355353                RETVAL
    356354        CLEANUP:
    357                 owl_list_cleanup(&l, g_free);
     355                owl_ptr_array_free(l, g_free);
    358356
    359357
     
    361359all_variables()
    362360        PREINIT:
    363                 owl_list l;
    364         CODE:
    365         {
    366                 owl_list_create(&l);
    367                 owl_dict_get_keys(owl_global_get_vardict(&g), &l);
    368                 RETVAL = owl_new_av(&l, (SV*(*)(const void*))owl_new_sv);
     361                GPtrArray *l;
     362        CODE:
     363        {
     364                l = owl_dict_get_keys(owl_global_get_vardict(&g));
     365                RETVAL = owl_new_av(l, (SV*(*)(const void*))owl_new_sv);
    369366                sv_2mortal((SV*)RETVAL);
    370367        }
     
    372369                RETVAL
    373370        CLEANUP:
    374                 owl_list_cleanup(&l, g_free);
     371                owl_ptr_array_free(l, g_free);
    375372
    376373
     
    378375all_keymaps()
    379376        PREINIT:
    380                 owl_list l;
     377                GPtrArray *l;
    381378                const owl_keyhandler *kh;
    382379        CODE:
    383380        {
    384381                kh = owl_global_get_keyhandler(&g);
    385                 owl_list_create(&l);
    386                 owl_keyhandler_get_keymap_names(kh, &l);
    387                 RETVAL = owl_new_av(&l, (SV*(*)(const void*))owl_new_sv);
     382                l = owl_keyhandler_get_keymap_names(kh);
     383                RETVAL = owl_new_av(l, (SV*(*)(const void*))owl_new_sv);
    388384                sv_2mortal((SV*)RETVAL);
    389385        }
     
    391387                RETVAL
    392388        CLEANUP:
    393                 owl_list_cleanup(&l, g_free);
     389                owl_ptr_array_free(l, g_free);
    394390
    395391void
  • popwin.c

    rd427f08 r6829afc  
    11#include "owl.h"
    22
    3 G_GNUC_WARN_UNUSED_RESULT owl_popwin *owl_popwin_new(void)
     3CALLER_OWN owl_popwin *owl_popwin_new(void)
    44{
    55  owl_popwin *pw = g_new0(owl_popwin, 1);
  • tester.c

    r4e37d56 r25891a8  
    2323int owl_fmtext_regtest(void);
    2424int owl_smartfilter_regtest(void);
     25int owl_history_regtest(void);
    2526
    2627extern void owl_perl_xs_init(pTHX);
     
    112113  numfailures += owl_fmtext_regtest();
    113114  numfailures += owl_smartfilter_regtest();
     115  numfailures += owl_history_regtest();
    114116  if (numfailures) {
    115117      fprintf(stderr, "# *** WARNING: %d failures total\n", numfailures);
     
    230232int owl_dict_regtest(void) {
    231233  owl_dict d;
    232   owl_list l;
     234  GPtrArray *l;
    233235  int numfailed=0;
    234236  char *av = g_strdup("aval"), *bv = g_strdup("bval"), *cv = g_strdup("cval"),
     
    251253
    252254  FAIL_UNLESS("get_size", 3==owl_dict_get_size(&d));
    253   owl_list_create(&l);
    254   owl_dict_get_keys(&d, &l);
    255   FAIL_UNLESS("get_keys result size", 3==owl_list_get_size(&l));
     255  l = owl_dict_get_keys(&d);
     256  FAIL_UNLESS("get_keys result size", 3 == l->len);
    256257 
    257258  /* these assume the returned keys are sorted */
    258   FAIL_UNLESS("get_keys result val",0==strcmp("a",owl_list_get_element(&l,0)));
    259   FAIL_UNLESS("get_keys result val",0==strcmp("b",owl_list_get_element(&l,1)));
    260   FAIL_UNLESS("get_keys result val",0==strcmp("c",owl_list_get_element(&l,2)));
    261 
    262   owl_list_cleanup(&l, g_free);
     259  FAIL_UNLESS("get_keys result val", 0 == strcmp("a", l->pdata[0]));
     260  FAIL_UNLESS("get_keys result val", 0 == strcmp("b", l->pdata[1]));
     261  FAIL_UNLESS("get_keys result val", 0 == strcmp("c", l->pdata[2]));
     262
     263  owl_ptr_array_free(l, g_free);
    263264  owl_dict_cleanup(&d, NULL);
    264265
     
    804805  return numfailed;
    805806}
     807
     808int owl_history_regtest(void)
     809{
     810  int numfailed = 0;
     811  int i;
     812  owl_history h;
     813
     814  printf("# BEGIN testing owl_history\n");
     815  owl_history_init(&h);
     816
     817  /* Operations on empty history. */
     818  FAIL_UNLESS("prev NULL", owl_history_get_prev(&h) == NULL);
     819  FAIL_UNLESS("next NULL", owl_history_get_next(&h) == NULL);
     820  FAIL_UNLESS("untouched", !owl_history_is_touched(&h));
     821
     822  /* Insert a few records. */
     823  owl_history_store(&h, "a", false);
     824  owl_history_store(&h, "b", false);
     825  owl_history_store(&h, "c", false);
     826  owl_history_store(&h, "d", true);
     827
     828  /* Walk up and down the history a bit. */
     829  FAIL_UNLESS("untouched", !owl_history_is_touched(&h));
     830  FAIL_UNLESS("prev c", strcmp(owl_history_get_prev(&h), "c") == 0);
     831  FAIL_UNLESS("touched", owl_history_is_touched(&h));
     832  FAIL_UNLESS("next d", strcmp(owl_history_get_next(&h), "d") == 0);
     833  FAIL_UNLESS("untouched", !owl_history_is_touched(&h));
     834  FAIL_UNLESS("next NULL", owl_history_get_next(&h) == NULL);
     835  FAIL_UNLESS("prev c", strcmp(owl_history_get_prev(&h), "c") == 0);
     836  FAIL_UNLESS("prev b", strcmp(owl_history_get_prev(&h), "b") == 0);
     837  FAIL_UNLESS("prev a", strcmp(owl_history_get_prev(&h), "a") == 0);
     838  FAIL_UNLESS("prev NULL", owl_history_get_prev(&h) == NULL);
     839
     840  /* Now insert something. It should reset and blow away 'd'. */
     841  owl_history_store(&h, "e", false);
     842  FAIL_UNLESS("untouched", !owl_history_is_touched(&h));
     843  FAIL_UNLESS("next NULL", owl_history_get_next(&h) == NULL);
     844  FAIL_UNLESS("prev c", strcmp(owl_history_get_prev(&h), "c") == 0);
     845  FAIL_UNLESS("touched", owl_history_is_touched(&h));
     846  FAIL_UNLESS("next e", strcmp(owl_history_get_next(&h), "e") == 0);
     847  FAIL_UNLESS("untouched", !owl_history_is_touched(&h));
     848
     849  /* Lines get de-duplicated on insert. */
     850  owl_history_store(&h, "e", false);
     851  owl_history_store(&h, "e", false);
     852  owl_history_store(&h, "e", false);
     853  FAIL_UNLESS("prev c", strcmp(owl_history_get_prev(&h), "c") == 0);
     854  FAIL_UNLESS("next e", strcmp(owl_history_get_next(&h), "e") == 0);
     855
     856  /* But a partial is not deduplicated, as it'll go away soon. */
     857  owl_history_store(&h, "e", true);
     858  FAIL_UNLESS("prev e", strcmp(owl_history_get_prev(&h), "e") == 0);
     859  FAIL_UNLESS("prev c", strcmp(owl_history_get_prev(&h), "c") == 0);
     860  FAIL_UNLESS("next e", strcmp(owl_history_get_next(&h), "e") == 0);
     861  FAIL_UNLESS("next e", strcmp(owl_history_get_next(&h), "e") == 0);
     862
     863  /* Reset moves to the front... */
     864  owl_history_store(&h, "f", true);
     865  FAIL_UNLESS("prev e", strcmp(owl_history_get_prev(&h), "e") == 0);
     866  FAIL_UNLESS("prev c", strcmp(owl_history_get_prev(&h), "c") == 0);
     867  owl_history_reset(&h);
     868  FAIL_UNLESS("untouched", !owl_history_is_touched(&h));
     869  /* ...and destroys any pending partial entry... */
     870  FAIL_UNLESS("prev c", strcmp(owl_history_get_prev(&h), "c") == 0);
     871  FAIL_UNLESS("prev b", strcmp(owl_history_get_prev(&h), "b") == 0);
     872  /* ...but not non-partial ones. */
     873  owl_history_reset(&h);
     874  FAIL_UNLESS("untouched", !owl_history_is_touched(&h));
     875
     876  /* Finally, check we are bounded by OWL_HISTORYSIZE. */
     877  for (i = 0; i < OWL_HISTORYSIZE; i++) {
     878    char *string = g_strdup_printf("mango%d", i);
     879    owl_history_store(&h, string, false);
     880    g_free(string);
     881  }
     882  /* The OWL_HISTORYSIZE'th prev gets NULL. */
     883  for (i = OWL_HISTORYSIZE - 2; i >= 0; i--) {
     884    char *string = g_strdup_printf("mango%d", i);
     885    FAIL_UNLESS("prev mango_N", strcmp(owl_history_get_prev(&h), string) == 0);
     886    g_free(string);
     887  }
     888  FAIL_UNLESS("prev NULL", owl_history_get_prev(&h) == NULL);
     889
     890  owl_history_cleanup(&h);
     891
     892  printf("# END testing owl_history (%d failures)\n", numfailed);
     893  return numfailed;
     894}
  • text.c

    rd427f08 r6829afc  
    77/* Returns a copy of 'in' with each line indented 'n'
    88 * characters. Result must be freed with g_free. */
    9 G_GNUC_WARN_UNUSED_RESULT char *owl_text_indent(const char *in, int n)
     9CALLER_OWN char *owl_text_indent(const char *in, int n)
    1010{
    1111  const char *ptr1, *ptr2, *last;
     
    4848
    4949/* caller must free the return */
    50 G_GNUC_WARN_UNUSED_RESULT char *owl_text_htmlstrip(const char *in)
     50CALLER_OWN char *owl_text_htmlstrip(const char *in)
    5151{
    5252  const char *ptr1, *end, *ptr2, *ptr3;
     
    129129
    130130/* Caller must free return */
    131 G_GNUC_WARN_UNUSED_RESULT char *owl_text_expand_tabs(const char *in)
     131CALLER_OWN char *owl_text_expand_tabs(const char *in)
    132132{
    133133  int len = 0;
     
    188188
    189189/* caller must free the return */
    190 G_GNUC_WARN_UNUSED_RESULT char *owl_text_wordwrap(const char *in, int col)
     190CALLER_OWN char *owl_text_wordwrap(const char *in, int col)
    191191{
    192192  char *out;
     
    269269 * Caller must free returned string.
    270270 */
    271 G_GNUC_WARN_UNUSED_RESULT char *owl_text_substitute(const char *in, const char *from, const char *to)
     271CALLER_OWN char *owl_text_substitute(const char *in, const char *from, const char *to)
    272272{
    273273  char **split = g_strsplit(in, from, 0), *out;
     
    284284 * On success returns the string, on error returns NULL.
    285285 */
    286 G_GNUC_WARN_UNUSED_RESULT char *owl_text_quote(const char *in, const char *toquote, const char *quotestr)
     286CALLER_OWN char *owl_text_quote(const char *in, const char *toquote, const char *quotestr)
    287287{
    288288  int i, x, r, place, escape;
  • variable.c

    rd427f08 rce68f23  
    646646}
    647647
    648 G_GNUC_WARN_UNUSED_RESULT owl_variable *owl_variable_newvar(const char *name, const char *summary, const char *description)
     648CALLER_OWN owl_variable *owl_variable_newvar(const char *name, const char *summary, const char *description)
    649649{
    650650  owl_variable * var = g_new0(owl_variable, 1);
     
    729729}
    730730
    731 void owl_variable_dict_get_names(const owl_vardict *d, owl_list *l) {
    732   owl_dict_get_keys(d, l);
     731CALLER_OWN GPtrArray *owl_variable_dict_get_names(const owl_vardict *d) {
     732  return owl_dict_get_keys(d);
    733733}
    734734
     
    825825}
    826826
    827 G_GNUC_WARN_UNUSED_RESULT char *owl_variable_get_tostring(const owl_vardict *d, const char *name)
     827CALLER_OWN char *owl_variable_get_tostring(const owl_vardict *d, const char *name)
    828828{
    829829  owl_variable *v;
     
    834834}
    835835
    836 G_GNUC_WARN_UNUSED_RESULT char *owl_variable_get_default_tostring(const owl_vardict *d, const char *name)
     836CALLER_OWN char *owl_variable_get_default_tostring(const owl_vardict *d, const char *name)
    837837{
    838838  owl_variable *v;
     
    995995}
    996996
    997 G_GNUC_WARN_UNUSED_RESULT char *owl_variable_bool_get_tostring_default(const owl_variable *v, const void *val)
     997CALLER_OWN char *owl_variable_bool_get_tostring_default(const owl_variable *v, const void *val)
    998998{
    999999  if (val == NULL) {
     
    10311031}
    10321032
    1033 G_GNUC_WARN_UNUSED_RESULT char *owl_variable_int_get_tostring_default(const owl_variable *v, const void *val)
     1033CALLER_OWN char *owl_variable_int_get_tostring_default(const owl_variable *v, const void *val)
    10341034{
    10351035  if (val == NULL) {
     
    10711071}
    10721072
    1073 G_GNUC_WARN_UNUSED_RESULT char *owl_variable_enum_get_tostring(const owl_variable *v, const void *val)
     1073CALLER_OWN char *owl_variable_enum_get_tostring(const owl_variable *v, const void *val)
    10741074{
    10751075  char **enums;
     
    11121112}
    11131113
    1114 G_GNUC_WARN_UNUSED_RESULT char *owl_variable_string_get_tostring_default(const owl_variable *v, const void *val)
     1114CALLER_OWN char *owl_variable_string_get_tostring_default(const owl_variable *v, const void *val)
    11151115{
    11161116  if (val == NULL) {
  • view.c

    r3b8a563 rfc8a87a  
    3737  ml=&(v->ml);
    3838
    39   /* nuke the old list */
    40   owl_list_cleanup(&ml->list, NULL);
     39  /* nuke the old list, don't free the messages */
     40  owl_messagelist_cleanup(ml, false);
    4141  owl_messagelist_create(&(v->ml));
    4242
     
    159159void owl_view_cleanup(owl_view *v)
    160160{
    161   owl_list_cleanup(&v->ml.list, NULL);
     161  owl_messagelist_cleanup(&v->ml, false);
    162162  g_free(v->name);
    163163}
  • viewwin.c

    rd427f08 r6829afc  
    1212 * will be used by the viewwin
    1313 */
    14 G_GNUC_WARN_UNUSED_RESULT owl_viewwin *owl_viewwin_new_text(owl_window *win, const char *text)
     14CALLER_OWN owl_viewwin *owl_viewwin_new_text(owl_window *win, const char *text)
    1515{
    1616  owl_viewwin *v = g_new0(owl_viewwin, 1);
     
    3434 * will be used by the viewwin
    3535 */
    36 G_GNUC_WARN_UNUSED_RESULT owl_viewwin *owl_viewwin_new_fmtext(owl_window *win, const owl_fmtext *fmtext)
     36CALLER_OWN owl_viewwin *owl_viewwin_new_fmtext(owl_window *win, const owl_fmtext *fmtext)
    3737{
    3838  char *text;
     
    237237}
    238238
    239 G_GNUC_WARN_UNUSED_RESULT owl_editwin *owl_viewwin_set_typwin_active(owl_viewwin *v, owl_history *hist) {
     239CALLER_OWN owl_editwin *owl_viewwin_set_typwin_active(owl_viewwin *v, owl_history *hist) {
    240240  int lines, cols;
    241241  owl_editwin *cmdline;
  • window.c

    rd427f08 r6829afc  
    569569};
    570570
    571 G_GNUC_WARN_UNUSED_RESULT GSource *owl_window_redraw_source_new(void)
     571CALLER_OWN GSource *owl_window_redraw_source_new(void)
    572572{
    573573  GSource *source;
  • zbuddylist.c

    rddbbcffa r7ed9bc6  
    33void owl_zbuddylist_create(owl_zbuddylist *zb)
    44{
    5   owl_list_create(&(zb->zusers));
     5  zb->zusers = g_ptr_array_new();
    66}
    77
    88int owl_zbuddylist_adduser(owl_zbuddylist *zb, const char *name)
    99{
    10   int i, j;
     10  int i;
    1111  char *user;
    1212
    1313  user=long_zuser(name);
    1414
    15   j=owl_list_get_size(&(zb->zusers));
    16   for (i=0; i<j; i++) {
    17     if (!strcasecmp(user, owl_list_get_element(&(zb->zusers), i))) {
     15  for (i = 0; i < zb->zusers->len; i++) {
     16    if (!strcasecmp(user, zb->zusers->pdata[i])) {
    1817      g_free(user);
    1918      return(-1);
    2019    }
    2120  }
    22   owl_list_append_element(&(zb->zusers), user);
     21  g_ptr_array_add(zb->zusers, user);
    2322  return(0);
    2423}
     
    2625int owl_zbuddylist_deluser(owl_zbuddylist *zb, const char *name)
    2726{
    28   int i, j;
    29   char *user, *ptr;
     27  int i;
     28  char *user;
    3029
    3130  user=long_zuser(name);
    3231
    33   j=owl_list_get_size(&(zb->zusers));
    34   for (i=0; i<j; i++) {
    35     ptr=owl_list_get_element(&(zb->zusers), i);
    36     if (!strcasecmp(user, ptr)) {
    37       owl_list_remove_element(&(zb->zusers), i);
    38       g_free(ptr);
     32  for (i = 0; i < zb->zusers->len; i++) {
     33    if (!strcasecmp(user, zb->zusers->pdata[i])) {
     34      g_free(g_ptr_array_remove_index(zb->zusers, i));
    3935      g_free(user);
    4036      return(0);
     
    4743int owl_zbuddylist_contains_user(const owl_zbuddylist *zb, const char *name)
    4844{
    49   int i, j;
     45  int i;
    5046  char *user;
    5147
    5248  user=long_zuser(name);
    5349
    54   j=owl_list_get_size(&(zb->zusers));
    55   for (i=0; i<j; i++) {
    56     if (!strcasecmp(user, owl_list_get_element(&(zb->zusers), i))) {
     50  for (i = 0; i < zb->zusers->len; i++) {
     51    if (!strcasecmp(user, zb->zusers->pdata[i])) {
    5752      g_free(user);
    5853      return(1);
  • zcrypt.c

    rd427f08 r6829afc  
    2727#include "filterproc.h"
    2828
     29/* Annotate functions in which the caller owns the return value and is
     30 * responsible for ensuring it is freed. */
     31#define CALLER_OWN G_GNUC_WARN_UNUSED_RESULT
     32
    2933#define MAX_KEY      128
    3034#define MAX_LINE     128
     
    5357} ZWRITEOPTIONS;
    5458
    55 G_GNUC_WARN_UNUSED_RESULT char *GetZephyrVarKeyFile(const char *whoami, const char *class, const char *instance);
     59CALLER_OWN char *GetZephyrVarKeyFile(const char *whoami, const char *class, const char *instance);
    5660int ParseCryptSpec(const char *spec, const char **keyfile);
    57 G_GNUC_WARN_UNUSED_RESULT char *BuildArgString(char **argv, int start, int end);
    58 G_GNUC_WARN_UNUSED_RESULT char *read_keystring(const char *keyfile);
     61CALLER_OWN char *BuildArgString(char **argv, int start, int end);
     62CALLER_OWN char *read_keystring(const char *keyfile);
    5963
    6064int do_encrypt(int zephyr, const char *class, const char *instance,
     
    364368/* Build a space-separated string from argv from elements between start  *
    365369 * and end - 1.  malloc()'s the returned string. */
    366 G_GNUC_WARN_UNUSED_RESULT char *BuildArgString(char **argv, int start, int end)
     370CALLER_OWN char *BuildArgString(char **argv, int start, int end)
    367371{
    368372  int len = 1;
     
    401405#define MAX_SEARCH 3
    402406/* Find the class/instance in the .crypt-table */
    403 G_GNUC_WARN_UNUSED_RESULT char *GetZephyrVarKeyFile(const char *whoami, const char *class, const char *instance)
     407CALLER_OWN char *GetZephyrVarKeyFile(const char *whoami, const char *class, const char *instance)
    404408{
    405409  char *keyfile = NULL;
     
    579583}
    580584
    581 G_GNUC_WARN_UNUSED_RESULT char *slurp_stdin(int ignoredot, int *length) {
     585CALLER_OWN char *slurp_stdin(int ignoredot, int *length) {
    582586  char *buf;
    583587  char *inptr;
     
    611615}
    612616
    613 G_GNUC_WARN_UNUSED_RESULT char *GetInputBuffer(ZWRITEOPTIONS *zoptions, int *length) {
     617CALLER_OWN char *GetInputBuffer(ZWRITEOPTIONS *zoptions, int *length) {
    614618  char *buf;
    615619
     
    637641}
    638642
    639 G_GNUC_WARN_UNUSED_RESULT char *read_keystring(const char *keyfile) {
     643CALLER_OWN char *read_keystring(const char *keyfile) {
    640644  char *keystring;
    641645  FILE *fkey = fopen(keyfile, "r");
  • zephyr.c

    rd427f08 recffae6  
    524524 */
    525525#ifdef HAVE_LIBZEPHYR
    526 G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_get_field(const ZNotice_t *n, int j)
     526CALLER_OWN char *owl_zephyr_get_field(const ZNotice_t *n, int j)
    527527{
    528528  int i, count, save;
     
    552552}
    553553
    554 G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_get_field_as_utf8(const ZNotice_t *n, int j)
     554CALLER_OWN char *owl_zephyr_get_field_as_utf8(const ZNotice_t *n, int j)
    555555{
    556556  int i, count, save;
     
    584584}
    585585#else
    586 G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_get_field(void *n, int j)
     586CALLER_OWN char *owl_zephyr_get_field(void *n, int j)
    587587{
    588588  return(g_strdup(""));
    589589}
    590 G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_get_field_as_utf8(void *n, int j)
     590CALLER_OWN char *owl_zephyr_get_field_as_utf8(void *n, int j)
    591591{
    592592  return owl_zephyr_get_field(n, j);
     
    621621 * caller must free the return
    622622 */
    623 G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_get_message(const ZNotice_t *n, const owl_message *m)
     623CALLER_OWN char *owl_zephyr_get_message(const ZNotice_t *n, const owl_message *m)
    624624{
    625625#define OWL_NFIELDS     5
     
    838838      zw.opcode = g_strdup(retnotice->z_opcode);
    839839      zw.zsig   = g_strdup("");
    840       owl_list_create(&(zw.recips));
    841       owl_list_append_element(&(zw.recips), g_strdup(retnotice->z_recipient));
     840      zw.recips = g_ptr_array_new();
     841      g_ptr_array_add(zw.recips, g_strdup(retnotice->z_recipient));
    842842
    843843      owl_log_outgoing_zephyr_error(&zw, buff);
     
    942942#endif
    943943
    944 G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_zlocate(const char *user, int auth)
     944CALLER_OWN char *owl_zephyr_zlocate(const char *user, int auth)
    945945{
    946946#ifdef HAVE_LIBZEPHYR
     
    10421042
    10431043/* caller must free the return */
    1044 G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_makesubline(const char *class, const char *inst, const char *recip)
     1044CALLER_OWN char *owl_zephyr_makesubline(const char *class, const char *inst, const char *recip)
    10451045{
    10461046  return g_strdup_printf("%s,%s,%s\n", class, inst, !strcmp(recip, "") ? "*" : recip);
     
    11221122 * free the return.
    11231123 */
    1124 G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_getsubs(void)
     1124CALLER_OWN char *owl_zephyr_getsubs(void)
    11251125{
    11261126#ifdef HAVE_LIBZEPHYR
     
    12421242 * The caller must free the return
    12431243 */
    1244 G_GNUC_WARN_UNUSED_RESULT char *short_zuser(const char *in)
     1244CALLER_OWN char *short_zuser(const char *in)
    12451245{
    12461246  char *ptr = strrchr(in, '@');
     
    12541254 * The caller must free the return.
    12551255 */
    1256 G_GNUC_WARN_UNUSED_RESULT char *long_zuser(const char *in)
     1256CALLER_OWN char *long_zuser(const char *in)
    12571257{
    12581258  char *ptr = strrchr(in, '@');
     
    12821282 * caller must free the return.
    12831283 */
    1284 G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_smartstripped_user(const char *in)
     1284CALLER_OWN char *owl_zephyr_smartstripped_user(const char *in)
    12851285{
    12861286  char *slash, *dot, *realm, *out;
     
    13241324}
    13251325
    1326 /* read the list of users in 'filename' as a .anyone file, and put the
    1327  * names of the zephyr users in the list 'in'.  If 'filename' is NULL,
    1328  * use the default .anyone file in the users home directory.  Returns
    1329  * -1 on failure, 0 on success.
     1326/* Read the list of users in 'filename' as a .anyone file, and return as a
     1327 * GPtrArray of strings.  If 'filename' is NULL, use the default .anyone file
     1328 * in the users home directory.  Returns NULL on failure.
    13301329 */
    1331 int owl_zephyr_get_anyone_list(owl_list *in, const char *filename)
     1330GPtrArray *owl_zephyr_get_anyone_list(const char *filename)
    13321331{
    13331332#ifdef HAVE_LIBZEPHYR
    13341333  char *ourfile, *tmp, *s = NULL;
    13351334  FILE *f;
     1335  GPtrArray *list;
    13361336
    13371337  ourfile = owl_zephyr_dotfile(".anyone", filename);
     
    13411341    owl_function_error("Error opening file %s: %s", ourfile, strerror(errno) ? strerror(errno) : "");
    13421342    g_free(ourfile);
    1343     return -1;
     1343    return NULL;
    13441344  }
    13451345  g_free(ourfile);
    13461346
     1347  list = g_ptr_array_new();
    13471348  while (owl_getline_chomp(&s, f)) {
    13481349    /* ignore comments, blank lines etc. */
     
    13601361      tmp[0] = '\0';
    13611362
    1362     owl_list_append_element(in, long_zuser(s));
     1363    g_ptr_array_add(list, long_zuser(s));
    13631364  }
    13641365  g_free(s);
    13651366  fclose(f);
    1366   return 0;
    1367 #else
    1368   return -1;
     1367  return list;
     1368#else
     1369  return NULL;
    13691370#endif
    13701371}
  • zwrite.c

    rd427f08 r3cdd6d2  
    55#include "owl.h"
    66
    7 G_GNUC_WARN_UNUSED_RESULT owl_zwrite *owl_zwrite_new(const char *line)
     7CALLER_OWN owl_zwrite *owl_zwrite_new(const char *line)
    88{
    99  owl_zwrite *z = g_new(owl_zwrite, 1);
     
    3434  z->cc=0;
    3535  z->noping=0;
    36   owl_list_create(&(z->recips));
     36  z->recips = g_ptr_array_new();
    3737  z->zwriteline = g_strdup(line);
    3838
     
    9797      }
    9898      /* we must already have users or a class or an instance */
    99       if (owl_list_get_size(&(z->recips))<1 && (!z->class) && (!z->inst)) {
     99      if (z->recips->len < 1 && (!z->class) && (!z->inst)) {
    100100        badargs=1;
    101101        break;
     
    117117    } else {
    118118      /* anything unattached is a recipient */
    119       owl_list_append_element(&(z->recips), owl_validate_utf8(myargv[0]));
     119      g_ptr_array_add(z->recips, owl_validate_utf8(myargv[0]));
    120120      myargv++;
    121121      myargc--;
     
    131131  if (z->class == NULL &&
    132132      z->inst == NULL &&
    133       owl_list_get_size(&(z->recips))==0) {
     133      z->recips->len == 0) {
    134134    owl_function_error("You must specify a recipient for zwrite");
    135135    return(-1);
     
    162162void owl_zwrite_send_ping(const owl_zwrite *z)
    163163{
    164   int i, j;
     164  int i;
    165165  char *to;
    166166
     
    173173  /* if there are no recipients we won't send a ping, which
    174174     is what we want */
    175   j=owl_list_get_size(&(z->recips));
    176   for (i=0; i<j; i++) {
     175  for (i = 0; i < z->recips->len; i++) {
    177176    to = owl_zwrite_get_recip_n_with_realm(z, i);
    178177    send_ping(to, z->class, z->inst);
     
    191190void owl_zwrite_set_message(owl_zwrite *z, const char *msg)
    192191{
    193   int i, j;
     192  int i;
    194193  GString *message;
    195194  char *tmp = NULL, *tmp2;
     
    197196  g_free(z->message);
    198197
    199   j=owl_list_get_size(&(z->recips));
    200   if (j>0 && z->cc) {
     198  if (z->recips->len > 0 && z->cc) {
    201199    message = g_string_new("CC: ");
    202     for (i=0; i<j; i++) {
     200    for (i = 0; i < z->recips->len; i++) {
    203201      tmp = owl_zwrite_get_recip_n_with_realm(z, i);
    204202      g_string_append_printf(message, "%s ", tmp);
     
    233231int owl_zwrite_send_message(const owl_zwrite *z)
    234232{
    235   int i, j, ret = 0;
     233  int i, ret = 0;
    236234  char *to = NULL;
    237235
    238236  if (z->message==NULL) return(-1);
    239237
    240   j=owl_list_get_size(&(z->recips));
    241   if (j>0) {
    242     for (i=0; i<j; i++) {
     238  if (z->recips->len > 0) {
     239    for (i = 0; i < z->recips->len; i++) {
    243240      to = owl_zwrite_get_recip_n_with_realm(z, i);
    244241      ret = send_zephyr(z->opcode, z->zsig, z->class, z->inst, to, z->message);
     
    312309int owl_zwrite_get_numrecips(const owl_zwrite *z)
    313310{
    314   return(owl_list_get_size(&(z->recips)));
     311  return z->recips->len;
    315312}
    316313
    317314const char *owl_zwrite_get_recip_n(const owl_zwrite *z, int n)
    318315{
    319   return(owl_list_get_element(&(z->recips), n));
     316  return z->recips->pdata[n];
    320317}
    321318
    322319/* Caller must free the result. */
    323 G_GNUC_WARN_UNUSED_RESULT char *owl_zwrite_get_recip_n_with_realm(const owl_zwrite *z, int n)
     320CALLER_OWN char *owl_zwrite_get_recip_n_with_realm(const owl_zwrite *z, int n)
    324321{
    325322  if (z->realm[0]) {
     
    333330{
    334331  /* return true if at least one of the recipients is personal */
    335   int i, j;
    336   char *foo;
    337 
    338   j=owl_list_get_size(&(z->recips));
    339   for (i=0; i<j; i++) {
    340     foo=owl_list_get_element(&(z->recips), i);
    341     if (foo[0]!='@') return(1);
     332  int i;
     333  char *recip;
     334
     335  for (i = 0; i < z->recips->len; i++) {
     336    recip = z->recips->pdata[i];
     337    if (recip[0] != '@') return 1;
    342338  }
    343339  return(0);
     
    352348void owl_zwrite_cleanup(owl_zwrite *z)
    353349{
    354   owl_list_cleanup(&(z->recips), &g_free);
     350  owl_ptr_array_free(z->recips, g_free);
    355351  g_free(z->cmd);
    356352  g_free(z->zwriteline);
     
    370366 * If not a CC, only the recip_index'th user will be replied to.
    371367 */
    372 G_GNUC_WARN_UNUSED_RESULT char *owl_zwrite_get_replyline(const owl_zwrite *z, int recip_index)
     368CALLER_OWN char *owl_zwrite_get_replyline(const owl_zwrite *z, int recip_index)
    373369{
    374370  /* Match ordering in zwrite help. */
     
    403399  }
    404400  if (z->cc) {
    405     for (i = 0; i < owl_list_get_size(&(z->recips)); i++) {
     401    for (i = 0; i < z->recips->len; i++) {
    406402      g_string_append_c(buf, ' ');
    407       owl_string_append_quoted_arg(buf, owl_list_get_element(&(z->recips), i));
     403      owl_string_append_quoted_arg(buf, z->recips->pdata[i]);
    408404    }
    409   } else if (recip_index < owl_list_get_size(&(z->recips))) {
     405  } else if (recip_index < z->recips->len) {
    410406    g_string_append_c(buf, ' ');
    411     owl_string_append_quoted_arg(buf, owl_list_get_element(&(z->recips), recip_index));
     407    owl_string_append_quoted_arg(buf, z->recips->pdata[recip_index]);
    412408  }
    413409
Note: See TracChangeset for help on using the changeset viewer.