Changes in / [7f86e3d:4f6097e]


Ignore:
Files:
37 added
42 deleted
94 edited

Legend:

Unmodified
Added
Removed
  • .gitignore

    rf93cc34 r1c22155  
    22*.o
    33*.par
    4 *~
    5 .#*
    6 .*.swp
    74.deps
     5/bin/
    86META.yml
     7MYMETA.yml
    98Makefile
    109Makefile.in
    1110Makefile.old
    1211TAGS
    13 \#*#
    1412aclocal.m4
    1513autom4te.cache
    16 barnowl.bin
    17 tester.bin
    18 zcrypt
     14barnowl
    1915blib
    2016config.cache
    2117config.h
    2218config.h.in
     19config.h.in~
    2320config.log
    2421config.status
     
    2623core
    2724depcomp
     25gmarshal_funcs.c
     26gmarshal_funcs.h
     27inc/
    2828install-sh
    2929jabber.log
     
    3232owl_prototypes.h.new
    3333perlglue.c
    34 perlwrap.c
    3534pm_to_blib
     35runtests.sh.log
     36runtests.sh.trs
    3637stamp-h1
     38test-driver
     39test-suite.log
     40tester
    3741varstubs.c
     42zcrypt
  • AUTHORS

    r1d2c4c3 r80c0fc7  
    33
    44The following people have provided patches or other contributions:
     5  Alex Vandiver
     6  Kevin Chen
     7  Arun Tharuvai
    58  Sam Hartman
    6   Alex Vandiver
    7   Geoffrey Thomas
    89  Derrick Brashear
    910  David Glasser
     11  Eric Price
    1012  Matthew Goldstein
    11   Arun Tharuvai
    12   Kevin Chen
    13   Eric Price
     13  Geoffrey Thomas
     14  Anders Kaseorg
     15  Greg Price
     16  Chris Lesniewski-Laas
     17  Alex Dehnert
     18  Edward Z. Yang
     19  Karl Ramm
     20  Evan Broder
     21  David Benjamin
     22  Cathy Zhang
     23  Joshua Oreman
     24  Leonid Grinberg
     25  Kevin Riggle
     26  Brian Sniffen
     27  William Throwe
     28  Jason Gross
     29  Adam Glasgall
     30  Tim Hill
     31  DD Liu
     32  Betsy Riley
     33  Robert Jacobs
    1434
    15 BarnOwl is based on code from Owl, which was originally primarly
     35BarnOwl is based on code from Owl, which was originally primarily
    1636written by James Kretchmar.  Erik Nygren also made substantial
    17 contributions and improvemnts to the program.
     37contributions and improvements to the program.
    1838
    19 The following people provided patches and other techincal support for
     39The following people provided patches and other technical support for
    2040Owl:
    2141
     
    3050  Mark Eichin
    3151
    32 Mark Eichin is also maintaining the debian package of Owl.
     52Mark Eichin is also maintaining the Debian package of Owl.
    3353
    3454The following people helped with beta testing the earliest versions of
  • COPYING

    rb03c714 rccc182c  
    549549
    550550That's all there is to it!
     551
     552======================================================================
     553
     554Files under perl/modules/Facebook/lib/Facebook are copyright (c) 2010 Plain
     555Black Corporation.
     556
     557This software is copyright (c) 2010 by Plain Black Corporation.
     558
     559This is free software; you can redistribute it and/or modify it under
     560the same terms as the Perl 5 programming language system itself.
     561
     562Terms of the Perl programming language system itself
     563
     564a) the GNU General Public License as published by the Free
     565   Software Foundation; either version 1, or (at your option) any
     566   later version, or
     567b) the "Artistic License"
     568
     569--- The GNU General Public License, Version 1, February 1989 ---
     570
     571This software is Copyright (c) 2010 by Plain Black Corporation.
     572
     573This is free software, licensed under:
     574
     575  The GNU General Public License, Version 1, February 1989
     576
     577                    GNU GENERAL PUBLIC LICENSE
     578                     Version 1, February 1989
     579
     580 Copyright (C) 1989 Free Software Foundation, Inc.
     581                    51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     582
     583 Everyone is permitted to copy and distribute verbatim copies
     584 of this license document, but changing it is not allowed.
     585
     586                            Preamble
     587
     588  The license agreements of most software companies try to keep users
     589at the mercy of those companies.  By contrast, our General Public
     590License is intended to guarantee your freedom to share and change free
     591software--to make sure the software is free for all its users.  The
     592General Public License applies to the Free Software Foundation's
     593software and to any other program whose authors commit to using it.
     594You can use it for your programs, too.
     595
     596  When we speak of free software, we are referring to freedom, not
     597price.  Specifically, the General Public License is designed to make
     598sure that you have the freedom to give away or sell copies of free
     599software, that you receive source code or can get it if you want it,
     600that you can change the software or use pieces of it in new free
     601programs; and that you know you can do these things.
     602
     603  To protect your rights, we need to make restrictions that forbid
     604anyone to deny you these rights or to ask you to surrender the rights.
     605These restrictions translate to certain responsibilities for you if you
     606distribute copies of the software, or if you modify it.
     607
     608  For example, if you distribute copies of a such a program, whether
     609gratis or for a fee, you must give the recipients all the rights that
     610you have.  You must make sure that they, too, receive or can get the
     611source code.  And you must tell them their rights.
     612
     613  We protect your rights with two steps: (1) copyright the software, and
     614(2) offer you this license which gives you legal permission to copy,
     615distribute and/or modify the software.
     616
     617  Also, for each author's protection and ours, we want to make certain
     618that everyone understands that there is no warranty for this free
     619software.  If the software is modified by someone else and passed on, we
     620want its recipients to know that what they have is not the original, so
     621that any problems introduced by others will not reflect on the original
     622authors' reputations.
     623
     624  The precise terms and conditions for copying, distribution and
     625modification follow.
     626
     627                    GNU GENERAL PUBLIC LICENSE
     628   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
     629
     630  0. This License Agreement applies to any program or other work which
     631contains a notice placed by the copyright holder saying it may be
     632distributed under the terms of this General Public License.  The
     633"Program", below, refers to any such program or work, and a "work based
     634on the Program" means either the Program or any work containing the
     635Program or a portion of it, either verbatim or with modifications.  Each
     636licensee is addressed as "you".
     637
     638  1. You may copy and distribute verbatim copies of the Program's source
     639code as you receive it, in any medium, provided that you conspicuously and
     640appropriately publish on each copy an appropriate copyright notice and
     641disclaimer of warranty; keep intact all the notices that refer to this
     642General Public License and to the absence of any warranty; and give any
     643other recipients of the Program a copy of this General Public License
     644along with the Program.  You may charge a fee for the physical act of
     645transferring a copy.
     646
     647  2. You may modify your copy or copies of the Program or any portion of
     648it, and copy and distribute such modifications under the terms of Paragraph
     6491 above, provided that you also do the following:
     650
     651    a) cause the modified files to carry prominent notices stating that
     652    you changed the files and the date of any change; and
     653
     654    b) cause the whole of any work that you distribute or publish, that
     655    in whole or in part contains the Program or any part thereof, either
     656    with or without modifications, to be licensed at no charge to all
     657    third parties under the terms of this General Public License (except
     658    that you may choose to grant warranty protection to some or all
     659    third parties, at your option).
     660
     661    c) If the modified program normally reads commands interactively when
     662    run, you must cause it, when started running for such interactive use
     663    in the simplest and most usual way, to print or display an
     664    announcement including an appropriate copyright notice and a notice
     665    that there is no warranty (or else, saying that you provide a
     666    warranty) and that users may redistribute the program under these
     667    conditions, and telling the user how to view a copy of this General
     668    Public License.
     669
     670    d) You may charge a fee for the physical act of transferring a
     671    copy, and you may at your option offer warranty protection in
     672    exchange for a fee.
     673
     674Mere aggregation of another independent work with the Program (or its
     675derivative) on a volume of a storage or distribution medium does not bring
     676the other work under the scope of these terms.
     677
     678  3. You may copy and distribute the Program (or a portion or derivative of
     679it, under Paragraph 2) in object code or executable form under the terms of
     680Paragraphs 1 and 2 above provided that you also do one of the following:
     681
     682    a) accompany it with the complete corresponding machine-readable
     683    source code, which must be distributed under the terms of
     684    Paragraphs 1 and 2 above; or,
     685
     686    b) accompany it with a written offer, valid for at least three
     687    years, to give any third party free (except for a nominal charge
     688    for the cost of distribution) a complete machine-readable copy of the
     689    corresponding source code, to be distributed under the terms of
     690    Paragraphs 1 and 2 above; or,
     691
     692    c) accompany it with the information you received as to where the
     693    corresponding source code may be obtained.  (This alternative is
     694    allowed only for noncommercial distribution and only if you
     695    received the program in object code or executable form alone.)
     696
     697Source code for a work means the preferred form of the work for making
     698modifications to it.  For an executable file, complete source code means
     699all the source code for all modules it contains; but, as a special
     700exception, it need not include source code for modules which are standard
     701libraries that accompany the operating system on which the executable
     702file runs, or for standard header files or definitions files that
     703accompany that operating system.
     704
     705  4. You may not copy, modify, sublicense, distribute or transfer the
     706Program except as expressly provided under this General Public License.
     707Any attempt otherwise to copy, modify, sublicense, distribute or transfer
     708the Program is void, and will automatically terminate your rights to use
     709the Program under this License.  However, parties who have received
     710copies, or rights to use copies, from you under this General Public
     711License will not have their licenses terminated so long as such parties
     712remain in full compliance.
     713
     714  5. By copying, distributing or modifying the Program (or any work based
     715on the Program) you indicate your acceptance of this license to do so,
     716and all its terms and conditions.
     717
     718  6. Each time you redistribute the Program (or any work based on the
     719Program), the recipient automatically receives a license from the original
     720licensor to copy, distribute or modify the Program subject to these
     721terms and conditions.  You may not impose any further restrictions on the
     722recipients' exercise of the rights granted herein.
     723
     724  7. The Free Software Foundation may publish revised and/or new versions
     725of the General Public License from time to time.  Such new versions will
     726be similar in spirit to the present version, but may differ in detail to
     727address new problems or concerns.
     728
     729Each version is given a distinguishing version number.  If the Program
     730specifies a version number of the license which applies to it and "any
     731later version", you have the option of following the terms and conditions
     732either of that version or of any later version published by the Free
     733Software Foundation.  If the Program does not specify a version number of
     734the license, you may choose any version ever published by the Free Software
     735Foundation.
     736
     737  8. If you wish to incorporate parts of the Program into other free
     738programs whose distribution conditions are different, write to the author
     739to ask for permission.  For software which is copyrighted by the Free
     740Software Foundation, write to the Free Software Foundation; we sometimes
     741make exceptions for this.  Our decision will be guided by the two goals
     742of preserving the free status of all derivatives of our free software and
     743of promoting the sharing and reuse of software generally.
     744
     745                            NO WARRANTY
     746
     747  9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
     748FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
     749OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
     750PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
     751OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     752MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
     753TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
     754PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
     755REPAIR OR CORRECTION.
     756
     757  10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
     758WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
     759REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
     760INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
     761OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
     762TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
     763YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
     764PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
     765POSSIBILITY OF SUCH DAMAGES.
     766
     767                     END OF TERMS AND CONDITIONS
     768
     769        Appendix: How to Apply These Terms to Your New Programs
     770
     771  If you develop a new program, and you want it to be of the greatest
     772possible use to humanity, the best way to achieve this is to make it
     773free software which everyone can redistribute and change under these
     774terms.
     775
     776  To do so, attach the following notices to the program.  It is safest to
     777attach them to the start of each source file to most effectively convey
     778the exclusion of warranty; and each file should have at least the
     779"copyright" line and a pointer to where the full notice is found.
     780
     781    <one line to give the program's name and a brief idea of what it does.>
     782    Copyright (C) 19yy  <name of author>
     783
     784    This program is free software; you can redistribute it and/or modify
     785    it under the terms of the GNU General Public License as published by
     786    the Free Software Foundation; either version 1, or (at your option)
     787    any later version.
     788
     789    This program is distributed in the hope that it will be useful,
     790    but WITHOUT ANY WARRANTY; without even the implied warranty of
     791    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     792    GNU General Public License for more details.
     793
     794    You should have received a copy of the GNU General Public License
     795    along with this program; if not, write to the Free Software
     796    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA  02110-1301 USA
     797
     798
     799Also add information on how to contact you by electronic and paper mail.
     800
     801If the program is interactive, make it output a short notice like this
     802when it starts in an interactive mode:
     803
     804    Gnomovision version 69, Copyright (C) 19xx name of author
     805    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
     806    This is free software, and you are welcome to redistribute it
     807    under certain conditions; type `show c' for details.
     808
     809The hypothetical commands `show w' and `show c' should show the
     810appropriate parts of the General Public License.  Of course, the
     811commands you use may be called something other than `show w' and `show
     812c'; they could even be mouse-clicks or menu items--whatever suits your
     813program.
     814
     815You should also get your employer (if you work as a programmer) or your
     816school, if any, to sign a "copyright disclaimer" for the program, if
     817necessary.  Here a sample; alter the names:
     818
     819  Yoyodyne, Inc., hereby disclaims all copyright interest in the
     820  program `Gnomovision' (a program to direct compilers to make passes
     821  at assemblers) written by James Hacker.
     822
     823  <signature of Ty Coon>, 1 April 1989
     824  Ty Coon, President of Vice
     825
     826That's all there is to it!
     827
     828
     829--- The Artistic License 1.0 ---
     830
     831This software is Copyright (c) 2010 by Plain Black Corporation.
     832
     833This is free software, licensed under:
     834
     835  The Artistic License 1.0
     836
     837The Artistic License
     838
     839Preamble
     840
     841The intent of this document is to state the conditions under which a Package
     842may be copied, such that the Copyright Holder maintains some semblance of
     843artistic control over the development of the package, while giving the users of
     844the package the right to use and distribute the Package in a more-or-less
     845customary fashion, plus the right to make reasonable modifications.
     846
     847Definitions:
     848
     849  - "Package" refers to the collection of files distributed by the Copyright
     850    Holder, and derivatives of that collection of files created through
     851    textual modification.
     852  - "Standard Version" refers to such a Package if it has not been modified,
     853    or has been modified in accordance with the wishes of the Copyright
     854    Holder.
     855  - "Copyright Holder" is whoever is named in the copyright or copyrights for
     856    the package.
     857  - "You" is you, if you're thinking about copying or distributing this Package.
     858  - "Reasonable copying fee" is whatever you can justify on the basis of media
     859    cost, duplication charges, time of people involved, and so on. (You will
     860    not be required to justify it to the Copyright Holder, but only to the
     861    computing community at large as a market that must bear the fee.)
     862  - "Freely Available" means that no fee is charged for the item itself, though
     863    there may be fees involved in handling the item. It also means that
     864    recipients of the item may redistribute it under the same conditions they
     865    received it.
     866
     8671. You may make and give away verbatim copies of the source form of the
     868Standard Version of this Package without restriction, provided that you
     869duplicate all of the original copyright notices and associated disclaimers.
     870
     8712. You may apply bug fixes, portability fixes and other modifications derived
     872from the Public Domain or from the Copyright Holder. A Package modified in such
     873a way shall still be considered the Standard Version.
     874
     8753. You may otherwise modify your copy of this Package in any way, provided that
     876you insert a prominent notice in each changed file stating how and when you
     877changed that file, and provided that you do at least ONE of the following:
     878
     879  a) place your modifications in the Public Domain or otherwise make them
     880     Freely Available, such as by posting said modifications to Usenet or an
     881     equivalent medium, or placing the modifications on a major archive site
     882     such as ftp.uu.net, or by allowing the Copyright Holder to include your
     883     modifications in the Standard Version of the Package.
     884
     885  b) use the modified Package only within your corporation or organization.
     886
     887  c) rename any non-standard executables so the names do not conflict with
     888     standard executables, which must also be provided, and provide a separate
     889     manual page for each non-standard executable that clearly documents how it
     890     differs from the Standard Version.
     891
     892  d) make other distribution arrangements with the Copyright Holder.
     893
     8944. You may distribute the programs of this Package in object code or executable
     895form, provided that you do at least ONE of the following:
     896
     897  a) distribute a Standard Version of the executables and library files,
     898     together with instructions (in the manual page or equivalent) on where to
     899     get the Standard Version.
     900
     901  b) accompany the distribution with the machine-readable source of the Package
     902     with your modifications.
     903
     904  c) accompany any non-standard executables with their corresponding Standard
     905     Version executables, giving the non-standard executables non-standard
     906     names, and clearly documenting the differences in manual pages (or
     907     equivalent), together with instructions on where to get the Standard
     908     Version.
     909
     910  d) make other distribution arrangements with the Copyright Holder.
     911
     9125. You may charge a reasonable copying fee for any distribution of this
     913Package.  You may charge any fee you choose for support of this Package. You
     914may not charge a fee for this Package itself. However, you may distribute this
     915Package in aggregate with other (possibly commercial) programs as part of a
     916larger (possibly commercial) software distribution provided that you do not
     917advertise this Package as a product of your own.
     918
     9196. The scripts and library files supplied as input to or produced as output
     920from the programs of this Package do not automatically fall under the copyright
     921of this Package, but belong to whomever generated them, and may be sold
     922commercially, and may be aggregated with this Package.
     923
     9247. C or perl subroutines supplied by you and linked into this Package shall not
     925be considered part of this Package.
     926
     9278. The name of the Copyright Holder may not be used to endorse or promote
     928products derived from this software without specific prior written permission.
     929
     9309. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
     931WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
     932MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
     933
     934The End
  • ChangeLog

    r2ff0693 r1b17f50  
     11.9
     2 * Add getnumlines() to perl interface -asedeno@mit.edu
     3 * Include names of invalid filters on filter errors -adehnert@mit.edu
     4 * Don't incorrectly mark decryption failures as decrypted -davidben@mit.edu
     5 * Hide the default cursor when possible -davidben@mit.edu
     6 * Complete viewperson and vp as viewuser and vu -davidben@mit.edu
     7 * Set z_charset = ZCHARSET_UTF_8 -andersk@mit.edu
     8 * Allow zsender spoofing on cross-realm classes -andersk@mit.edu
     9 * Append the realm to the zsender if missing -andersk@mit.edu
     10 * Redisplay on setting colorztext -jgross@mit.edu
     11 * Rename default config file to .owl/init.pl -kevinr@free-dissociation.com
     12 * Add completion for jabberlogout -adehnert@mit.edu
     13 * Switch to interactive context before sourcing the startup file -davidben@mit.edu
     14 * Add completion for reload-module -adehnert@mit.edu
     15 * editwin callback for canceling the editwin -jgross@mit.edu
     16 * Fix dirtying windows inside a redraw handler -davidben@mit.edu
     17 * Facebook module -ezyang@mit.edu
     18 * Complete unstartup command just like startup command -jgross@mit.edu
     19 * Fix the description of disable-ctrl-d -jgross@mit.edu
     20 * Use wbkgrndset instead of wbkgdset in _owl_fmtext_wcolor_set -davidben@mit.edu
     21 * Show the time zone in :info -jgross@mit.edu
     22 * Treat [!.?]" as end of sentence in edit:fill-paragraph -jgross@mit.edu
     23 * Correctly display multiline fields in :info -jgross@mit.edu
     24
     251.8.1
     26 * Only add outgoing messages for personal part of half-personal messages -andersk@mit.edu
     27 * Don’t write CC: line on zwrite -C '' -andersk@mit.edu
     28 * Don’t send public pings on zwrite '' or zwrite @REALM -andersk@mit.edu
     29 * Don’t treat zwrite '' as personal -andersk@mit.edu
     30 * Stop pretending to support zwrite * -andersk@mit.edu
     31 * Show foreign realms on non-personal zephyrs like Owl did -andersk@mit.edu
     32 * Fix memory leak in zcrypt -davidben@mit.edu
     33 * Don't attempt to switch filters in :view -d if invalid -davidben@mit.edu
     34 * Fixed typo in unbindkey usage error -rileyb@mit.edu
     35 * Fix bug generating filter text in 256-color mode -asedeno@mit.edu
     36 * Remove ^noc from reply-lockout -geofft@mit.edu
     37 * Avoid quadratic loops when receiving zephyrs -andersk@mit.edu
     38 * Fix hang on empty zcrypt messages -adehnert@MIT.EDU
     39
     401.8
     41 * Compute the home directory in zcrypt consistently with BarnOwl -davidben@mit.edu
     42 * Make help show the correct keybinding for A -jgross@mit.edu
     43 * Add a delete-and-expunge command. -jgross@mit.edu
     44 * Fix a bug in the expunge command -jgross@mit.edu
     45 * Replace 'Owl' with 'BarnOwl' in user visible places -jgross@mit.edu
     46 * Allow zsigs to be '0' -jgross@mit.edu
     47 * Reformat the man page to look more like others -davidben@mit.edu
     48 * Consistently use BarnOwl or barnowl -davidben@mit.edu
     49 * Update autoconf macros -andersk@mit.edu
     50 * history: Do not deduplicate a partial entry -andersk@mit.edu
     51 * Drop show timers feature -davidben@mit.edu
     52 * Add new dependencies, AnyEvent and perl-Glib -davidben@mit.edu
     53 * Bump required glib version to 2.16 -davidben@mit.edu
     54 * Don't leak timestr when setting time in a perl message -asedeno@mit.edu
     55 * Build with -Wwrite-strings -andersk@mit.edu
     56 * Build with C99 -davidben@mit.edu
     57 * Jabber: Handle nicks with leading dashes (e.g. Facebook XMPP) -ezyang@mit.edu
     58 * Move log-writing onto a background thread. -adam@crossproduct.net
     59 * Remove the length limit on field values in :info -jgross@mit.edu
     60 * Show how far you are in a long message -jgross@mit.edu
     61 * stderr_redirect_handler: Handle partial or failed reads -andersk@mit.edu
     62 * Inform the user when an unpunt command does nothing -davidben@mit.edu
     63 * Replace custom event loop with GLib's GMainLoop -davidben@mit.edu
     64 * Encode glib version requirements in pkg-config check -asedeno@mit.edu
     65 * Fix color pair usage on ncurses builds without ext-color -davidben@mit.edu
     66 * IRC: Fix reconnect behavior. -nelhage@mit.edu
     67 * IRC: Make nick-change events LOGIN messages instead of ADMIN. -nelhage@mit.edu
     68 * IRC: Port module to AnyEvent::IRC. -asedeno@mit.edu, nelhage@nelhage.com
     69 * Ability to set exposure arbitrarily (like "zctl set exposure") -jgross@mit.edu
     70 * Kill --remove-debug option -davidben@mit.edu
     71 * exec: Fix input redirection of multistatement commands -andersk@mit.edu
     72 * Correctly set the realm in outgoing zwrite errors -davidben@mit.edu
     73 * Correctly compute the realm for outgoing messages -davidben@mit.edu
     74 * In duplicated outgoing zephyrs only reply on the relevant recipient -davidben@mit.edu
     75 * Create per-recipient copies of outgoing messages for non-CC'd personals -liudi@mit.edu
     76 * Add black to :show colors -andersk@mit.edu
     77 * Fix reporting of errors from libzephyr -kcr@1ts.org
     78 * Load Encode module for IRC. -timhill@alum.mit.edu
     79 * IRC: Sort the output of :irc-names -nelhage@mit.edu
     80 * Prepend "UNAUTH: " to displayed sender for unauthenticated zephyrs -adam@crossproduct.net
     81 * For ‘punt’ with one argument, quote the filter name -andersk@mit.edu
     82 * Fix spurious error running ‘punt’ with no arguments -andersk@mit.edu
     83 * Only handle CCs in messages sent directly to you. -davidben@mit.edu
     84 * Update copyright notices for 2011 -davidben@mit.edu
     85 * If a smartfilter fails to parse, handle the error -davidben@mit.edu
     86 * Replace per-editwin killbuf with a global one. -adam@crossproduct.net
     87 * Don't use error_message if we are building without Zephyr. -nelhage@mit.edu
     88 * Fix replying to outgoing zwrite when -m is passed -davidben@mit.edu
     89 * Fix a number of quoting bugs -davidben@mit.edu
     90 * Check passwd entries to determine home dir -davidben@mit.edu
     91
     921.7.1
     93 * Append sender's realm to CC'd unqualified names when replying. -adam@crossproduct.net
     94 * Don't reset ncurses colorpairs in the middle of drawing. -davidben@mit.edu
     95 * Fix viewuser when an unqualified name is given. -davidben@mit.edu
     96
    1971.7
     98 * Fix quoting bugs in smartfilter, zpunt, and numerous other commands. -davidben@mit.edu
    299 * Download Twitter consumer keys from barnowl.mit.edu. -nelhage@MIT.EDU
    3100 * Fix unsub when .zephyr.subs is a symlink. -jgross@MIT.EDU
  • Makefile.am

    r3535a6e ra223b6b  
    44GIT_FLAGS := $(if $(GIT_DESCRIPTION),-DGIT_VERSION=$(GIT_DESCRIPTION:barnowl-%=%))
    55
    6 bin_PROGRAMS = barnowl.bin
     6bin_PROGRAMS = bin/barnowl
    77if ENABLE_ZCRYPT
    88bin_PROGRAMS += zcrypt
     
    1111zcrypt_SOURCES = zcrypt.c filterproc.c
    1212
    13 check_PROGRAMS = tester.bin
     13check_PROGRAMS = bin/tester
     14dist_check_DATA = t
     15dist_check_SCRIPTS = runtests.sh
    1416
    15 barnowl_bin_SOURCES = $(BASE_SRCS) \
    16      owl.h owl_perl.h config.h \
    17      owl.c \
    18      $(GEN_C) $(GEN_H)
     17noinst_SCRIPTS = barnowl
     18check_SCRIPTS = tester
    1919
    20 man_MANS = doc/barnowl.1
    21 doc_DATA = doc/intro.txt doc/advanced.txt
     20barnowl tester: %: barnowl-wrapper.in bin/% Makefile
     21        sed \
     22            -e 's,[@]abs_srcdir[@],$(abs_srcdir),g' \
     23            -e 's,[@]abs_builddir[@],$(abs_builddir),g' \
     24            $< > $@
     25        chmod +x $@
    2226
    23 barnowl_bin_LDADD = compat/libcompat.a libfaim/libfaim.a
     27bin_barnowl_SOURCES = $(BASE_SRCS) \
     28     owl.h owl_perl.h \
     29     owl.c
     30nodist_bin_barnowl_SOURCES = $(GEN_C) $(GEN_H)
    2431
    25 tester_bin_SOURCES = $(BASE_SRCS) \
    26      owl.h owl_perl.h config.h \
    27      $(GEN_C) $(GEN_H) \
     32dist_man_MANS = doc/barnowl.1
     33dist_doc_DATA = doc/intro.txt doc/advanced.txt
     34
     35bin_barnowl_LDADD = compat/libcompat.a libfaim/libfaim.a
     36
     37bin_tester_SOURCES = $(BASE_SRCS) \
     38     owl.h owl_perl.h \
    2839     tester.c
     40nodist_bin_tester_SOURCES = $(GEN_C) $(GEN_H)
    2941
    30 tester_bin_LDADD = compat/libcompat.a libfaim/libfaim.a
     42bin_tester_LDADD = compat/libcompat.a libfaim/libfaim.a
    3143
    3244TESTS=runtests.sh
    3345
    34 AM_CPPFLAGS = -I$(top_srcdir)/ \
     46AM_CPPFLAGS = \
    3547           -I$(top_srcdir)/libfaim/ \
    3648           -DDATADIR='"$(pkgdatadir)"' \
     
    3850           $(GIT_FLAGS)
    3951
    40 CODELIST_SRCS=list.c message.c mainwin.c popwin.c zephyr.c messagelist.c \
    41      commands.c global.c text.c fmtext.c editwin.c util.c logging.c \
     52CODELIST_SRCS=message.c mainwin.c popwin.c zephyr.c messagelist.c \
     53     commands.c global.c text.c fmtext.c editwin.c \
     54     util.c logging.c \
    4255     perlconfig.c keys.c functions.c zwrite.c viewwin.c help.c filter.c \
    4356     regex.c history.c view.c dict.c variable.c filterelement.c pair.c \
     
    4558     aim.c buddy.c buddylist.c style.c errqueue.c \
    4659     zbuddylist.c popexec.c select.c wcwidth.c \
    47      glib_compat.c mainpanel.c msgwin.c sepbar.c editcontext.c signal.c
     60     mainpanel.c msgwin.c sepbar.c editcontext.c signal.c closures.c
    4861
    49 NORMAL_SRCS = filterproc.c window.c windowcb.c
     62NORMAL_SRCS = filterproc.c filterproc.h window.c window.h windowcb.c
    5063
    5164BASE_SRCS = $(CODELIST_SRCS) $(NORMAL_SRCS)
    5265
    53 GEN_C = varstubs.c perlglue.c
    54 GEN_H = owl_prototypes.h
     66GEN_C = varstubs.c perlglue.c gmarshal_funcs.c
     67GEN_H = owl_prototypes.h owl_prototypes.h.new gmarshal_funcs.h
    5568
    5669BUILT_SOURCES = $(GEN_C) $(GEN_H)
     
    6578proto: owl_prototypes.h
    6679
    67 perlglue.c: perlglue.xs $(TYPEMAP)
    68         $(AM_V_GEN)perl $(XSUBPPDIR)/xsubpp $(XSUBPPFLAGS) -prototypes perlglue.xs > perlglue.c
     80perlglue.c: perlglue.xs typemap
     81        $(AM_V_GEN)perl $(XSUBPPDIR)/xsubpp $(XSUBPPFLAGS) -prototypes $< > $@
    6982
    7083varstubs.c: stubgen.pl variable.c
     
    7487        $(AM_V_GEN)perl $< $(sort $(filter-out $<,$+)) > $@
    7588
     89gmarshal_funcs.h: marshal_types
     90        glib-genmarshal --header $< > $@
     91gmarshal_funcs.c: marshal_types
     92        glib-genmarshal --body $< > $@
     93
    7694# For emacs flymake-mode
    7795check-syntax: proto
    7896        $(COMPILE) -Wall -Wextra -pedantic -fsyntax-only $(CHK_SOURCES)
    7997
    80 install-data-local:
    81         $(mkinstalldirs) ${DESTDIR}${pkgdatadir}/lib
    82         (cd perl/lib && tar -cf - . ) | (cd ${DESTDIR}${pkgdatadir}/lib && tar -xf - )
    83 
    84 do_transform = $(shell echo '$(1)' | sed '$(transform)')
    85 install-exec-hook:
    86         mv -f $(DESTDIR)$(bindir)/$(call do_transform,barnowl.bin) \
    87               $(DESTDIR)$(bindir)/$(call do_transform,barnowl)
     98CLEANFILES = $(BUILT_SOURCES) $(noinst_SCRIPTS) $(check_SCRIPTS)
     99EXTRA_DIST = \
     100    autogen.sh \
     101    barnowl-wrapper.in \
     102    codelist.pl \
     103    doc/code.txt \
     104    doc/owl-window.txt \
     105    doc/releasing-barnowl.txt \
     106    examples \
     107    marshal_types \
     108    perlglue.xs \
     109    scripts \
     110    stubgen.pl \
     111    typemap
    88112
    89113SUBDIRS = compat libfaim perl
  • README

    r13ee8f2 r1c22155  
    77Notes:
    88-----
    9 This project's perl/lib/ contains the lib directories from the
     9This project's perl/modules/ contains the lib directories from the
    1010following CPAN modules:
    1111
     12Facebook::Graph
    1213Net::Jabber
    1314Net::XMPP
    1415XML::Stream
    1516
    16 They have been modified slightly for the needs of this project.
     17Some have been modified slightly for the needs of this project.
    1718
    1819BarnOwl currently requires the following perl modules off of CPAN:
    1920
    2021AnyEvent
     22Class::Accessor
     23ExtUtils::Depends
     24Glib
     25Module::Install
    2126PAR
    22 Net::DNS
    23 Authen::SASL::Perl
    24 IO::Socket::SSL
    25 Digest::SHA1
    2627
    2728(Note that these are all available as Debian packages)
     
    2930these for you.
    3031
     32The Facebook module requires:
     33
     34Any::Moose
     35AnyEvent::HTTP
     36DateTime
     37DateTime::Format::Strptime
     38JSON
     39MIME::Base64::URLSafe
     40Ouch
     41URI
     42URI::Encode
     43
    3144The IRC module requires:
    3245
    3346AnyEvent::IRC
    34 Class::Accessor
     47
     48The Jabber module requires:
     49
     50Net::DNS
     51Authen::SASL::Perl
     52IO::Socket::SSL
     53Digest::SHA
     54
     55The Twitter module requires:
     56
     57HTML::Entities
     58Net::Twitter::Lite
    3559
    3660The WordWrap module requires:
  • aim.c

    rdc1edbd r8258ea5  
    1 #include <stdio.h>
    2 #include <stdio.h>
    3 #include <sys/stat.h>
    41#include "owl.h"
    52
     
    113110}
    114111
    115 void owl_aim_send_nop(owl_timer *t, void *data) {
    116     if(owl_global_is_doaimevents(&g)) {
    117         aim_session_t *sess = owl_global_get_aimsess(&g);
    118         aim_flap_nop(sess, aim_getconn_type(sess, AIM_CONN_TYPE_BOS));
    119     }
     112gboolean owl_aim_send_nop(gpointer data) {
     113  owl_global *g = data;
     114  if (owl_global_is_doaimevents(g)) {
     115    aim_session_t *sess = owl_global_get_aimsess(g);
     116    aim_flap_nop(sess, aim_getconn_type(sess, AIM_CONN_TYPE_BOS));
     117  }
     118  return TRUE;
    120119}
    121120
     
    183182  owl_function_debugmsg("owl_aim_login: connecting");
    184183
    185   g.aim_nop_timer = owl_select_add_timer("owl_aim_send_nop", 30, 30, owl_aim_send_nop, NULL, NULL);
     184  g.aim_nop_timer = g_timeout_add_seconds(30, owl_aim_send_nop, &g);
    186185
    187186  return(0);
    188187}
    189188
    190 static void owl_aim_unset_ignorelogin(owl_timer *t, void *data)
    191 {
    192     owl_global_unset_ignore_aimlogin(&g);
     189static gboolean owl_aim_unset_ignorelogin(void *data)
     190{
     191  owl_global *g = data;
     192  owl_global_unset_ignore_aimlogin(g);
     193  return FALSE;  /* only run once. */
    193194}
    194195
     
    209210  /* start the ingorelogin timer */
    210211  owl_global_set_ignore_aimlogin(&g);
    211   owl_select_add_timer("owl_aim_unset_ignorelogin",
    212                        owl_global_get_aim_ignorelogin_timer(&g),
    213                        0, owl_aim_unset_ignorelogin, NULL, NULL);
     212  g_timeout_add_seconds(owl_global_get_aim_ignorelogin_timer(&g),
     213                        owl_aim_unset_ignorelogin, &g);
    214214
    215215  /* aim_ssi_setpresence(owl_global_get_aimsess(&g), 0x00000400); */
     
    225225  owl_global_set_aimnologgedin(&g);
    226226  owl_global_set_no_doaimevents(&g);
    227   owl_select_remove_timer(g.aim_nop_timer);
     227  if (g.aim_nop_timer) {
     228    g_source_remove(g.aim_nop_timer);
     229    g.aim_nop_timer = 0;
     230  }
    228231}
    229232
     
    244247  owl_global_set_aimnologgedin(&g);
    245248  owl_global_set_no_doaimevents(&g);
    246   owl_select_remove_timer(g.aim_nop_timer);
     249  if (g.aim_nop_timer) {
     250    g_source_remove(g.aim_nop_timer);
     251    g.aim_nop_timer = 0;
     252  }
    247253}
    248254
     
    428434
    429435/* caller must free the return */
    430 char *owl_aim_normalize_screenname(const char *in)
     436CALLER_OWN char *owl_aim_normalize_screenname(const char *in)
    431437{
    432438  char *out;
     
    701707{
    702708  aim_clientready(sess, fr->conn);
    703   owl_function_debugmsg("conninitdone_admin: initializtion done for admin connection");
     709  owl_function_debugmsg("conninitdone_admin: initialization done for admin connection");
    704710  return(1);
    705711}
     
    830836  params = va_arg(ap, struct aim_icbmparameters *);
    831837  va_end(ap);
    832  
    833   owl_function_debugmsg("faimtest_icbmparaminfo: ICBM Parameters: maxchannel = %d, default flags = 0x%08x, max msg len = %d, max sender evil = %f, max reciever evil = %f, min msg interval = %u",
     838
     839  owl_function_debugmsg("faimtest_icbmparaminfo: ICBM Parameters: maxchannel = %d, default flags = 0x%08x, max msg len = %d, max sender evil = %f, max receiver evil = %f, min msg interval = %u",
    834840                       params->maxchan, params->flags, params->maxmsglen, ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, params->minmsginterval);
    835841     
     
    10551061  g_free(wrapmsg);
    10561062  g_free(nz_screenname);
     1063  g_free(realmsg);
    10571064
    10581065  return(1);
    10591066
    1060   owl_function_debugmsg("faimtest_parse_incoming_im_chan1: icbm: message: %s\n", realmsg);
    1061  
    1062   if (args->icbmflags & AIM_IMFLAGS_MULTIPART) {
    1063     aim_mpmsg_section_t *sec;
    1064     int z;
    1065 
    1066     owl_function_debugmsg("faimtest_parse_incoming_im_chan1: icbm: multipart: this message has %d parts\n", args->mpmsg.numparts);
    1067    
    1068     for (sec = args->mpmsg.parts, z = 0; sec; sec = sec->next, z++) {
    1069       if ((sec->charset == 0x0000) || (sec->charset == 0x0003) || (sec->charset == 0xffff)) {
    1070         owl_function_debugmsg("faimtest_parse_incoming_im_chan1: icbm: multipart:   part %d: charset 0x%04x, subset 0x%04x, msg = %s\n", z, sec->charset, sec->charsubset, sec->data);
    1071       } else {
    1072         owl_function_debugmsg("faimtest_parse_incoming_im_chan1: icbm: multipart:   part %d: charset 0x%04x, subset 0x%04x, binary or UNICODE data\n", z, sec->charset, sec->charsubset);
    1073       }
    1074     }
    1075   }
    1076  
    1077   if (args->icbmflags & AIM_IMFLAGS_HASICON) {
    1078     /* aim_send_im(sess, userinfo->sn, AIM_IMFLAGS_BUDDYREQ, "You have an icon"); */
    1079     owl_function_debugmsg("faimtest_parse_incoming_im_chan1: icbm: their icon: iconstamp = %ld, iconlen = 0x%08x, iconsum = 0x%04x\n", args->iconstamp, args->iconlen, args->iconsum);
    1080   }
    1081 
    1082   g_free(realmsg);
    1083 
    1084   return(1);
     1067  /* TODO: Multipart? See history from before 1.8 release. */
    10851068}
    10861069
     
    14301413  const char *address, *SNs;
    14311414  int num, i;
    1432   owl_list list;
     1415  GPtrArray *list;
    14331416 
    14341417  va_start(ap, fr);
     
    14381421  va_end(ap);
    14391422
    1440   owl_list_create(&list);
     1423  list = g_ptr_array_new();
    14411424 
    14421425  owl_function_debugmsg("faimtest_parse_searchreply: E-Mail Search Results for %s: ", address);
    14431426  for (i=0; i<num; i++) {
    14441427    owl_function_debugmsg("  %s", &SNs[i*(MAXSNLEN+1)]);
    1445     owl_list_append_element(&list, (void *)&SNs[i*(MAXSNLEN+1)]);
    1446   }
    1447   owl_function_aimsearch_results(address, &list);
    1448   owl_list_cleanup(&list, NULL);
    1449   return(1);
     1428    g_ptr_array_add(list, (void *)&SNs[i*(MAXSNLEN+1)]);
     1429  }
     1430  owl_function_aimsearch_results(address, list);
     1431  g_ptr_array_free(list, true);
     1432  return 1;
    14501433}
    14511434
     
    18031786  GPollFD *fd;
    18041787  int i;
    1805   if (len < event_source->fds->len)
     1788  if (len < event_source->fds->len) {
    18061789    owl_function_debugmsg("Truncating AIM PollFDs to %d, was %d", len, event_source->fds->len);
    1807   for (i = len; i < event_source->fds->len; i++) {
    1808     fd = event_source->fds->pdata[i];
    1809     g_source_remove_poll(&event_source->source, fd);
    1810     g_free(fd);
    1811   }
    1812   g_ptr_array_remove_range(event_source->fds, len, event_source->fds->len - len);
     1790    for (i = len; i < event_source->fds->len; i++) {
     1791      fd = event_source->fds->pdata[i];
     1792      g_source_remove_poll(&event_source->source, fd);
     1793      g_free(fd);
     1794    }
     1795    g_ptr_array_remove_range(event_source->fds, len, event_source->fds->len - len);
     1796  }
    18131797}
    18141798
     
    18421826      fd = event_source->fds->pdata[i];
    18431827      fd->fd = cur->fd;
    1844       fd->events |= G_IO_IN | G_IO_HUP | G_IO_ERR;
     1828      fd->events = G_IO_IN | G_IO_HUP | G_IO_ERR;
    18451829      if (cur->status & AIM_CONN_STATUS_INPROGRESS) {
    1846         /* Yes, we're checking writable sockets here. Without it, AIM
    1847            login is really slow. */
     1830        /* AIM login requires checking writable sockets. See aim_select. */
    18481831        fd->events |= G_IO_OUT;
    18491832      }
     
    18811864{
    18821865  owl_aim_event_source *event_source = (owl_aim_event_source*)source;
    1883   truncate_pollfd_list(event_source, 0);
    1884   g_ptr_array_free(event_source->fds, TRUE);
     1866  /* Don't remove the GPollFDs. We are being finalized, so they'll be removed
     1867   * for us. Moreover, glib will fire asserts if g_source_remove_poll is called
     1868   * on a source which has been destroyed (which occurs when g_source_remove is
     1869   * called on it). */
     1870  owl_ptr_array_free(event_source->fds, g_free);
    18851871}
    18861872
  • 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

    r4c7c21f rf271129  
    1 #include <stdio.h>
    2 #include <stdlib.h>
    3 #include <string.h>
    4 #include <unistd.h>
    51#include "owl.h"
    6 
    7 extern const owl_cmd commands_to_init[];
    82
    93/**************************************************************************/
     
    115/**************************************************************************/
    126
    13 int owl_cmddict_setup(owl_cmddict *cd) {
     7void owl_cmddict_setup(owl_cmddict *cd)
     8{
    149  owl_cmddict_init(cd);
    15   if (0 != owl_cmddict_add_from_list(cd, commands_to_init)) return(-1);
    16   return(0);
     10  owl_cmd_add_defaults(cd);
    1711}
    1812
     
    2216
    2317/* for bulk initialization at startup */
    24 int owl_cmddict_add_from_list(owl_cmddict *cd, const owl_cmd *cmds) {
     18void owl_cmddict_add_from_list(owl_cmddict *cd, const owl_cmd *cmds)
     19{
    2520  const owl_cmd *cur;
    26   int ret = 0;
    2721  for (cur = cmds; cur->name != NULL; cur++) {
    28     ret = owl_cmddict_add_cmd(cd, cur);
    29     if (ret < 0) break;
    30   }
    31   return ret;
    32 }
    33 
    34 void owl_cmddict_get_names(const owl_cmddict *d, owl_list *l) {
    35   owl_dict_get_keys(d, l);
     22    owl_cmddict_add_cmd(cd, cur);
     23  }
     24}
     25
     26GPtrArray *owl_cmddict_get_names(const owl_cmddict *d) {
     27  return owl_dict_get_keys(d);
    3628}
    3729
     
    4133
    4234/* creates a new command alias */
    43 int owl_cmddict_add_alias(owl_cmddict *cd, const char *alias_from, const char *alias_to) {
     35void owl_cmddict_add_alias(owl_cmddict *cd, const char *alias_from, const char *alias_to) {
    4436  owl_cmd *cmd;
    4537  cmd = g_new(owl_cmd, 1);
     
    4739  owl_perlconfig_new_command(cmd->name);
    4840  owl_dict_insert_element(cd, cmd->name, cmd, (void (*)(void *))owl_cmd_delete);
    49   return(0);
    5041}
    5142
     
    6051}
    6152
    62 char *_owl_cmddict_execute(const owl_cmddict *cd, const owl_context *ctx, const char *const *argv, int argc, const char *buff) {
     53/* caller must free the return */
     54CALLER_OWN char *_owl_cmddict_execute(const owl_cmddict *cd, const owl_context *ctx, const char *const *argv, int argc, const char *buff)
     55{
    6356  char *retval = NULL;
    6457  const owl_cmd *cmd;
     
    7568}
    7669
    77 char *owl_cmddict_execute(const owl_cmddict *cd, const owl_context *ctx, const char *cmdbuff) {
     70/* caller must free the return */
     71CALLER_OWN char *owl_cmddict_execute(const owl_cmddict *cd, const owl_context *ctx, const char *cmdbuff)
     72{
    7873  char **argv;
    7974  int argc;
     
    9792}
    9893
    99 char *owl_cmddict_execute_argv(const owl_cmddict *cd, const owl_context *ctx, const char *const *argv, int argc) {
     94/* caller must free the return */
     95CALLER_OWN char *owl_cmddict_execute_argv(const owl_cmddict *cd, const owl_context *ctx, const char *const *argv, int argc)
     96{
    10097  char *buff;
    10198  char *retval = NULL;
     
    124121}
    125122
    126 int owl_cmd_create_alias(owl_cmd *cmd, const char *name, const char *aliased_to) {
     123void owl_cmd_create_alias(owl_cmd *cmd, const char *name, const char *aliased_to) {
    127124  memset(cmd, 0, sizeof(owl_cmd));
    128125  cmd->name = g_strdup(name);
    129126  cmd->cmd_aliased_to = g_strdup(aliased_to);
    130127  cmd->summary = g_strdup_printf("%s%s", OWL_CMD_ALIAS_SUMMARY_PREFIX, aliased_to);
    131   return(0);
    132128}
    133129
     
    153149}
    154150
    155 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) {
     151/* caller must free the result */
     152CALLER_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)
     153{
    156154  static int alias_recurse_depth = 0;
    157155  int ival=0;
     
    226224
    227225/* returns a summary line describing this keymap.  the caller must free. */
    228 char *owl_cmd_describe(const owl_cmd *cmd) {
     226CALLER_OWN char *owl_cmd_describe(const owl_cmd *cmd)
     227{
    229228  if (!cmd || !cmd->name || !cmd->summary) return NULL;
    230229  return g_strdup_printf("%-25s - %s", cmd->name, cmd->summary);
     
    257256  if (cmd->usage && *cmd->usage) {
    258257    s = cmd->usage;
    259     indent = owl_text_indent(s, OWL_TAB);
     258    indent = owl_text_indent(s, OWL_TAB, true);
    260259    owl_fmtext_append_bold(fm, "\nSYNOPSIS\n");
    261260    owl_fmtext_append_normal(fm, indent);
     
    271270  if (cmd->description && *cmd->description) {
    272271    s = cmd->description;
    273     indent = owl_text_indent(s, OWL_TAB);
     272    indent = owl_text_indent(s, OWL_TAB, true);
    274273    owl_fmtext_append_bold(fm, "\nDESCRIPTION\n");
    275274    owl_fmtext_append_normal(fm, indent);
  • commands.c

    r697221f r3b9ca71  
     1#include "owl.h"
    12#include <getopt.h>
    2 #include <stdio.h>
    3 #include <stdlib.h>
    4 #include <string.h>
    5 #include <unistd.h>
    6 #include "owl.h"
    73
    84/* fn is "char *foo(int argc, const char *const *argv, const char *buff)" */
    95#define OWLCMD_ARGS(name, fn, ctx, summary, usage, description) \
    10         { name, summary, usage, description, ctx, \
     6        { g_strdup(name), g_strdup(summary), g_strdup(usage), g_strdup(description), ctx, \
    117          NULL, fn, NULL, NULL, NULL, NULL, NULL, NULL }
    128
    139/* fn is "void foo(void)" */
    1410#define OWLCMD_VOID(name, fn, ctx, summary, usage, description) \
    15         { name, summary, usage, description, ctx, \
     11        { g_strdup(name), g_strdup(summary), g_strdup(usage), g_strdup(description), ctx, \
    1612          NULL, NULL, fn, NULL, NULL, NULL, NULL, NULL }
    1713
    1814/* fn is "void foo(int)" */
    1915#define OWLCMD_INT(name, fn, ctx, summary, usage, description) \
    20         { name, summary, usage, description, ctx, \
     16        { g_strdup(name), g_strdup(summary), g_strdup(usage), g_strdup(description), ctx, \
    2117          NULL, NULL, NULL, fn, NULL, NULL, NULL, NULL }
    2218
    2319#define OWLCMD_ALIAS(name, actualname) \
    24         { name, OWL_CMD_ALIAS_SUMMARY_PREFIX actualname, "", "", OWL_CTX_ANY, \
    25           actualname, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
     20        { g_strdup(name), g_strdup(OWL_CMD_ALIAS_SUMMARY_PREFIX actualname), g_strdup(""), g_strdup(""), OWL_CTX_ANY, \
     21          g_strdup(actualname), NULL, NULL, NULL, NULL, NULL, NULL, NULL }
    2622
    2723/* fn is "char *foo(void *ctx, int argc, const char *const *argv, const char *buff)" */
    2824#define OWLCMD_ARGS_CTX(name, fn, ctx, summary, usage, description) \
    29         { name, summary, usage, description, ctx, \
     25        { g_strdup(name), g_strdup(summary), g_strdup(usage), g_strdup(description), ctx, \
    3026          NULL, NULL, NULL, NULL, ((char*(*)(void*,int,const char*const *,const char*))fn), NULL, NULL, NULL }
    3127
    3228/* fn is "void foo(void)" */
    3329#define OWLCMD_VOID_CTX(name, fn, ctx, summary, usage, description) \
    34         { name, summary, usage, description, ctx, \
     30        { g_strdup(name), g_strdup(summary), g_strdup(usage), g_strdup(description), ctx, \
    3531          NULL, NULL, NULL, NULL, NULL, ((void(*)(void*))(fn)), NULL, NULL }
    3632
    3733/* fn is "void foo(int)" */
    3834#define OWLCMD_INT_CTX(name, fn, ctx, summary, usage, description) \
    39         { name, summary, usage, description, ctx, \
     35        { g_strdup(name), g_strdup(summary), g_strdup(usage), g_strdup(description), ctx, \
    4036          NULL, NULL, NULL, NULL, NULL, NULL, ((void(*)(void*,int))fn), NULL }
    4137
    4238
    43 const owl_cmd commands_to_init[]
    44   = {
     39void owl_cmd_add_defaults(owl_cmddict *cd)
     40{
     41  owl_cmd commands_to_init[] = {
     42
    4543  OWLCMD_ARGS("zlog", owl_command_zlog, OWL_CTX_ANY,
    4644              "send a login or logout notification",
     
    4846              "zlog in will send a login notification, zlog out will send a\n"
    4947              "logout notification.  By default a login notification is sent\n"
    50               "when owl is started and a logout notification is sent when owl\n"
     48              "when BarnOwl is started and a logout notification is sent when owl\n"
    5149              "is exited.  This behavior can be changed with the 'startuplogin'\n"
    5250              "and 'shutdownlogout' variables.  If a tty is specified for zlog in\n"
    53               "then the owl variable 'tty' will be set to that string, causing\n"
     51              "then the BarnOwl variable 'tty' will be set to that string, causing\n"
    5452              "it to be used as the zephyr location tty.\n"),
    5553
    5654  OWLCMD_VOID("quit", owl_command_quit, OWL_CTX_ANY,
    57               "exit owl",
     55              "exit BarnOwl",
    5856              "",
    59               "Exit owl and run any shutdown activities."),
     57              "Exit BarnOwl and run any shutdown activities."),
    6058  OWLCMD_ALIAS("exit", "quit"),
    6159  OWLCMD_ALIAS("q",    "quit"),
     
    9896  OWLCMD_ARGS("unbindkey", owl_command_unbindkey, OWL_CTX_ANY,
    9997              "removes a binding in a keymap",
    100               "bindkey <keymap> <keyseq>",
     98              "unbindkey <keymap> <keyseq>",
    10199              "Removes a binding of a key sequence within a keymap.\n"
    102100              "Use 'show keymaps' to see the existing keymaps.\n"
     
    178176
    179177  OWLCMD_ARGS("startup", owl_command_startup, OWL_CTX_ANY,
    180               "run a command and set it to be run at every Owl startup",
     178              "run a command and set it to be run at every BarnOwl startup",
    181179              "startup <commands> ...",
    182180              "Everything on the command line after the startup command\n"
    183               "is executed as a normal owl command and is also placed in\n"
    184               "a file so that the command is executed every time owl\n"
     181              "is executed as a normal BarnOwl command and is also placed in\n"
     182              "a file so that the command is executed every time BarnOwl\n"
    185183              "is started"),
    186184
    187185  OWLCMD_ARGS("unstartup", owl_command_unstartup, OWL_CTX_ANY,
    188               "remove a command from the list of those to be run at Owl startup",
     186              "remove a command from the list of those to be run at BarnOwl startup",
    189187              "unstartup <commands> ...",
    190188              ""),
    191189
    192190  OWLCMD_VOID("version", owl_command_version, OWL_CTX_ANY,
    193               "print the version of the running owl", "", ""),
     191              "print the version of the running BarnOwl", "", ""),
    194192
    195193  OWLCMD_ARGS("subscribe", owl_command_subscribe, OWL_CTX_ANY,
     
    202200              "only be temporary, i.e., it will not be written to\n"
    203201              "the subscription file and will therefore not be\n"
    204               "present the next time owl is started.\n"),
     202              "present the next time BarnOwl is started.\n"),
    205203  OWLCMD_ALIAS("sub", "subscribe"),
    206204
     
    214212              "only be temporary, i.e., it will not be updated in\n"
    215213              "the subscription file and will therefore not be\n"
    216               "in effect the next time owl is started.\n"),
     214              "in effect the next time BarnOwl is started.\n"),
    217215  OWLCMD_ALIAS("unsub", "unsubscribe"),
    218216
     
    232230
    233231  OWLCMD_ARGS("source", owl_command_source, OWL_CTX_ANY,
    234               "execute owl commands from a file",
     232              "execute BarnOwl commands from a file",
    235233              "source <filename>",
    236               "Execute the owl commands in <filename>.\n"),
     234              "Execute the BarnOwl commands in <filename>.\n"),
    237235
    238236  OWLCMD_ARGS("aim", owl_command_aim, OWL_CTX_INTERACTIVE,
     
    303301 
    304302  OWLCMD_ARGS("help", owl_command_help, OWL_CTX_INTERACTIVE,
    305               "display help on using owl",
     303              "display help on using BarnOwl",
    306304              "help [command]", ""),
    307305
     
    416414
    417415  OWLCMD_VOID("suspend", owl_command_suspend, OWL_CTX_ANY,
    418               "suspend owl", "", ""),
     416              "suspend BarnOwl", "", ""),
    419417
    420418  OWLCMD_ARGS("echo", owl_command_echo, OWL_CTX_ANY,
     
    507505
    508506  OWLCMD_VOID("about", owl_command_about, OWL_CTX_INTERACTIVE,
    509               "print information about owl", "", ""),
     507              "print information about BarnOwl", "", ""),
    510508
    511509  OWLCMD_VOID("status", owl_command_status, OWL_CTX_ANY,
    512               "print status information about the running owl", "", ""),
     510              "print status information about the running BarnOwl", "", ""),
    513511 
    514512  OWLCMD_ARGS("zlocate", owl_command_zlocate, OWL_CTX_INTERACTIVE,
     
    588586              "The other usages listed above are abbreviated forms that simply set\n"
    589587              "the filter of the current view. The -d option allows you to write a\n"
    590               "filter expression that will be dynamically created by owl and then\n"
     588              "filter expression that will be dynamically created by BarnOwl and then\n"
    591589              "applied as the view's filter\n"
    592590              "SEE ALSO: filter, viewclass, viewuser\n"),
     
    654652              "show subscriptions / show subs\n"
    655653              "show terminal\n"
    656               "show timers\n"
    657654              "show variables\n"
    658655              "show variable <variable>\n"
     
    675672              "for formatting messages.\n\n"
    676673              "Show variables will list the names of all variables.\n\n"
    677               "Show errors will show a list of errors encountered by Owl.\n\n"
     674              "Show errors will show a list of errors encountered by BarnOwl.\n\n"
    678675              "SEE ALSO: filter, view, alias, bindkey, help\n"),
    679676 
     
    693690  OWLCMD_ALIAS("del", "delete"),
    694691
     692  OWLCMD_ARGS("delete-and-expunge", owl_command_delete_and_expunge, OWL_CTX_INTERACTIVE,
     693              "delete a message",
     694              "delete-and-expunge [-id msgid] [-q | --quiet]",
     695              "If no message id is specified the current message is deleted.\n"
     696              "Otherwise the message with the given message id is deleted.\n"
     697              "If --quiet is specified, then there is no message displayed on\n"
     698              "success.\n"),
     699  OWLCMD_ALIAS("delx", "delete-and-expunge"),
     700
    695701  OWLCMD_ARGS("undelete", owl_command_undelete, OWL_CTX_INTERACTIVE,
    696702              "unmark a message for deletion",
     
    10271033  OWLCMD_ARGS_CTX("popless:start-search", owl_viewwin_command_start_search, OWL_CTX_POPLESS,
    10281034                  "starts a command line to search for particular string",
    1029                   "popless:start-search [-r] [inital-value]",
     1035                  "popless:start-search [-r] [initial-value]",
    10301036                  "Initializes the command-line to search for initial-value. If\n"
    10311037                  "-r is used, the search will be performed backwards.\n\n"
     
    10371043  { NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
    10381044
    1039 };
     1045  };
     1046
     1047  owl_cmddict_add_from_list(cd, commands_to_init);
     1048  owl_cmd *cmd;
     1049  for (cmd = commands_to_init; cmd->name != NULL; cmd++)
     1050    owl_cmd_cleanup(cmd);
     1051}
    10401052
    10411053void owl_command_info(void)
     
    13661378}
    13671379
    1368 char *owl_command_smartfilter(int argc, const char *const *argv, const char *buff)
     1380CALLER_OWN char *owl_command_smartfilter(int argc, const char *const *argv, const char *buff)
    13691381{
    13701382  char *filtname = NULL;
     
    14061418}
    14071419
    1408 char *owl_command_get_shift(int argc, const char *const *argv, const char *buff)
     1420CALLER_OWN char *owl_command_get_shift(int argc, const char *const *argv, const char *buff)
    14091421{
    14101422  if(argc != 1)
     
    15651577  int  silent=0;
    15661578  int requirebool=0;
     1579  owl_variable *v;
    15671580
    15681581  if (argc == 1) {
     
    15871600    return NULL;
    15881601  }
    1589   owl_variable_set_fromstring(owl_global_get_vardict(&g), var, val, !silent, requirebool);
     1602
     1603  v = owl_variable_get_var(owl_global_get_vardict(&g), var);
     1604  if (v == NULL) {
     1605    if (!silent) owl_function_error("Unknown variable '%s'", var);
     1606  } else if (requirebool && !v->takes_on_off) {
     1607    if (!silent) owl_function_error("Variable '%s' is not a boolean", var);
     1608  } else {
     1609    owl_variable_set_fromstring(v, val, !silent);
     1610  }
    15901611  return NULL;
    15911612}
     
    15931614char *owl_command_unset(int argc, const char *const *argv, const char *buff)
    15941615{
     1616  owl_variable *v;
    15951617  const char *var, *val;
    15961618  int  silent=0;
     
    16071629    return NULL;
    16081630  }
    1609   owl_variable_set_fromstring(owl_global_get_vardict(&g), var, val, !silent, 1);
     1631
     1632  v = owl_variable_get_var(owl_global_get_vardict(&g), var);
     1633  if (v == NULL) {
     1634    if (!silent) owl_function_error("Unknown variable '%s'", var);
     1635  } else if (!v->takes_on_off) {
     1636    if (!silent) owl_function_error("Variable '%s' is not a boolean", var);
     1637  } else {
     1638    owl_variable_set_fromstring(v, val, !silent);
     1639  }
    16101640  return NULL;
    16111641}
     
    16151645  const char *var;
    16161646  char *value;
     1647  const owl_variable *v;
    16171648
    16181649  if (argc==1) {
     
    16261657  var=argv[1];
    16271658   
    1628   value = owl_variable_get_tostring(owl_global_get_vardict(&g), var);
    1629   if (value) {
    1630     owl_function_makemsg("%s = '%s'", var, value);
     1659  v = owl_variable_get_var(owl_global_get_vardict(&g), var);
     1660  if (v) {
     1661    value = owl_variable_get_tostring(v);
     1662    if (value == NULL)
     1663      owl_function_makemsg("%s = <null>", var);
     1664    else
     1665      owl_function_makemsg("%s = '%s'", var, value);
    16311666    g_free(value);
    16321667  } else {
     
    16371672
    16381673
    1639 char *owl_command_exec(int argc, const char *const *argv, const char *buff)
     1674CALLER_OWN char *owl_command_exec(int argc, const char *const *argv, const char *buff)
    16401675{
    16411676  return owl_function_exec(argc, argv, buff, OWL_OUTPUT_RETURN);
    16421677}
    16431678
    1644 char *owl_command_pexec(int argc, const char *const *argv, const char *buff)
     1679CALLER_OWN char *owl_command_pexec(int argc, const char *const *argv, const char *buff)
    16451680{
    16461681  return owl_function_exec(argc, argv, buff, OWL_OUTPUT_POPUP);
    16471682}
    16481683
    1649 char *owl_command_aexec(int argc, const char *const *argv, const char *buff)
     1684CALLER_OWN char *owl_command_aexec(int argc, const char *const *argv, const char *buff)
    16501685{
    16511686  return owl_function_exec(argc, argv, buff, OWL_OUTPUT_ADMINMSG);
    16521687}
    16531688
    1654 char *owl_command_perl(int argc, const char *const *argv, const char *buff)
     1689CALLER_OWN char *owl_command_perl(int argc, const char *const *argv, const char *buff)
    16551690{
    16561691  return owl_function_perl(argc, argv, buff, OWL_OUTPUT_RETURN);
    16571692}
    16581693
    1659 char *owl_command_pperl(int argc, const char *const *argv, const char *buff)
     1694CALLER_OWN char *owl_command_pperl(int argc, const char *const *argv, const char *buff)
    16601695{
    16611696  return owl_function_perl(argc, argv, buff, OWL_OUTPUT_POPUP);
    16621697}
    16631698
    1664 char *owl_command_aperl(int argc, const char *const *argv, const char *buff)
     1699CALLER_OWN char *owl_command_aperl(int argc, const char *const *argv, const char *buff)
    16651700{
    16661701  return owl_function_perl(argc, argv, buff, OWL_OUTPUT_ADMINMSG);
    16671702}
    16681703
    1669 char *owl_command_multi(int argc, const char *const *argv, const char *buff)
     1704CALLER_OWN char *owl_command_multi(int argc, const char *const *argv, const char *buff)
    16701705{
    16711706  char *lastrv = NULL, *newbuff;
     
    17431778
    17441779  if (argc < 3) {
    1745     owl_function_makemsg("Usage: bindkey <keymap> <binding>");
     1780    owl_function_makemsg("Usage: unbindkey <keymap> <binding>");
    17461781    return NULL;
    17471782  }
     
    19501985  }
    19511986  /* check for a zwrite -m */
    1952   z = owl_zwrite_new(buff);
     1987  z = owl_zwrite_new(argc, argv);
    19531988  if (!z) {
    19541989    owl_function_error("Error in zwrite arguments");
     
    21262161      myargv[i]=argv[i];
    21272162    }
    2128     owl_function_create_filter(argc, myargv);
    2129     owl_function_change_currentview_filter("owl-dynamic");
     2163    if (owl_function_create_filter(argc, myargv)) {
     2164      owl_function_change_currentview_filter("owl-dynamic");
     2165    }
    21302166    g_free(myargv);
    21312167    return NULL;
     
    21542190    if (!strcmp(argv[0], "-f")) {
    21552191      if (argc<2) {
    2156         owl_function_makemsg("Too few argments to the view command");
     2192        owl_function_makemsg("Too few arguments to the view command");
    21572193        return(NULL);
    21582194      }
     
    21662202    } else if (!strcmp(argv[0], "-s")) {
    21672203      if (argc<2) {
    2168         owl_function_makemsg("Too few argments to the view command");
     2204        owl_function_makemsg("Too few arguments to the view command");
    21692205        return(NULL);
    21702206      }
     
    21732209      argv+=2;
    21742210    } else {
    2175       owl_function_makemsg("Too few argments to the view command");
     2211      owl_function_makemsg("Too few arguments to the view command");
    21762212      return(NULL);
    21772213    }
     
    22252261  } else if (!strcmp(argv[1], "styles")) {
    22262262    owl_function_show_styles();
    2227   } else if (!strcmp(argv[1], "timers")) {
    2228     owl_function_show_timers();
    22292263  } else if (!strcmp(argv[1], "subs") || !strcmp(argv[1], "subscriptions")) {
    22302264    owl_function_getsubs();
     
    23262360}
    23272361
     2362char *owl_command_delete_and_expunge(int argc, const char *const *argv, const char *buff)
     2363{
     2364  bool exclaim_success = true;
     2365
     2366  if (argc > 1 && (!strcmp(argv[1], "-q") || !strcmp(argv[1], "--quiet"))) {
     2367    exclaim_success = false;
     2368    argc--;
     2369    argv++;
     2370  } else if (!strcmp(argv[argc - 1], "-q") || !strcmp(argv[argc - 1], "--quiet")) {
     2371    exclaim_success = false;
     2372    argc--;
     2373  }
     2374
     2375  if (argc == 1) {
     2376    owl_function_delete_and_expunge_cur(exclaim_success);
     2377    return NULL;
     2378  }
     2379
     2380  if (argc == 3 && (!strcmp(argv[1], "-id") || !strcmp(argv[1], "--id"))) {
     2381    owl_function_delete_and_expunge_by_id(atoi(argv[2]), exclaim_success);
     2382    return NULL;
     2383  }
     2384
     2385  owl_function_makemsg("Unknown arguments to delete-and-expunge command");
     2386  return NULL;
     2387}
     2388
    23282389char *owl_command_undelete(int argc, const char *const *argv, const char *buff)
    23292390{
     
    24622523void owl_command_punt_unpunt(int argc, const char *const * argv, const char *buff, int unpunt)
    24632524{
    2464   owl_list * fl;
    2465   owl_filter * f;
     2525  GPtrArray * fl;
    24662526  int i;
    24672527
     
    24712531  } else if(argc == 2) {
    24722532    /* Handle :unpunt <number> */
    2473     if(unpunt && (i=atoi(argv[1])) !=0) {
     2533    if (unpunt && (i = atoi(argv[1])) > 0) {
    24742534      i--;      /* Accept 1-based indexing */
    2475       if(i < owl_list_get_size(fl)) {
    2476         f = owl_list_get_element(fl, i);
    2477         owl_list_remove_element(fl, i);
    2478         owl_filter_delete(f);
     2535      if (i < fl->len) {
     2536        owl_filter_delete(g_ptr_array_remove_index(fl, i));
    24792537        return;
    24802538      } else {
     
    25032561}
    25042562
    2505 char *owl_command_getvar(int argc, const char *const *argv, const char *buff)
    2506 {
     2563CALLER_OWN char *owl_command_getvar(int argc, const char *const *argv, const char *buff)
     2564{
     2565  const owl_variable *v;
    25072566  if (argc != 2) {
    25082567    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);
    25092568    return NULL;
    25102569  }
    2511   return owl_variable_get_tostring(owl_global_get_vardict(&g), argv[1]);
     2570  v = owl_variable_get_var(owl_global_get_vardict(&g), argv[1]);
     2571  if (v == NULL) return NULL;
     2572  return owl_variable_get_tostring(v);
    25122573}
    25132574
     
    25892650}
    25902651
    2591 char *owl_command_getstyle(int argc, const char *const *argv, const char *buff)
     2652CALLER_OWN char *owl_command_getstyle(int argc, const char *const *argv, const char *buff)
    25922653{
    25932654  const char *stylename;
     
    26272688  ptr = skiptokens(buff, 1);
    26282689  hist = owl_global_get_cmd_history(&g);
    2629   owl_history_store(hist, ptr);
    2630   owl_history_reset(hist);
     2690  owl_history_store(hist, ptr, false);
    26312691  /* owl_function_makemsg("History '%s' stored successfully", ptr+1); */
    26322692  return NULL;
    26332693}
    26342694
    2635 char *owl_command_with_history(int argc, const char *const *argv, const char *buff)
     2695CALLER_OWN char *owl_command_with_history(int argc, const char *const *argv, const char *buff)
    26362696{
    26372697  owl_history *hist;
     
    26502710
    26512711  hist = owl_global_get_cmd_history(&g);
    2652   owl_history_store(hist, ptr);
    2653   owl_history_reset(hist);
     2712  owl_history_store(hist, ptr, false);
    26542713  return owl_function_command(ptr);
    26552714}
     
    27342793
    27352794  hist = owl_editwin_get_history(e);
    2736   if (hist) {
    2737     owl_history_store(hist, owl_editwin_get_text(e));
    2738     owl_history_reset(hist);
    2739   }
    2740 
     2795  if (hist)
     2796    owl_history_store(hist, owl_editwin_get_text(e), false);
     2797
     2798  /* Take a reference to the editwin, so that it survives the pop
     2799   * context. TODO: We should perhaps refcount or otherwise protect
     2800   * the context so that, even if a command pops a context, the
     2801   * context itself will last until the command returns. */
     2802  owl_editwin_ref(e);
    27412803  owl_global_pop_context(&g);
     2804
     2805  owl_editwin_do_callback(e, false);
     2806  owl_editwin_unref(e);
    27422807}
    27432808
     
    27502815  if (!hist)
    27512816    return;
    2752   if (!owl_history_is_touched(hist)) {
    2753     owl_history_store(hist, owl_editwin_get_text(e));
    2754     owl_history_set_partial(hist);
    2755   }
     2817  if (!owl_history_is_touched(hist))
     2818    owl_history_store(hist, owl_editwin_get_text(e), true);
    27562819  ptr=owl_history_get_prev(hist);
    27572820  if (ptr) {
     
    27912854  owl_history *hist=owl_editwin_get_history(e);
    27922855
    2793   if (hist) {
    2794     owl_history_store(hist, owl_editwin_get_text(e));
    2795     owl_history_reset(hist);
    2796   }
     2856  if (hist)
     2857    owl_history_store(hist, owl_editwin_get_text(e), false);
    27972858
    27982859  /* Take a reference to the editwin, so that it survives the pop
     
    28032864  owl_global_pop_context(&g);
    28042865
    2805   owl_editwin_do_callback(e);
     2866  owl_editwin_do_callback(e, true);
    28062867  owl_editwin_unref(e);
    28072868}
  • compat/Makefile.am

    r12a6616 rb80bae0  
    11noinst_LIBRARIES = libcompat.a
    22
    3 libcompat_a_SOURCES =
     3libcompat_a_SOURCES = compat.h
    44libcompat_a_LIBADD = $(LIBOBJS)
  • compat/compat.h

    r4dde585 r6249a88f  
    22#define INC_BARNOWL_COMPAT_COMPAT_H
    33
    4 #include "../config.h"
     4#include <config.h>
    55
    66#include <stddef.h>
  • configure.ac

    r1255365 re4b8f93  
    11dnl Process this file with autoconf to produce a configure script.
    2 AC_INIT([BarnOwl],[1.8dev],[bug-barnowl@mit.edu])
    3 AM_INIT_AUTOMAKE([1.7.0 -Wall -Wno-portability foreign])
     2AC_INIT([BarnOwl],[1.10dev],[bug-barnowl@mit.edu])
     3AM_INIT_AUTOMAKE([1.7.0 foreign std-options -Wall -Wno-portability])
     4AM_MAINTAINER_MODE([enable])
    45m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
    56
     
    89
    910AC_PROG_CC
     11AC_PROG_CC_C99
     12AC_PROG_LN_S
     13
     14AC_ARG_WITH([zephyr-default-format],
     15    [AS_HELP_STRING([--with-zephyr-default-format],
     16                    [value for the default format zephyrgram field])],
     17    [
     18        case $withval in
     19            yes) withval='Config error: see http://mit.edu/df';;
     20            no) withval='';;
     21        esac
     22        zephyr_default_format=$withval
     23    ],
     24    [zephyr_default_format='Config error: see http://mit.edu/df'])
     25AC_DEFINE_UNQUOTED(
     26    [ZEPHYR_DEFAULT_FORMAT], ["$zephyr_default_format"],
     27    [Value for the default format zephyrgram field]
     28)
    1029
    1130AC_ARG_WITH([stack-protector],
     
    1635
    1736AS_IF([test "x$with_stack_protector" != xno],
    18   [AX_C_CHECK_FLAG([-fstack-protector],[],[],
     37  [AX_CHECK_COMPILE_FLAG([-fstack-protector],
    1938    [AM_CFLAGS="$AM_CFLAGS -fstack-protector"],
    2039    [if test "x$with_stack_protector" != xcheck; then
     
    4059
    4160AS_IF([test "x$with_zephyr" != xno],
    42   [AS_IF([test "x$with_krb4" != "xno"],
     61  [have_krb4=no
     62
     63   AS_IF([test "x$with_krb4" != "xno"],
    4364   [AC_MSG_CHECKING([for Kerberos IV])
    4465    AS_IF([krb5-config krb4 --libs >/dev/null 2>&1],
    4566      [AC_MSG_RESULT([yes])
     67       have_krb4=yes
    4668       AC_DEFINE([HAVE_KERBEROS_IV], [1], [Define if you have kerberos IV])
    4769       AM_CFLAGS="${AM_CFLAGS} `krb5-config krb4 --cflags`"
     
    5072      [AC_MSG_RESULT([no])
    5173       AS_IF([test "x$with_krb4" = "xyes"],
    52              [AC_MSG_ERROR([Kerberos IV requested but not found])])
    53        PKG_CHECK_MODULES([LIBCRYPTO], [libcrypto])
    54        AM_CFLAGS="${AM_CFLAGS} ${LIBCRYPTO_CFLAGS}"
    55        LIBS="${LIBS} ${LIBCRYPTO_LIBS}"
    56      ])])
     74             [AC_MSG_ERROR([Kerberos IV requested but not found])])])])
     75
     76   AS_IF([test "x$have_krb4" != xyes],
     77     [PKG_CHECK_MODULES([LIBCRYPTO], [libcrypto],
     78        [AM_CFLAGS="${AM_CFLAGS} ${LIBCRYPTO_CFLAGS}"
     79         LIBS="${LIBS} ${LIBCRYPTO_LIBS}"
     80        ],
     81        [PKG_CHECK_MODULES([OPENSSL], [openssl],
     82           [AM_CFLAGS="${AM_CFLAGS} ${OPENSSL_CFLAGS}"
     83            LIBS="${LIBS} ${OPENSSL_LIBS}"
     84           ])])])
     85
    5786   AC_CHECK_LIB([zephyr], [ZGetSender],
    5887   [LIBS="$LIBS -lzephyr"
     
    80109AC_HEADER_STDC
    81110AC_HEADER_SYS_WAIT
    82 AC_HEADER_STDBOOL
    83 AC_CHECK_HEADERS(strings.h sys/ioctl.h sys/filio.h unistd.h)
     111AC_CHECK_HEADERS(stdbool.h strings.h sys/ioctl.h sys/filio.h unistd.h)
    84112
    85113dnl Add CFLAGS for embeded perl
     
    90118dnl Find the location of perl XSUBPP
    91119AC_MSG_CHECKING(for the perl xsubpp precompiler)
    92 XSUBPPDIR="`(perl -MExtUtils::MakeMaker -e 'print ExtUtils::MakeMaker->new({NAME => qw(owl)})->tool_xsubpp;') | grep \^XSUBPPDIR | sed -e 's/XSUBPPDIR = //g;'`"
     120XSUBPPDIR="`cd "$srcdir" && perl -MExtUtils::MakeMaker -e 'print ExtUtils::MakeMaker->new({NAME => qw(owl)})->tool_xsubpp;' | grep \^XSUBPPDIR | sed -e 's/XSUBPPDIR = //g;'`"
    93121if test -n "${XSUBPPDIR}"; then
    94122   AC_MSG_RESULT(${XSUBPPDIR})
     
    109137AC_CHECK_LIB([perl], [perl_alloc],, AC_MSG_ERROR([No libperl found]))
    110138
     139AX_PROG_PERL_MODULES([AnyEvent],,
     140                     [AC_MSG_ERROR([cannot find perl module AnyEvent.])])
    111141AX_PROG_PERL_MODULES([Class::Accessor::Fast],,
    112142                     [AC_MSG_ERROR([cannot find perl module Class::Accessor::Fast.])])
     143AX_PROG_PERL_MODULES([ExtUtils::Depends],,
     144                     [AC_MSG_ERROR([cannot find perl module ExtUtils::Depends])])
     145AX_PROG_PERL_MODULES([Glib],,
     146                     [AC_MSG_ERROR([cannot find perl module Glib.])])
     147AX_PROG_PERL_MODULES([Module::Install::Base],,
     148                     [AC_MSG_ERROR([cannot find perl module Module::Install::Base])])
    113149AX_PROG_PERL_MODULES([PAR],,
    114150                     [AC_MSG_WARN([PAR.pm not found. Loadable modules will be disabled.])])
    115151
    116152dnl Add CFLAGS and LIBS for glib-2.0
    117 PKG_CHECK_MODULES(GLIB,[glib-2.0 >= 2.12 gobject-2.0 gthread-2.0])
     153PKG_CHECK_MODULES(GLIB,[glib-2.0 >= 2.16 gobject-2.0 gthread-2.0])
    118154
    119155AC_MSG_NOTICE([Adding glib-2.0 CFLAGS ${GLIB_CFLAGS}])
     
    126162fi
    127163
     164dnl Add CFLAGS for glib-perl
     165GLIB_PERL_CFLAGS=`perl -MExtUtils::Depends -e 'my $e = ExtUtils::Depends->new("BarnOwl","Glib"); my %h = $e->get_makefile_vars; print $h{"INC"}'`
     166AC_MSG_NOTICE([Adding glib-perl CFLAGS ${GLIB_PERL_CFLAGS}])
     167AM_CFLAGS="${GLIB_PERL_CFLAGS} ${AM_CFLAGS}"
     168
    128169dnl Checks for typedefs, structures, and compiler characteristics.
    129170
    130171AX_CFLAGS_WARN_ALL([AM_CFLAGS])
    131 AX_C_CHECK_FLAG([-Wstrict-prototypes],[],[],[AM_CFLAGS="$AM_CFLAGS -Wstrict-prototypes"])
     172AX_APPEND_COMPILE_FLAGS([-Wstrict-prototypes -Wwrite-strings],[AM_CFLAGS])
    132173
    133174dnl Shut gcc up about zero-length format strings; the warning's apparently for
    134175dnl efficiency reasons, which is bogus for custom functions.
    135 AX_C_CHECK_FLAG([-Wno-format-zero-length],[],[],[AM_CFLAGS="$AM_CFLAGS -Wno-format-zero-length"])
    136 
    137 m4_foreach([myflag],
    138   [[-Wno-pointer-sign],[-Wno-empty-body],[-Wno-unused-value]],
    139   [AX_C_CHECK_FLAG([myflag],[],[],[LIBFAIM_CFLAGS="$LIBFAIM_CFLAGS myflag"])])
     176AX_APPEND_COMPILE_FLAGS([-Wno-format-zero-length],[AM_CFLAGS])
     177
     178AX_APPEND_COMPILE_FLAGS([-Wno-pointer-sign -Wno-empty-body -Wno-unused-value],[LIBFAIM_CFLAGS])
    140179
    141180AM_CONDITIONAL([ENABLE_ZCRYPT], [test "$HAVE_DES_STRING_TO_KEY" && dnl
     
    143182                                 test "$HAVE_DES_ECB_ENCRYPT"])
    144183
    145 AM_CFLAGS="$AM_CFLAGS -D_XOPEN_SOURCE=500"
     184AM_CFLAGS="$AM_CFLAGS -D_XOPEN_SOURCE=600"
    146185dnl Define _BSD_SOURCE because zephyr needs caddr_t.
    147186AM_CFLAGS="$AM_CFLAGS -D_BSD_SOURCE"
     
    166205AC_REPLACE_FUNCS([memrchr])
    167206
     207AC_SUBST([abs_builddir])
     208AC_SUBST([abs_srcdir])
     209
    168210AC_CONFIG_FILES([Makefile compat/Makefile libfaim/Makefile perl/Makefile perl/modules/Makefile])
    169211AC_OUTPUT
  • context.c

    rd4927a7 rf271129  
    1 #include <string.h>
    21#include "owl.h"
    32
     
    65
    76/* TODO: dependency from owl_context -> owl_window is annoying. */
    8 owl_context *owl_context_new(int mode, void *data, const char *keymap, owl_window *cursor)
     7CALLER_OWN owl_context *owl_context_new(int mode, void *data, const char *keymap, owl_window *cursor)
    98{
    109  owl_context *c;
  • dict.c

    r4c7c21f rf271129  
    66 */
    77
    8 #include <stdlib.h>
    9 #include <string.h>
    10 #include <unistd.h>
    118#include "owl.h"
    12 
    139
    1410#define INITSIZE 30
     
    5652}
    5753
    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) {
     54/* Returns a GPtrArray of dictionary keys. Duplicates the keys, so
     55 * they will need to be freed by the caller with g_free. */
     56CALLER_OWN GPtrArray *owl_dict_get_keys(const owl_dict *d) {
     57  GPtrArray *keys = g_ptr_array_sized_new(d->size);
    6158  int i;
    62   for (i=0; i<d->size; i++) {
    63     owl_list_append_element(l, g_strdup(d->els[i].k));
     59  for (i = 0; i < d->size; i++) {
     60    g_ptr_array_add(keys, g_strdup(d->els[i].k));
    6461  }
     62  return keys;
    6563}
    6664
     
    107105/* Doesn't free the value of the element, but does
    108106 * return it so the caller can free it. */
    109 void *owl_dict_remove_element(owl_dict *d, const char *k) {
     107CALLER_OWN void *owl_dict_remove_element(owl_dict *d, const char *k)
     108{
    110109  int i;
    111110  int pos, found;
  • doc/barnowl.1

    rfa1b15b r8135737  
    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.  The config file is
     38an arbitrary Perl script evaluated in the \fImain\fP package, and if it
     39overrides the \fIBarnOwl::startup\fP method that is run when \fBBarnOwl\fP
     40starts.  (Compare \fI~/.owl/startup\fP, which contains \fBBarnOwl\fP commands
     41that are run at startup after the config file is loaded.)
    4842
    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
     43By default, \fBBarnOwl\fP uses the first of \fI~/.owl/init.pl\fP,
     44\fI~/.barnowlconf\fP, or \fI~/.owlconf\fP that exists.
    5445
    55 .B \-s \fIconfigdir\fP
    56 .IP
    57 Specify an alternate configuration directory. By default, BarnOwl uses
    58 ~/.owl/.
    59 .LP
     46.TP
     47\fB\-s\fP, \fB\-\-config\-dir\fP=\fIDIR\fP
     48Specify an alternate configuration directory.  By default, \fBBarnOwl\fP uses
     49\fI~/.owl/\fP.
    6050
    61 .B \-t \fItty\fP
    62 .IP
    63 Specifiy the tty name to use for the zephyr location.
    64 .LP
     51.TP
     52\fB\-t\fP, \fB\-\-tty\fP=\fITTY\fP
     53Specify the tty name to use for the zephyr location.
    6554
    66 .B \-v
    67 .IP
    68 Print the version number of barnowl and exit.
    69 .LP
     55.TP
     56\fB\-v\fP, \fB\-\-version\fP
     57Print the version number of \fBBarnOwl\fP and exit.
    7058
    71 .B \-d
    72 .IP
    73 Enable debugging.  By default debugging information is placed in
    74 /var/tmp/owldebug.
    75 .LP
     59.TP
     60\fB\-d\fP, \fB\-\-debug\fP
     61Enable debugging.  By default, debugging information is placed in
     62\fI/var/tmp/barnowl\-debug.PID\fP.
    7663
    77 .B \-D
    78 .IP
    79 Enable debugging, but first delete any existing debugging file.
    80 .LP
     64.TP
     65\fB\-h\fP, \fB\-\-help\fP
     66Print command\(hyline option help.
    8167
    82 .B \-h
    83 .IP
    84 Print command line option help.
    85 .LP
    86 
    87 .SH AUTHOR
     68.SH AUTHORS
    8869Written by Nelson Elhage and Alejandro Sedeno at the Massachusetts
    89 Institute of Technology. Based on Owl by James Kretchmar.
     70Institute of Technology.  Based on Owl by James Kretchmar.
    9071
    9172Comments, questions, and bug reports may be mailed to
    92 \fBbug-barnowl@mit.edu\fP.
     73\fBbug\-barnowl@mit.edu\fP.
  • editcontext.c

    r4a41f16 rf271129  
    11#include "owl.h"
    2 
    32#include <assert.h>
    43
     
    87}
    98
    10 owl_context *owl_editcontext_new(int mode, owl_editwin *e, const char *keymap, void (*deactivate_cb)(owl_context*), void *cbdata)
     9CALLER_OWN owl_context *owl_editcontext_new(int mode, owl_editwin *e, const char *keymap, void (*deactivate_cb)(owl_context*), void *cbdata)
    1110{
    1211  owl_context *ctx = owl_context_new(mode, owl_editwin_ref(e), keymap,
  • editwin.c

    r3b8a563 r8258ea5  
    11#include "owl.h"
    2 #include <stdlib.h>
    3 #include <unistd.h>
    4 #include <string.h>
    5 #include <ctype.h>
    62
    73#define VALID_EXCURSION (0x9a2b4729)
     
    3733  oe_excursion *excursions;
    3834
    39   void (*callback)(struct _owl_editwin*);
     35  void (*callback)(struct _owl_editwin *e, bool success);
    4036  void (*destroy_cbdata)(void *);
    4137  void *cbdata;
     
    6157static const char *oe_copy_buf(owl_editwin *e, const char *buf, int len);
    6258static int oe_copy_region(owl_editwin *e);
    63 static char *oe_chunk(owl_editwin *e, int start, int end);
     59static CALLER_OWN char *oe_chunk(owl_editwin *e, int start, int end);
    6460static void oe_destroy_cbdata(owl_editwin *e);
    6561static void oe_dirty(owl_editwin *e);
     
    7066#define WHITESPACE " \n\t"
    7167
    72 static owl_editwin *owl_editwin_allocate(void)
     68static CALLER_OWN owl_editwin *owl_editwin_allocate(void)
    7369{
    7470  owl_editwin *e = g_new0(owl_editwin, 1);
     
    142138}
    143139
    144 owl_editwin *owl_editwin_new(owl_window *win, int winlines, int wincols, int style, owl_history *hist)
     140CALLER_OWN owl_editwin *owl_editwin_new(owl_window *win, int winlines, int wincols, int style, owl_history *hist)
    145141{
    146142  owl_editwin *e = owl_editwin_allocate();
     
    224220}
    225221
    226 void owl_editwin_set_callback(owl_editwin *e, void (*cb)(owl_editwin*))
     222void owl_editwin_set_callback(owl_editwin *e, void (*cb)(owl_editwin *, bool))
    227223{
    228224  e->callback = cb;
    229225}
    230226
    231 void (*owl_editwin_get_callback(owl_editwin *e))(owl_editwin*)
     227void (*owl_editwin_get_callback(owl_editwin *e))(owl_editwin *, bool)
    232228{
    233229  return e->callback;
     
    252248}
    253249
    254 void owl_editwin_do_callback(owl_editwin *e) {
    255   void (*cb)(owl_editwin*);
    256   cb=owl_editwin_get_callback(e);
    257   if(!cb) {
     250void owl_editwin_do_callback(owl_editwin *e, bool success)
     251{
     252  void (*cb)(owl_editwin *, bool);
     253  cb = owl_editwin_get_callback(e);
     254  if (!cb) {
    258255    owl_function_error("Internal error: No editwin callback!");
    259256  } else {
    260     /* owl_function_error("text: |%s|", owl_editwin_get_text(e)); */
    261     cb(e);
     257    cb(e, success);
    262258  }
    263259}
     
    623619
    624620  if (!g_utf8_validate(s, -1, NULL)) {
    625     owl_function_debugmsg("owl_editwin_insert_string: received non-utf-8 string.");
     621    owl_function_debugmsg("owl_editwin_insert_string: received non-UTF-8 string.");
    626622    return 0;
    627623  }
     
    11511147{
    11521148  oe_excursion x;
    1153   gunichar ch;
     1149  gunichar ch = 0;
     1150  gunichar last_ch;
    11541151  int sentence;
    11551152
     
    11841181    }
    11851182
     1183    last_ch = ch;
    11861184    ch = owl_editwin_get_char_at_point(e);
    11871185
     
    12011199    }
    12021200
    1203     if(ch == '.' || ch == '!' || ch == '?')
     1201    if (ch == '.' || ch == '!' || ch == '?' ||
     1202        (ch == '"' && (last_ch == '.' || last_ch == '!' || last_ch == '?')))
    12041203      sentence = 1;
    12051204    else
     
    13691368}
    13701369
    1371 char *owl_editwin_get_region(owl_editwin *e)
     1370CALLER_OWN char *owl_editwin_get_region(owl_editwin *e)
    13721371{
    13731372  int start, end;
     
    13881387}
    13891388
    1390 static char *oe_chunk(owl_editwin *e, int start, int end)
     1389static CALLER_OWN char *oe_chunk(owl_editwin *e, int start, int end)
    13911390{
    13921391  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

    re56303f rc068c03  
    1 #include <string.h>
    21#include "owl.h"
    32
     
    125124
    126125  op1 = owl_filter_parse_primitive_expression(argc-i, argv+i, &skip);
     126  if(!op1) goto err;
    127127  i += skip;
    128   if(!op1) goto err;
    129128
    130129  while(i < argc) {
     
    200199
    201200
    202 char* owl_filter_print(const owl_filter *f)
     201CALLER_OWN char *owl_filter_print(const owl_filter *f)
    203202{
    204203  GString *out = g_string_new("");
     
    220219    }
    221220    else {
    222       g_string_append_printf(out, "%i",f->fgcolor);
     221      g_string_append_printf(out, "%i",f->bgcolor);
    223222    }
    224223    g_string_append(out, " ");
  • filterelement.c

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

    re2cc848 r7155955  
    1 #include <signal.h>
     1#include "filterproc.h"
     2#include <sys/wait.h>
     3#include <fcntl.h>
     4#include <glib.h>
     5#include <poll.h>
     6#include <string.h>
    27#include <unistd.h>
    3 #include <sys/select.h>
    4 #include <sys/types.h>
    5 #include <sys/wait.h>
    6 #include <poll.h>
    7 #include <fcntl.h>
    8 #include <string.h>
    98
    10 #include <glib.h>
    11 
    12 int send_receive(int rfd, int wfd, const char *out, char **in)
     9/* Even in case of error, send_receive is responsible for closing wfd
     10 * (to EOF the child) and rfd (for consistency). */
     11static int send_receive(int rfd, int wfd, const char *out, char **in)
    1312{
    1413  GString *str = g_string_new("");
     
    2524  fds[1].fd = wfd;
    2625  fds[1].events = POLLOUT;
     26
     27  if(!out || !*out) {
     28    /* Nothing to write. Close our end so the child doesn't hang waiting. */
     29    close(wfd); wfd = -1;
     30    out = NULL;
     31  }
    2732
    2833  while(1) {
     
    4752      }
    4853      if(!out || !*out || fds[1].revents & (POLLERR | POLLHUP)) {
    49         close(wfd);
     54        close(wfd); wfd = -1;
    5055        out = NULL;
    5156      }
     
    6368  }
    6469
     70  if (wfd >= 0) close(wfd);
     71  close(rfd);
    6572  *in = g_string_free(str, err < 0);
    6673  return err;
    6774}
    6875
    69 int call_filter(const char *prog, const char *const *argv, const char *in, char **out, int *status)
     76int call_filter(const char *const *argv, const char *in, char **out, int *status)
    7077{
    71   int err = 0;
    72   pid_t pid;
    73   int rfd[2];
    74   int wfd[2];
     78  int err;
     79  GPid child_pid;
     80  int child_stdin, child_stdout;
    7581
    76   if((err = pipe(rfd))) goto out;
    77   if((err = pipe(wfd))) goto out_close_rfd;
    78 
    79   pid = fork();
    80   if(pid < 0) {
    81     err = pid;
    82     goto out_close_all;
    83   }
    84   if(pid) {
    85     /* parent */
    86     close(rfd[1]);
    87     close(wfd[0]);
    88     err = send_receive(rfd[0], wfd[1], in, out);
    89     if(err == 0) {
    90       waitpid(pid, status, 0);
    91     }
    92   } else {
    93     /* child */
    94     close(rfd[0]);
    95     close(wfd[1]);
    96     dup2(rfd[1], 1);
    97     dup2(wfd[0], 0);
    98     close(rfd[1]);
    99     close(wfd[0]);
    100 
    101     if(execvp(prog, (char *const *)argv)) {
    102       _exit(-1);
    103     }
     82  if (!g_spawn_async_with_pipes(NULL, (char**)argv, NULL,
     83                                G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
     84                                NULL, NULL,
     85                                &child_pid, &child_stdin, &child_stdout, NULL,
     86                                NULL)) {
     87    *out = NULL;
     88    return 1;
    10489  }
    10590
    106  out_close_all:
    107   close(wfd[0]);
    108   close(wfd[1]);
    109  out_close_rfd:
    110   close(rfd[0]);
    111   close(rfd[1]);
    112  out:
     91  err = send_receive(child_stdout, child_stdin, in, out);
     92  if (err == 0) {
     93    waitpid(child_pid, status, 0);
     94  }
    11395  return err;
    11496}
  • filterproc.h

    r06adc25 r97cdbaf5  
    22#define INC_BARNOWL_FILTER_PROC_H
    33
    4 int call_filter(const char *prog,
    5                 const char *const *argv,
     4int call_filter(const char *const *argv,
    65                const char *in,
    76                char **out, int *status);
  • fmtext.c

    r7b4f3be rf271129  
    11#include "owl.h"
    2 #include <stdlib.h>
    3 #include <string.h>
    42
    53/* initialize an fmtext with no data */
     
    171169 * freeing the return
    172170 */
    173 char *owl_fmtext_print_plain(const owl_fmtext *f)
     171CALLER_OWN char *owl_fmtext_print_plain(const owl_fmtext *f)
    174172{
    175173  return owl_strip_format_chars(f->buff->str);
     
    186184static void _owl_fmtext_wcolor_set(WINDOW *w, short pair)
    187185{
     186  cchar_t background;
     187  wchar_t blank[2] = { ' ', 0 };
    188188  if (has_colors()) {
    189       wcolor_set(w,pair,NULL);
    190       wbkgdset(w, COLOR_PAIR(pair));
     189      wcolor_set(w, pair, NULL);
     190      /* Set the background with wbkgrndset so that we can handle color-pairs
     191       * past 256 on ncurses ABI 6 and later. */
     192      setcchar(&background, blank, 0, pair, NULL);
     193      wbkgrndset(w, &background);
    191194  }
    192195}
     
    686689         * but zwgc seems to be smarter about some screw cases than I am
    687690         */
     691        g_free(buff);
    688692        owl_fmtext_append_attr(f, "@", curattrs, curcolor, OWL_COLOR_DEFAULT);
    689693        txtptr++;
     
    755759 * If format_fn is specified, passes it the list element value
    756760 * 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;
     761void owl_fmtext_append_list(owl_fmtext *f, const GPtrArray *l, const char *join_with, char *(format_fn)(const char *))
     762{
     763  int i;
    760764  const char *elem;
    761765  char *text;
    762766
    763   size = owl_list_get_size(l);
    764   for (i=0; i<size; i++) {
    765     elem = owl_list_get_element(l,i);
     767  for (i = 0; i < l->len; i++) {
     768    elem = l->pdata[i];
    766769    if (elem && format_fn) {
    767770      text = format_fn(elem);
     
    773776      owl_fmtext_append_normal(f, elem);
    774777    }
    775     if ((i < size-1) && join_with) {
     778    if ((i < l->len - 1) && join_with) {
    776779      owl_fmtext_append_normal(f, join_with);
    777780    }
  • functions.c

    r259e60a8 r60e8617  
     1#include "owl.h"
     2#include "filterproc.h"
    13#include <stdio.h>
    2 #include <stdlib.h>
    3 #include <unistd.h>
    4 #include <signal.h>
    5 #include <netinet/in.h>
    6 #include <string.h>
    7 #include <time.h>
    8 #include <sys/types.h>
    94#include <sys/stat.h>
    105#include <sys/wait.h>
    11 #include <errno.h>
    12 #include <signal.h>
    13 #include "owl.h"
    14 #include "filterproc.h"
    15 
    16 char *owl_function_command(const char *cmdbuff)
     6
     7CALLER_OWN char *owl_function_command(const char *cmdbuff)
    178{
    189  owl_function_debugmsg("executing command: %s", cmdbuff);
     
    2112}
    2213
    23 char *owl_function_command_argv(const char *const *argv, int argc)
     14CALLER_OWN char *owl_function_command_argv(const char *const *argv, int argc)
    2415{
    2516  return owl_cmddict_execute_argv(owl_global_get_cmddict(&g),
     
    4738void owl_function_show_commands(void)
    4839{
    49   owl_list l;
     40  GPtrArray *l;
    5041  owl_fmtext fm;
    5142
     
    5344  owl_fmtext_append_bold(&fm, "Commands:  ");
    5445  owl_fmtext_append_normal(&fm, "(use 'show command <name>' for details)\n");
    55   owl_list_create(&l);
    56   owl_cmddict_get_names(owl_global_get_cmddict(&g), &l);
    57   owl_fmtext_append_list(&fm, &l, "\n", owl_function_cmd_describe);
     46  l = owl_cmddict_get_names(owl_global_get_cmddict(&g));
     47  owl_fmtext_append_list(&fm, l, "\n", owl_function_cmd_describe);
    5848  owl_fmtext_append_normal(&fm, "\n");
    5949  owl_function_popless_fmtext(&fm);
    60   owl_list_cleanup(&l, g_free);
     50  owl_ptr_array_free(l, g_free);
    6151  owl_fmtext_cleanup(&fm);
    6252}
     
    8171
    8272void owl_function_show_styles(void) {
    83   owl_list l;
     73  GPtrArray *l;
    8474  owl_fmtext fm;
    8575
    8676  owl_fmtext_init_null(&fm);
    8777  owl_fmtext_append_bold(&fm, "Styles:\n");
    88   owl_list_create(&l);
    89   owl_global_get_style_names(&g, &l);
    90   owl_fmtext_append_list(&fm, &l, "\n", owl_function_style_describe);
     78  l = owl_global_get_style_names(&g);
     79  owl_fmtext_append_list(&fm, l, "\n", owl_function_style_describe);
    9180  owl_fmtext_append_normal(&fm, "\n");
    9281  owl_function_popless_fmtext(&fm);
    93   owl_list_cleanup(&l, g_free);
     82  owl_ptr_array_free(l, g_free);
    9483  owl_fmtext_cleanup(&fm);
    9584}
    9685
    97 static void _owl_function_timer_append_fmtext(gpointer data, gpointer user_data) {
    98   owl_fmtext *fm = user_data;
    99   owl_timer *timer = data;
    100   char *str = g_strdup_printf("- %s: in %d seconds",
    101                               timer->name ? timer->name : "(unnamed)",
    102                               (int)(timer->time - time(NULL)));
    103   owl_fmtext_append_normal(fm, str);
    104   g_free(str);
    105   if (timer->interval) {
    106     str = g_strdup_printf(", repeat every %d seconds", timer->interval);
    107     owl_fmtext_append_normal(fm, str);
    108     g_free(str);
    109   }
    110   owl_fmtext_append_normal(fm, "\n");
    111 }
    112 
    113 void owl_function_show_timers(void) {
    114   owl_fmtext fm;
    115   GList **timers;
    116 
    117   owl_fmtext_init_null(&fm);
    118   owl_fmtext_append_bold(&fm, "Active timers:\n");
    119 
    120   timers = owl_global_get_timerlist(&g);
    121   g_list_foreach(*timers, _owl_function_timer_append_fmtext, &fm);
    122 
    123   owl_function_popless_fmtext(&fm);
    124   owl_fmtext_cleanup(&fm);
    125 }
    126 
    127 char *owl_function_style_describe(const char *name) {
     86CALLER_OWN char *owl_function_style_describe(const char *name)
     87{
    12888  const char *desc;
    12989  char *s;
     
    141101}
    142102
    143 char *owl_function_cmd_describe(const char *name)
     103CALLER_OWN char *owl_function_cmd_describe(const char *name)
    144104{
    145105  const owl_cmd *cmd = owl_cmddict_find(owl_global_get_cmddict(&g), name);
     
    158118
    159119  text=""
    160     "barnowl version " OWL_VERSION_STRING "\n"
     120    "BarnOwl version " OWL_VERSION_STRING "\n"
    161121    "Copyright (c) 2006-2011 The BarnOwl Developers. All rights reserved.\n"
    162122    "Copyright (c) 2004 James Kretchmar. All rights reserved.\n"
     
    175135    "\n"
    176136    "   * Redistributions in any form must be accompanied by information on\n"
    177     "     how to obtain complete source code for the Owl software and any\n"
    178     "     accompanying software that uses the Owl software. The source code\n"
     137    "     how to obtain complete source code for the BarnOwl software and any\n"
     138    "     accompanying software that uses the BarnOwl software. The source code\n"
    179139    "     must either be included in the distribution or be available for no\n"
    180140    "     more than the cost of distribution plus a nominal fee, and must be\n"
     
    244204
    245205  /* do followlast if necessary */
    246   if (owl_global_should_followlast(&g)) owl_function_lastmsg_noredisplay();
     206  if (owl_global_should_followlast(&g)) owl_function_lastmsg();
    247207
    248208  /* redisplay etc. */
     
    256216void owl_function_add_outgoing_zephyrs(const owl_zwrite *z)
    257217{
    258   if (z->cc || owl_zwrite_get_numrecips(z) == 0) {
     218  if (z->cc && owl_zwrite_is_personal(z)) {
    259219    /* create the message */
    260220    owl_message *m = g_new(owl_message, 1);
     
    265225    int i;
    266226    for (i = 0; i < owl_zwrite_get_numrecips(z); i++) {
     227      owl_message *m;
     228
     229      if (!owl_zwrite_recip_is_personal(owl_zwrite_get_recip_n(z, i)))
     230        continue;
     231
    267232      /* create the message */
    268       owl_message *m = g_new(owl_message, 1);
     233      m = g_new(owl_message, 1);
    269234      owl_message_create_from_zwrite(m, z, owl_zwrite_get_message(z), i);
    270235
     
    279244 * owl_global_messagequeue_addmsg() for that.
    280245 */
    281 owl_message *owl_function_make_outgoing_aim(const char *body, const char *to)
     246CALLER_OWN owl_message *owl_function_make_outgoing_aim(const char *body, const char *to)
    282247{
    283248  owl_message *m;
     
    300265 * owl_global_messagequeue_addmsg() for that.
    301266 */
    302 owl_message *owl_function_make_outgoing_loopback(const char *body)
     267CALLER_OWN owl_message *owl_function_make_outgoing_loopback(const char *body)
    303268{
    304269  owl_message *m;
     
    312277}
    313278
    314 void owl_function_start_edit_win(const char *line, void (*callback)(owl_editwin *), void *data, void (*cleanup)(void *))
     279owl_editwin *owl_function_start_edit_win(const char *line)
    315280{
    316281  owl_editwin *e;
     
    326291  g_free(s);
    327292
    328   owl_editwin_set_cbdata(e, data, cleanup);
    329   owl_editwin_set_callback(e, callback);
    330293  ctx = owl_editcontext_new(OWL_CTX_EDITMULTI, e, "editmulti",
    331294                            owl_global_deactivate_editcontext, &g);
    332295  owl_global_push_context_obj(&g, ctx);
    333 
     296  return e;
    334297}
    335298
     
    349312void owl_function_zwrite_setup(owl_zwrite *z)
    350313{
     314  owl_editwin *e;
    351315  /* send a ping if necessary */
    352316  if (owl_global_is_txping(&g)) {
     
    356320
    357321  owl_function_write_setup("zephyr");
    358   owl_function_start_edit_win(z->zwriteline,
    359                               &owl_callback_zwrite,
    360                               z, (void(*)(void*))owl_zwrite_delete);
     322  e = owl_function_start_edit_win(z->zwriteline);
     323  owl_editwin_set_cbdata(e, z, (void (*)(void *))owl_zwrite_delete);
     324  owl_editwin_set_callback(e, &owl_callback_zwrite);
    361325}
    362326
    363327void owl_function_aimwrite_setup(const char *to)
    364328{
     329  owl_editwin *e;
    365330  /* TODO: We probably actually want an owl_aimwrite object like
    366331   * owl_zwrite. */
    367332  char *line = g_strdup_printf("aimwrite %s", to);
    368333  owl_function_write_setup("message");
    369   owl_function_start_edit_win(line,
    370                               &owl_callback_aimwrite,
    371                               g_strdup(to),
    372                               g_free);
     334  e = owl_function_start_edit_win(line);
     335  owl_editwin_set_cbdata(e, g_strdup(to), g_free);
     336  owl_editwin_set_callback(e, &owl_callback_aimwrite);
    373337  g_free(line);
    374338}
     
    376340void owl_function_loopwrite_setup(void)
    377341{
     342  owl_editwin *e;
    378343  owl_function_write_setup("message");
    379   owl_function_start_edit_win("loopwrite",
    380                               &owl_callback_loopwrite,
    381                               NULL, NULL);
    382 }
    383 
    384 void owl_callback_zwrite(owl_editwin *e) {
     344  e = owl_function_start_edit_win("loopwrite");
     345  owl_editwin_set_callback(e, &owl_callback_loopwrite);
     346}
     347
     348void owl_callback_zwrite(owl_editwin *e, bool success)
     349{
     350  if (!success) return;
    385351  owl_zwrite *z = owl_editwin_get_cbdata(e);
    386352  owl_function_zwrite(z, owl_editwin_get_text(e));
     
    412378  owl_function_makemsg("Waiting for ack...");
    413379
    414   /* If it's personal */
    415   if (owl_zwrite_is_personal(z)) {
    416     /* create the outgoing message */
    417     owl_function_add_outgoing_zephyrs(z);
    418   }
     380  /* create the outgoing message */
     381  owl_function_add_outgoing_zephyrs(z);
    419382}
    420383#else
     
    441404  old_msg = g_strdup(owl_zwrite_get_message(z));
    442405
    443   zcrypt = g_strdup_printf("%s/zcrypt", owl_get_bindir());
    444   argv[0] = "zcrypt";
     406  zcrypt = g_build_filename(owl_get_bindir(), "zcrypt", NULL);
     407  argv[0] = zcrypt;
    445408  argv[1] = "-E";
    446409  argv[2] = "-c"; argv[3] = owl_zwrite_get_class(z);
     
    448411  argv[6] = NULL;
    449412
    450   rv = call_filter(zcrypt, argv, owl_zwrite_get_message(z), &cryptmsg, &status);
     413  rv = call_filter(argv, owl_zwrite_get_message(z), &cryptmsg, &status);
    451414
    452415  g_free(zcrypt);
     
    466429  owl_function_makemsg("Waiting for ack...");
    467430
    468   /* If it's personal */
    469   if (owl_zwrite_is_personal(z)) {
    470     /* Create the outgoing message. Restore the un-crypted message for display. */
    471     owl_zwrite_set_message_raw(z, old_msg);
    472     owl_function_add_outgoing_zephyrs(z);
    473   }
    474 
    475   /* free the zwrite */
     431  /* Create the outgoing message. Restore the un-crypted message for display. */
     432  owl_zwrite_set_message_raw(z, old_msg);
     433  owl_function_add_outgoing_zephyrs(z);
     434
     435  /* Clean up. */
    476436  g_free(cryptmsg);
    477 }
    478 
    479 void owl_callback_aimwrite(owl_editwin *e) {
     437  g_free(old_msg);
     438}
     439
     440void owl_callback_aimwrite(owl_editwin *e, bool success)
     441{
     442  if (!success) return;
    480443  char *to = owl_editwin_get_cbdata(e);
    481444  owl_function_aimwrite(to, owl_editwin_get_text(e), true);
     
    541504}
    542505
    543 void owl_callback_loopwrite(owl_editwin *e) {
     506void owl_callback_loopwrite(owl_editwin *e, bool success)
     507{
     508  if (!success) return;
    544509  owl_function_loopwrite(owl_editwin_get_text(e));
    545510}
     
    691656{
    692657  owl_function_prevmsg_full(NULL, 1, 1);
     658}
     659
     660void owl_function_delete_and_expunge_message(int n)
     661{
     662  owl_messagelist *ml = owl_global_get_msglist(&g);
     663  owl_view *v = owl_global_get_current_view(&g);
     664  int lastmsgid = owl_function_get_curmsg_id(v);
     665
     666  /* delete and expunge the message */
     667  owl_messagelist_delete_and_expunge_element(ml, n);
     668
     669  owl_function_redisplay_to_nearest(lastmsgid, v);
     670}
     671
     672void owl_function_delete_and_expunge_cur(bool exclaim_success)
     673{
     674  int curmsg;
     675  const owl_view *v = owl_global_get_current_view(&g);
     676
     677  /* bail if there's no current message */
     678  if (owl_view_get_size(v) < 1) {
     679    owl_function_error("No current message to delete");
     680    return;
     681  }
     682
     683  /* delete the current message */
     684  curmsg = owl_global_get_curmsg(&g);
     685  owl_function_delete_and_expunge_message(curmsg);
     686  if (exclaim_success)
     687    owl_function_makemsg("Message deleted and expunged");
    693688}
    694689
     
    752747}
    753748
     749/* returns the current message id, if it exists.  Otherwise returns
     750 * -1 if we are past the end of the message list, and 0 otherwise. */
     751int owl_function_get_curmsg_id(const owl_view *v)
     752{
     753  int curmsg = owl_global_get_curmsg(&g);
     754  const owl_message *m = owl_view_get_element(v, curmsg);
     755  if (m)
     756    return owl_message_get_id(m);
     757  if (curmsg > 0) /* past the end of the message list (probably) */
     758    return -1;
     759  return 0;
     760}
     761
     762/* redisplays the view to the nearest message to the id given.
     763 * if msgid < 0, redisplay to past the end of the message list */
     764void owl_function_redisplay_to_nearest(int msgid, owl_view *v)
     765{
     766  int curmsg;
     767  /* update all views (we only have one right now) */
     768  owl_view_recalculate(v);
     769
     770  /* find where the new position should be */
     771  if (msgid < 0) {
     772    /* If already at the end, blank the screen and move curmsg
     773     * past the end of the messages. */
     774    curmsg = owl_view_get_size(v);
     775    owl_global_set_topmsg(&g, curmsg);
     776    owl_global_set_curmsg(&g, curmsg);
     777  } else {
     778    curmsg = owl_view_get_nearest_to_msgid(v, msgid);
     779    if (curmsg > owl_view_get_size(v) - 1)
     780      curmsg = owl_view_get_size(v) - 1;
     781    if (curmsg < 0)
     782      curmsg = 0;
     783    owl_global_set_curmsg(&g, curmsg);
     784    owl_function_calculate_topmsg(OWL_DIRECTION_NONE);
     785  }
     786  /* if there are no messages set the direction to down in case we
     787   * delete everything upwards */
     788  owl_global_set_direction_downwards(&g);
     789
     790  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
     791}
     792
    754793void owl_function_expunge(void)
    755794{
    756   int curmsg;
    757   const owl_message *m;
    758   owl_messagelist *ml;
    759   owl_view *v;
    760   int lastmsgid=0;
    761 
    762   curmsg=owl_global_get_curmsg(&g);
    763   v=owl_global_get_current_view(&g);
    764   ml=owl_global_get_msglist(&g);
    765 
    766   m=owl_view_get_element(v, curmsg);
    767   if (m) lastmsgid = owl_message_get_id(m);
     795  owl_messagelist *ml = owl_global_get_msglist(&g);
     796  owl_view *v = owl_global_get_current_view(&g);
     797  int lastmsgid = owl_function_get_curmsg_id(v);
    768798
    769799  /* expunge the message list */
    770800  owl_messagelist_expunge(ml);
    771801
    772   /* update all views (we only have one right now) */
    773   owl_view_recalculate(v);
    774 
    775   /* find where the new position should be
    776      (as close as possible to where we last where) */
    777   curmsg = owl_view_get_nearest_to_msgid(v, lastmsgid);
    778   if (curmsg>owl_view_get_size(v)-1) curmsg = owl_view_get_size(v)-1;
    779   if (curmsg<0) curmsg = 0;
    780   owl_global_set_curmsg(&g, curmsg);
    781   owl_function_calculate_topmsg(OWL_DIRECTION_NONE);
    782   /* if there are no messages set the direction to down in case we
    783      delete everything upwards */
    784   owl_global_set_direction_downwards(&g);
     802  owl_function_redisplay_to_nearest(lastmsgid, v);
    785803 
    786804  owl_function_makemsg("Messages expunged");
    787   owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    788805}
    789806
     
    796813}
    797814
    798 void owl_function_lastmsg_noredisplay(void)
     815void owl_function_lastmsg(void)
    799816{
    800817  int oldcurmsg, curmsg;
     
    814831    owl_global_set_curmsg(&g, curmsg+1);
    815832  }
    816   /* owl_mainwin_redisplay(owl_global_get_mainwin(&g)); */
     833  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    817834  owl_global_set_direction_downwards(&g);
    818 }
    819 
    820 void owl_function_lastmsg(void)
    821 {
    822   owl_function_lastmsg_noredisplay();
    823   owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 
    824835}
    825836
     
    844855void owl_function_unsuball(void)
    845856{
    846   unsuball();
    847   owl_function_makemsg("Unsubscribed from all messages.");
     857  if (unsuball())
     858    owl_function_makemsg("Unsubscribed from all messages.");
    848859}
    849860
     
    860871void owl_function_loadsubs(const char *file)
    861872{
    862   int ret, ret2;
    863   const char *foo;
     873  int ret, ret2, ret3;
    864874  char *path;
    865875
     
    873883
    874884  /* for backwards compatibility for now */
    875   ret2=owl_zephyr_loaddefaultsubs();
     885  ret2 = owl_zephyr_loaddefaultsubs();
     886  ret3 = owl_zephyr_loadbarnowldefaultsubs();
    876887
    877888  if (!owl_context_is_interactive(owl_global_get_context(&g))) return;
    878889
    879   foo=file?file:"file";
    880   if (ret==0 && ret2==0) {
     890  if (ret == 0 && ret2 == 0 && ret3 == 0) {
    881891    if (!file) {
    882892      owl_function_makemsg("Subscribed to messages.");
     
    884894      owl_function_makemsg("Subscribed to messages from %s", file);
    885895    }
    886   } else if (ret==-1) {
    887     owl_function_error("Could not read %s", foo);
    888   } else {
     896  } else if (ret == -1) {
     897    owl_function_error("Could not read %s", file ? file : "file");
     898  } else if (ret2 == -1) {
    889899    owl_function_error("Error subscribing to messages");
     900  } else {
     901    owl_function_error("Error subscribing to instanced personals");
    890902  }
    891903}
     
    906918}
    907919
    908 void owl_callback_aimlogin(owl_editwin *e) {
     920void owl_callback_aimlogin(owl_editwin *e, bool success)
     921{
     922  if (!success) return;
    909923  char *user = owl_editwin_get_cbdata(e);
    910924  owl_function_aimlogin(user,
     
    10031017  }
    10041018
    1005   owl_function_debugmsg("Quitting Owl");
     1019  owl_function_debugmsg("Quitting BarnOwl");
    10061020  owl_select_quit_loop();
    10071021}
     
    12021216void G_GNUC_PRINTF(1, 2) owl_function_debugmsg(const char *fmt, ...)
    12031217{
     1218  char *tmpbuff;
    12041219  FILE *file;
    12051220  time_t now;
     
    12161231  now = time(NULL);
    12171232
    1218   fprintf(file, "[%d -  %.24s - %lds]: ",
    1219           (int) getpid(), ctime(&now), now - owl_global_get_starttime(&g));
     1233  tmpbuff = owl_util_format_time(localtime(&now));
     1234  fprintf(file, "[%d -  %s - %lds]: ",
     1235          (int) getpid(), tmpbuff, now - owl_global_get_starttime(&g));
     1236  g_free(tmpbuff);
    12201237  vfprintf(file, fmt, ap);
    12211238  putc('\n', file);
     
    12571274}
    12581275
    1259 static void _dirty_everything(owl_window *w) {
     1276static void _dirty_everything(gpointer data, gpointer user_data) {
     1277  owl_window *w = data;
    12601278  if (!owl_window_is_realized(w))
    12611279    return;
    12621280  owl_window_dirty(w);
    1263   owl_window_children_foreach(w, (GFunc)_dirty_everything, NULL);
     1281  owl_window_children_foreach(w, _dirty_everything, NULL);
    12641282}
    12651283
     
    12671285{
    12681286  /* Ask every widget to redraw itself. */
    1269   _dirty_everything(owl_window_get_screen());
     1287  _dirty_everything(owl_window_get_screen(), NULL);
    12701288  /* Force ncurses to redisplay everything. */
    12711289  clearok(stdscr, TRUE);
     
    13351353{
    13361354  owl_function_popless_text(
    1337     "This is barnowl version " OWL_VERSION_STRING ".\n\n"
    1338     "barnowl is a fork of the Owl zephyr client, written and\n"
     1355    "This is BarnOwl version " OWL_VERSION_STRING ".\n\n"
     1356    "BarnOwl is a fork of the Owl zephyr client, written and\n"
    13391357    "maintained by Alejandro Sedeno and Nelson Elhage at the\n"
    13401358    "Massachusetts Institute of Technology. \n"
     
    13451363    "The name 'owl' was chosen in reference to the owls in the\n"
    13461364    "Harry Potter novels, who are tasked with carrying messages\n"
    1347     "between Witches and Wizards. The name 'barnowl' was chosen\n"
     1365    "between Witches and Wizards. The name 'BarnOwl' was chosen\n"
    13481366    "because we feel our owls should live closer to our ponies.\n"
    13491367    "\n"
     
    13631381  owl_fmtext fm, attrfm;
    13641382  const owl_view *v;
     1383  char *time;
    13651384#ifdef HAVE_LIBZEPHYR
    13661385  const ZNotice_t *n;
     
    13931412  }
    13941413
    1395   owl_fmtext_appendf_normal(&fm, "  Time      : %s\n", owl_message_get_timestr(m));
     1414  time = owl_message_format_time(m);
     1415  owl_fmtext_appendf_normal(&fm, "  Time      : %s\n", time);
     1416  g_free(time);
    13961417
    13971418  if (!owl_message_is_type_admin(m)) {
     
    14071428    owl_fmtext_appendf_normal(&fm, "  Opcode    : %s\n", owl_message_get_opcode(m));
    14081429#ifdef HAVE_LIBZEPHYR
    1409     if (owl_message_is_direction_in(m)) {
    1410       char *tmpbuff;
     1430    n = owl_message_get_notice(m);
     1431    if (n != NULL) {
     1432      char *tmpbuff, *tmpbuff2;
    14111433      int i, fields;
    1412 
    1413       n=owl_message_get_notice(m);
     1434      const char *f;
    14141435
    14151436      if (!owl_message_is_pseudo(m)) {
     
    14531474        owl_fmtext_appendf_normal(&fm, "  Fields    : %i\n", fields);
    14541475
    1455         for (i = 0; i < fields; i++) {
    1456           tmpbuff = owl_zephyr_get_field_as_utf8(n, i + 1);
    1457 
    1458           g_strdelimit(tmpbuff, "\n", '~');
    1459           g_strdelimit(tmpbuff, "\r", '!');
    1460 
    1461           owl_fmtext_appendf_normal(&fm, "  Field %i   : %s\n", i + 1, tmpbuff);
    1462           g_free(tmpbuff);
     1476        for (i = 0, f = owl_zephyr_first_raw_field(n); f != NULL;
     1477             i++, f = owl_zephyr_next_raw_field(n, f)) {
     1478          tmpbuff = owl_zephyr_field_as_utf8(n, f);
     1479          tmpbuff2 = owl_text_indent(tmpbuff, 14, false);
     1480          owl_fmtext_appendf_normal(&fm, "  Field %i   : %s\n", i + 1, tmpbuff2);
     1481          g_free(tmpbuff2);
     1482          g_free(tmpbuff);
    14631483        }
    1464         owl_fmtext_appendf_normal(&fm, "  Default Fm: %s\n", n->z_default_format);
     1484        tmpbuff = owl_text_indent(n->z_default_format, 14, false);
     1485        owl_fmtext_appendf_normal(&fm, "  Default Fm: %s\n", tmpbuff);
     1486        g_free(tmpbuff);
    14651487      }
    14661488
     
    14691491  }
    14701492
    1471   owl_fmtext_append_bold(&fm, "\nOwl Message Attributes:\n");
     1493  owl_fmtext_append_bold(&fm, "\nBarnOwl Message Attributes:\n");
    14721494  owl_message_attributes_tofmtext(m, &attrfm);
    14731495  owl_fmtext_append_fmtext(&fm, &attrfm);
     
    16021624void owl_function_printallvars(void)
    16031625{
     1626  const owl_variable *v;
    16041627  const char *name;
    16051628  char *var;
    1606   owl_list varnames;
    1607   int i, numvarnames;
     1629  GPtrArray *varnames;
     1630  int i;
    16081631  GString *str   = g_string_new("");
    16091632
    16101633  g_string_append_printf(str, "%-20s = %s\n", "VARIABLE", "VALUE");
    16111634  g_string_append_printf(str, "%-20s   %s\n",  "--------", "-----");
    1612   owl_list_create(&varnames);
    1613   owl_variable_dict_get_names(owl_global_get_vardict(&g), &varnames);
    1614   numvarnames = owl_list_get_size(&varnames);
    1615   for (i=0; i<numvarnames; i++) {
    1616     name = owl_list_get_element(&varnames, i);
     1635  varnames = owl_variable_dict_get_names(owl_global_get_vardict(&g));
     1636  for (i = 0; i < varnames->len; i++) {
     1637    name = varnames->pdata[i];
    16171638    if (name && name[0]!='_') {
    16181639      g_string_append_printf(str, "\n%-20s = ", name);
    1619       var = owl_variable_get_tostring(owl_global_get_vardict(&g), name);
     1640      v = owl_variable_get_var(owl_global_get_vardict(&g), name);
     1641      var = owl_variable_get_tostring(v);
    16201642      if (var) {
    1621         g_string_append(str, var);
    1622         g_free(var);
     1643        g_string_append(str, var);
     1644        g_free(var);
     1645      } else {
     1646        g_string_append(str, "<null>");
    16231647      }
    16241648    }
    16251649  }
    16261650  g_string_append(str, "\n");
    1627   owl_list_cleanup(&varnames, g_free);
     1651  owl_ptr_array_free(varnames, g_free);
    16281652
    16291653  owl_function_popless_text(str->str);
     
    16331657void owl_function_show_variables(void)
    16341658{
    1635   owl_list varnames;
     1659  const owl_variable *v;
     1660  GPtrArray *varnames;
    16361661  owl_fmtext fm; 
    1637   int i, numvarnames;
     1662  int i;
    16381663  const char *varname;
    16391664
     
    16411666  owl_fmtext_append_bold(&fm,
    16421667      "Variables: (use 'show variable <name>' for details)\n");
    1643   owl_list_create(&varnames);
    1644   owl_variable_dict_get_names(owl_global_get_vardict(&g), &varnames);
    1645   numvarnames = owl_list_get_size(&varnames);
    1646   for (i=0; i<numvarnames; i++) {
    1647     varname = owl_list_get_element(&varnames, i);
     1668  varnames = owl_variable_dict_get_names(owl_global_get_vardict(&g));
     1669  for (i = 0; i < varnames->len; i++) {
     1670    varname = varnames->pdata[i];
    16481671    if (varname && varname[0]!='_') {
    1649       owl_variable_describe(owl_global_get_vardict(&g), varname, &fm);
    1650     }
    1651   }
    1652   owl_list_cleanup(&varnames, g_free);
     1672      v = owl_variable_get_var(owl_global_get_vardict(&g), varname);
     1673      owl_variable_describe(v, &fm);
     1674    }
     1675  }
     1676  owl_ptr_array_free(varnames, g_free);
    16531677  owl_function_popless_fmtext(&fm);
    16541678  owl_fmtext_cleanup(&fm);
     
    16571681void owl_function_show_variable(const char *name)
    16581682{
     1683  const owl_variable *v;
    16591684  owl_fmtext fm; 
    16601685
    16611686  owl_fmtext_init_null(&fm);
    1662   owl_variable_get_help(owl_global_get_vardict(&g), name, &fm);
     1687  v = owl_variable_get_var(owl_global_get_vardict(&g), name);
     1688  if (v)
     1689    owl_variable_get_help(v, &fm);
     1690  else
     1691    owl_fmtext_append_normal(&fm, "No such variable...\n");
    16631692  owl_function_popless_fmtext(&fm);
    16641693  owl_fmtext_cleanup(&fm);
     1694}
     1695
     1696void owl_function_delete_and_expunge_by_id(int id, bool exclaim_success)
     1697{
     1698  const owl_messagelist *ml = owl_global_get_msglist(&g);
     1699  int msg = owl_messagelist_get_index_by_id(ml, id);
     1700  if (msg < 0) {
     1701    owl_function_error("No message with id %d: unable to delete", id);
     1702  } else {
     1703    owl_function_delete_and_expunge_message(msg);
     1704    if (exclaim_success)
     1705      owl_function_makemsg("Message deleted and expunged");
     1706  }
    16651707}
    16661708
     
    17191761void owl_function_status(void)
    17201762{
     1763  char *tmpbuff;
    17211764  char buff[MAXPATHLEN+1];
    17221765  time_t start;
     
    17461789  owl_fmtext_append_normal(&fm, "\n");
    17471790
    1748   owl_fmtext_appendf_normal(&fm, "  Startup Time: %s", ctime(&start));
     1791  tmpbuff = owl_util_format_time(localtime(&start));
     1792  owl_fmtext_appendf_normal(&fm, "  Startup Time: %s\n", tmpbuff);
     1793  g_free(tmpbuff);
    17491794
    17501795  up=owl_global_get_runtime(&g);
     
    18691914    if (enter) {
    18701915      owl_history *hist = owl_global_get_cmd_history(&g);
    1871       owl_history_store(hist, buff);
    1872       owl_history_reset(hist);
     1916      owl_history_store(hist, buff, false);
    18731917      owl_function_command_norv(buff);
    18741918    } else {
     
    19001944}
    19011945
    1902 void owl_callback_command(owl_editwin *e)
    1903 {
     1946void owl_callback_command(owl_editwin *e, bool success)
     1947{
     1948  if (!success) return;
    19041949  char *rv;
    19051950  const char *line = owl_editwin_get_text(e);
     
    19121957}
    19131958
    1914 void owl_function_start_command(const char *line)
     1959owl_editwin *owl_function_start_command(const char *line)
    19151960{
    19161961  owl_editwin *tw;
     
    19271972  owl_global_push_context_obj(&g, ctx);
    19281973  owl_editwin_set_callback(tw, owl_callback_command);
     1974  return tw;
    19291975}
    19301976
     
    19612007}
    19622008
    1963 char *owl_function_exec(int argc, const char *const *argv, const char *buff, int type)
     2009CALLER_OWN char *owl_function_exec(int argc, const char *const *argv, const char *buff, int type)
    19642010{
    19652011  /* if type == 1 display in a popup
     
    20042050}
    20052051
    2006 char *owl_function_perl(int argc, const char *const *argv, const char *buff, int type)
     2052CALLER_OWN char *owl_function_perl(int argc, const char *const *argv, const char *buff, int type)
    20072053{
    20082054  /* if type == 1 display in a popup
     
    20852131
    20862132/* Create a new filter, or replace an existing one
    2087  * with a new definition.
     2133 * with a new definition. Returns true on success.
    20882134 */
    2089 void owl_function_create_filter(int argc, const char *const *argv)
     2135bool owl_function_create_filter(int argc, const char *const *argv)
    20902136{
    20912137  owl_filter *f;
     
    20952141  if (argc < 2) {
    20962142    owl_function_error("Wrong number of arguments to filter command");
    2097     return;
     2143    return false;
    20982144  }
    20992145
     
    21052151  if (!strcmp(argv[1], "all")) {
    21062152    owl_function_error("You may not change the 'all' filter.");
    2107     return;
     2153    return false;
    21082154  }
    21092155
     
    21132159    if (!f) {
    21142160      owl_function_error("The filter '%s' does not exist.", argv[1]);
    2115       return;
     2161      return false;
    21162162    }
    21172163    if (owl_util_string_to_color(argv[3])==OWL_COLOR_INVALID) {
    21182164      owl_function_error("The color '%s' is not available.", argv[3]);
    2119       return;
     2165      return false;
    21202166    }
    21212167    owl_filter_set_fgcolor(f, owl_util_string_to_color(argv[3]));
    21222168    owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    2123     return;
     2169    return false;
    21242170  }
    21252171  if (argc==4 && !strcmp(argv[2], "-b")) {
     
    21272173    if (!f) {
    21282174      owl_function_error("The filter '%s' does not exist.", argv[1]);
    2129       return;
     2175      return false;
    21302176    }
    21312177    if (owl_util_string_to_color(argv[3])==OWL_COLOR_INVALID) {
    21322178      owl_function_error("The color '%s' is not available.", argv[3]);
    2133       return;
     2179      return false;
    21342180    }
    21352181    owl_filter_set_bgcolor(f, owl_util_string_to_color(argv[3]));
    21362182    owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    2137     return;
     2183    return true;
    21382184  }
    21392185
     
    21412187  f = owl_filter_new(argv[1], argc-2, argv+2);
    21422188  if (f == NULL) {
    2143     owl_function_error("Invalid filter");
    2144     return;
     2189    owl_function_error("Invalid filter: %s", argv[1]);
     2190    return false;
    21452191  }
    21462192
     
    21632209  }
    21642210  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
     2211  return true;
    21652212}
    21662213
     
    21742221 * Returns the name of the negated filter, which the caller must free.
    21752222 */
    2176 char *owl_function_create_negative_filter(const char *filtername)
     2223CALLER_OWN char *owl_function_create_negative_filter(const char *filtername)
    21772224{
    21782225  char *newname;
     
    22442291{
    22452292  const owl_filter *f;
    2246   const owl_list *fl;
     2293  const GPtrArray *fl;
    22472294  char *tmp;
    22482295  owl_fmtext fm;
    2249   int i, j;
     2296  int i;
    22502297
    22512298  owl_fmtext_init_null(&fm);
    22522299
    22532300  fl=owl_global_get_puntlist(&g);
    2254   j=owl_list_get_size(fl);
    22552301  owl_fmtext_append_bold(&fm, "Active zpunt filters:\n");
    22562302
    2257   for (i=0; i<j; i++) {
    2258     f=owl_list_get_element(fl, i);
     2303  for (i = 0; i < fl->len; i++) {
     2304    f = fl->pdata[i];
    22592305    owl_fmtext_appendf_normal(&fm, "[% 2d] ", i+1);
    22602306    tmp = owl_filter_print(f);
     
    22712317 * If 'related' is nonzero, encompass unclasses and .d classes as well.
    22722318 */
    2273 char *owl_function_classinstfilt(const char *c, const char *i, int related)
     2319CALLER_OWN char *owl_function_classinstfilt(const char *c, const char *i, int related)
    22742320{
    22752321  owl_filter *f;
     
    23582404 * the filter, which the caller must free.
    23592405 */
    2360 char *owl_function_zuserfilt(const char *longuser)
     2406CALLER_OWN char *owl_function_zuserfilt(const char *longuser)
    23612407{
    23622408  owl_filter *f;
     
    24042450 * Returns the name of the filter, which the caller must free.
    24052451 */
    2406 char *owl_function_aimuserfilt(const char *user)
     2452CALLER_OWN char *owl_function_aimuserfilt(const char *user)
    24072453{
    24082454  owl_filter *f;
     
    24152461  /* if it already exists then go with it.  This lets users override */
    24162462  if (owl_global_get_filter(&g, filtname)) {
    2417     return(g_strdup(filtname));
     2463    return filtname;
    24182464  }
    24192465
     
    24422488}
    24432489
    2444 char *owl_function_typefilt(const char *type)
     2490CALLER_OWN char *owl_function_typefilt(const char *type)
    24452491{
    24462492  owl_filter *f;
     
    24982544}
    24992545
    2500 static char *owl_function_smartfilter_cc(const owl_message *m) {
     2546static CALLER_OWN char *owl_function_smartfilter_cc(const owl_message *m)
     2547{
    25012548  const char *ccs;
    25022549  char *ccs_quoted;
     
    25492596 *    name to the AIM conversation with that user
    25502597 */
    2551 char *owl_function_smartfilter(int type, int invert_related)
     2598CALLER_OWN char *owl_function_smartfilter(int type, int invert_related)
    25522599{
    25532600  const owl_view *v;
     
    28082855
    28092856  owl_function_punt(argv->len, (const char *const*) argv->pdata, direction);
    2810   g_ptr_array_foreach(argv, (GFunc)g_free, NULL);
    2811   g_ptr_array_free(argv, true);
     2857  owl_ptr_array_free(argv, g_free);
    28122858}
    28132859
     
    28152861{
    28162862  owl_filter *f;
    2817   owl_list *fl;
    2818   int i, j;
     2863  GPtrArray *fl;
     2864  int i;
    28192865  fl=owl_global_get_puntlist(&g);
    28202866
     
    28272873
    28282874  /* Check for an identical filter */
    2829   j=owl_list_get_size(fl);
    2830   for (i=0; i<j; i++) {
    2831     if (owl_filter_equiv(f, owl_list_get_element(fl, i))) {
     2875  for (i = 0; i < fl->len; i++) {
     2876    if (owl_filter_equiv(f, fl->pdata[i])) {
    28322877      owl_function_debugmsg("found an equivalent punt filter");
    28332878      /* if we're punting, then just silently bow out on this duplicate */
     
    28392884      /* if we're unpunting, then remove this filter from the puntlist */
    28402885      if (direction==1) {
    2841         owl_filter_delete(owl_list_get_element(fl, i));
    2842         owl_list_remove_element(fl, i);
     2886        owl_filter_delete(g_ptr_array_remove_index(fl, i));
    28432887        owl_filter_delete(f);
    28442888        return;
     
    28502894    owl_function_debugmsg("punting");
    28512895    /* If we're punting, add the filter to the global punt list */
    2852     owl_list_append_element(fl, f);
     2896    g_ptr_array_add(fl, f);
    28532897  } else if (direction == 1) {
    28542898    owl_function_makemsg("No matching punt filter");
     
    28582902void owl_function_show_keymaps(void)
    28592903{
    2860   owl_list l;
     2904  GPtrArray *l;
    28612905  owl_fmtext fm;
    28622906  const owl_keymap *km;
    28632907  const owl_keyhandler *kh;
    2864   int i, numkm;
     2908  int i;
    28652909  const char *kmname;
    28662910
     
    28692913  owl_fmtext_append_bold(&fm, "Keymaps:   ");
    28702914  owl_fmtext_append_normal(&fm, "(use 'show keymap <name>' for details)\n");
    2871   owl_list_create(&l);
    2872   owl_keyhandler_get_keymap_names(kh, &l);
    2873   owl_fmtext_append_list(&fm, &l, "\n", owl_function_keymap_summary);
     2915  l = owl_keyhandler_get_keymap_names(kh);
     2916  owl_fmtext_append_list(&fm, l, "\n", owl_function_keymap_summary);
    28742917  owl_fmtext_append_normal(&fm, "\n");
    28752918
    2876   numkm = owl_list_get_size(&l);
    2877   for (i=0; i<numkm; i++) {
    2878     kmname = owl_list_get_element(&l, i);
     2919  for (i = 0; i < l->len; i++) {
     2920    kmname = l->pdata[i];
    28792921    km = owl_keyhandler_get_keymap(kh, kmname);
    28802922    owl_fmtext_append_bold(&fm, "\n\n----------------------------------------------------------------------------------------------------\n\n");
     
    28842926 
    28852927  owl_function_popless_fmtext(&fm);
    2886   owl_list_cleanup(&l, g_free);
     2928  owl_ptr_array_free(l, g_free);
    28872929  owl_fmtext_cleanup(&fm);
    28882930}
    28892931
    2890 char *owl_function_keymap_summary(const char *name)
     2932CALLER_OWN char *owl_function_keymap_summary(const char *name)
    28912933{
    28922934  const owl_keymap *km
     
    30023044/* strips formatting from ztext and returns the unformatted text.
    30033045 * caller is responsible for freeing. */
    3004 char *owl_function_ztext_stylestrip(const char *zt)
     3046CALLER_OWN char *owl_function_ztext_stylestrip(const char *zt)
    30053047{
    30063048  owl_fmtext fm;
     
    30253067#ifdef HAVE_LIBZEPHYR
    30263068  int x;
    3027   owl_list anyone;
     3069  GPtrArray *anyone;
    30283070  const char *user;
    30293071  char *tmp;
     
    30453087      idle=owl_buddy_get_idle_time(b);
    30463088      if (idle!=0) {
    3047         timestr=owl_util_minutes_to_timestr(idle);
     3089        timestr=owl_util_format_minutes(idle);
    30483090      } else {
    30493091        timestr=g_strdup("");
     
    30603102    } else {
    30613103      owl_fmtext_append_bold(&fm, "Zephyr users logged in:\n");
    3062       owl_list_create(&anyone);
    3063       ret=owl_zephyr_get_anyone_list(&anyone, filename);
    3064       if (ret) {
     3104      anyone = owl_zephyr_get_anyone_list(filename);
     3105      if (anyone == NULL) {
    30653106        if (errno == ENOENT) {
    30663107          owl_fmtext_append_normal(&fm, " You have not added any zephyr buddies.  Use the\n");
     
    30723113        }
    30733114      } else {
    3074         j=owl_list_get_size(&anyone);
    3075         for (i=0; i<j; i++) {
    3076           user=owl_list_get_element(&anyone, i);
     3115        for (i = 0; i < anyone->len; i++) {
     3116          user = anyone->pdata[i];
    30773117          ret=ZLocateUser(zstr(user), &numlocs, ZAUTH);
    30783118
     
    31063146        }
    31073147      }
    3108       owl_list_cleanup(&anyone, g_free);
     3148      owl_ptr_array_free(anyone, g_free);
    31093149    }
    31103150  }
     
    31833223    }
    31843224   
    3185     /* if it exited, fork & exec a new one */
     3225    /* if it exited, spawn a new one */
    31863226    if (owl_global_get_newmsgproc_pid(&g)==0) {
    3187       pid_t i;
    31883227      int myargc;
    3189       i=fork();
    3190       if (i) {
    3191         /* parent set the child's pid */
    3192         owl_global_set_newmsgproc_pid(&g, i);
    3193         owl_function_debugmsg("I'm the parent and I started a new newmsgproc with pid %i", i);
    3194       } else {
    3195         /* child exec's the program */
    3196         char **parsed;
    3197         parsed=owl_parseline(owl_global_get_newmsgproc(&g), &myargc);
    3198         if (myargc < 0) {
    3199           owl_function_debugmsg("Could not parse newmsgproc '%s': unbalanced quotes?", owl_global_get_newmsgproc(&g));
    3200         }
    3201         if (myargc <= 0) {
    3202           _exit(127);
    3203         }
    3204         owl_function_debugmsg("About to exec \"%s\" with %d arguments", parsed[0], myargc);
    3205        
    3206         execvp(parsed[0], parsed);
    3207        
    3208        
    3209         /* was there an error exec'ing? */
    3210         owl_function_debugmsg("Cannot run newmsgproc '%s': cannot exec '%s': %s",
    3211                               owl_global_get_newmsgproc(&g), parsed[0], strerror(errno));
    3212         _exit(127);
     3228      char **argv = owl_parseline(owl_global_get_newmsgproc(&g), &myargc);
     3229      if (myargc < 0) {
     3230        owl_function_debugmsg("Could not parse newmsgproc '%s': unbalanced quotes?",
     3231                              owl_global_get_newmsgproc(&g));
     3232      } else if (myargc > 0) {
     3233        /* Spawn the child. */
     3234        GPid pid;
     3235        GError *error = NULL;
     3236        owl_function_debugmsg("About to exec \"%s\" with %d arguments", argv[0], myargc);
     3237        if (g_spawn_async(NULL, argv, NULL,
     3238                          G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
     3239                          NULL, NULL, &pid, &error)) {
     3240          owl_global_set_newmsgproc_pid(&g, pid);
     3241          owl_function_debugmsg("I'm the parent and I started a new newmsgproc with pid %i", pid);
     3242        } else {
     3243          owl_function_debugmsg("Cannot run newmsgproc '%s': %s",
     3244                                owl_global_get_newmsgproc(&g), error->message);
     3245          g_error_free(error);
     3246        }
    32133247      }
     3248      g_strfreev(argv);
    32143249    }
    32153250  }
     
    33803415  char *buff;
    33813416
    3382   now=time(NULL);
    3383   date=g_strdup(ctime(&now));
    3384   date[strlen(date)-1]='\0';
     3417  now = time(NULL);
     3418  date = owl_util_format_time(localtime(&now));
    33853419
    33863420  buff = g_strdup_printf("%s %s", date, string);
     
    34233457{
    34243458#ifdef HAVE_LIBZEPHYR
    3425   int i, j;
    3426   owl_list anyone;
     3459  int i;
     3460  GPtrArray *anyone;
    34273461  GList **zaldlist;
    34283462  GList *zaldptr;
     
    34443478  *zaldlist = NULL;
    34453479
    3446   owl_list_create(&anyone);
    3447   owl_zephyr_get_anyone_list(&anyone, NULL);
    3448   j = owl_list_get_size(&anyone);
    3449   for (i = 0; i < j; i++) {
    3450     user = owl_list_get_element(&anyone, i);
    3451     zald = g_new(ZAsyncLocateData_t, 1);
    3452     if (ZRequestLocations(zstr(user), zald, UNACKED, ZAUTH) == ZERR_NONE) {
    3453       *zaldlist = g_list_append(*zaldlist, zald);
    3454     } else {
    3455       g_free(zald);
    3456     }
    3457   }
    3458 
    3459   owl_list_cleanup(&anyone, g_free);
     3480  anyone = owl_zephyr_get_anyone_list(NULL);
     3481  if (anyone != NULL) {
     3482    for (i = 0; i < anyone->len; i++) {
     3483      user = anyone->pdata[i];
     3484      zald = g_new(ZAsyncLocateData_t, 1);
     3485      if (ZRequestLocations(zstr(user), zald, UNACKED, ZAUTH) == ZERR_NONE) {
     3486        *zaldlist = g_list_append(*zaldlist, zald);
     3487      } else {
     3488        g_free(zald);
     3489      }
     3490    }
     3491    owl_ptr_array_free(anyone, g_free);
     3492  }
    34603493#endif
    34613494}
    34623495
    3463 void owl_function_aimsearch_results(const char *email, owl_list *namelist)
     3496void owl_function_aimsearch_results(const char *email, GPtrArray *namelist)
    34643497{
    34653498  owl_fmtext fm;
    3466   int i, j;
     3499  int i;
    34673500
    34683501  owl_fmtext_init_null(&fm);
     
    34713504  owl_fmtext_append_normal(&fm, ":\n");
    34723505
    3473   j=owl_list_get_size(namelist);
    3474   for (i=0; i<j; i++) {
     3506  for (i = 0; i < namelist->len; i++) {
    34753507    owl_fmtext_append_normal(&fm, "  ");
    3476     owl_fmtext_append_normal(&fm, owl_list_get_element(namelist, i));
     3508    owl_fmtext_append_normal(&fm, namelist->pdata[i]);
    34773509    owl_fmtext_append_normal(&fm, "\n");
    34783510  }
  • global.c

    rdc1edbd r6383920  
     1#include "owl.h"
    12#include <stdio.h>
    2 #include <unistd.h>
    3 #include <stdlib.h>
    4 #include <string.h>
    5 #include <netdb.h>
    6 #include <termios.h>
    73#include <sys/ioctl.h>
    8 #include <time.h>
    9 #include "owl.h"
    104
    115static void _owl_global_init_windows(owl_global *g);
     
    159  const char *homedir;
    1610
     11#if !GLIB_CHECK_VERSION(2, 35, 0)
    1712  g_type_init();
     13#endif
     14#if !GLIB_CHECK_VERSION(2, 31, 0)
    1815  g_thread_init(NULL);
     16#endif
    1917
    2018  owl_select_init();
     
    4745  owl_dict_create(&(g->filters));
    4846  g->filterlist = NULL;
    49   owl_list_create(&(g->puntlist));
     47  g->puntlist = g_ptr_array_new();
    5048  g->messagequeue = g_queue_new();
    5149  owl_dict_create(&(g->styledict));
     
    5351  g->resizepending=0;
    5452  g->direction=OWL_DIRECTION_DOWNWARDS;
    55   g->zaway=0;
    5653  owl_fmtext_init_colorpair_mgr(&(g->cpmgr));
    5754  g->debug=OWL_DEBUG;
     
    6562  owl_history_init(&(g->msghist));
    6663  owl_history_init(&(g->cmdhist));
    67   owl_history_set_norepeats(&(g->cmdhist));
    6864  g->nextmsgid=0;
    6965
     
    7975  g->confdir = NULL;
    8076  g->startupfile = NULL;
    81   cd = g_strdup_printf("%s/%s", g->homedir, OWL_CONFIG_DIR);
     77  cd = g_build_filename(g->homedir, OWL_CONFIG_DIR, NULL);
    8278  owl_global_set_confdir(g, cd);
    8379  g_free(cd);
    8480
    85   owl_messagelist_create(&(g->msglist));
     81  g->msglist = owl_messagelist_new();
    8682
    8783  _owl_global_init_windows(g);
     
    105101
    106102  owl_message_init_fmtext_cache();
    107   owl_list_create(&(g->io_dispatch_list));
    108   g->timerlist = NULL;
    109103  g->kill_buffer = NULL;
    110104
    111105  g->interrupt_count = 0;
     106#if GLIB_CHECK_VERSION(2, 31, 0)
     107  g_mutex_init(&g->interrupt_lock);
     108#else
    112109  g->interrupt_lock = g_mutex_new();
     110#endif
    113111}
    114112
     
    119117
    120118  /* Create the widgets */
    121   owl_mainwin_init(&(g->mw), g->mainpanel.recwin);
     119  g->mw = owl_mainwin_new(g->mainpanel.recwin);
    122120  owl_msgwin_init(&(g->msgwin), g->mainpanel.msgwin);
    123121  owl_sepbar_init(g->mainpanel.sepwin);
     
    175173/* Pops the current context from the context stack and returns it. Caller is
    176174 * responsible for freeing. */
    177 owl_context *owl_global_pop_context_no_delete(owl_global *g) {
     175CALLER_OWN owl_context *owl_global_pop_context_no_delete(owl_global *g)
     176{
    178177  owl_context *c;
    179178  if (!g->context_stack)
     
    250249/* windows */
    251250
    252 owl_mainwin *owl_global_get_mainwin(owl_global *g) {
    253   return(&(g->mw));
     251owl_mainwin *owl_global_get_mainwin(owl_global *g)
     252{
     253  return g->mw;
    254254}
    255255
     
    265265
    266266owl_messagelist *owl_global_get_msglist(owl_global *g) {
    267   return(&(g->msglist));
     267  return g->msglist;
    268268}
    269269
     
    367367  g->confdir = g_strdup(cd);
    368368  g_free(g->startupfile);
    369   g->startupfile = g_strdup_printf("%s/startup", cd);
     369  g->startupfile = g_build_filename(cd, "startup", NULL);
    370370}
    371371
     
    581581/* puntlist */
    582582
    583 owl_list *owl_global_get_puntlist(owl_global *g) {
    584   return(&(g->puntlist));
     583GPtrArray *owl_global_get_puntlist(owl_global *g) {
     584  return g->puntlist;
    585585}
    586586
    587587int owl_global_message_is_puntable(owl_global *g, const owl_message *m) {
    588   const owl_list *pl;
    589   int i, j;
    590 
    591   pl=owl_global_get_puntlist(g);
    592   j=owl_list_get_size(pl);
    593   for (i=0; i<j; i++) {
    594     if (owl_filter_message_match(owl_list_get_element(pl, i), m)) return(1);
    595   }
    596   return(0);
     588  const GPtrArray *pl;
     589  int i;
     590
     591  pl = owl_global_get_puntlist(g);
     592  for (i = 0; i < pl->len; i++) {
     593    if (owl_filter_message_match(pl->pdata[i], m)) return 1;
     594  }
     595  return 0;
    597596}
    598597
     
    727726 * necessary.
    728727 */
    729 owl_message *owl_global_messagequeue_popmsg(owl_global *g)
     728CALLER_OWN owl_message *owl_global_messagequeue_popmsg(owl_global *g)
    730729{
    731730  owl_message *out;
     
    756755}
    757756
    758 void owl_global_get_style_names(const owl_global *g, owl_list *l) {
    759   owl_dict_get_keys(&(g->styledict), l);
     757CALLER_OWN GPtrArray *owl_global_get_style_names(const owl_global *g)
     758{
     759  return owl_dict_get_keys(&g->styledict);
    760760}
    761761
     
    841841}
    842842
    843 owl_list *owl_global_get_io_dispatch_list(owl_global *g)
    844 {
    845   return &(g->io_dispatch_list);
    846 }
    847 
    848 GList **owl_global_get_timerlist(owl_global *g)
    849 {
    850   return &(g->timerlist);
    851 }
    852 
    853843void owl_global_setup_default_filters(owl_global *g)
    854844{
     
    859849  } filters[] = {
    860850    { "personal",
    861       "isprivate ^true$ and ( not type ^zephyr$ or ( class ^message  ) )" },
     851      "isprivate ^true$ and ( not type ^zephyr$ or ( class ^message$ ) )" },
    862852    { "trash",
    863853      "class ^mail$ or opcode ^ping$ or type ^admin$ or ( not login ^none$ )" },
     
    866856    { "auto", "opcode ^auto$" },
    867857    { "login", "not login ^none$" },
    868     { "reply-lockout", "class ^noc or class ^mail$" },
     858    { "reply-lockout", "class ^mail$ or class ^filsrv$" },
    869859    { "out", "direction ^out$" },
    870860    { "aim", "type ^aim$" },
     
    917907}
    918908
     909static GMutex *owl_global_get_interrupt_lock(owl_global *g)
     910{
     911#if GLIB_CHECK_VERSION(2, 31, 0)
     912  return &g->interrupt_lock;
     913#else
     914  return g->interrupt_lock;
     915#endif
     916}
     917
    919918void owl_global_add_interrupt(owl_global *g) {
    920919  /* TODO: This can almost certainly be done with atomic
    921920   * operations. Whatever. */
    922   g_mutex_lock(g->interrupt_lock);
     921  g_mutex_lock(owl_global_get_interrupt_lock(g));
    923922  g->interrupt_count++;
    924   g_mutex_unlock(g->interrupt_lock);
     923  g_mutex_unlock(owl_global_get_interrupt_lock(g));
    925924}
    926925
    927926bool owl_global_take_interrupt(owl_global *g) {
    928927  bool ans = false;
    929   g_mutex_lock(g->interrupt_lock);
     928  g_mutex_lock(owl_global_get_interrupt_lock(g));
    930929  if (g->interrupt_count > 0) {
    931930    ans = true;
    932931    g->interrupt_count--;
    933932  }
    934   g_mutex_unlock(g->interrupt_lock);
     933  g_mutex_unlock(owl_global_get_interrupt_lock(g));
    935934  return ans;
    936935}
  • help.c

    rf25df21 r8258ea5  
    11#include "owl.h"
    2 #include <string.h>
    32
    43void owl_help(void)
    54{
     5  const owl_variable *v;
    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);
     
    6565     "\n"
    6666     "    l             Print a zephyr/AIM buddy listing\n"
    67      "    A             Toggle zaway\n"
     67     "    A             Toggle away\n"
    6868     "    o             Toggle one-line display mode\n"
    6969     "    w             Open a URL in the current message\n"
    7070     "    C-l           Refresh the screen\n"
    71      "    C-z           Suspend Owl\n"
     71     "    C-z           Suspend BarnOwl\n"
    7272     "    h             Print this help message\n"
    7373     "    : , M-x       Enter command mode\n"
    7474     "\n"
    75      "    /             Foward search\n"
     75     "    /             Forward search\n"
    7676     "    ?             Reverse search\n"
    7777     "\n\n"
     
    8383  owl_fmtext_append_normal
    8484    (&fm,
    85      "    quit, exit    Exit owl\n"
     85     "    quit, exit    Exit BarnOwl\n"
    8686     "    help          Get help about commands\n"
    87      "    show          Show information about owl (see detailed help)\n"
     87     "    show          Show information about BarnOwl (see detailed help)\n"
    8888     "\n"
    8989     "    zwrite        Send a zephyr\n"
     
    101101     "    set           Set a variable (see list below)\n"
    102102     "    print         Print a variable's value (variables listed below)\n"
    103      "    startup       Set a command to be run at every Owl startup\n"
    104      "    unstartup     Remove a command to be run at every Owl startup\n"
     103     "    startup       Set a command to be run at every BarnOwl startup\n"
     104     "    unstartup     Remove a command to be run at every BarnOwl startup\n"
    105105     "\n"
    106106     "    getsubs       Print a list of current subscriptions\n"
    107107     "    unsuball      Unsubscribe from all zephyr classes\n"
    108108     "    load-subs     Load zephyr subscriptions from a file\n"
    109      "    zpunt         Supress messages from a zephyr triplet\n"
     109     "    zpunt         Suppress messages from a zephyr triplet\n"
    110110     "    zlog          Send a login or logout notification\n"
    111111     "    zlist         Print a list of zephyr buddies logged in\n"
     
    121121     "    dump          Dump messagelist as text to a file\n"
    122122     "\n"
    123      "    about         Print information about owl\n"
    124      "    status        Print status information about the running owl\n"
    125      "    version       Print the version number of owl\n"
     123     "    about         Print information about BarnOwl\n"
     124     "    status        Print status information about the running BarnOwl\n"
     125     "    version       Print the version number of BarnOwl\n"
    126126     "\n");
    127127 
     
    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]!='_') {
    137       owl_variable_describe(owl_global_get_vardict(&g), varname, &fm);
     135      v = owl_variable_get_var(owl_global_get_vardict(&g), varname);
     136      owl_variable_describe(v, &fm);
    138137    }
    139138  }
    140   owl_list_cleanup(&varnames, g_free);
     139  owl_ptr_array_free(varnames, g_free);
    141140
    142141  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

    r3b8a563 rf271129  
    1 #include <ctype.h>
    2 #include <string.h>
    31#include "owl.h"
    42
     
    1412
    1513/* sets up a new keybinding for a command */
    16 owl_keybinding *owl_keybinding_new(const char *keyseq, const char *command, void (*function_fn)(void), const char *desc)
     14CALLER_OWN owl_keybinding *owl_keybinding_new(const char *keyseq, const char *command, void (*function_fn)(void), const char *desc)
    1715{
    1816  owl_keybinding *kb = g_new(owl_keybinding, 1);
     
    8583}
    8684
    87 char *owl_keybinding_stack_tostring(int *j, int len)
     85CALLER_OWN char *owl_keybinding_stack_tostring(int *j, int len)
    8886{
    8987  GString *string;
     
    10098}
    10199
    102 char *owl_keybinding_tostring(const owl_keybinding *kb)
     100CALLER_OWN char *owl_keybinding_tostring(const owl_keybinding *kb)
    103101{
    104102  return owl_keybinding_stack_tostring(kb->keys, kb->len);
  • keymap.c

    r4c7c21f rf271129  
    1 #include <string.h>
    21#include "owl.h"
    32
     
    1110  km->name = g_strdup(name);
    1211  km->desc = g_strdup(desc);
    13   owl_list_create(&km->bindings);
     12  km->bindings = g_ptr_array_new();
    1413  km->parent = NULL;
    1514  km->default_fn = default_fn;
     
    2423  g_free(km->name);
    2524  g_free(km->desc);
    26   owl_list_cleanup(&km->bindings, (void (*)(void *))owl_keybinding_delete);
     25  owl_ptr_array_free(km->bindings, (GDestroyNotify)owl_keybinding_delete);
    2726}
    2827
     
    3534int owl_keymap_create_binding(owl_keymap *km, const char *keyseq, const char *command, void (*function_fn)(void), const char *desc)
    3635{
    37   owl_keybinding *kb, *curkb;
     36  owl_keybinding *kb;
    3837  int i;
    3938
     
    4443   * otherwise just add this one.
    4544   */
    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   return owl_list_append_element(&km->bindings, kb); 
    54 
     45  for (i = km->bindings->len-1; i >= 0; i--) {
     46    if (owl_keybinding_equal(km->bindings->pdata[i], kb)) {
     47      owl_keybinding_delete(g_ptr_array_remove_index(km->bindings, i));
     48    }
     49  }
     50  g_ptr_array_add(km->bindings, kb);
     51  return 0;
    5552}
    5653
     
    5855int owl_keymap_remove_binding(owl_keymap *km, const char *keyseq)
    5956{
    60   owl_keybinding *kb, *curkb;
     57  owl_keybinding *kb;
    6158  int i;
    6259
     
    6562    return -1;
    6663
    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);
     64  for (i = km->bindings->len-1; i >= 0; i--) {
     65    if (owl_keybinding_equal(km->bindings->pdata[i], kb)) {
     66      owl_keybinding_delete(g_ptr_array_remove_index(km->bindings, i));
    7267      owl_keybinding_delete(kb);
    7368      return(0);
     
    8075
    8176/* returns a summary line describing this keymap.  the caller must free. */
    82 char *owl_keymap_summary(const owl_keymap *km)
     77CALLER_OWN char *owl_keymap_summary(const owl_keymap *km)
    8378{
    8479  if (!km || !km->name || !km->desc) return NULL;
     
    139134static void _owl_keymap_format_bindings(const owl_keymap *km, owl_fmtext *fm)
    140135{
    141   int i, nbindings;
     136  int i;
    142137  const owl_keybinding *kb;
    143138 
    144   nbindings = owl_list_get_size(&km->bindings);
    145   for (i=0; i<nbindings; i++) {
     139  for (i = 0; i < km->bindings->len; i++) {
    146140    char *kbstr;
    147141    const owl_cmd *cmd;
    148142    const char *tmpdesc, *desc = "";
    149143
    150     kb = owl_list_get_element(&km->bindings, i);
     144    kb = km->bindings->pdata[i];
    151145    kbstr = owl_keybinding_tostring(kb);
    152146    owl_fmtext_append_normal(fm, OWL_TABSTR);
     
    214208}
    215209
    216 void owl_keyhandler_get_keymap_names(const owl_keyhandler *kh, owl_list *l)
    217 {
    218   owl_dict_get_keys(&kh->keymaps, l);
     210CALLER_OWN GPtrArray *owl_keyhandler_get_keymap_names(const owl_keyhandler *kh)
     211{
     212  return owl_dict_get_keys(&kh->keymaps);
    219213}
    220214
     
    274268   * keyhandler and keymap apart.  */
    275269  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);
     270    for (i = km->bindings->len-1; i >= 0; i--) {
     271      kb = km->bindings->pdata[i];
    278272      match = owl_keybinding_match(kb, kh);
    279273      if (match == 1) {         /* subset match */
  • keypress.c

    rd07af84 rf271129  
    1 #include <ctype.h>
    2 #include <string.h>
    31#include "owl.h"
    42
     
    129127/* OWL_META is definied in owl.h */
    130128
    131 char *owl_keypress_tostring(int j, int esc)
     129CALLER_OWN char *owl_keypress_tostring(int j, int esc)
    132130{
    133131  GString *kb;
  • libfaim/Makefile.am

    r215c119 rb80bae0  
    1313libfaim_a_CPPFLAGS = -DAIM_BUILDDATE=\"x\" -DAIM_BUILDTIME=\"x\" \
    1414                     -I${top_srcdir}/libfaim
     15
     16EXTRA_DIST = oscar.c
  • libfaim/aim.h

    r63de71c rfe73d0c  
    1818
    1919#include "config.h"
    20 #ifdef HAVE_STDBOOL_H
    2120#include <stdbool.h>
    22 #else
    23 #ifndef HAVE__BOOL
    24 #define _Bool signed char
    25 #endif
    26 #define bool _Bool
    27 #define false 0
    28 #define true 1
    29 #define __bool_true_false_are_defined 1
    30 #endif  /* HAVE_STDBOOL_H */
    3121
    3222#include <stdio.h>
  • logging.c

    rcc305b5 r0792d99  
    11#include "owl.h"
    2 #include <stdlib.h>
    3 #include <string.h>
    4 #include <ctype.h>
    5 #include <sys/param.h>
     2#include <stdio.h>
    63
    74typedef struct _owl_log_entry { /* noproto */
     
    8077}
    8178
    82 char *owl_log_zephyr(const owl_message *m) {
     79CALLER_OWN char *owl_log_zephyr(const owl_message *m)
     80{
    8381    char *tmp = NULL;
    8482    GString *buffer = NULL;
     
    103101}
    104102
    105 char *owl_log_aim(const owl_message *m) {
     103CALLER_OWN char *owl_log_aim(const owl_message *m)
     104{
    106105    GString *buffer = NULL;
    107106    buffer = g_string_new("");
     
    120119}
    121120
    122 char *owl_log_jabber(const owl_message *m) {
     121CALLER_OWN char *owl_log_jabber(const owl_message *m)
     122{
    123123    GString *buffer = NULL;
    124124    buffer = g_string_new("");
     
    132132}
    133133
    134 char *owl_log_generic(const owl_message *m) {
     134CALLER_OWN char *owl_log_generic(const owl_message *m)
     135{
    135136    GString *buffer;
    136137    buffer = g_string_new("");
     
    220221    while (cc != NULL) {
    221222      temp = short_zuser(cc->data);
    222       filename = g_strdup_printf("%s/%s", logpath, temp);
     223      filename = g_build_filename(logpath, temp, NULL);
    223224      owl_log_append(m, filename);
    224225
     
    244245  }
    245246
    246   filename = g_strdup_printf("%s/%s", logpath, to);
     247  filename = g_build_filename(logpath, to, NULL);
    247248  owl_log_append(m, filename);
    248249  g_free(to);
    249250  g_free(filename);
    250251
    251   filename = g_strdup_printf("%s/all", logpath);
     252  filename = g_build_filename(logpath, "all", NULL);
    252253  owl_log_append(m, filename);
    253254  g_free(logpath);
     
    281282  /* expand ~ in path names */
    282283  logpath = owl_util_makepath(owl_global_get_logpath(&g));
    283   filename = g_strdup_printf("%s/%s", logpath, tobuff);
     284  filename = g_build_filename(logpath, tobuff, NULL);
    284285  msgbuf = g_string_new("");
    285286  g_string_printf(msgbuf, "ERROR (owl): %s\n%s\n", tobuff, text);
     
    290291  g_string_free(msgbuf, TRUE);
    291292
    292   filename = g_strdup_printf("%s/all", logpath);
     293  filename = g_build_filename(logpath, "all", NULL);
    293294  g_free(logpath);
    294295  msgbuf = g_string_new("");
     
    389390  if (personal) {
    390391    logpath = owl_util_makepath(owl_global_get_logpath(&g));
    391     filename = g_strdup_printf("%s/%s", logpath, from);
    392     allfilename = g_strdup_printf("%s/all", logpath);
     392    filename = g_build_filename(logpath, from, NULL);
     393    allfilename = g_build_filename(logpath, "all", NULL);
    393394    owl_log_append(m, allfilename);
    394395    g_free(allfilename);
    395396  } else {
    396397    logpath = owl_util_makepath(owl_global_get_classlogpath(&g));
    397     filename = g_strdup_printf("%s/%s", logpath, from);
     398    filename = g_build_filename(logpath, from, NULL);
    398399  }
    399400
     
    411412      temp = short_zuser(cc->data);
    412413      if (strcasecmp(temp, frombuff) != 0) {
    413         filename = g_strdup_printf("%s/%s", logpath, temp);
     414        filename = g_build_filename(logpath, temp, NULL);
    414415        owl_log_append(m, filename);
    415416        g_free(filename);
     
    428429static gpointer owl_log_thread_func(gpointer data)
    429430{
    430   log_context = g_main_context_new();
    431431  log_loop = g_main_loop_new(log_context, FALSE);
    432432  g_main_loop_run(log_loop);
     
    436436void owl_log_init(void)
    437437{
     438  log_context = g_main_context_new();
     439#if GLIB_CHECK_VERSION(2, 31, 0)
     440  logging_thread = g_thread_new("logging",
     441                                owl_log_thread_func,
     442                                NULL);
     443#else
    438444  GError *error = NULL;
    439445  logging_thread = g_thread_create(owl_log_thread_func,
     
    447453    exit(1);
    448454  }
     455#endif
    449456 
    450457}
  • m4/ax_cflags_warn_all.m4

    r8073852 re9b4a2c  
    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
    2626#    - $4 action-if-not-found : nothing
    2727#
     28#   NOTE: These macros depend on AX_APPEND_FLAG.
     29#
    2830# LICENSE
    2931#
    3032#   Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
     33#   Copyright (c) 2010 Rhys Ulerich <rhys.ulerich@gmail.com>
    3134#
    3235#   This program is free software; you can redistribute it and/or modify it
    3336#   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
     37#   Free Software Foundation; either version 3 of the License, or (at your
    3538#   option) any later version.
    3639#
     
    5659#   exception to the GPL to apply to your modified version as well.
    5760
    58 AC_DEFUN([AX_CFLAGS_WARN_ALL],[dnl
    59 AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl
    60 AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_warn_all])dnl
     61#serial 14
     62
     63AC_DEFUN([AX_FLAGS_WARN_ALL],[dnl
     64AS_VAR_PUSHDEF([FLAGS],[_AC_LANG_PREFIX[]FLAGS])dnl
     65AS_VAR_PUSHDEF([VAR],[ac_cv_[]_AC_LANG_ABBREV[]flags_warn_all])dnl
    6166AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings],
    6267VAR,[VAR="no, unknown"
    63  AC_LANG_SAVE
    64  AC_LANG_C
    65  ac_save_[]FLAGS="$[]FLAGS"
     68ac_save_[]FLAGS="$[]FLAGS"
    6669for ac_arg dnl
    67 in "-pedantic  % -Wall"       dnl   GCC
     70in "-warn all  % -warn all"   dnl Intel
     71   "-pedantic  % -Wall"       dnl GCC
    6872   "-xstrconst % -v"          dnl Solaris C
    6973   "-std1      % -verbose -w0 -warnprotos" dnl Digital Unix
     
    7579   #
    7680do 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])
     81   AC_COMPILE_IFELSE([AC_LANG_PROGRAM],
     82                     [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
    7983done
    80  FLAGS="$ac_save_[]FLAGS"
    81  AC_LANG_RESTORE
     84FLAGS="$ac_save_[]FLAGS"
    8285])
     86AS_VAR_POPDEF([FLAGS])dnl
     87AC_REQUIRE([AX_APPEND_FLAG])
    8388case ".$VAR" in
    8489     .ok|.ok,*) m4_ifvaln($3,$3) ;;
    85    .|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[
    86         AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])
    87                       m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])]) ;;
    88    *) m4_ifvaln($3,$3,[
    89    if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
    90    then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
    91    else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
    92                       m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
    93    fi ]) ;;
     90   .|.no|.no,*) m4_default($4,[m4_ifval($2,[AX_APPEND_FLAG([$2], [$1])])]) ;;
     91   *) m4_default($3,[AX_APPEND_FLAG([$VAR], [$1])]) ;;
    9492esac
    9593AS_VAR_POPDEF([VAR])dnl
    96 AS_VAR_POPDEF([FLAGS])dnl
    97 ])
    98 
    99 dnl the only difference - the LANG selection... and the default FLAGS
    100 
    101 AC_DEFUN([AX_CXXFLAGS_WARN_ALL],[dnl
    102 AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl
    103 AS_VAR_PUSHDEF([VAR],[ac_cv_cxxflags_warn_all])dnl
    104 AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings],
    105 VAR,[VAR="no, unknown"
    106  AC_LANG_SAVE
    107  AC_LANG_CPLUSPLUS
    108  ac_save_[]FLAGS="$[]FLAGS"
    109 for ac_arg dnl
    110 in "-pedantic  % -Wall"       dnl   GCC
    111    "-xstrconst % -v"          dnl Solaris C
    112    "-std1      % -verbose -w0 -warnprotos" dnl Digital Unix
    113    "-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX
    114    "-ansi -ansiE % -fullwarn" dnl IRIX
    115    "+ESlit     % +w1"         dnl HP-UX C
    116    "-Xc        % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10)
    117    "-h conform % -h msglevel 2" dnl Cray C (Unicos)
    118    #
    119 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])
    122 done
    123  FLAGS="$ac_save_[]FLAGS"
    124  AC_LANG_RESTORE
    125 ])
    126 case ".$VAR" in
    127      .ok|.ok,*) m4_ifvaln($3,$3) ;;
    128    .|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[
    129         AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])
    130                       m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])]) ;;
    131    *) m4_ifvaln($3,$3,[
    132    if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
    133    then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
    134    else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
    135                       m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
    136    fi ]) ;;
    137 esac
    138 AS_VAR_POPDEF([VAR])dnl
    139 AS_VAR_POPDEF([FLAGS])dnl
    140 ])
    141 
     94])dnl AX_FLAGS_WARN_ALL
    14295dnl  implementation tactics:
    14396dnl   the for-argument contains a list of options. The first part of
     
    148101dnl   like -Woption or -Xoption as they think of it is a pass-through
    149102dnl   to later compile stages or something. The "%" is used as a
    150 dnl   delimimiter. A non-option comment can be given after "%%" marks
     103dnl   delimiter. A non-option comment can be given after "%%" marks
    151104dnl   which will be shown but not added to the respective C/CXXFLAGS.
     105
     106AC_DEFUN([AX_CFLAGS_WARN_ALL],[dnl
     107AC_LANG_PUSH([C])
     108AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4])
     109AC_LANG_POP([C])
     110])
     111
     112AC_DEFUN([AX_CXXFLAGS_WARN_ALL],[dnl
     113AC_LANG_PUSH([C++])
     114AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4])
     115AC_LANG_POP([C++])
     116])
     117
     118AC_DEFUN([AX_FCFLAGS_WARN_ALL],[dnl
     119AC_LANG_PUSH([Fortran])
     120AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4])
     121AC_LANG_POP([Fortran])
     122])
  • 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 r13a39ae8  
    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
     160
     161
     162# PKG_INSTALLDIR(DIRECTORY)
     163# -------------------------
     164# Substitutes the variable pkgconfigdir as the location where a module
     165# should install pkg-config .pc files. By default the directory is
     166# $libdir/pkgconfig, but the default can be changed by passing
     167# DIRECTORY. The user can override through the --with-pkgconfigdir
     168# parameter.
     169AC_DEFUN([PKG_INSTALLDIR],
     170[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
     171m4_pushdef([pkg_description],
     172    [pkg-config installation directory @<:@]pkg_default[@:>@])
     173AC_ARG_WITH([pkgconfigdir],
     174    [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
     175    [with_pkgconfigdir=]pkg_default)
     176AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
     177m4_popdef([pkg_default])
     178m4_popdef([pkg_description])
     179]) dnl PKG_INSTALLDIR
     180
     181
     182# PKG_NOARCH_INSTALLDIR(DIRECTORY)
     183# -------------------------
     184# Substitutes the variable noarch_pkgconfigdir as the location where a
     185# module should install arch-independent pkg-config .pc files. By
     186# default the directory is $datadir/pkgconfig, but the default can be
     187# changed by passing DIRECTORY. The user can override through the
     188# --with-noarch-pkgconfigdir parameter.
     189AC_DEFUN([PKG_NOARCH_INSTALLDIR],
     190[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
     191m4_pushdef([pkg_description],
     192    [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
     193AC_ARG_WITH([noarch-pkgconfigdir],
     194    [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
     195    [with_noarch_pkgconfigdir=]pkg_default)
     196AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
     197m4_popdef([pkg_default])
     198m4_popdef([pkg_description])
     199]) dnl PKG_NOARCH_INSTALLDIR
     200
     201
     202# PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
     203# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
     204# -------------------------------------------
     205# Retrieves the value of the pkg-config variable for the given module.
     206AC_DEFUN([PKG_CHECK_VAR],
     207[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
     208AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
     209
     210_PKG_CONFIG([$1], [variable="][$3]["], [$2])
     211AS_VAR_COPY([$1], [pkg_cv_][$1])
     212
     213AS_VAR_IF([$1], [""], [$5], [$4])dnl
     214])# PKG_CHECK_VAR
  • mainwin.c

    r099597c rab88b05  
    44static void owl_mainwin_resized(owl_window *w, void *user_data);
    55
    6 void owl_mainwin_init(owl_mainwin *mw, owl_window *window)
     6CALLER_OWN owl_mainwin *owl_mainwin_new(owl_window *window)
    77{
     8  owl_mainwin *mw = g_new(owl_mainwin, 1);
    89  mw->curtruncated=0;
    910  mw->lastdisplayed=-1;
     
    1617  /* For now, we do not bother with connecting up dependencies; that'll be a
    1718   * future refactor of the mainwin */
     19
     20  return mw;
    1821}
    1922
  • message.c

    r259e60a8 r2354e9a  
    1 #include <stdlib.h>
    2 #include <unistd.h>
    3 #include <string.h>
    4 #include <sys/socket.h>
    5 #include <netdb.h>
    6 #include <sys/types.h>
    7 #include <sys/socket.h>
    8 #include <netinet/in.h>
    9 #include <arpa/inet.h>
    10 #include <time.h>
    111#include "owl.h"
    122#include "filterproc.h"
     3#include <sys/socket.h>
     4#include <arpa/inet.h>
    135
    146static owl_fmtext_cache fmtext_cache[OWL_FMTEXT_CACHE_SIZE];
     
    4234  m->delete=0;
    4335
     36#ifdef HAVE_LIBZEPHYR
     37  m->has_notice = false;
     38#endif
     39
    4440  owl_message_set_hostname(m, "");
    45   owl_list_create(&(m->attributes));
     41  m->attributes = g_ptr_array_new();
    4642 
    4743  /* save the time */
    48   m->time=time(NULL);
    49   m->timestr=g_strdup(ctime(&(m->time)));
    50   m->timestr[strlen(m->timestr)-1]='\0';
     44  m->time = time(NULL);
     45  m->timestr = g_strdup(ctime(&m->time));
     46  m->timestr[strlen(m->timestr)-1] = '\0';
    5147
    5248  m->fmtext = NULL;
     
    5854void owl_message_set_attribute(owl_message *m, const char *attrname, const char *attrvalue)
    5955{
    60   int i, j;
     56  int i;
    6157  owl_pair *p = NULL, *pair = NULL;
    6258
     
    6460
    6561  /* 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);
     62  for (i = 0; i < m->attributes->len; i++) {
     63    p = m->attributes->pdata[i];
    6964    if (owl_pair_get_key(p) == attrname) {
    7065      g_free(owl_pair_get_value(p));
     
    7772    pair = g_new(owl_pair, 1);
    7873    owl_pair_create(pair, attrname, NULL);
    79     owl_list_append_element(&(m->attributes), pair);
     74    g_ptr_array_add(m->attributes, pair);
    8075  }
    8176  owl_pair_set_value(pair, owl_validate_or_convert(attrvalue));
     
    8782const char *owl_message_get_attribute_value(const owl_message *m, const char *attrname)
    8883{
    89   int i, j;
     84  int i;
    9085  owl_pair *p;
    9186  GQuark quark;
     
    9792  attrname = g_quark_to_string(quark);
    9893
    99   j=owl_list_get_size(&(m->attributes));
    100   for (i=0; i<j; i++) {
    101     p=owl_list_get_element(&(m->attributes), i);
     94  for (i = 0; i < m->attributes->len; i++) {
     95    p = m->attributes->pdata[i];
    10296    if (owl_pair_get_key(p) == attrname) {
    10397      return(owl_pair_get_value(p));
     
    118112 */
    119113void owl_message_attributes_tofmtext(const owl_message *m, owl_fmtext *fm) {
    120   int i, j;
     114  int i;
    121115  owl_pair *p;
    122116  char *buff, *tmpbuff;
     
    124118  owl_fmtext_init_null(fm);
    125119
    126   j=owl_list_get_size(&(m->attributes));
    127   for (i=0; i<j; i++) {
    128     p=owl_list_get_element(&(m->attributes), i);
    129 
    130     tmpbuff = g_strdup(owl_pair_get_value(p));
    131     g_strdelimit(tmpbuff, "\n", '~');
    132     g_strdelimit(tmpbuff, "\r", '!');
    133     buff = g_strdup_printf("  %-15.15s: %s\n", owl_pair_get_key(p), tmpbuff);
    134     g_free(tmpbuff);
     120  for (i = 0; i < m->attributes->len; i++) {
     121    p = m->attributes->pdata[i];
     122
     123    buff = g_strdup(owl_pair_get_value(p));
     124    if (buff) {
     125      tmpbuff = owl_text_indent(buff, 19, false);
     126      g_free(buff);
     127      buff = g_strdup_printf("  %-15.15s: %s\n", owl_pair_get_key(p), tmpbuff);
     128      g_free(tmpbuff);
     129    }
    135130
    136131    if(buff == NULL) {
     
    352347}
    353348
     349CALLER_OWN char *owl_message_format_time(const owl_message *m)
     350{
     351  return owl_util_format_time(localtime(&m->time));
     352}
     353
    354354void owl_message_set_type_admin(owl_message *m)
    355355{
     
    500500const ZNotice_t *owl_message_get_notice(const owl_message *m)
    501501{
    502   return(&(m->notice));
     502  return m->has_notice ? &m->notice : NULL;
    503503}
    504504#else
     
    580580
    581581/* caller must free return value. */
    582 char *owl_message_get_cc(const owl_message *m)
     582CALLER_OWN char *owl_message_get_cc(const owl_message *m)
    583583{
    584584  const char *cur;
     
    597597
    598598/* caller must free return value */
    599 GList *owl_message_get_cc_without_recipient(const owl_message *m)
     599CALLER_OWN GList *owl_message_get_cc_without_recipient(const owl_message *m)
    600600{
    601601  char *cc, *shortuser, *recip;
     
    791791  /* first save the full notice */
    792792  m->notice = *n;
     793  m->has_notice = true;
    793794
    794795  /* a little gross, we'll replace \r's with ' ' for now */
     
    797798  /* save the time, we need to nuke the string saved by message_init */
    798799  if (m->timestr) g_free(m->timestr);
    799   m->time=n->z_time.tv_sec;
    800   m->timestr=g_strdup(ctime(&(m->time)));
    801   m->timestr[strlen(m->timestr)-1]='\0';
     800  m->time = n->z_time.tv_sec;
     801  m->timestr = g_strdup(ctime(&m->time));
     802  m->timestr[strlen(m->timestr)-1] = '\0';
    802803
    803804  /* set other info */
     
    835836
    836837 
    837   /* set the "isprivate" attribute if it's a private zephyr.
    838    ``private'' means recipient is non-empty and doesn't start wit
    839    `@' */
    840   if (*n->z_recipient && *n->z_recipient != '@') {
     838  /* set the "isprivate" attribute if it's a private zephyr. */
     839  if (owl_zwrite_recip_is_personal(n->z_recipient)) {
    841840    owl_message_set_isprivate(m);
    842841  }
     
    876875  if (owl_global_is_zcrypt(&g) && !strcasecmp(n->z_opcode, "crypt")) {
    877876    const char *argv[] = {
    878       "zcrypt",
     877      NULL,
    879878      "-D",
    880879      "-c", owl_message_get_class(m),
     
    882881      NULL
    883882    };
    884     char *out;
     883    char *out = NULL;
    885884    int rv;
    886885    int status;
    887886    char *zcrypt;
    888887
    889     zcrypt = g_strdup_printf("%s/zcrypt", owl_get_bindir());
    890 
    891     rv = call_filter(zcrypt, argv, owl_message_get_body(m), &out, &status);
     888    zcrypt = g_build_filename(owl_get_bindir(), "zcrypt", NULL);
     889    argv[0] = zcrypt;
     890
     891    rv = call_filter(argv, owl_message_get_body(m), &out, &status);
    892892    g_free(zcrypt);
    893893
     
    898898      }
    899899      owl_message_set_body(m, out);
    900       g_free(out);
    901     } else if(out) {
    902       g_free(out);
    903     }
     900    } else {
     901      /* Replace the opcode. Otherwise the UI and other bits of code think the
     902       * message was encrypted. */
     903      owl_message_set_opcode(m, "failed-decrypt");
     904    }
     905    g_free(out);
    904906  }
    905907
     
    10041006void owl_message_cleanup(owl_message *m)
    10051007{
    1006   int i, j;
     1008  int i;
    10071009  owl_pair *p;
    10081010#ifdef HAVE_LIBZEPHYR   
    1009   if (owl_message_is_type_zephyr(m) && owl_message_is_direction_in(m)) {
     1011  if (m->has_notice) {
    10101012    ZFreeNotice(&(m->notice));
    10111013  }
     
    10141016
    10151017  /* 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);
     1018  for (i = 0; i < m->attributes->len; i++) {
     1019    p = m->attributes->pdata[i];
    10191020    g_free(owl_pair_get_value(p));
    10201021    g_free(p);
    10211022  }
    10221023
    1023   owl_list_cleanup(&(m->attributes), NULL);
     1024  g_ptr_array_free(m->attributes, true);
    10241025 
    10251026  owl_message_invalidate_format(m);
  • messagelist.c

    r66a8cd6 r219f52c