Changeset e1d3607
- Timestamp:
- Jun 25, 2011, 7:22:24 AM (14 years ago)
- 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. - 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" 2 2 .SH NAME 3 barnowl \- ttybased zephyr client3 BarnOwl \- tty\(hybased zephyr client 4 4 .SH SYNOPSIS 5 5 .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] 25 14 .br 26 15 .SH DESCRIPTION 27 16 .B BarnOwl 28 is a fully integrated tty 29 it supports AOL Instant Messenger, MIT Zephyr, and Jabber. It is30 curses -based, allows for emacs-style editing of outgoing messagesand31 uses perl as an extension and configuration language. BarnOwlwill17 is a fully integrated tty\(hybased instant messaging client. Currently 18 it supports AOL Instant Messenger, MIT Zephyr, Jabber, IRC, and Twitter. It is 19 curses\(hybased, allows for emacs\(hystyle editing of outgoing messages, and 20 uses Perl as an extension and configuration language. \fBBarnOwl\fP will 32 21 also run happily without a configuration file. 33 22 34 Once BarnOwl is started, typing 'h'will display a help screen.35 Typing \ ':\' enters command mode, allowing the user to type a barnowl23 Once \fBBarnOwl\fP is started, typing \(oqh\(cq will display a help screen. 24 Typing \(oq:\(cq enters command mode, allowing the user to type a \fBBarnOwl\fP 36 25 command line. 37 26 38 .PP 39 .SH USE 40 The following command line options are avilable when running barnowl: 27 .SH OPTIONS 28 The following command\-line options are avilable when running \fBBarnOwl\fP: 29 .TP 30 \fB\-n\fP, \fB\-\-no\-subs\fP 31 Do not subscribe to zephyr messages on startup. By default, \fBBarnOwl\fP 32 subscribes to the default subscriptions and to anything found in 33 \fI~/.zephyr.subs\fP. When this option is used, no subscriptions are loaded. 41 34 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 37 Specify 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. 48 39 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 42 Specify an alternate configuration directory. By default, \fBBarnOwl\fP uses 43 \fI~/.owl/\fP. 54 44 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 47 Specify the tty name to use for the zephyr location. 60 48 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 51 Print the version number of \fBBarnOwl\fP and exit. 65 52 66 . B \-v67 .IP68 Print the version number of barnowl and exit. 69 .LP 53 .TP 54 \fB\-d\fP, \fB\-\-debug\fP 55 Enable debugging. By default, debugging information is placed in 56 \fI/var/tmp/barnowl\-debug.PID\fP. 70 57 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 60 Print command\(hyline option help. 76 61 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 88 63 Written by Nelson Elhage and Alejandro Sedeno at the Massachusetts 89 Institute of Technology. Based on Owl by James Kretchmar.64 Institute of Technology. Based on Owl by James Kretchmar. 90 65 91 66 Comments, questions, and bug reports may be mailed to 92 \fBbug -barnowl@mit.edu\fP.67 \fBbug\-barnowl@mit.edu\fP. -
functions.c
rce68f23 re1d3607 127 127 128 128 text="" 129 " barnowl version " OWL_VERSION_STRING "\n"129 "BarnOwl version " OWL_VERSION_STRING "\n" 130 130 "Copyright (c) 2006-2011 The BarnOwl Developers. All rights reserved.\n" 131 131 "Copyright (c) 2004 James Kretchmar. All rights reserved.\n" … … 1305 1305 { 1306 1306 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" 1309 1309 "maintained by Alejandro Sedeno and Nelson Elhage at the\n" 1310 1310 "Massachusetts Institute of Technology. \n" … … 1315 1315 "The name 'owl' was chosen in reference to the owls in the\n" 1316 1316 "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" 1318 1318 "because we feel our owls should live closer to our ponies.\n" 1319 1319 "\n" -
owl.c
r2244836 r413c910 89 89 break; 90 90 case 'v': 91 printf("This is barnowl version %s\n", OWL_VERSION_STRING);91 printf("This is BarnOwl version %s\n", OWL_VERSION_STRING); 92 92 exit(0); 93 93 case 'h': … … 584 584 owl_function_adminmsg("", 585 585 "-----------------------------------------------------------------------\n" 586 "Welcome to barnowl version " OWL_VERSION_STRING ".\n"586 "Welcome to BarnOwl version " OWL_VERSION_STRING ".\n" 587 587 "To see a quick introduction, type ':show quickstart'. \n" 588 588 "Press 'h' for on-line help. \n" -
owl_perl.h
r06adc25 r413c910 13 13 * * args - a code block responsible for pushing args (other than the object) 14 14 * * err - a string with a %s format specifier to log in case of error 15 * * fatalp - if true, perl errors terminate barnowl15 * * fatalp - if true, perl errors terminate BarnOwl 16 16 * * ret - a code block executed if the call succeeded 17 17 * -
perl/lib/BarnOwl.pm
rbcde7926 r413c910 52 52 The BarnOwl module contains the core of BarnOwl's perl 53 53 bindings. Source in this module is also run at startup to bootstrap 54 barnowl by defining things like the default style.54 BarnOwl by defining things like the default style. 55 55 56 56 =for NOTE … … 80 80 =head2 zephyr_getrealm 81 81 82 Returns the zephyr realm barnowl is running in82 Returns the zephyr realm BarnOwl is running in 83 83 84 84 =head2 zephyr_getsender 85 85 86 Returns the fully-qualified name of the zephyr sender barnowl is86 Returns the fully-qualified name of the zephyr sender BarnOwl is 87 87 running as, e.g. C<nelhage@ATHENA.MIT.EDU> 88 88 … … 239 239 =head2 create_style NAME OBJECT 240 240 241 Creates a new barnowl style with the given NAME defined by the given241 Creates a new BarnOwl style with the given NAME defined by the given 242 242 object. The object must have a C<description> method which returns a 243 243 string description of the style, and a and C<format_message> method -
perl/lib/BarnOwl/Hooks.pm
r3aa0522 r413c910 146 146 } 147 147 148 # These are the internal hooks called by the barnowl C code, which148 # These are the internal hooks called by the BarnOwl C code, which 149 149 # take care of dispatching to the appropriate perl hooks, and deal 150 150 # with compatibility by calling the old, fixed-name hooks. -
perl/lib/Module/Install/BarnOwl.pm
r3519d06 r413c910 8 8 =head1 DESCRIPTION 9 9 10 Module::Install::BarnOwl is a M::I module to help building barnowl10 Module::Install::BarnOwl is a M::I module to help building BarnOwl 11 11 modules, 12 12 … … 28 28 29 29 As well as make rules to generate Jabber.par, and to put some 30 additional barnowl-specific information into META.yml30 additional BarnOwl-specific information into META.yml 31 31 32 32 =cut -
perl/modules/IRC/lib/BarnOwl/Module/IRC.pm
r5c6d661 r413c910 10 10 =head1 DESCRIPTION 11 11 12 This module implements IRC support for barnowl.12 This module implements IRC support for BarnOwl. 13 13 14 14 =cut -
perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm
rc8d9f84 r413c910 10 10 =head1 DESCRIPTION 11 11 12 This module implements Jabber support for barnowl.12 This module implements Jabber support for BarnOwl. 13 13 14 14 =cut … … 36 36 if($IO::Socket::SSL::VERSION eq "0.97") { 37 37 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" . 39 39 "Jabber support. We recommend updating to the latest\n" . 40 40 "IO::Socket::SSL from CPAN. \n"); -
perl/modules/Jabber/lib/BarnOwl/Module/Jabber/ConnectionManager.pm
r2cca044 r413c910 8 8 =head1 DESCRIPTION 9 9 10 A class to keep track of all the active connection in the barnowl11 jabber module10 A class to keep track of all the active connection in the BarnOwl 11 Jabber module 12 12 13 13 =cut -
perl/modules/Twitter/README
r8c6e2c1 r413c910 118 118 the sender. Has no effect if poll_for_tweets is false. 119 119 120 * oauth_key, oauth_secret (strings, default barnowl's consumer credentials)120 * oauth_key, oauth_secret (strings, default BarnOwl's consumer credentials) 121 121 These are the OAuth consumer key and secret to use to negotiate an 122 122 OAuth connection to Twitter. These credentials must be enabled for -
perl/modules/Twitter/lib/BarnOwl/Module/Twitter.pm
rf6e1262 r413c910 193 193 194 194 sub poll_messages { 195 # If we are reloaded into a barnowl with the old195 # If we are reloaded into a BarnOwl with the old 196 196 # BarnOwl::Module::Twitter loaded, it still has a main loop hook 197 197 # that will call this function every second. If we just delete it, -
scripts/do-release
r74312ad r413c910 9 9 cat >&2 <<EOF 10 10 Usage: $0 [options] 11 Generate a barnowl release tarball.11 Generate a BarnOwl release tarball. 12 12 13 13 OPTIONS: … … 37 37 else 38 38 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" 40 40 fi 41 41 TAG=barnowl-$VERS -
util.c
r3cdd6d2 re1d3607 221 221 /* 222 222 * 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 barnowl223 * the varargs provided, quoting them to be safe for placing in a BarnOwl 224 224 * command line. 225 225 */ -
Makefile.am
r4f746f8 rc266281 38 38 $(GIT_FLAGS) 39 39 40 CODELIST_SRCS= list.cmessage.c mainwin.c popwin.c zephyr.c messagelist.c \40 CODELIST_SRCS=message.c mainwin.c popwin.c zephyr.c messagelist.c \ 41 41 commands.c global.c text.c fmtext.c editwin.c util.c logging.c \ 42 42 perlconfig.c keys.c functions.c zwrite.c viewwin.c help.c filter.c \ -
aim.c
rd427f08 re4524da 437 437 438 438 /* caller must free the return */ 439 G_GNUC_WARN_UNUSED_RESULTchar *owl_aim_normalize_screenname(const char *in)439 CALLER_OWN char *owl_aim_normalize_screenname(const char *in) 440 440 { 441 441 char *out; … … 1439 1439 const char *address, *SNs; 1440 1440 int num, i; 1441 owl_listlist;1441 GPtrArray *list; 1442 1442 1443 1443 va_start(ap, fr); … … 1447 1447 va_end(ap); 1448 1448 1449 owl_list_create(&list);1449 list = g_ptr_array_new(); 1450 1450 1451 1451 owl_function_debugmsg("faimtest_parse_searchreply: E-Mail Search Results for %s: ", address); 1452 1452 for (i=0; i<num; i++) { 1453 1453 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; 1459 1459 } 1460 1460 -
buddylist.c
r96828e4 r3cdd6d2 3 3 void owl_buddylist_init(owl_buddylist *bl) 4 4 { 5 owl_list_create(&(bl->buddies));5 bl->buddies = g_ptr_array_new(); 6 6 } 7 7 … … 14 14 15 15 owl_buddy_create(b, OWL_PROTOCOL_AIM, screenname); 16 owl_list_append_element(&(bl->buddies), b);16 g_ptr_array_add(bl->buddies, b); 17 17 } 18 18 … … 21 21 int owl_buddylist_remove_aim_buddy(owl_buddylist *bl, const char *name) 22 22 { 23 int i , j;23 int i; 24 24 owl_buddy *b; 25 25 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]; 29 28 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)); 32 30 return(0); 33 31 } … … 87 85 int owl_buddylist_get_size(const owl_buddylist *bl) 88 86 { 89 return (owl_list_get_size(&(bl->buddies)));87 return bl->buddies->len; 90 88 } 91 89 … … 97 95 if (index>(owl_buddylist_get_size(bl)-1)) return(NULL); 98 96 99 return (owl_list_get_element(&(bl->buddies), index));97 return bl->buddies->pdata[index]; 100 98 } 101 99 … … 105 103 owl_buddy *owl_buddylist_get_aim_buddy(const owl_buddylist *bl, const char *name) 106 104 { 107 int i , j;105 int i; 108 106 owl_buddy *b; 109 107 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]; 113 110 if (!strcasecmp(name, owl_buddy_get_name(b))) return(b); 114 111 } … … 131 128 void owl_buddylist_clear(owl_buddylist *bl) 132 129 { 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); 135 132 } 136 133 137 134 void owl_buddylist_cleanup(owl_buddylist *bl) 138 135 { 139 owl_ list_cleanup(&(bl->buddies), (void (*)(void *))owl_buddy_delete);136 owl_ptr_array_free(bl->buddies, (GDestroyNotify)owl_buddy_delete); 140 137 } -
cmd.c
rd427f08 rce68f23 28 28 } 29 29 30 void owl_cmddict_get_names(const owl_cmddict *d, owl_list *l) {31 owl_dict_get_keys(d, l);30 GPtrArray *owl_cmddict_get_names(const owl_cmddict *d) { 31 return owl_dict_get_keys(d); 32 32 } 33 33 … … 56 56 57 57 /* caller must free the return */ 58 G_GNUC_WARN_UNUSED_RESULTchar *_owl_cmddict_execute(const owl_cmddict *cd, const owl_context *ctx, const char *const *argv, int argc, const char *buff)58 CALLER_OWN char *_owl_cmddict_execute(const owl_cmddict *cd, const owl_context *ctx, const char *const *argv, int argc, const char *buff) 59 59 { 60 60 char *retval = NULL; … … 73 73 74 74 /* caller must free the return */ 75 G_GNUC_WARN_UNUSED_RESULTchar *owl_cmddict_execute(const owl_cmddict *cd, const owl_context *ctx, const char *cmdbuff)75 CALLER_OWN char *owl_cmddict_execute(const owl_cmddict *cd, const owl_context *ctx, const char *cmdbuff) 76 76 { 77 77 char **argv; … … 97 97 98 98 /* caller must free the return */ 99 G_GNUC_WARN_UNUSED_RESULTchar *owl_cmddict_execute_argv(const owl_cmddict *cd, const owl_context *ctx, const char *const *argv, int argc)99 CALLER_OWN char *owl_cmddict_execute_argv(const owl_cmddict *cd, const owl_context *ctx, const char *const *argv, int argc) 100 100 { 101 101 char *buff; … … 154 154 155 155 /* caller must free the result */ 156 G_GNUC_WARN_UNUSED_RESULTchar *owl_cmd_execute(const owl_cmd *cmd, const owl_cmddict *cd, const owl_context *ctx, int argc, const char *const *argv, const char *cmdbuff)156 CALLER_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) 157 157 { 158 158 static int alias_recurse_depth = 0; … … 228 228 229 229 /* returns a summary line describing this keymap. the caller must free. */ 230 G_GNUC_WARN_UNUSED_RESULTchar *owl_cmd_describe(const owl_cmd *cmd)230 CALLER_OWN char *owl_cmd_describe(const owl_cmd *cmd) 231 231 { 232 232 if (!cmd || !cmd->name || !cmd->summary) return NULL; -
commands.c
rd427f08 re6d7e4e 1373 1373 } 1374 1374 1375 G_GNUC_WARN_UNUSED_RESULTchar *owl_command_smartfilter(int argc, const char *const *argv, const char *buff)1375 CALLER_OWN char *owl_command_smartfilter(int argc, const char *const *argv, const char *buff) 1376 1376 { 1377 1377 char *filtname = NULL; … … 1413 1413 } 1414 1414 1415 G_GNUC_WARN_UNUSED_RESULTchar *owl_command_get_shift(int argc, const char *const *argv, const char *buff)1415 CALLER_OWN char *owl_command_get_shift(int argc, const char *const *argv, const char *buff) 1416 1416 { 1417 1417 if(argc != 1) … … 1644 1644 1645 1645 1646 G_GNUC_WARN_UNUSED_RESULTchar *owl_command_exec(int argc, const char *const *argv, const char *buff)1646 CALLER_OWN char *owl_command_exec(int argc, const char *const *argv, const char *buff) 1647 1647 { 1648 1648 return owl_function_exec(argc, argv, buff, OWL_OUTPUT_RETURN); 1649 1649 } 1650 1650 1651 G_GNUC_WARN_UNUSED_RESULTchar *owl_command_pexec(int argc, const char *const *argv, const char *buff)1651 CALLER_OWN char *owl_command_pexec(int argc, const char *const *argv, const char *buff) 1652 1652 { 1653 1653 return owl_function_exec(argc, argv, buff, OWL_OUTPUT_POPUP); 1654 1654 } 1655 1655 1656 G_GNUC_WARN_UNUSED_RESULTchar *owl_command_aexec(int argc, const char *const *argv, const char *buff)1656 CALLER_OWN char *owl_command_aexec(int argc, const char *const *argv, const char *buff) 1657 1657 { 1658 1658 return owl_function_exec(argc, argv, buff, OWL_OUTPUT_ADMINMSG); 1659 1659 } 1660 1660 1661 G_GNUC_WARN_UNUSED_RESULTchar *owl_command_perl(int argc, const char *const *argv, const char *buff)1661 CALLER_OWN char *owl_command_perl(int argc, const char *const *argv, const char *buff) 1662 1662 { 1663 1663 return owl_function_perl(argc, argv, buff, OWL_OUTPUT_RETURN); 1664 1664 } 1665 1665 1666 G_GNUC_WARN_UNUSED_RESULTchar *owl_command_pperl(int argc, const char *const *argv, const char *buff)1666 CALLER_OWN char *owl_command_pperl(int argc, const char *const *argv, const char *buff) 1667 1667 { 1668 1668 return owl_function_perl(argc, argv, buff, OWL_OUTPUT_POPUP); 1669 1669 } 1670 1670 1671 G_GNUC_WARN_UNUSED_RESULTchar *owl_command_aperl(int argc, const char *const *argv, const char *buff)1671 CALLER_OWN char *owl_command_aperl(int argc, const char *const *argv, const char *buff) 1672 1672 { 1673 1673 return owl_function_perl(argc, argv, buff, OWL_OUTPUT_ADMINMSG); 1674 1674 } 1675 1675 1676 G_GNUC_WARN_UNUSED_RESULTchar *owl_command_multi(int argc, const char *const *argv, const char *buff)1676 CALLER_OWN char *owl_command_multi(int argc, const char *const *argv, const char *buff) 1677 1677 { 1678 1678 char *lastrv = NULL, *newbuff; … … 2467 2467 void owl_command_punt_unpunt(int argc, const char *const * argv, const char *buff, int unpunt) 2468 2468 { 2469 owl_list * fl; 2470 owl_filter * f; 2469 GPtrArray * fl; 2471 2470 int i; 2472 2471 … … 2478 2477 if(unpunt && (i=atoi(argv[1])) !=0) { 2479 2478 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)); 2484 2481 return; 2485 2482 } else { … … 2594 2591 } 2595 2592 2596 G_GNUC_WARN_UNUSED_RESULTchar *owl_command_getstyle(int argc, const char *const *argv, const char *buff)2593 CALLER_OWN char *owl_command_getstyle(int argc, const char *const *argv, const char *buff) 2597 2594 { 2598 2595 const char *stylename; … … 2632 2629 ptr = skiptokens(buff, 1); 2633 2630 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); 2636 2632 /* owl_function_makemsg("History '%s' stored successfully", ptr+1); */ 2637 2633 return NULL; 2638 2634 } 2639 2635 2640 G_GNUC_WARN_UNUSED_RESULTchar *owl_command_with_history(int argc, const char *const *argv, const char *buff)2636 CALLER_OWN char *owl_command_with_history(int argc, const char *const *argv, const char *buff) 2641 2637 { 2642 2638 owl_history *hist; … … 2655 2651 2656 2652 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); 2659 2654 return owl_function_command(ptr); 2660 2655 } … … 2739 2734 2740 2735 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); 2745 2738 2746 2739 owl_global_pop_context(&g); … … 2755 2748 if (!hist) 2756 2749 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); 2761 2752 ptr=owl_history_get_prev(hist); 2762 2753 if (ptr) { … … 2796 2787 owl_history *hist=owl_editwin_get_history(e); 2797 2788 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); 2802 2791 2803 2792 /* Take a reference to the editwin, so that it survives the pop -
configure.ac
r4f746f8 rf2a96c0 17 17 18 18 AS_IF([test "x$with_stack_protector" != xno], 19 [AX_C _CHECK_FLAG([-fstack-protector],[],[],19 [AX_CHECK_COMPILE_FLAG([-fstack-protector], 20 20 [AM_CFLAGS="$AM_CFLAGS -fstack-protector"], 21 21 [if test "x$with_stack_protector" != xcheck; then … … 129 129 130 130 AX_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"]) 131 AX_APPEND_COMPILE_FLAGS([-Wstrict-prototypes -Wwrite-strings],[AM_CFLAGS]) 133 132 134 133 dnl Shut gcc up about zero-length format strings; the warning's apparently for 135 134 dnl 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"])135 AX_APPEND_COMPILE_FLAGS([-Wno-format-zero-length],[AM_CFLAGS]) 137 136 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"])]) 137 AX_APPEND_COMPILE_FLAGS([-Wno-pointer-sign -Wno-empty-body -Wno-unused-value],[LIBFAIM_CFLAGS]) 141 138 142 139 AM_CONDITIONAL([ENABLE_ZCRYPT], [test "$HAVE_DES_STRING_TO_KEY" && dnl -
context.c
rd427f08 r6829afc 6 6 7 7 /* TODO: dependency from owl_context -> owl_window is annoying. */ 8 G_GNUC_WARN_UNUSED_RESULTowl_context *owl_context_new(int mode, void *data, const char *keymap, owl_window *cursor)8 CALLER_OWN owl_context *owl_context_new(int mode, void *data, const char *keymap, owl_window *cursor) 9 9 { 10 10 owl_context *c; -
dict.c
rd427f08 rce68f23 56 56 } 57 57 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. */ 60 CALLER_OWN GPtrArray *owl_dict_get_keys(const owl_dict *d) { 61 GPtrArray *keys = g_ptr_array_sized_new(d->size); 61 62 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)); 64 65 } 66 return keys; 65 67 } 66 68 … … 107 109 /* Doesn't free the value of the element, but does 108 110 * return it so the caller can free it. */ 109 G_GNUC_WARN_UNUSED_RESULTvoid *owl_dict_remove_element(owl_dict *d, const char *k)111 CALLER_OWN void *owl_dict_remove_element(owl_dict *d, const char *k) 110 112 { 111 113 int i; -
editcontext.c
rd427f08 r6829afc 8 8 } 9 9 10 G_GNUC_WARN_UNUSED_RESULTowl_context *owl_editcontext_new(int mode, owl_editwin *e, const char *keymap, void (*deactivate_cb)(owl_context*), void *cbdata)10 CALLER_OWN owl_context *owl_editcontext_new(int mode, owl_editwin *e, const char *keymap, void (*deactivate_cb)(owl_context*), void *cbdata) 11 11 { 12 12 owl_context *ctx = owl_context_new(mode, owl_editwin_ref(e), keymap, -
editwin.c
rd427f08 r6829afc 61 61 static const char *oe_copy_buf(owl_editwin *e, const char *buf, int len); 62 62 static int oe_copy_region(owl_editwin *e); 63 static G_GNUC_WARN_UNUSED_RESULTchar *oe_chunk(owl_editwin *e, int start, int end);63 static CALLER_OWN char *oe_chunk(owl_editwin *e, int start, int end); 64 64 static void oe_destroy_cbdata(owl_editwin *e); 65 65 static void oe_dirty(owl_editwin *e); … … 70 70 #define WHITESPACE " \n\t" 71 71 72 static G_GNUC_WARN_UNUSED_RESULTowl_editwin *owl_editwin_allocate(void)72 static CALLER_OWN owl_editwin *owl_editwin_allocate(void) 73 73 { 74 74 owl_editwin *e = g_new0(owl_editwin, 1); … … 142 142 } 143 143 144 G_GNUC_WARN_UNUSED_RESULTowl_editwin *owl_editwin_new(owl_window *win, int winlines, int wincols, int style, owl_history *hist)144 CALLER_OWN owl_editwin *owl_editwin_new(owl_window *win, int winlines, int wincols, int style, owl_history *hist) 145 145 { 146 146 owl_editwin *e = owl_editwin_allocate(); … … 1369 1369 } 1370 1370 1371 G_GNUC_WARN_UNUSED_RESULTchar *owl_editwin_get_region(owl_editwin *e)1371 CALLER_OWN char *owl_editwin_get_region(owl_editwin *e) 1372 1372 { 1373 1373 int start, end; … … 1388 1388 } 1389 1389 1390 static G_GNUC_WARN_UNUSED_RESULTchar *oe_chunk(owl_editwin *e, int start, int end)1390 static CALLER_OWN char *oe_chunk(owl_editwin *e, int start, int end) 1391 1391 { 1392 1392 char *p; -
errqueue.c
rd4927a7 reb897c6 3 3 void owl_errqueue_init(owl_errqueue *eq) 4 4 { 5 owl_list_create(&(eq->errlist));5 eq->errlist = g_ptr_array_new(); 6 6 } 7 7 8 8 void owl_errqueue_append_err(owl_errqueue *eq, const char *msg) 9 9 { 10 owl_list_append_element(&(eq->errlist), g_strdup(msg));10 g_ptr_array_add(eq->errlist, g_strdup(msg)); 11 11 } 12 12 … … 14 14 void owl_errqueue_to_fmtext(const owl_errqueue *eq, owl_fmtext *fm) 15 15 { 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]); 21 19 owl_fmtext_append_normal(fm, "\n"); 22 20 } -
filter.c
rd427f08 r2560529 200 200 201 201 202 char G_GNUC_WARN_UNUSED_RESULT*owl_filter_print(const owl_filter *f)202 CALLER_OWN char *owl_filter_print(const owl_filter *f) 203 203 { 204 204 GString *out = g_string_new(""); -
fmtext.c
rd427f08 r2560529 171 171 * freeing the return 172 172 */ 173 char G_GNUC_WARN_UNUSED_RESULT*owl_fmtext_print_plain(const owl_fmtext *f)173 CALLER_OWN char *owl_fmtext_print_plain(const owl_fmtext *f) 174 174 { 175 175 return owl_strip_format_chars(f->buff->str); … … 755 755 * If format_fn is specified, passes it the list element value 756 756 * 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;757 void owl_fmtext_append_list(owl_fmtext *f, const GPtrArray *l, const char *join_with, char *(format_fn)(const char *)) 758 { 759 int i; 760 760 const char *elem; 761 761 char *text; 762 762 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]; 766 765 if (elem && format_fn) { 767 766 text = format_fn(elem); … … 773 772 owl_fmtext_append_normal(f, elem); 774 773 } 775 if ((i < size-1) && join_with) {774 if ((i < l->len - 1) && join_with) { 776 775 owl_fmtext_append_normal(f, join_with); 777 776 } -
global.c
rd427f08 r2560529 47 47 owl_dict_create(&(g->filters)); 48 48 g->filterlist = NULL; 49 owl_list_create(&(g->puntlist));49 g->puntlist = g_ptr_array_new(); 50 50 g->messagequeue = g_queue_new(); 51 51 owl_dict_create(&(g->styledict)); … … 65 65 owl_history_init(&(g->msghist)); 66 66 owl_history_init(&(g->cmdhist)); 67 owl_history_set_norepeats(&(g->cmdhist));68 67 g->nextmsgid=0; 69 68 … … 173 172 /* Pops the current context from the context stack and returns it. Caller is 174 173 * responsible for freeing. */ 175 G_GNUC_WARN_UNUSED_RESULTowl_context *owl_global_pop_context_no_delete(owl_global *g)174 CALLER_OWN owl_context *owl_global_pop_context_no_delete(owl_global *g) 176 175 { 177 176 owl_context *c; … … 580 579 /* puntlist */ 581 580 582 owl_list*owl_global_get_puntlist(owl_global *g) {583 return (&(g->puntlist));581 GPtrArray *owl_global_get_puntlist(owl_global *g) { 582 return g->puntlist; 584 583 } 585 584 586 585 int 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; 596 594 } 597 595 … … 726 724 * necessary. 727 725 */ 728 owl_message G_GNUC_WARN_UNUSED_RESULT*owl_global_messagequeue_popmsg(owl_global *g)726 CALLER_OWN owl_message *owl_global_messagequeue_popmsg(owl_global *g) 729 727 { 730 728 owl_message *out; … … 755 753 } 756 754 757 void owl_global_get_style_names(const owl_global *g, owl_list *l) { 758 owl_dict_get_keys(&(g->styledict), l); 755 CALLER_OWN GPtrArray *owl_global_get_style_names(const owl_global *g) 756 { 757 return owl_dict_get_keys(&g->styledict); 759 758 } 760 759 -
help.c
rf25df21 rce68f23 6 6 owl_fmtext fm; 7 7 const char *varname; 8 owl_listvarnames;9 int i , numvarnames;8 GPtrArray *varnames; 9 int i; 10 10 11 11 owl_fmtext_init_null(&fm); … … 129 129 owl_fmtext_append_bold(&fm, 130 130 "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]; 136 134 if (varname && varname[0]!='_') { 137 135 owl_variable_describe(owl_global_get_vardict(&g), varname, &fm); 138 136 } 139 137 } 140 owl_ list_cleanup(&varnames, g_free);138 owl_ptr_array_free(varnames, g_free); 141 139 142 140 owl_fmtext_append_normal(&fm, "\n"); -
history.c
rd4927a7 r25891a8 3 3 void owl_history_init(owl_history *h) 4 4 { 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? */ 10 8 } 11 9 12 void owl_history_ set_norepeats(owl_history *h)10 void owl_history_cleanup(owl_history *h) 13 11 { 14 h->repeats=0; 12 g_queue_foreach(&h->hist, (GFunc)g_free, NULL); 13 g_queue_clear(&h->hist); 15 14 } 16 15 17 16 const char *owl_history_get_prev(owl_history *h) 18 17 { 18 if (!h) return NULL; 19 19 20 if (!h) return NULL; 21 h->touched=1; 20 if (h->cur == NULL || g_list_previous(h->cur) == NULL) return NULL; 22 21 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; 32 24 } 33 25 … … 35 27 { 36 28 if (!h) return NULL; 37 if (owl_list_get_size(&(h->hist))==0) return(NULL);38 if (h->cur==0) {39 return(NULL);40 }41 29 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; 44 34 } 45 35 46 void owl_history_store(owl_history *h, const char *line )36 void owl_history_store(owl_history *h, const char *line, bool partial) 47 37 { 48 i nt size;38 if (!h) return; 49 39 50 if (!h) return; 51 size=owl_list_get_size(&(h->hist)); 40 owl_history_reset(h); 52 41 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; 63 46 64 47 /* 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)); 69 50 70 51 /* 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; 78 55 } 79 56 … … 81 58 { 82 59 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; 86 68 } 87 69 … … 89 71 { 90 72 if (!h) return(0); 91 if (h->touched) return(1); 92 return(0); 73 return h->cur != NULL && g_list_next(h->cur) != NULL; 93 74 } -
keybinding.c
rd427f08 r6829afc 14 14 15 15 /* sets up a new keybinding for a command */ 16 G_GNUC_WARN_UNUSED_RESULTowl_keybinding *owl_keybinding_new(const char *keyseq, const char *command, void (*function_fn)(void), const char *desc)16 CALLER_OWN owl_keybinding *owl_keybinding_new(const char *keyseq, const char *command, void (*function_fn)(void), const char *desc) 17 17 { 18 18 owl_keybinding *kb = g_new(owl_keybinding, 1); … … 85 85 } 86 86 87 G_GNUC_WARN_UNUSED_RESULTchar *owl_keybinding_stack_tostring(int *j, int len)87 CALLER_OWN char *owl_keybinding_stack_tostring(int *j, int len) 88 88 { 89 89 GString *string; … … 100 100 } 101 101 102 G_GNUC_WARN_UNUSED_RESULTchar *owl_keybinding_tostring(const owl_keybinding *kb)102 CALLER_OWN char *owl_keybinding_tostring(const owl_keybinding *kb) 103 103 { 104 104 return owl_keybinding_stack_tostring(kb->keys, kb->len); -
keymap.c
rd427f08 rce68f23 11 11 km->name = g_strdup(name); 12 12 km->desc = g_strdup(desc); 13 owl_list_create(&km->bindings);13 km->bindings = g_ptr_array_new(); 14 14 km->parent = NULL; 15 15 km->default_fn = default_fn; … … 24 24 g_free(km->name); 25 25 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); 27 27 } 28 28 … … 35 35 int owl_keymap_create_binding(owl_keymap *km, const char *keyseq, const char *command, void (*function_fn)(void), const char *desc) 36 36 { 37 owl_keybinding *kb , *curkb;37 owl_keybinding *kb; 38 38 int i; 39 39 … … 44 44 * otherwise just add this one. 45 45 */ 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); 54 52 return 0; 55 53 } … … 58 56 int owl_keymap_remove_binding(owl_keymap *km, const char *keyseq) 59 57 { 60 owl_keybinding *kb , *curkb;58 owl_keybinding *kb; 61 59 int i; 62 60 … … 65 63 return -1; 66 64 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)); 72 68 owl_keybinding_delete(kb); 73 69 return(0); … … 80 76 81 77 /* returns a summary line describing this keymap. the caller must free. */ 82 G_GNUC_WARN_UNUSED_RESULTchar *owl_keymap_summary(const owl_keymap *km)78 CALLER_OWN char *owl_keymap_summary(const owl_keymap *km) 83 79 { 84 80 if (!km || !km->name || !km->desc) return NULL; … … 139 135 static void _owl_keymap_format_bindings(const owl_keymap *km, owl_fmtext *fm) 140 136 { 141 int i , nbindings;137 int i; 142 138 const owl_keybinding *kb; 143 139 144 nbindings = owl_list_get_size(&km->bindings); 145 for (i=0; i<nbindings; i++) { 140 for (i = 0; i < km->bindings->len; i++) { 146 141 char *kbstr; 147 142 const owl_cmd *cmd; 148 143 const char *tmpdesc, *desc = ""; 149 144 150 kb = owl_list_get_element(&km->bindings, i);145 kb = km->bindings->pdata[i]; 151 146 kbstr = owl_keybinding_tostring(kb); 152 147 owl_fmtext_append_normal(fm, OWL_TABSTR); … … 214 209 } 215 210 216 void owl_keyhandler_get_keymap_names(const owl_keyhandler *kh, owl_list *l)217 { 218 owl_dict_get_keys(&kh->keymaps, l);211 CALLER_OWN GPtrArray *owl_keyhandler_get_keymap_names(const owl_keyhandler *kh) 212 { 213 return owl_dict_get_keys(&kh->keymaps); 219 214 } 220 215 … … 274 269 * keyhandler and keymap apart. */ 275 270 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]; 278 273 match = owl_keybinding_match(kb, kh); 279 274 if (match == 1) { /* subset match */ -
keypress.c
rd427f08 r2560529 129 129 /* OWL_META is definied in owl.h */ 130 130 131 char G_GNUC_WARN_UNUSED_RESULT*owl_keypress_tostring(int j, int esc)131 CALLER_OWN char *owl_keypress_tostring(int j, int esc) 132 132 { 133 133 GString *kb; -
logging.c
rd427f08 r6829afc 80 80 } 81 81 82 G_GNUC_WARN_UNUSED_RESULTchar *owl_log_zephyr(const owl_message *m)82 CALLER_OWN char *owl_log_zephyr(const owl_message *m) 83 83 { 84 84 char *tmp = NULL; … … 104 104 } 105 105 106 G_GNUC_WARN_UNUSED_RESULTchar *owl_log_aim(const owl_message *m)106 CALLER_OWN char *owl_log_aim(const owl_message *m) 107 107 { 108 108 GString *buffer = NULL; … … 122 122 } 123 123 124 G_GNUC_WARN_UNUSED_RESULTchar *owl_log_jabber(const owl_message *m)124 CALLER_OWN char *owl_log_jabber(const owl_message *m) 125 125 { 126 126 GString *buffer = NULL; … … 135 135 } 136 136 137 G_GNUC_WARN_UNUSED_RESULTchar *owl_log_generic(const owl_message *m)137 CALLER_OWN char *owl_log_generic(const owl_message *m) 138 138 { 139 139 GString *buffer; -
m4/ax_cflags_warn_all.m4
r8073852 r378ede7 1 1 # =========================================================================== 2 # http://autoconf-archive.cryp.to/ax_cflags_warn_all.html2 # http://www.gnu.org/software/autoconf-archive/ax_cflags_warn_all.html 3 3 # =========================================================================== 4 4 # 5 5 # SYNOPSIS 6 6 # 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]])] 8 10 # 9 11 # DESCRIPTION 10 12 # 11 13 # Try to find a compiler option that enables most reasonable warnings. 12 # This macro is directly derived from VL_PROG_CC_WARNINGS which is split13 # up into two AX_CFLAGS_WARN_ALL and AX_CFLAGS_WARN_ALL_ANSI14 14 # 15 # For the GNU CC compiler it will be -Wall (and -ansi -pedantic) The16 # result is added to the shellvar beingCFLAGS 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. 17 17 # 18 # Currently this macro knows about GCC, Solaris C compiler, Digital Unix C19 # compiler, C for AIX Compiler, HP-UX C compiler, IRIX C compiler, NEC20 # SX-5 (Super-UX 10) C compiler, and Cray J90 (Unicos 10.0.0.8) C21 # 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. 22 22 # 23 # - $1 shell-variable-to-add-to : CFLAGS 23 # - $1 shell-variable-to-add-to : CFLAGS, CXXFLAGS, or FCFLAGS 24 24 # - $2 add-value-if-not-found : nothing 25 25 # - $3 action-if-found : add value to shellvariable … … 29 29 # 30 30 # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de> 31 # Copyright (c) 2010 Rhys Ulerich <rhys.ulerich@gmail.com> 31 32 # 32 33 # This program is free software; you can redistribute it and/or modify it 33 34 # under the terms of the GNU General Public License as published by the 34 # Free Software Foundation; either version 2of the License, or (at your35 # Free Software Foundation; either version 3 of the License, or (at your 35 36 # option) any later version. 36 37 # … … 56 57 # exception to the GPL to apply to your modified version as well. 57 58 59 #serial 10 60 58 61 AC_DEFUN([AX_CFLAGS_WARN_ALL],[dnl 59 62 AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl … … 61 64 AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings], 62 65 VAR,[VAR="no, unknown" 63 AC_LANG_SAVE 64 AC_LANG_C 66 AC_LANG_PUSH([C]) 65 67 ac_save_[]FLAGS="$[]FLAGS" 66 68 for ac_arg dnl … … 75 77 # 76 78 do 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]) 79 81 done 80 82 FLAGS="$ac_save_[]FLAGS" 81 AC_LANG_ RESTORE83 AC_LANG_POP([C]) 82 84 ]) 83 85 case ".$VAR" in … … 101 103 AC_DEFUN([AX_CXXFLAGS_WARN_ALL],[dnl 102 104 AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl 103 AS_VAR_PUSHDEF([VAR],[a c_cv_cxxflags_warn_all])dnl105 AS_VAR_PUSHDEF([VAR],[ax_cv_cxxflags_warn_all])dnl 104 106 AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings], 105 107 VAR,[VAR="no, unknown" 106 AC_LANG_SAVE 107 AC_LANG_CPLUSPLUS 108 AC_LANG_PUSH([C++]) 108 109 ac_save_[]FLAGS="$[]FLAGS" 109 110 for ac_arg dnl … … 118 119 # 119 120 do 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]) 122 123 done 123 124 FLAGS="$ac_save_[]FLAGS" 124 AC_LANG_RESTORE 125 AC_LANG_POP([C++]) 126 ]) 127 case ".$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 ]) ;; 138 esac 139 AS_VAR_POPDEF([VAR])dnl 140 AS_VAR_POPDEF([FLAGS])dnl 141 ]) 142 143 dnl the only difference - the LANG selection... and the default FLAGS 144 145 AC_DEFUN([AX_FCFLAGS_WARN_ALL],[dnl 146 AS_VAR_PUSHDEF([FLAGS],[FCFLAGS])dnl 147 AS_VAR_PUSHDEF([VAR],[ax_cv_fcflags_warn_all])dnl 148 AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings], 149 VAR,[VAR="no, unknown" 150 AC_LANG_PUSH([Fortran]) 151 ac_save_[]FLAGS="$[]FLAGS" 152 for ac_arg dnl 153 in "-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 # 163 do 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]) 166 done 167 FLAGS="$ac_save_[]FLAGS" 168 AC_LANG_POP([Fortran]) 125 169 ]) 126 170 case ".$VAR" in … … 148 192 dnl like -Woption or -Xoption as they think of it is a pass-through 149 193 dnl to later compile stages or something. The "%" is used as a 150 dnl delimi miter. A non-option comment can be given after "%%" marks194 dnl delimiter. A non-option comment can be given after "%%" marks 151 195 dnl which will be shown but not added to the respective C/CXXFLAGS. -
m4/ax_prog_perl_modules.m4
r2d3ed95 r378ede7 1 1 # =========================================================================== 2 # http://www.nongnu.org/autoconf-archive/ax_prog_perl_modules.html2 # http://www.gnu.org/software/autoconf-archive/ax_prog_perl_modules.html 3 3 # =========================================================================== 4 4 # … … 33 33 # warranty. 34 34 35 #serial 635 #serial 7 36 36 37 37 AU_ALIAS([AC_PROG_PERL_MODULES], [AX_PROG_PERL_MODULES]) -
m4/pkg.m4
r8073852 r650fb2c 1 1 # pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- 2 # serial 1 (pkg-config-0.24) 2 3 # 3 4 # Copyright © 2004 Scott James Remnant <scott@netsplit.com>. … … 26 27 AC_DEFUN([PKG_PROG_PKG_CONFIG], 27 28 [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 29 m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) 30 m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) 31 AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) 32 AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) 33 AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) 34 30 35 if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then 31 36 AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) … … 40 45 PKG_CONFIG="" 41 46 fi 42 43 47 fi[]dnl 44 48 ])# PKG_PROG_PKG_CONFIG … … 49 53 # to PKG_CHECK_MODULES(), but does not set variables or print errors. 50 54 # 51 # 52 # Similar to PKG_CHECK_MODULES, make sure that the first instance of53 # this or PKG_CHECK_MODULES is called, or make sure to call54 # PKG_CHECK_EXISTS manually55 # 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 55 59 # -------------------------------------------------------------- 56 60 AC_DEFUN([PKG_CHECK_EXISTS], … … 58 62 if test -n "$PKG_CONFIG" && \ 59 63 AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then 60 m4_ ifval([$2],[$2], [:])64 m4_default([$2], [:]) 61 65 m4_ifvaln([$3], [else 62 66 $3])dnl 63 67 fi]) 64 68 65 66 69 # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) 67 70 # --------------------------------------------- 68 71 m4_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 79 81 fi[]dnl 80 82 ])# _PKG_CONFIG … … 118 120 119 121 if test $pkg_failed = yes; then 122 AC_MSG_RESULT([no]) 120 123 _PKG_SHORT_ERRORS_SUPPORTED 121 124 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` 123 126 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` 125 128 fi 126 129 # Put the nasty error message in config.log where it belongs 127 130 echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD 128 131 129 ifelse([$4], , [AC_MSG_ERROR(dnl132 m4_default([$4], [AC_MSG_ERROR( 130 133 [Package requirements ($2) were not met: 131 134 … … 135 138 installed software in a non-standard prefix. 136 139 137 _PKG_TEXT 138 ])], 139 [AC_MSG_RESULT([no]) 140 $4]) 140 _PKG_TEXT])[]dnl 141 ]) 141 142 elif test $pkg_failed = untried; then 142 ifelse([$4], , [AC_MSG_FAILURE(dnl 143 AC_MSG_RESULT([no]) 144 m4_default([$4], [AC_MSG_FAILURE( 143 145 [The pkg-config script could not be found or is too old. Make sure it 144 146 is in your PATH or set the PKG_CONFIG environment variable to the full … … 147 149 _PKG_TEXT 148 150 149 To get pkg-config, see <http://pkg-config.freedesktop.org/>.]) ],150 [$4])151 To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl 152 ]) 151 153 else 152 154 $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS 153 155 $1[]_LIBS=$pkg_cv_[]$1[]_LIBS 154 156 AC_MSG_RESULT([yes]) 155 ifelse([$3], , :, [$3])157 $3 156 158 fi[]dnl 157 159 ])# PKG_CHECK_MODULES -
message.c
rd427f08 rf9df2f0 43 43 44 44 owl_message_set_hostname(m, ""); 45 owl_list_create(&(m->attributes));45 m->attributes = g_ptr_array_new(); 46 46 47 47 /* save the time */ … … 58 58 void owl_message_set_attribute(owl_message *m, const char *attrname, const char *attrvalue) 59 59 { 60 int i , j;60 int i; 61 61 owl_pair *p = NULL, *pair = NULL; 62 62 … … 64 64 65 65 /* 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]; 69 68 if (owl_pair_get_key(p) == attrname) { 70 69 g_free(owl_pair_get_value(p)); … … 77 76 pair = g_new(owl_pair, 1); 78 77 owl_pair_create(pair, attrname, NULL); 79 owl_list_append_element(&(m->attributes), pair);78 g_ptr_array_add(m->attributes, pair); 80 79 } 81 80 owl_pair_set_value(pair, owl_validate_or_convert(attrvalue)); … … 87 86 const char *owl_message_get_attribute_value(const owl_message *m, const char *attrname) 88 87 { 89 int i , j;88 int i; 90 89 owl_pair *p; 91 90 GQuark quark; … … 97 96 attrname = g_quark_to_string(quark); 98 97 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]; 102 100 if (owl_pair_get_key(p) == attrname) { 103 101 return(owl_pair_get_value(p)); … … 118 116 */ 119 117 void owl_message_attributes_tofmtext(const owl_message *m, owl_fmtext *fm) { 120 int i , j;118 int i; 121 119 owl_pair *p; 122 120 char *buff, *tmpbuff; … … 124 122 owl_fmtext_init_null(fm); 125 123 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]; 129 126 130 127 tmpbuff = g_strdup(owl_pair_get_value(p)); … … 580 577 581 578 /* caller must free return value. */ 582 G_GNUC_WARN_UNUSED_RESULTchar *owl_message_get_cc(const owl_message *m)579 CALLER_OWN char *owl_message_get_cc(const owl_message *m) 583 580 { 584 581 const char *cur; … … 597 594 598 595 /* caller must free return value */ 599 G_GNUC_WARN_UNUSED_RESULTGList *owl_message_get_cc_without_recipient(const owl_message *m)596 CALLER_OWN GList *owl_message_get_cc_without_recipient(const owl_message *m) 600 597 { 601 598 char *cc, *shortuser, *recip; … … 1004 1001 void owl_message_cleanup(owl_message *m) 1005 1002 { 1006 int i , j;1003 int i; 1007 1004 owl_pair *p; 1008 1005 #ifdef HAVE_LIBZEPHYR … … 1014 1011 1015 1012 /* 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]; 1019 1015 g_free(owl_pair_get_value(p)); 1020 1016 g_free(p); 1021 1017 } 1022 1018 1023 owl_list_cleanup(&(m->attributes), NULL);1019 g_ptr_array_free(m->attributes, true); 1024 1020 1025 1021 owl_message_invalidate_format(m); -
messagelist.c
rd427f08 rfc8a87a 3 3 #include <string.h> 4 4 5 intowl_messagelist_create(owl_messagelist *ml)5 void owl_messagelist_create(owl_messagelist *ml) 6 6 { 7 owl_list_create(&(ml->list)); 8 return(0); 7 ml->list = g_ptr_array_new(); 8 } 9 10 void 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); 9 15 } 10 16 11 17 int owl_messagelist_get_size(const owl_messagelist *ml) 12 18 { 13 return (owl_list_get_size(&(ml->list)));19 return ml->list->len; 14 20 } 15 21 16 22 void *owl_messagelist_get_element(const owl_messagelist *ml, int n) 17 23 { 18 return (owl_list_get_element(&(ml->list), n));24 return ml->list->pdata[n]; 19 25 } 20 26 … … 26 32 27 33 first = 0; 28 last = owl_list_get_size(&(ml->list))- 1;34 last = ml->list->len - 1; 29 35 while (first <= last) { 30 36 mid = (first + last) / 2; 31 m = owl_list_get_element(&(ml->list), mid);37 m = ml->list->pdata[mid]; 32 38 msg_id = owl_message_get_id(m); 33 39 if (msg_id == target_id) { … … 44 50 void owl_messagelist_append_element(owl_messagelist *ml, void *element) 45 51 { 46 owl_list_append_element(&ml->list, element);52 g_ptr_array_add(ml->list, element); 47 53 } 48 54 … … 51 57 { 52 58 /* 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]); 54 60 return(0); 55 61 } … … 58 64 { 59 65 /* 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]); 61 67 return(0); 62 68 } … … 65 71 { 66 72 /* expunge deleted messages */ 67 int i , j;68 owl_listnewlist;73 int i; 74 GPtrArray *newlist; 69 75 owl_message *m; 70 76 71 owl_list_create(&newlist);77 newlist = g_ptr_array_new(); 72 78 /*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]; 76 81 if (owl_message_is_delete(m)) { 77 82 owl_message_delete(m); 78 83 } else { 79 owl_list_append_element(&newlist, m);84 g_ptr_array_add(newlist, m); 80 85 } 81 86 } 82 87 83 88 /* free the old list */ 84 owl_list_cleanup(&(ml->list), NULL);89 g_ptr_array_free(ml->list, true); 85 90 86 91 /* copy the new list to the old list */ … … 92 97 void owl_messagelist_invalidate_formats(const owl_messagelist *ml) 93 98 { 94 int i , j;99 int i; 95 100 owl_message *m; 96 101 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]; 100 104 owl_message_invalidate_format(m); 101 105 } -
owl.h
rd427f08 r2560529 199 199 #define OWL_ENABLE_ZCRYPT 1 200 200 #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 201 205 202 206 #define OWL_META(key) ((key)|010000) … … 251 255 * WARNING: this approach is hard to make 252 256 * 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); 254 258 /* converts val to a string; 255 259 * caller must free the result */ … … 266 270 GString *buff; 267 271 } owl_fmtext; 268 269 typedef struct _owl_list {270 int size;271 int avail;272 void **list;273 } owl_list;274 272 275 273 typedef struct _owl_dict_el { … … 313 311 314 312 /* 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); 316 314 /* takes argv and the full command as buff. 317 315 * caller must free return value if !NULL */ … … 320 318 321 319 /* 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); 323 321 /* takes argv and the full command as buff. 324 322 * caller must free return value if !NULL */ … … 338 336 char *zsig; 339 337 char *message; 340 owl_listrecips;338 GPtrArray *recips; 341 339 int cc; 342 340 int noping; … … 359 357 int delete; 360 358 const char *hostname; 361 owl_list attributes;/* this is a list of pairs */359 GPtrArray *attributes; /* this is a list of pairs */ 362 360 char *timestr; 363 361 time_t time; … … 418 416 419 417 typedef struct _owl_messagelist { 420 owl_listlist;418 GPtrArray *list; 421 419 } owl_messagelist; 422 420 … … 455 453 456 454 typedef 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; 462 458 } owl_history; 463 459 … … 483 479 char *name; /* name of keymap */ 484 480 char *desc; /* description */ 485 owl_listbindings; /* key bindings */481 GPtrArray *bindings; /* key bindings */ 486 482 const struct _owl_keymap *parent; /* parent */ 487 483 void (*default_fn)(owl_input j); /* default action (takes a keypress) */ … … 506 502 507 503 typedef struct _owl_buddylist { 508 owl_listbuddies;504 GPtrArray *buddies; 509 505 } owl_buddylist; 510 506 511 507 typedef struct _owl_zbuddylist { 512 owl_listzusers;508 GPtrArray *zusers; 513 509 } owl_zbuddylist; 514 510 515 511 typedef struct _owl_errqueue { 516 owl_listerrlist;512 GPtrArray *errlist; 517 513 } owl_errqueue; 518 514 … … 540 536 owl_dict filters; 541 537 GList *filterlist; 542 owl_listpuntlist;538 GPtrArray *puntlist; 543 539 owl_vardict vars; 544 540 owl_cmddict cmds; -
perlconfig.c
rd427f08 rce68f23 23 23 24 24 25 G_GNUC_WARN_UNUSED_RESULTSV *owl_new_sv(const char * str)25 CALLER_OWN SV *owl_new_sv(const char * str) 26 26 { 27 27 SV *ret = newSVpv(str, 0); … … 36 36 } 37 37 38 G_GNUC_WARN_UNUSED_RESULT AV *owl_new_av(const owl_list*l, SV *(*to_sv)(const void *))38 CALLER_OWN AV *owl_new_av(const GPtrArray *l, SV *(*to_sv)(const void *)) 39 39 { 40 40 AV *ret; … … 44 44 ret = newAV(); 45 45 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]; 48 48 av_push(ret, to_sv(element)); 49 49 } … … 52 52 } 53 53 54 G_GNUC_WARN_UNUSED_RESULTHV *owl_new_hv(const owl_dict *d, SV *(*to_sv)(const void *))54 CALLER_OWN HV *owl_new_hv(const owl_dict *d, SV *(*to_sv)(const void *)) 55 55 { 56 56 HV *ret; 57 owl_list l;57 GPtrArray *keys; 58 58 const char *key; 59 59 void *element; … … 63 63 64 64 /* 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]; 69 68 element = owl_dict_find_element(d, key); 70 69 (void)hv_store(ret, key, strlen(key), to_sv(element), 0); 71 70 } 72 owl_ list_cleanup(&l, g_free);71 owl_ptr_array_free(keys, g_free); 73 72 74 73 return ret; 75 74 } 76 75 77 G_GNUC_WARN_UNUSED_RESULTSV *owl_perlconfig_message2hashref(const owl_message *m)76 CALLER_OWN SV *owl_perlconfig_message2hashref(const owl_message *m) 78 77 { 79 78 HV *h, *stash; … … 115 114 } 116 115 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]; 120 118 (void)hv_store(h, owl_pair_get_key(pair), strlen(owl_pair_get_key(pair)), 121 119 owl_new_sv(owl_pair_get_value(pair)),0); … … 165 163 } 166 164 167 G_GNUC_WARN_UNUSED_RESULTSV *owl_perlconfig_curmessage2hashref(void)165 CALLER_OWN SV *owl_perlconfig_curmessage2hashref(void) 168 166 { 169 167 int curmsg; … … 183 181 This has been somewhat addressed, but is still not lossless. 184 182 */ 185 G_GNUC_WARN_UNUSED_RESULTowl_message *owl_perlconfig_hashref2message(SV *msg)183 CALLER_OWN owl_message *owl_perlconfig_hashref2message(SV *msg) 186 184 { 187 185 owl_message * m; … … 251 249 /* Calls in a scalar context, passing it a hash reference. 252 250 If return value is non-null, caller must free. */ 253 G_GNUC_WARN_UNUSED_RESULTchar *owl_perlconfig_call_with_message(const char *subname, const owl_message *m)251 CALLER_OWN char *owl_perlconfig_call_with_message(const char *subname, const owl_message *m) 254 252 { 255 253 dSP ; … … 300 298 If the return value is non-null, the caller must free it. 301 299 */ 302 G_GNUC_WARN_UNUSED_RESULTchar *owl_perlconfig_message_call_method(const owl_message *m, const char *method, int argc, const char **argv)300 CALLER_OWN char *owl_perlconfig_message_call_method(const owl_message *m, const char *method, int argc, const char **argv) 303 301 { 304 302 dSP; … … 350 348 351 349 /* caller must free result, if not NULL */ 352 G_GNUC_WARN_UNUSED_RESULTchar *owl_perlconfig_initperl(const char *file, int *Pargc, char ***Pargv, char ***Penv)350 CALLER_OWN char *owl_perlconfig_initperl(const char *file, int *Pargc, char ***Pargv, char ***Penv) 353 351 { 354 352 int ret; … … 436 434 437 435 /* caller is responsible for freeing returned string */ 438 G_GNUC_WARN_UNUSED_RESULTchar *owl_perlconfig_execute(const char *line)436 CALLER_OWN char *owl_perlconfig_execute(const char *line) 439 437 { 440 438 STRLEN len; … … 506 504 507 505 /* caller must free the result */ 508 G_GNUC_WARN_UNUSED_RESULTchar *owl_perlconfig_perlcmd(const owl_cmd *cmd, int argc, const char *const *argv)506 CALLER_OWN char *owl_perlconfig_perlcmd(const owl_cmd *cmd, int argc, const char *const *argv) 509 507 { 510 508 int i, count; -
perlglue.xs
rbcde7926 rce68f23 329 329 all_filters() 330 330 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); 337 336 sv_2mortal((SV*)RETVAL); 338 owl_ list_cleanup(&fl, g_free);337 owl_ptr_array_free(fl, g_free); 339 338 } 340 339 OUTPUT: … … 344 343 all_styles() 345 344 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); 352 350 sv_2mortal((SV*)RETVAL); 353 351 } … … 355 353 RETVAL 356 354 CLEANUP: 357 owl_ list_cleanup(&l, g_free);355 owl_ptr_array_free(l, g_free); 358 356 359 357 … … 361 359 all_variables() 362 360 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); 369 366 sv_2mortal((SV*)RETVAL); 370 367 } … … 372 369 RETVAL 373 370 CLEANUP: 374 owl_ list_cleanup(&l, g_free);371 owl_ptr_array_free(l, g_free); 375 372 376 373 … … 378 375 all_keymaps() 379 376 PREINIT: 380 owl_listl;377 GPtrArray *l; 381 378 const owl_keyhandler *kh; 382 379 CODE: 383 380 { 384 381 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); 388 384 sv_2mortal((SV*)RETVAL); 389 385 } … … 391 387 RETVAL 392 388 CLEANUP: 393 owl_ list_cleanup(&l, g_free);389 owl_ptr_array_free(l, g_free); 394 390 395 391 void -
popwin.c
rd427f08 r6829afc 1 1 #include "owl.h" 2 2 3 G_GNUC_WARN_UNUSED_RESULTowl_popwin *owl_popwin_new(void)3 CALLER_OWN owl_popwin *owl_popwin_new(void) 4 4 { 5 5 owl_popwin *pw = g_new0(owl_popwin, 1); -
tester.c
r4e37d56 r25891a8 23 23 int owl_fmtext_regtest(void); 24 24 int owl_smartfilter_regtest(void); 25 int owl_history_regtest(void); 25 26 26 27 extern void owl_perl_xs_init(pTHX); … … 112 113 numfailures += owl_fmtext_regtest(); 113 114 numfailures += owl_smartfilter_regtest(); 115 numfailures += owl_history_regtest(); 114 116 if (numfailures) { 115 117 fprintf(stderr, "# *** WARNING: %d failures total\n", numfailures); … … 230 232 int owl_dict_regtest(void) { 231 233 owl_dict d; 232 owl_listl;234 GPtrArray *l; 233 235 int numfailed=0; 234 236 char *av = g_strdup("aval"), *bv = g_strdup("bval"), *cv = g_strdup("cval"), … … 251 253 252 254 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); 256 257 257 258 /* 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); 263 264 owl_dict_cleanup(&d, NULL); 264 265 … … 804 805 return numfailed; 805 806 } 807 808 int 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 7 7 /* Returns a copy of 'in' with each line indented 'n' 8 8 * characters. Result must be freed with g_free. */ 9 G_GNUC_WARN_UNUSED_RESULTchar *owl_text_indent(const char *in, int n)9 CALLER_OWN char *owl_text_indent(const char *in, int n) 10 10 { 11 11 const char *ptr1, *ptr2, *last; … … 48 48 49 49 /* caller must free the return */ 50 G_GNUC_WARN_UNUSED_RESULTchar *owl_text_htmlstrip(const char *in)50 CALLER_OWN char *owl_text_htmlstrip(const char *in) 51 51 { 52 52 const char *ptr1, *end, *ptr2, *ptr3; … … 129 129 130 130 /* Caller must free return */ 131 G_GNUC_WARN_UNUSED_RESULTchar *owl_text_expand_tabs(const char *in)131 CALLER_OWN char *owl_text_expand_tabs(const char *in) 132 132 { 133 133 int len = 0; … … 188 188 189 189 /* caller must free the return */ 190 G_GNUC_WARN_UNUSED_RESULTchar *owl_text_wordwrap(const char *in, int col)190 CALLER_OWN char *owl_text_wordwrap(const char *in, int col) 191 191 { 192 192 char *out; … … 269 269 * Caller must free returned string. 270 270 */ 271 G_GNUC_WARN_UNUSED_RESULTchar *owl_text_substitute(const char *in, const char *from, const char *to)271 CALLER_OWN char *owl_text_substitute(const char *in, const char *from, const char *to) 272 272 { 273 273 char **split = g_strsplit(in, from, 0), *out; … … 284 284 * On success returns the string, on error returns NULL. 285 285 */ 286 G_GNUC_WARN_UNUSED_RESULTchar *owl_text_quote(const char *in, const char *toquote, const char *quotestr)286 CALLER_OWN char *owl_text_quote(const char *in, const char *toquote, const char *quotestr) 287 287 { 288 288 int i, x, r, place, escape; -
variable.c
rd427f08 rce68f23 646 646 } 647 647 648 G_GNUC_WARN_UNUSED_RESULTowl_variable *owl_variable_newvar(const char *name, const char *summary, const char *description)648 CALLER_OWN owl_variable *owl_variable_newvar(const char *name, const char *summary, const char *description) 649 649 { 650 650 owl_variable * var = g_new0(owl_variable, 1); … … 729 729 } 730 730 731 void owl_variable_dict_get_names(const owl_vardict *d, owl_list *l) {732 owl_dict_get_keys(d, l);731 CALLER_OWN GPtrArray *owl_variable_dict_get_names(const owl_vardict *d) { 732 return owl_dict_get_keys(d); 733 733 } 734 734 … … 825 825 } 826 826 827 G_GNUC_WARN_UNUSED_RESULTchar *owl_variable_get_tostring(const owl_vardict *d, const char *name)827 CALLER_OWN char *owl_variable_get_tostring(const owl_vardict *d, const char *name) 828 828 { 829 829 owl_variable *v; … … 834 834 } 835 835 836 G_GNUC_WARN_UNUSED_RESULTchar *owl_variable_get_default_tostring(const owl_vardict *d, const char *name)836 CALLER_OWN char *owl_variable_get_default_tostring(const owl_vardict *d, const char *name) 837 837 { 838 838 owl_variable *v; … … 995 995 } 996 996 997 G_GNUC_WARN_UNUSED_RESULTchar *owl_variable_bool_get_tostring_default(const owl_variable *v, const void *val)997 CALLER_OWN char *owl_variable_bool_get_tostring_default(const owl_variable *v, const void *val) 998 998 { 999 999 if (val == NULL) { … … 1031 1031 } 1032 1032 1033 G_GNUC_WARN_UNUSED_RESULTchar *owl_variable_int_get_tostring_default(const owl_variable *v, const void *val)1033 CALLER_OWN char *owl_variable_int_get_tostring_default(const owl_variable *v, const void *val) 1034 1034 { 1035 1035 if (val == NULL) { … … 1071 1071 } 1072 1072 1073 G_GNUC_WARN_UNUSED_RESULTchar *owl_variable_enum_get_tostring(const owl_variable *v, const void *val)1073 CALLER_OWN char *owl_variable_enum_get_tostring(const owl_variable *v, const void *val) 1074 1074 { 1075 1075 char **enums; … … 1112 1112 } 1113 1113 1114 G_GNUC_WARN_UNUSED_RESULTchar *owl_variable_string_get_tostring_default(const owl_variable *v, const void *val)1114 CALLER_OWN char *owl_variable_string_get_tostring_default(const owl_variable *v, const void *val) 1115 1115 { 1116 1116 if (val == NULL) { -
view.c
r3b8a563 rfc8a87a 37 37 ml=&(v->ml); 38 38 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); 41 41 owl_messagelist_create(&(v->ml)); 42 42 … … 159 159 void owl_view_cleanup(owl_view *v) 160 160 { 161 owl_ list_cleanup(&v->ml.list, NULL);161 owl_messagelist_cleanup(&v->ml, false); 162 162 g_free(v->name); 163 163 } -
viewwin.c
rd427f08 r6829afc 12 12 * will be used by the viewwin 13 13 */ 14 G_GNUC_WARN_UNUSED_RESULTowl_viewwin *owl_viewwin_new_text(owl_window *win, const char *text)14 CALLER_OWN owl_viewwin *owl_viewwin_new_text(owl_window *win, const char *text) 15 15 { 16 16 owl_viewwin *v = g_new0(owl_viewwin, 1); … … 34 34 * will be used by the viewwin 35 35 */ 36 G_GNUC_WARN_UNUSED_RESULTowl_viewwin *owl_viewwin_new_fmtext(owl_window *win, const owl_fmtext *fmtext)36 CALLER_OWN owl_viewwin *owl_viewwin_new_fmtext(owl_window *win, const owl_fmtext *fmtext) 37 37 { 38 38 char *text; … … 237 237 } 238 238 239 G_GNUC_WARN_UNUSED_RESULTowl_editwin *owl_viewwin_set_typwin_active(owl_viewwin *v, owl_history *hist) {239 CALLER_OWN owl_editwin *owl_viewwin_set_typwin_active(owl_viewwin *v, owl_history *hist) { 240 240 int lines, cols; 241 241 owl_editwin *cmdline; -
window.c
rd427f08 r6829afc 569 569 }; 570 570 571 G_GNUC_WARN_UNUSED_RESULTGSource *owl_window_redraw_source_new(void)571 CALLER_OWN GSource *owl_window_redraw_source_new(void) 572 572 { 573 573 GSource *source; -
zbuddylist.c
rddbbcffa r7ed9bc6 3 3 void owl_zbuddylist_create(owl_zbuddylist *zb) 4 4 { 5 owl_list_create(&(zb->zusers));5 zb->zusers = g_ptr_array_new(); 6 6 } 7 7 8 8 int owl_zbuddylist_adduser(owl_zbuddylist *zb, const char *name) 9 9 { 10 int i , j;10 int i; 11 11 char *user; 12 12 13 13 user=long_zuser(name); 14 14 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])) { 18 17 g_free(user); 19 18 return(-1); 20 19 } 21 20 } 22 owl_list_append_element(&(zb->zusers), user);21 g_ptr_array_add(zb->zusers, user); 23 22 return(0); 24 23 } … … 26 25 int owl_zbuddylist_deluser(owl_zbuddylist *zb, const char *name) 27 26 { 28 int i , j;29 char *user , *ptr;27 int i; 28 char *user; 30 29 31 30 user=long_zuser(name); 32 31 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)); 39 35 g_free(user); 40 36 return(0); … … 47 43 int owl_zbuddylist_contains_user(const owl_zbuddylist *zb, const char *name) 48 44 { 49 int i , j;45 int i; 50 46 char *user; 51 47 52 48 user=long_zuser(name); 53 49 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])) { 57 52 g_free(user); 58 53 return(1); -
zcrypt.c
rd427f08 r6829afc 27 27 #include "filterproc.h" 28 28 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 29 33 #define MAX_KEY 128 30 34 #define MAX_LINE 128 … … 53 57 } ZWRITEOPTIONS; 54 58 55 G_GNUC_WARN_UNUSED_RESULTchar *GetZephyrVarKeyFile(const char *whoami, const char *class, const char *instance);59 CALLER_OWN char *GetZephyrVarKeyFile(const char *whoami, const char *class, const char *instance); 56 60 int ParseCryptSpec(const char *spec, const char **keyfile); 57 G_GNUC_WARN_UNUSED_RESULTchar *BuildArgString(char **argv, int start, int end);58 G_GNUC_WARN_UNUSED_RESULTchar *read_keystring(const char *keyfile);61 CALLER_OWN char *BuildArgString(char **argv, int start, int end); 62 CALLER_OWN char *read_keystring(const char *keyfile); 59 63 60 64 int do_encrypt(int zephyr, const char *class, const char *instance, … … 364 368 /* Build a space-separated string from argv from elements between start * 365 369 * and end - 1. malloc()'s the returned string. */ 366 G_GNUC_WARN_UNUSED_RESULTchar *BuildArgString(char **argv, int start, int end)370 CALLER_OWN char *BuildArgString(char **argv, int start, int end) 367 371 { 368 372 int len = 1; … … 401 405 #define MAX_SEARCH 3 402 406 /* Find the class/instance in the .crypt-table */ 403 G_GNUC_WARN_UNUSED_RESULTchar *GetZephyrVarKeyFile(const char *whoami, const char *class, const char *instance)407 CALLER_OWN char *GetZephyrVarKeyFile(const char *whoami, const char *class, const char *instance) 404 408 { 405 409 char *keyfile = NULL; … … 579 583 } 580 584 581 G_GNUC_WARN_UNUSED_RESULTchar *slurp_stdin(int ignoredot, int *length) {585 CALLER_OWN char *slurp_stdin(int ignoredot, int *length) { 582 586 char *buf; 583 587 char *inptr; … … 611 615 } 612 616 613 G_GNUC_WARN_UNUSED_RESULTchar *GetInputBuffer(ZWRITEOPTIONS *zoptions, int *length) {617 CALLER_OWN char *GetInputBuffer(ZWRITEOPTIONS *zoptions, int *length) { 614 618 char *buf; 615 619 … … 637 641 } 638 642 639 G_GNUC_WARN_UNUSED_RESULTchar *read_keystring(const char *keyfile) {643 CALLER_OWN char *read_keystring(const char *keyfile) { 640 644 char *keystring; 641 645 FILE *fkey = fopen(keyfile, "r"); -
zephyr.c
rd427f08 recffae6 524 524 */ 525 525 #ifdef HAVE_LIBZEPHYR 526 G_GNUC_WARN_UNUSED_RESULTchar *owl_zephyr_get_field(const ZNotice_t *n, int j)526 CALLER_OWN char *owl_zephyr_get_field(const ZNotice_t *n, int j) 527 527 { 528 528 int i, count, save; … … 552 552 } 553 553 554 G_GNUC_WARN_UNUSED_RESULTchar *owl_zephyr_get_field_as_utf8(const ZNotice_t *n, int j)554 CALLER_OWN char *owl_zephyr_get_field_as_utf8(const ZNotice_t *n, int j) 555 555 { 556 556 int i, count, save; … … 584 584 } 585 585 #else 586 G_GNUC_WARN_UNUSED_RESULTchar *owl_zephyr_get_field(void *n, int j)586 CALLER_OWN char *owl_zephyr_get_field(void *n, int j) 587 587 { 588 588 return(g_strdup("")); 589 589 } 590 G_GNUC_WARN_UNUSED_RESULTchar *owl_zephyr_get_field_as_utf8(void *n, int j)590 CALLER_OWN char *owl_zephyr_get_field_as_utf8(void *n, int j) 591 591 { 592 592 return owl_zephyr_get_field(n, j); … … 621 621 * caller must free the return 622 622 */ 623 G_GNUC_WARN_UNUSED_RESULTchar *owl_zephyr_get_message(const ZNotice_t *n, const owl_message *m)623 CALLER_OWN char *owl_zephyr_get_message(const ZNotice_t *n, const owl_message *m) 624 624 { 625 625 #define OWL_NFIELDS 5 … … 838 838 zw.opcode = g_strdup(retnotice->z_opcode); 839 839 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)); 842 842 843 843 owl_log_outgoing_zephyr_error(&zw, buff); … … 942 942 #endif 943 943 944 G_GNUC_WARN_UNUSED_RESULTchar *owl_zephyr_zlocate(const char *user, int auth)944 CALLER_OWN char *owl_zephyr_zlocate(const char *user, int auth) 945 945 { 946 946 #ifdef HAVE_LIBZEPHYR … … 1042 1042 1043 1043 /* caller must free the return */ 1044 G_GNUC_WARN_UNUSED_RESULTchar *owl_zephyr_makesubline(const char *class, const char *inst, const char *recip)1044 CALLER_OWN char *owl_zephyr_makesubline(const char *class, const char *inst, const char *recip) 1045 1045 { 1046 1046 return g_strdup_printf("%s,%s,%s\n", class, inst, !strcmp(recip, "") ? "*" : recip); … … 1122 1122 * free the return. 1123 1123 */ 1124 G_GNUC_WARN_UNUSED_RESULTchar *owl_zephyr_getsubs(void)1124 CALLER_OWN char *owl_zephyr_getsubs(void) 1125 1125 { 1126 1126 #ifdef HAVE_LIBZEPHYR … … 1242 1242 * The caller must free the return 1243 1243 */ 1244 G_GNUC_WARN_UNUSED_RESULTchar *short_zuser(const char *in)1244 CALLER_OWN char *short_zuser(const char *in) 1245 1245 { 1246 1246 char *ptr = strrchr(in, '@'); … … 1254 1254 * The caller must free the return. 1255 1255 */ 1256 G_GNUC_WARN_UNUSED_RESULTchar *long_zuser(const char *in)1256 CALLER_OWN char *long_zuser(const char *in) 1257 1257 { 1258 1258 char *ptr = strrchr(in, '@'); … … 1282 1282 * caller must free the return. 1283 1283 */ 1284 G_GNUC_WARN_UNUSED_RESULTchar *owl_zephyr_smartstripped_user(const char *in)1284 CALLER_OWN char *owl_zephyr_smartstripped_user(const char *in) 1285 1285 { 1286 1286 char *slash, *dot, *realm, *out; … … 1324 1324 } 1325 1325 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. 1330 1329 */ 1331 int owl_zephyr_get_anyone_list(owl_list *in,const char *filename)1330 GPtrArray *owl_zephyr_get_anyone_list(const char *filename) 1332 1331 { 1333 1332 #ifdef HAVE_LIBZEPHYR 1334 1333 char *ourfile, *tmp, *s = NULL; 1335 1334 FILE *f; 1335 GPtrArray *list; 1336 1336 1337 1337 ourfile = owl_zephyr_dotfile(".anyone", filename); … … 1341 1341 owl_function_error("Error opening file %s: %s", ourfile, strerror(errno) ? strerror(errno) : ""); 1342 1342 g_free(ourfile); 1343 return -1;1343 return NULL; 1344 1344 } 1345 1345 g_free(ourfile); 1346 1346 1347 list = g_ptr_array_new(); 1347 1348 while (owl_getline_chomp(&s, f)) { 1348 1349 /* ignore comments, blank lines etc. */ … … 1360 1361 tmp[0] = '\0'; 1361 1362 1362 owl_list_append_element(in, long_zuser(s));1363 g_ptr_array_add(list, long_zuser(s)); 1363 1364 } 1364 1365 g_free(s); 1365 1366 fclose(f); 1366 return 0;1367 #else 1368 return -1;1367 return list; 1368 #else 1369 return NULL; 1369 1370 #endif 1370 1371 } -
zwrite.c
rd427f08 r3cdd6d2 5 5 #include "owl.h" 6 6 7 G_GNUC_WARN_UNUSED_RESULTowl_zwrite *owl_zwrite_new(const char *line)7 CALLER_OWN owl_zwrite *owl_zwrite_new(const char *line) 8 8 { 9 9 owl_zwrite *z = g_new(owl_zwrite, 1); … … 34 34 z->cc=0; 35 35 z->noping=0; 36 owl_list_create(&(z->recips));36 z->recips = g_ptr_array_new(); 37 37 z->zwriteline = g_strdup(line); 38 38 … … 97 97 } 98 98 /* 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)) { 100 100 badargs=1; 101 101 break; … … 117 117 } else { 118 118 /* 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])); 120 120 myargv++; 121 121 myargc--; … … 131 131 if (z->class == NULL && 132 132 z->inst == NULL && 133 owl_list_get_size(&(z->recips))==0) {133 z->recips->len == 0) { 134 134 owl_function_error("You must specify a recipient for zwrite"); 135 135 return(-1); … … 162 162 void owl_zwrite_send_ping(const owl_zwrite *z) 163 163 { 164 int i , j;164 int i; 165 165 char *to; 166 166 … … 173 173 /* if there are no recipients we won't send a ping, which 174 174 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++) { 177 176 to = owl_zwrite_get_recip_n_with_realm(z, i); 178 177 send_ping(to, z->class, z->inst); … … 191 190 void owl_zwrite_set_message(owl_zwrite *z, const char *msg) 192 191 { 193 int i , j;192 int i; 194 193 GString *message; 195 194 char *tmp = NULL, *tmp2; … … 197 196 g_free(z->message); 198 197 199 j=owl_list_get_size(&(z->recips)); 200 if (j>0 && z->cc) { 198 if (z->recips->len > 0 && z->cc) { 201 199 message = g_string_new("CC: "); 202 for (i =0; i<j; i++) {200 for (i = 0; i < z->recips->len; i++) { 203 201 tmp = owl_zwrite_get_recip_n_with_realm(z, i); 204 202 g_string_append_printf(message, "%s ", tmp); … … 233 231 int owl_zwrite_send_message(const owl_zwrite *z) 234 232 { 235 int i, j,ret = 0;233 int i, ret = 0; 236 234 char *to = NULL; 237 235 238 236 if (z->message==NULL) return(-1); 239 237 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++) { 243 240 to = owl_zwrite_get_recip_n_with_realm(z, i); 244 241 ret = send_zephyr(z->opcode, z->zsig, z->class, z->inst, to, z->message); … … 312 309 int owl_zwrite_get_numrecips(const owl_zwrite *z) 313 310 { 314 return (owl_list_get_size(&(z->recips)));311 return z->recips->len; 315 312 } 316 313 317 314 const char *owl_zwrite_get_recip_n(const owl_zwrite *z, int n) 318 315 { 319 return (owl_list_get_element(&(z->recips), n));316 return z->recips->pdata[n]; 320 317 } 321 318 322 319 /* Caller must free the result. */ 323 G_GNUC_WARN_UNUSED_RESULTchar *owl_zwrite_get_recip_n_with_realm(const owl_zwrite *z, int n)320 CALLER_OWN char *owl_zwrite_get_recip_n_with_realm(const owl_zwrite *z, int n) 324 321 { 325 322 if (z->realm[0]) { … … 333 330 { 334 331 /* 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; 342 338 } 343 339 return(0); … … 352 348 void owl_zwrite_cleanup(owl_zwrite *z) 353 349 { 354 owl_ list_cleanup(&(z->recips), &g_free);350 owl_ptr_array_free(z->recips, g_free); 355 351 g_free(z->cmd); 356 352 g_free(z->zwriteline); … … 370 366 * If not a CC, only the recip_index'th user will be replied to. 371 367 */ 372 G_GNUC_WARN_UNUSED_RESULTchar *owl_zwrite_get_replyline(const owl_zwrite *z, int recip_index)368 CALLER_OWN char *owl_zwrite_get_replyline(const owl_zwrite *z, int recip_index) 373 369 { 374 370 /* Match ordering in zwrite help. */ … … 403 399 } 404 400 if (z->cc) { 405 for (i = 0; i < owl_list_get_size(&(z->recips)); i++) {401 for (i = 0; i < z->recips->len; i++) { 406 402 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]); 408 404 } 409 } else if (recip_index < owl_list_get_size(&(z->recips))) {405 } else if (recip_index < z->recips->len) { 410 406 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]); 412 408 } 413 409
Note: See TracChangeset
for help on using the changeset viewer.