Changeset 88e7b2e


Ignore:
Timestamp:
Jun 22, 2013, 9:49:56 PM (8 years ago)
Author:
Jason Gross <jasongross9@gmail.com>
Parents:
96d80e9 (diff), 50970e1 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:
Merge 50970e1c5d96255a716f6e51b6545cf70d01e8c7 into 96d80e9b4aa667605b9c786b0272e1ab04dfbe9b
Files:
37 added
40 deleted
96 edited
1 moved

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

    rce35060 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
     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

    raeadc74 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
     21AnyEvent
     22Class::Accessor
     23ExtUtils::Depends
     24Glib
     25Module::Install
    2026PAR
    21 Net::DNS
    22 Authen::SASL::Perl
    23 IO::Socket::SSL
    24 Digest::SHA1
    2527
    2628(Note that these are all available as Debian packages)
     
    2830these for you.
    2931
     32The Facebook module requires:
     33
     34Any::Moose
     35AnyEvent::HTTP
     36DateTime
     37DateTime::Format::Strptime
     38JSON
     39MIME::Base64::URLSafe
     40Ouch
     41URI
     42URI::Encode
     43
    3044The IRC module requires:
    3145
    32 Net::IRC
    33 Class::Accessor
     46AnyEvent::IRC
     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
    3459
    3560The WordWrap module requires:
  • aim.c

    r3472845 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;
     
    446452}
    447453
    448 int owl_aim_process_events(void)
    449 {
    450   aim_session_t *aimsess;
     454int owl_aim_process_events(aim_session_t *aimsess)
     455{
    451456  aim_conn_t *waitingconn = NULL;
    452457  struct timeval tv;
     
    454459  struct owlfaim_priv *priv;
    455460
    456   aimsess=owl_global_get_aimsess(&g);
    457461  priv = aimsess->aux_data;
    458462
     
    703707{
    704708  aim_clientready(sess, fr->conn);
    705   owl_function_debugmsg("conninitdone_admin: initializtion done for admin connection");
     709  owl_function_debugmsg("conninitdone_admin: initialization done for admin connection");
    706710  return(1);
    707711}
     
    832836  params = va_arg(ap, struct aim_icbmparameters *);
    833837  va_end(ap);
    834  
    835   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",
    836840                       params->maxchan, params->flags, params->maxmsglen, ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, params->minmsginterval);
    837841     
     
    10571061  g_free(wrapmsg);
    10581062  g_free(nz_screenname);
     1063  g_free(realmsg);
    10591064
    10601065  return(1);
    10611066
    1062   owl_function_debugmsg("faimtest_parse_incoming_im_chan1: icbm: message: %s\n", realmsg);
    1063  
    1064   if (args->icbmflags & AIM_IMFLAGS_MULTIPART) {
    1065     aim_mpmsg_section_t *sec;
    1066     int z;
    1067 
    1068     owl_function_debugmsg("faimtest_parse_incoming_im_chan1: icbm: multipart: this message has %d parts\n", args->mpmsg.numparts);
    1069    
    1070     for (sec = args->mpmsg.parts, z = 0; sec; sec = sec->next, z++) {
    1071       if ((sec->charset == 0x0000) || (sec->charset == 0x0003) || (sec->charset == 0xffff)) {
    1072         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);
    1073       } else {
    1074         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);
    1075       }
    1076     }
    1077   }
    1078  
    1079   if (args->icbmflags & AIM_IMFLAGS_HASICON) {
    1080     /* aim_send_im(sess, userinfo->sn, AIM_IMFLAGS_BUDDYREQ, "You have an icon"); */
    1081     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);
    1082   }
    1083 
    1084   g_free(realmsg);
    1085 
    1086   return(1);
     1067  /* TODO: Multipart? See history from before 1.8 release. */
    10871068}
    10881069
     
    14321413  const char *address, *SNs;
    14331414  int num, i;
    1434   owl_list list;
     1415  GPtrArray *list;
    14351416 
    14361417  va_start(ap, fr);
     
    14401421  va_end(ap);
    14411422
    1442   owl_list_create(&list);
     1423  list = g_ptr_array_new();
    14431424 
    14441425  owl_function_debugmsg("faimtest_parse_searchreply: E-Mail Search Results for %s: ", address);
    14451426  for (i=0; i<num; i++) {
    14461427    owl_function_debugmsg("  %s", &SNs[i*(MAXSNLEN+1)]);
    1447     owl_list_append_element(&list, (void *)&SNs[i*(MAXSNLEN+1)]);
    1448   }
    1449   owl_function_aimsearch_results(address, &list);
    1450   owl_list_cleanup(&list, NULL);
    1451   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;
    14521433}
    14531434
     
    17951776}
    17961777
    1797 void owl_process_aim(void)
    1798 {
    1799   if (owl_global_is_doaimevents(&g)) {
    1800     owl_aim_process_events();
    1801   }
    1802 }
     1778typedef struct _owl_aim_event_source { /*noproto*/
     1779  GSource source;
     1780  aim_session_t *sess;
     1781  GPtrArray *fds;
     1782} owl_aim_event_source;
     1783
     1784static void truncate_pollfd_list(owl_aim_event_source *event_source, int len)
     1785{
     1786  GPollFD *fd;
     1787  int i;
     1788  if (len < event_source->fds->len) {
     1789    owl_function_debugmsg("Truncating AIM PollFDs to %d, was %d", len, event_source->fds->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  }
     1797}
     1798
     1799static gboolean owl_aim_event_source_prepare(GSource *source, int *timeout)
     1800{
     1801  owl_aim_event_source *event_source = (owl_aim_event_source*)source;
     1802  aim_conn_t *cur;
     1803  GPollFD *fd;
     1804  int i;
     1805
     1806  /* AIM HACK:
     1807   *
     1808   *  The problem - I'm not sure where to hook into the owl/faim
     1809   *  interface to keep track of when the AIM socket(s) open and
     1810   *  close. In particular, the bosconn thing throws me off. So,
     1811   *  rather than register particular dispatchers for AIM, I look up
     1812   *  the relevant FDs and add them to select's watch lists, then
     1813   *  check for them individually before moving on to the other
     1814   *  dispatchers. --asedeno
     1815   */
     1816  i = 0;
     1817  for (cur = event_source->sess->connlist; cur; cur = cur->next) {
     1818    if (cur->fd != -1) {
     1819      /* Add new GPollFDs as necessary. */
     1820      if (i == event_source->fds->len) {
     1821        fd = g_new0(GPollFD, 1);
     1822        g_ptr_array_add(event_source->fds, fd);
     1823        g_source_add_poll(source, fd);
     1824        owl_function_debugmsg("Allocated new AIM PollFD, len = %d", event_source->fds->len);
     1825      }
     1826      fd = event_source->fds->pdata[i];
     1827      fd->fd = cur->fd;
     1828      fd->events = G_IO_IN | G_IO_HUP | G_IO_ERR;
     1829      if (cur->status & AIM_CONN_STATUS_INPROGRESS) {
     1830        /* AIM login requires checking writable sockets. See aim_select. */
     1831        fd->events |= G_IO_OUT;
     1832      }
     1833      i++;
     1834    }
     1835  }
     1836  /* If the number of GPollFDs went down, clean up. */
     1837  truncate_pollfd_list(event_source, i);
     1838
     1839  *timeout = -1;
     1840  return FALSE;
     1841}
     1842
     1843static gboolean owl_aim_event_source_check(GSource *source)
     1844{
     1845  owl_aim_event_source *event_source = (owl_aim_event_source*)source;
     1846  int i;
     1847
     1848  for (i = 0; i < event_source->fds->len; i++) {
     1849    GPollFD *fd = event_source->fds->pdata[i];
     1850    if (fd->revents & fd->events)
     1851      return TRUE;
     1852  }
     1853  return FALSE;
     1854}
     1855
     1856static gboolean owl_aim_event_source_dispatch(GSource *source, GSourceFunc callback, gpointer user_data)
     1857{
     1858  owl_aim_event_source *event_source = (owl_aim_event_source*)source;
     1859  owl_aim_process_events(event_source->sess);
     1860  return TRUE;
     1861}
     1862
     1863static void owl_aim_event_source_finalize(GSource *source)
     1864{
     1865  owl_aim_event_source *event_source = (owl_aim_event_source*)source;
     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);
     1871}
     1872
     1873static GSourceFuncs aim_event_funcs = {
     1874  owl_aim_event_source_prepare,
     1875  owl_aim_event_source_check,
     1876  owl_aim_event_source_dispatch,
     1877  owl_aim_event_source_finalize,
     1878};
     1879
     1880GSource *owl_aim_event_source_new(aim_session_t *sess)
     1881{
     1882  GSource *source;
     1883  owl_aim_event_source *event_source;
     1884
     1885  source = g_source_new(&aim_event_funcs, sizeof(owl_aim_event_source));
     1886  event_source = (owl_aim_event_source *)source;
     1887  event_source->sess = sess;
     1888  /* TODO: When we depend on glib 2.22+, use g_ptr_array_new_with_free_func. */
     1889  event_source->fds = g_ptr_array_new();
     1890  return source;
     1891}
  • 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

    rf25df21 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) {
    14   if (0 != owl_cmddict_init(cd)) return(-1);
    15   if (0 != owl_cmddict_add_from_list(cd, commands_to_init)) return(-1);
    16   return(0);
    17 }
    18 
    19 int owl_cmddict_init(owl_cmddict *cd) {
    20   if (owl_dict_create(cd)) return(-1);
    21   return(0);
     7void owl_cmddict_setup(owl_cmddict *cd)
     8{
     9  owl_cmddict_init(cd);
     10  owl_cmd_add_defaults(cd);
     11}
     12
     13void owl_cmddict_init(owl_cmddict *cd) {
     14  owl_dict_create(cd);
    2215}
    2316
    2417/* for bulk initialization at startup */
    25 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{
    2620  const owl_cmd *cur;
    27   int ret = 0;
    2821  for (cur = cmds; cur->name != NULL; cur++) {
    29     ret = owl_cmddict_add_cmd(cd, cur);
    30     if (ret < 0) break;
    31   }
    32   return ret;
    33 }
    34 
    35 void owl_cmddict_get_names(const owl_cmddict *d, owl_list *l) {
    36   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);
    3728}
    3829
     
    4233
    4334/* creates a new command alias */
    44 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) {
    4536  owl_cmd *cmd;
    4637  cmd = g_new(owl_cmd, 1);
     
    4839  owl_perlconfig_new_command(cmd->name);
    4940  owl_dict_insert_element(cd, cmd->name, cmd, (void (*)(void *))owl_cmd_delete);
    50   return(0);
    5141}
    5242
     
    6151}
    6252
    63 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{
    6456  char *retval = NULL;
    6557  const owl_cmd *cmd;
     
    7668}
    7769
    78 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{
    7973  char **argv;
    8074  int argc;
     
    9892}
    9993
    100 char *owl_cmddict_execute_argv(const owl_cmddict *cd, const owl_context *ctx, const char *const *argv, int argc) {
    101   GString *buf = g_string_new("");
    102   int i;
    103   char *retval;
    104 
    105   /* We weren't given a command line, so fabricate a valid one. */
    106   for(i = 0; i < argc; i++) {
    107     if (i != 0)
    108       g_string_append_c(buf, ' ');
    109     owl_string_append_quoted_arg(buf, argv[i]);
    110   }
    111 
    112   retval = _owl_cmddict_execute(cd, ctx, argv, argc, buf->str);
    113 
    114   g_string_free(buf, true);
     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{
     97  char *buff;
     98  char *retval = NULL;
     99
     100  buff = g_strjoinv(" ", (char**)argv);
     101  retval = _owl_cmddict_execute(cd, ctx, argv, argc, buff);
     102  g_free(buff);
     103
    115104  return retval;
    116105}
     
    132121}
    133122
    134 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) {
    135124  memset(cmd, 0, sizeof(owl_cmd));
    136125  cmd->name = g_strdup(name);
    137126  cmd->cmd_aliased_to = g_strdup(aliased_to);
    138127  cmd->summary = g_strdup_printf("%s%s", OWL_CMD_ALIAS_SUMMARY_PREFIX, aliased_to);
    139   return(0);
    140128}
    141129
    142130void owl_cmd_cleanup(owl_cmd *cmd)
    143131{
    144   if (cmd->name) g_free(cmd->name);
    145   if (cmd->summary) g_free(cmd->summary);
    146   if (cmd->usage) g_free(cmd->usage);
    147   if (cmd->description) g_free(cmd->description);
    148   if (cmd->cmd_aliased_to) g_free(cmd->cmd_aliased_to);
     132  g_free(cmd->name);
     133  g_free(cmd->summary);
     134  g_free(cmd->usage);
     135  g_free(cmd->description);
     136  g_free(cmd->cmd_aliased_to);
    149137  if (cmd->cmd_perl) owl_perlconfig_cmd_cleanup(cmd);
    150138}
     
    161149}
    162150
    163 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{
    164154  static int alias_recurse_depth = 0;
    165155  int ival=0;
     
    234224
    235225/* returns a summary line describing this keymap.  the caller must free. */
    236 char *owl_cmd_describe(const owl_cmd *cmd) {
     226CALLER_OWN char *owl_cmd_describe(const owl_cmd *cmd)
     227{
    237228  if (!cmd || !cmd->name || !cmd->summary) return NULL;
    238229  return g_strdup_printf("%-25s - %s", cmd->name, cmd->summary);
     
    265256  if (cmd->usage && *cmd->usage) {
    266257    s = cmd->usage;
    267     indent = owl_text_indent(s, OWL_TAB);
     258    indent = owl_text_indent(s, OWL_TAB, true);
    268259    owl_fmtext_append_bold(fm, "\nSYNOPSIS\n");
    269260    owl_fmtext_append_normal(fm, indent);
     
    279270  if (cmd->description && *cmd->description) {
    280271    s = cmd->description;
    281     indent = owl_text_indent(s, OWL_TAB);
     272    indent = owl_text_indent(s, OWL_TAB, true);
    282273    owl_fmtext_append_bold(fm, "\nDESCRIPTION\n");
    283274    owl_fmtext_append_normal(fm, indent);
  • commands.c

    rc809f5e 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,
     
    281279  OWLCMD_ARGS("punt", owl_command_punt, OWL_CTX_ANY,
    282280              "suppress an arbitrary filter",
    283               "punt <filter-text>",
    284               "punt <filter-text (multiple words)>\n"
     281              "punt <filter-name>\n"
     282              "punt <filter-text (multiple words)>",
    285283              "The punt command will suppress messages to the specified\n"
    286284              "filter\n\n"
     
    289287  OWLCMD_ARGS("unpunt", owl_command_unpunt, OWL_CTX_ANY,
    290288              "remove an entry from the punt list",
    291               "unpunt <filter-text>\n"
    292               "unpunt <filter-text>\n"
    293               "unpunt <number>\n",
     289              "unpunt <number>\n"
     290              "unpunt <filter-name>\n"
     291              "unpunt <filter-text (multiple words)>",
    294292              "The unpunt command will remove an entry from the puntlist.\n"
    295               "The first two forms correspond to the first two forms of the :punt\n"
    296               "command. The latter allows you to remove a specific entry from the\n"
     293              "The last two forms correspond to the two forms of the :punt\n"
     294              "command. The first allows you to remove a specific entry from\n"
    297295              "the list (see :show zpunts)\n\n"
    298296              "SEE ALSO:  punt, zpunt, zunpunt, show zpunts\n"),
     
    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)
     
    12881300  }
    12891301  owl_function_nextmsg_full(filter, skip_deleted, last_if_none);
    1290   if (filter) g_free(filter);
     1302  g_free(filter);
    12911303  return(NULL);
    12921304}
     
    13181330  }
    13191331  owl_function_prevmsg_full(filter, skip_deleted, first_if_none);
    1320   if (filter) g_free(filter);
     1332  g_free(filter);
    13211333  return(NULL);
    13221334}
     
    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;
     
    16911726  commands = g_strsplit_set(newbuff, ";", 0);
    16921727  for (i = 0; commands[i] != NULL; i++) {
    1693     if (lastrv) {
    1694       g_free(lastrv);
    1695     }
     1728    g_free(lastrv);
    16961729    lastrv = owl_function_command(commands[i]);
    16971730  }
     
    17451778
    17461779  if (argc < 3) {
    1747     owl_function_makemsg("Usage: bindkey <keymap> <binding>");
     1780    owl_function_makemsg("Usage: unbindkey <keymap> <binding>");
    17481781    return NULL;
    17491782  }
     
    19521985  }
    19531986  /* check for a zwrite -m */
    1954   z = owl_zwrite_new(buff);
     1987  z = owl_zwrite_new(argc, argv);
    19551988  if (!z) {
    19561989    owl_function_error("Error in zwrite arguments");
     
    21282161      myargv[i]=argv[i];
    21292162    }
    2130     owl_function_create_filter(argc, myargv);
    2131     owl_function_change_currentview_filter("owl-dynamic");
     2163    if (owl_function_create_filter(argc, myargv)) {
     2164      owl_function_change_currentview_filter("owl-dynamic");
     2165    }
    21322166    g_free(myargv);
    21332167    return NULL;
     
    21562190    if (!strcmp(argv[0], "-f")) {
    21572191      if (argc<2) {
    2158         owl_function_makemsg("Too few argments to the view command");
     2192        owl_function_makemsg("Too few arguments to the view command");
    21592193        return(NULL);
    21602194      }
     
    21682202    } else if (!strcmp(argv[0], "-s")) {
    21692203      if (argc<2) {
    2170         owl_function_makemsg("Too few argments to the view command");
     2204        owl_function_makemsg("Too few arguments to the view command");
    21712205        return(NULL);
    21722206      }
     
    21752209      argv+=2;
    21762210    } else {
    2177       owl_function_makemsg("Too few argments to the view command");
     2211      owl_function_makemsg("Too few arguments to the view command");
    21782212      return(NULL);
    21792213    }
     
    22272261  } else if (!strcmp(argv[1], "styles")) {
    22282262    owl_function_show_styles();
    2229   } else if (!strcmp(argv[1], "timers")) {
    2230     owl_function_show_timers();
    22312263  } else if (!strcmp(argv[1], "subs") || !strcmp(argv[1], "subscriptions")) {
    22322264    owl_function_getsubs();
     
    23282360}
    23292361
     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
    23302389char *owl_command_undelete(int argc, const char *const *argv, const char *buff)
    23312390{
     
    24642523void owl_command_punt_unpunt(int argc, const char *const * argv, const char *buff, int unpunt)
    24652524{
    2466   owl_list * fl;
    2467   owl_filter * f;
    2468   char * text;
     2525  GPtrArray * fl;
    24692526  int i;
    24702527
     
    24742531  } else if(argc == 2) {
    24752532    /* Handle :unpunt <number> */
    2476     if(unpunt && (i=atoi(argv[1])) !=0) {
     2533    if (unpunt && (i = atoi(argv[1])) > 0) {
    24772534      i--;      /* Accept 1-based indexing */
    2478       if(i < owl_list_get_size(fl)) {
    2479         f = owl_list_get_element(fl, i);
    2480         owl_list_remove_element(fl, i);
    2481         owl_filter_delete(f);
     2535      if (i < fl->len) {
     2536        owl_filter_delete(g_ptr_array_remove_index(fl, i));
    24822537        return;
    24832538      } else {
    2484         owl_function_error("No such filter number: %d", i+1);
     2539        owl_function_makemsg("No such filter number: %d.", i+1);
    24852540      }
    24862541    }
    2487     text = owl_string_build_quoted("filter %q", argv[1]);
    2488     owl_function_punt(text, unpunt);
    2489     g_free(text);
     2542    const char *filter[] = {"filter", argv[1]};
     2543    owl_function_punt(2, filter, unpunt);
    24902544  } else {
    2491     owl_function_punt(skiptokens(buff, 1), unpunt);
     2545    /* Pass in argv[1]..argv[argc-1]. */
     2546    owl_function_punt(argc - 1, argv + 1, unpunt);
    24922547  }
    24932548}
     
    25062561}
    25072562
    2508 char *owl_command_getvar(int argc, const char *const *argv, const char *buff)
    2509 {
     2563CALLER_OWN char *owl_command_getvar(int argc, const char *const *argv, const char *buff)
     2564{
     2565  const owl_variable *v;
    25102566  if (argc != 2) {
    25112567    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);
    25122568    return NULL;
    25132569  }
    2514   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);
    25152573}
    25162574
     
    25922650}
    25932651
    2594 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)
    25952653{
    25962654  const char *stylename;
     
    26302688  ptr = skiptokens(buff, 1);
    26312689  hist = owl_global_get_cmd_history(&g);
    2632   owl_history_store(hist, ptr);
    2633   owl_history_reset(hist);
     2690  owl_history_store(hist, ptr, false);
    26342691  /* owl_function_makemsg("History '%s' stored successfully", ptr+1); */
    26352692  return NULL;
    26362693}
    26372694
    2638 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)
    26392696{
    26402697  owl_history *hist;
     
    26532710
    26542711  hist = owl_global_get_cmd_history(&g);
    2655   owl_history_store(hist, ptr);
    2656   owl_history_reset(hist);
     2712  owl_history_store(hist, ptr, false);
    26572713  return owl_function_command(ptr);
    26582714}
     
    27372793
    27382794  hist = owl_editwin_get_history(e);
    2739   if (hist) {
    2740     owl_history_store(hist, owl_editwin_get_text(e));
    2741     owl_history_reset(hist);
    2742   }
    2743 
     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);
    27442803  owl_global_pop_context(&g);
     2804
     2805  owl_editwin_do_callback(e, false);
     2806  owl_editwin_unref(e);
    27452807}
    27462808
     
    27532815  if (!hist)
    27542816    return;
    2755   if (!owl_history_is_touched(hist)) {
    2756     owl_history_store(hist, owl_editwin_get_text(e));
    2757     owl_history_set_partial(hist);
    2758   }
     2817  if (!owl_history_is_touched(hist))
     2818    owl_history_store(hist, owl_editwin_get_text(e), true);
    27592819  ptr=owl_history_get_prev(hist);
    27602820  if (ptr) {
     
    27942854  owl_history *hist=owl_editwin_get_history(e);
    27952855
    2796   if (hist) {
    2797     owl_history_store(hist, owl_editwin_get_text(e));
    2798     owl_history_reset(hist);
    2799   }
     2856  if (hist)
     2857    owl_history_store(hist, owl_editwin_get_text(e), false);
    28002858
    28012859  /* Take a reference to the editwin, so that it survives the pop
     
    28062864  owl_global_pop_context(&g);
    28072865
    2808   owl_editwin_do_callback(e);
     2866  owl_editwin_do_callback(e, true);
    28092867  owl_editwin_unref(e);
    28102868}
  • 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

    r4479497 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 gobject-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

    rf25df21 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
    1511#define GROWBY 3 / 2
    1612
    17 int owl_dict_create(owl_dict *d) {
     13void owl_dict_create(owl_dict *d) {
    1814  d->size=0;
    1915  d->els=g_new(owl_dict_el, INITSIZE);
    2016  d->avail=INITSIZE;
    21   if (d->els==NULL) return(-1);
    22   return(0);
    2317}
    2418
     
    5852}
    5953
    60 /* Appends dictionary keys to a list.  Duplicates the keys,
    61  * so they will need to be freed by the caller. */
    62 int 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);
    6358  int i;
    64   char *dupk;
    65   for (i=0; i<d->size; i++) {
    66     if ((dupk = g_strdup(d->els[i].k)) == NULL) return(-1);
    67     owl_list_append_element(l, dupk);
     59  for (i = 0; i < d->size; i++) {
     60    g_ptr_array_add(keys, g_strdup(d->els[i].k));
    6861  }
    69   return(0);
     62  return keys;
    7063}
    7164
     
    8477{
    8578  int pos, found;
    86   char *dupk;
    8779  found = _owl_dict_find_pos(d, k, &pos);
    8880  if (found && delete_on_replace) {
     
    9991      if (d->els==NULL) return(-1);
    10092    }
    101     if ((dupk = g_strdup(k)) == NULL) return(-1);
    10293    if (pos!=d->size) {
    10394      /* shift forward to leave us a slot */
     
    10697    }
    10798    d->size++;
    108     d->els[pos].k = dupk;
     99    d->els[pos].k = g_strdup(k);
    109100    d->els[pos].v = v;   
    110101    return(0);
     
    114105/* Doesn't free the value of the element, but does
    115106 * return it so the caller can free it. */
    116 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{
    117109  int i;
    118110  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

    r47e0a6a 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}
     
    317313  }
    318314
    319   if (locktext)
    320     g_free(locktext);
     315  g_free(locktext);
    321316
    322317  oe_set_index(e, lock);
     
    624619
    625620  if (!g_utf8_validate(s, -1, NULL)) {
    626     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.");
    627622    return 0;
    628623  }
     
    11521147{
    11531148  oe_excursion x;
    1154   gunichar ch;
     1149  gunichar ch = 0;
     1150  gunichar last_ch;
    11551151  int sentence;
    11561152
     
    11851181    }
    11861182
     1183    last_ch = ch;
    11871184    ch = owl_editwin_get_char_at_point(e);
    11881185
     
    12021199    }
    12031200
    1204     if(ch == '.' || ch == '!' || ch == '?')
     1201    if (ch == '.' || ch == '!' || ch == '?' ||
     1202        (ch == '"' && (last_ch == '.' || last_ch == '!' || last_ch == '?')))
    12051203      sentence = 1;
    12061204    else
     
    13701368}
    13711369
    1372 char *owl_editwin_get_region(owl_editwin *e)
     1370CALLER_OWN char *owl_editwin_get_region(owl_editwin *e)
    13731371{
    13741372  int start, end;
     
    13891387}
    13901388
    1391 static char *oe_chunk(owl_editwin *e, int start, int end)
     1389static CALLER_OWN char *oe_chunk(owl_editwin *e, int start, int end)
    13921390{
    13931391  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

    rd564c3d 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("");
     
    1716  int err = 0;
    1817  struct pollfd fds[2];
    19   struct sigaction sig = {.sa_handler = SIG_IGN}, old;
    2018
    2119  fcntl(rfd, F_SETFL, O_NONBLOCK | fcntl(rfd, F_GETFL));
     
    2725  fds[1].events = POLLOUT;
    2826
    29   sigaction(SIGPIPE, &sig, &old);
    30  
     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  }
     32
    3133  while(1) {
    3234    if(out && *out) {
     
    5052      }
    5153      if(!out || !*out || fds[1].revents & (POLLERR | POLLHUP)) {
    52         close(wfd);
     54        close(wfd); wfd = -1;
    5355        out = NULL;
    5456      }
     
    6668  }
    6769
     70  if (wfd >= 0) close(wfd);
     71  close(rfd);
    6872  *in = g_string_free(str, err < 0);
    69   sigaction(SIGPIPE, &old, NULL);
    7073  return err;
    7174}
    7275
    73 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)
    7477{
    75   int err = 0;
    76   pid_t pid;
    77   int rfd[2];
    78   int wfd[2];
     78  int err;
     79  GPid child_pid;
     80  int child_stdin, child_stdout;
    7981
    80   if((err = pipe(rfd))) goto out;
    81   if((err = pipe(wfd))) goto out_close_rfd;
    82 
    83   pid = fork();
    84   if(pid < 0) {
    85     err = pid;
    86     goto out_close_all;
    87   }
    88   if(pid) {
    89     /* parent */
    90     close(rfd[1]);
    91     close(wfd[0]);
    92     err = send_receive(rfd[0], wfd[1], in, out);
    93     if(err == 0) {
    94       waitpid(pid, status, 0);
    95     }
    96   } else {
    97     /* child */
    98     close(rfd[0]);
    99     close(wfd[1]);
    100     dup2(rfd[1], 1);
    101     dup2(wfd[0], 0);
    102     close(rfd[1]);
    103     close(wfd[0]);
    104 
    105     if(execvp(prog, (char *const *)argv)) {
    106       _exit(-1);
    107     }
     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;
    10889  }
    10990
    110  out_close_all:
    111   close(wfd[0]);
    112   close(wfd[1]);
    113  out_close_rfd:
    114   close(rfd[0]);
    115   close(rfd[1]);
    116  out:
     91  err = send_receive(child_stdout, child_stdin, in, out);
     92  if (err == 0) {
     93    waitpid(child_pid, status, 0);
     94  }
    11795  return err;
    11896}
  • 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

    r4479497 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);
     
    184182}
    185183
    186 static void _owl_fmtext_update_colorpair(short fg, short bg, short *pair)
    187 {
    188   if (owl_global_get_hascolors(&g)) {
    189     *pair = owl_fmtext_get_colorpair(fg, bg);
    190   }
    191 }
    192 
    193184static void _owl_fmtext_wcolor_set(WINDOW *w, short pair)
    194185{
    195   if (owl_global_get_hascolors(&g)) {
    196       wcolor_set(w,pair,NULL);
    197       wbkgdset(w, COLOR_PAIR(pair));
     186  cchar_t background;
     187  wchar_t blank[2] = { ' ', 0 };
     188  if (has_colors()) {
     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);
    198194  }
    199195}
     
    221217  bg = default_bgcolor;
    222218  _owl_fmtext_wattrset(w, attr);
    223   _owl_fmtext_update_colorpair(fg, bg, &pair);
     219  pair = owl_fmtext_get_colorpair(fg, bg);
    224220  _owl_fmtext_wcolor_set(w, pair);
    225221
     
    270266      if (bg == OWL_COLOR_DEFAULT) bg = default_bgcolor;
    271267      _owl_fmtext_wattrset(w, attr);
    272       _owl_fmtext_update_colorpair(fg, bg, &pair);
     268      pair = owl_fmtext_get_colorpair(fg, bg);
    273269      _owl_fmtext_wcolor_set(w, pair);
    274270
     
    662658           continue */
    663659      } else if (!strcasecmp(buff, "@color")
    664                  && owl_global_get_hascolors(&g)
    665660                 && owl_global_is_colorztext(&g)) {
    666661        g_free(buff);
     
    694689         * but zwgc seems to be smarter about some screw cases than I am
    695690         */
     691        g_free(buff);
    696692        owl_fmtext_append_attr(f, "@", curattrs, curcolor, OWL_COLOR_DEFAULT);
    697693        txtptr++;
     
    763759 * If format_fn is specified, passes it the list element value
    764760 * and it will return a string which this needs to free. */
    765 void owl_fmtext_append_list(owl_fmtext *f, const owl_list *l, const char *join_with, char *(format_fn)(const char *))
    766 {
    767   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;
    768764  const char *elem;
    769765  char *text;
    770766
    771   size = owl_list_get_size(l);
    772   for (i=0; i<size; i++) {
    773     elem = owl_list_get_element(l,i);
     767  for (i = 0; i < l->len; i++) {
     768    elem = l->pdata[i];
    774769    if (elem && format_fn) {
    775770      text = format_fn(elem);
     
    781776      owl_fmtext_append_normal(f, elem);
    782777    }
    783     if ((i < size-1) && join_with) {
     778    if ((i < l->len - 1) && join_with) {
    784779      owl_fmtext_append_normal(f, join_with);
    785780    }
     
    820815    }
    821816  }
    822   if (owl_global_get_hascolors(&g)) {
     817  if (has_colors()) {
    823818    for(i = 0; i < 8; i++) {
    824819      short fg, bg;
     
    835830  owl_colorpair_mgr *cpmgr;
    836831  short pair;
     832
     833  if (!has_colors())
     834    return 0;
    837835
    838836  /* Sanity (Bounds) Check */
     
    852850  if (!(pair != -1 && pair < cpmgr->next)) {
    853851    /* If we didn't find a pair, search for a free one to assign. */
    854     pair = (cpmgr->next < COLOR_PAIRS) ? cpmgr->next : -1;
     852    pair = (cpmgr->next < owl_util_get_colorpairs()) ? cpmgr->next : -1;
    855853    if (pair != -1) {
    856854      /* We found a free pair, initialize it. */
  • functions.c

    r1a30f05 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),
     
    3223  char *rv;
    3324  rv=owl_function_command(cmdbuff);
    34   if (rv) g_free(rv);
     25  g_free(rv);
    3526}
    3627
     
    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);
    453416
    454417  if (rv || status) {
    455     if(cryptmsg) g_free(cryptmsg);
     418    g_free(cryptmsg);
    456419    g_free(old_msg);
    457420    owl_function_error("Error in zcrypt, possibly no key found.  Message not sent.");
     
    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,
     
    9911005  /* execute the commands in shutdown */
    9921006  ret = owl_perlconfig_execute("BarnOwl::Hooks::_shutdown();");
    993   if (ret) g_free(ret);
     1007  g_free(ret);
    9941008
    9951009  /* signal our child process, if any */
     
    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 *ptr, tmpbuff[1024];
    1411       int i, j, fields, len;
    1412 
    1413       n=owl_message_get_notice(m);
     1430    n = owl_message_get_notice(m);
     1431    if (n != NULL) {
     1432      char *tmpbuff, *tmpbuff2;
     1433      int i, fields;
     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           ptr=owl_zephyr_get_field_as_utf8(n, i+1);
    1457           len=strlen(ptr);
    1458           if (len<30) {
    1459             strncpy(tmpbuff, ptr, len);
    1460             tmpbuff[len]='\0';
    1461           } else {
    1462             strncpy(tmpbuff, ptr, 30);
    1463             tmpbuff[30]='\0';
    1464             strcat(tmpbuff, "...");
    1465           }
    1466           g_free(ptr);
    1467 
    1468           for (j=0; j<strlen(tmpbuff); j++) {
    1469             if (tmpbuff[j]=='\n') tmpbuff[j]='~';
    1470             if (tmpbuff[j]=='\r') tmpbuff[j]='!';
    1471           }
    1472 
    1473           owl_fmtext_appendf_normal(&fm, "  Field %i   : %s\n", i+1, 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);
    14741483        }
    1475         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);
    14761487      }
    14771488
     
    14801491  }
    14811492
    1482   owl_fmtext_append_bold(&fm, "\nOwl Message Attributes:\n");
     1493  owl_fmtext_append_bold(&fm, "\nBarnOwl Message Attributes:\n");
    14831494  owl_message_attributes_tofmtext(m, &attrfm);
    14841495  owl_fmtext_append_fmtext(&fm, &attrfm);
     
    16131624void owl_function_printallvars(void)
    16141625{
     1626  const owl_variable *v;
    16151627  const char *name;
    16161628  char *var;
    1617   owl_list varnames;
    1618   int i, numvarnames;
     1629  GPtrArray *varnames;
     1630  int i;
    16191631  GString *str   = g_string_new("");
    16201632
    16211633  g_string_append_printf(str, "%-20s = %s\n", "VARIABLE", "VALUE");
    16221634  g_string_append_printf(str, "%-20s   %s\n",  "--------", "-----");
    1623   owl_list_create(&varnames);
    1624   owl_variable_dict_get_names(owl_global_get_vardict(&g), &varnames);
    1625   numvarnames = owl_list_get_size(&varnames);
    1626   for (i=0; i<numvarnames; i++) {
    1627     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];
    16281638    if (name && name[0]!='_') {
    16291639      g_string_append_printf(str, "\n%-20s = ", name);
    1630       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);
    16311642      if (var) {
    1632         g_string_append(str, var);
    1633         g_free(var);
     1643        g_string_append(str, var);
     1644        g_free(var);
     1645      } else {
     1646        g_string_append(str, "<null>");
    16341647      }
    16351648    }
    16361649  }
    16371650  g_string_append(str, "\n");
    1638   owl_list_cleanup(&varnames, g_free);
     1651  owl_ptr_array_free(varnames, g_free);
    16391652
    16401653  owl_function_popless_text(str->str);
     
    16441657void owl_function_show_variables(void)
    16451658{
    1646   owl_list varnames;
     1659  const owl_variable *v;
     1660  GPtrArray *varnames;
    16471661  owl_fmtext fm; 
    1648   int i, numvarnames;
     1662  int i;
    16491663  const char *varname;
    16501664
     
    16521666  owl_fmtext_append_bold(&fm,
    16531667      "Variables: (use 'show variable <name>' for details)\n");
    1654   owl_list_create(&varnames);
    1655   owl_variable_dict_get_names(owl_global_get_vardict(&g), &varnames);
    1656   numvarnames = owl_list_get_size(&varnames);
    1657   for (i=0; i<numvarnames; i++) {
    1658     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];
    16591671    if (varname && varname[0]!='_') {
    1660       owl_variable_describe(owl_global_get_vardict(&g), varname, &fm);
    1661     }
    1662   }
    1663   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);
    16641677  owl_function_popless_fmtext(&fm);
    16651678  owl_fmtext_cleanup(&fm);
     
    16681681void owl_function_show_variable(const char *name)
    16691682{
     1683  const owl_variable *v;
    16701684  owl_fmtext fm; 
    16711685
    16721686  owl_fmtext_init_null(&fm);
    1673   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");
    16741692  owl_function_popless_fmtext(&fm);
    16751693  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  }
    16761707}
    16771708
     
    17301761void owl_function_status(void)
    17311762{
     1763  char *tmpbuff;
    17321764  char buff[MAXPATHLEN+1];
    17331765  time_t start;
     
    17571789  owl_fmtext_append_normal(&fm, "\n");
    17581790
    1759   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);
    17601794
    17611795  up=owl_global_get_runtime(&g);
     
    18171851          owl_global_get_cols(&g));
    18181852
    1819   if (owl_global_get_hascolors(&g)) {
     1853  if (has_colors()) {
    18201854    owl_fmtext_append_normal(&fm, "Color: Yes\n");
    1821     owl_fmtext_appendf_normal(&fm, "Number of color pairs: %i\n", owl_global_get_colorpairs(&g));
     1855    owl_fmtext_appendf_normal(&fm, "Number of color pairs: %i\n", owl_util_get_colorpairs());
    18221856    owl_fmtext_appendf_normal(&fm, "Can change colors: %s\n", can_change_color() ? "yes" : "no");
    18231857  } else {
     
    18801914    if (enter) {
    18811915      owl_history *hist = owl_global_get_cmd_history(&g);
    1882       owl_history_store(hist, buff);
    1883       owl_history_reset(hist);
     1916      owl_history_store(hist, buff, false);
    18841917      owl_function_command_norv(buff);
    18851918    } else {
     
    19111944}
    19121945
    1913 void owl_callback_command(owl_editwin *e)
    1914 {
     1946void owl_callback_command(owl_editwin *e, bool success)
     1947{
     1948  if (!success) return;
    19151949  char *rv;
    19161950  const char *line = owl_editwin_get_text(e);
     
    19231957}
    19241958
    1925 void owl_function_start_command(const char *line)
     1959owl_editwin *owl_function_start_command(const char *line)
    19261960{
    19271961  owl_editwin *tw;
     
    19381972  owl_global_push_context_obj(&g, ctx);
    19391973  owl_editwin_set_callback(tw, owl_callback_command);
     1974  return tw;
    19401975}
    19411976
     
    19722007}
    19732008
    1974 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)
    19752010{
    19762011  /* if type == 1 display in a popup
     
    20152050}
    20162051
    2017 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)
    20182053{
    20192054  /* if type == 1 display in a popup
     
    20962131
    20972132/* Create a new filter, or replace an existing one
    2098  * with a new definition.
     2133 * with a new definition. Returns true on success.
    20992134 */
    2100 void owl_function_create_filter(int argc, const char *const *argv)
     2135bool owl_function_create_filter(int argc, const char *const *argv)
    21012136{
    21022137  owl_filter *f;
     
    21062141  if (argc < 2) {
    21072142    owl_function_error("Wrong number of arguments to filter command");
    2108     return;
     2143    return false;
    21092144  }
    21102145
     
    21162151  if (!strcmp(argv[1], "all")) {
    21172152    owl_function_error("You may not change the 'all' filter.");
    2118     return;
     2153    return false;
    21192154  }
    21202155
     
    21242159    if (!f) {
    21252160      owl_function_error("The filter '%s' does not exist.", argv[1]);
    2126       return;
     2161      return false;
    21272162    }
    21282163    if (owl_util_string_to_color(argv[3])==OWL_COLOR_INVALID) {
    21292164      owl_function_error("The color '%s' is not available.", argv[3]);
    2130       return;
     2165      return false;
    21312166    }
    21322167    owl_filter_set_fgcolor(f, owl_util_string_to_color(argv[3]));
    21332168    owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    2134     return;
     2169    return false;
    21352170  }
    21362171  if (argc==4 && !strcmp(argv[2], "-b")) {
     
    21382173    if (!f) {
    21392174      owl_function_error("The filter '%s' does not exist.", argv[1]);
    2140       return;
     2175      return false;
    21412176    }
    21422177    if (owl_util_string_to_color(argv[3])==OWL_COLOR_INVALID) {
    21432178      owl_function_error("The color '%s' is not available.", argv[3]);
    2144       return;
     2179      return false;
    21452180    }
    21462181    owl_filter_set_bgcolor(f, owl_util_string_to_color(argv[3]));
    21472182    owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    2148     return;
     2183    return true;
    21492184  }
    21502185
     
    21522187  f = owl_filter_new(argv[1], argc-2, argv+2);
    21532188  if (f == NULL) {
    2154     owl_function_error("Invalid filter");
    2155     return;
     2189    owl_function_error("Invalid filter: %s", argv[1]);
     2190    return false;
    21562191  }
    21572192
     
    21742209  }
    21752210  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
     2211  return true;
    21762212}
    21772213
     
    21852221 * Returns the name of the negated filter, which the caller must free.
    21862222 */
    2187 char *owl_function_create_negative_filter(const char *filtername)
     2223CALLER_OWN char *owl_function_create_negative_filter(const char *filtername)
    21882224{
    21892225  char *newname;
     
    22262262    f = fl->data;
    22272263    owl_fmtext_append_normal(&fm, "   ");
    2228     if (owl_global_get_hascolors(&g)) {
    2229       owl_fmtext_append_normal_color(&fm, owl_filter_get_name(f), owl_filter_get_fgcolor(f), owl_filter_get_bgcolor(f));
    2230     } else {
    2231       owl_fmtext_append_normal(&fm, owl_filter_get_name(f));
    2232     }
     2264    owl_fmtext_append_normal_color(&fm, owl_filter_get_name(f),
     2265                                   owl_filter_get_fgcolor(f),
     2266                                   owl_filter_get_bgcolor(f));
    22332267    owl_fmtext_append_normal(&fm, "\n");
    22342268  }
     
    22572291{
    22582292  const owl_filter *f;
    2259   const owl_list *fl;
     2293  const GPtrArray *fl;
    22602294  char *tmp;
    22612295  owl_fmtext fm;
    2262   int i, j;
     2296  int i;
    22632297
    22642298  owl_fmtext_init_null(&fm);
    22652299
    22662300  fl=owl_global_get_puntlist(&g);
    2267   j=owl_list_get_size(fl);
    22682301  owl_fmtext_append_bold(&fm, "Active zpunt filters:\n");
    22692302
    2270   for (i=0; i<j; i++) {
    2271     f=owl_list_get_element(fl, i);
     2303  for (i = 0; i < fl->len; i++) {
     2304    f = fl->pdata[i];
    22722305    owl_fmtext_appendf_normal(&fm, "[% 2d] ", i+1);
    22732306    tmp = owl_filter_print(f);
     
    22842317 * If 'related' is nonzero, encompass unclasses and .d classes as well.
    22852318 */
    2286 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)
    22872320{
    22882321  owl_filter *f;
     
    23602393done:
    23612394  g_free(class);
    2362   if (instance) {
    2363     g_free(instance);
    2364   }
     2395  g_free(instance);
    23652396  return(filtname);
    23662397}
     
    23732404 * the filter, which the caller must free.
    23742405 */
    2375 char *owl_function_zuserfilt(const char *longuser)
     2406CALLER_OWN char *owl_function_zuserfilt(const char *longuser)
    23762407{
    23772408  owl_filter *f;
     
    24192450 * Returns the name of the filter, which the caller must free.
    24202451 */
    2421 char *owl_function_aimuserfilt(const char *user)
     2452CALLER_OWN char *owl_function_aimuserfilt(const char *user)
    24222453{
    24232454  owl_filter *f;
     
    24302461  /* if it already exists then go with it.  This lets users override */
    24312462  if (owl_global_get_filter(&g, filtname)) {
    2432     return(g_strdup(filtname));
     2463    return filtname;
    24332464  }
    24342465
     
    24572488}
    24582489
    2459 char *owl_function_typefilt(const char *type)
     2490CALLER_OWN char *owl_function_typefilt(const char *type)
    24602491{
    24612492  owl_filter *f;
     
    25132544}
    25142545
    2515 static char *owl_function_smartfilter_cc(const owl_message *m) {
     2546static CALLER_OWN char *owl_function_smartfilter_cc(const owl_message *m)
     2547{
    25162548  const char *ccs;
    25172549  char *ccs_quoted;
     
    25232555
    25242556  filtname = g_strdup_printf("conversation-%s", ccs);
    2525   owl_text_tr(filtname, ' ', '-');
     2557  g_strdelimit(filtname, " ", '-');
    25262558
    25272559  if (owl_global_get_filter(&g, filtname)) {
     
    25642596 *    name to the AIM conversation with that user
    25652597 */
    2566 char *owl_function_smartfilter(int type, int invert_related)
     2598CALLER_OWN char *owl_function_smartfilter(int type, int invert_related)
    25672599{
    25682600  const owl_view *v;
     
    27852817void owl_function_zpunt(const char *class, const char *inst, const char *recip, int direction)
    27862818{
    2787   GString *buf;
     2819  GPtrArray *argv;
    27882820  char *quoted;
    27892821
    2790   buf = g_string_new("");
     2822  argv = g_ptr_array_new();
    27912823  if (!strcmp(class, "*")) {
    2792     g_string_append(buf, "class .*");
     2824    g_ptr_array_add(argv, g_strdup("class"));
     2825    g_ptr_array_add(argv, g_strdup(".*"));
    27932826  } else {
    27942827    quoted=owl_text_quote(class, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    2795     owl_string_appendf_quoted(buf, "class ^(un)*%q(\\.d)*$", quoted);
     2828    g_ptr_array_add(argv, g_strdup("class"));
     2829    g_ptr_array_add(argv, g_strdup_printf("^(un)*%s(\\.d)*$", quoted));
    27962830    g_free(quoted);
    27972831  }
    27982832  if (!strcmp(inst, "*")) {
    2799     g_string_append(buf, " and instance .*");
     2833    g_ptr_array_add(argv, g_strdup("and"));
     2834    g_ptr_array_add(argv, g_strdup("instance"));
     2835    g_ptr_array_add(argv, g_strdup(".*"));
    28002836  } else {
    28012837    quoted=owl_text_quote(inst, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    2802     owl_string_appendf_quoted(buf, " and instance ^(un)*%q(\\.d)*$", quoted);
     2838    g_ptr_array_add(argv, g_strdup("and"));
     2839    g_ptr_array_add(argv, g_strdup("instance"));
     2840    g_ptr_array_add(argv, g_strdup_printf("^(un)*%s(\\.d)*$", quoted));
    28032841    g_free(quoted);
    28042842  }
    28052843  if (!strcmp(recip, "*")) {
    2806     /* g_string_append(buf, ""); */
     2844    /* nothing */
    28072845  } else {
    28082846    if(!strcmp(recip, "%me%")) {
     
    28102848    }
    28112849    quoted=owl_text_quote(recip, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    2812     owl_string_appendf_quoted(buf, " and recipient ^%q$", quoted);
     2850    g_ptr_array_add(argv, g_strdup("and"));
     2851    g_ptr_array_add(argv, g_strdup("recipient"));
     2852    g_ptr_array_add(argv, g_strdup_printf("^%s$", quoted));
    28132853    g_free(quoted);
    28142854  }
    28152855
    2816   owl_function_punt(buf->str, direction);
    2817   g_string_free(buf, true);
    2818 }
    2819 
    2820 void owl_function_punt(const char *filter, int direction)
     2856  owl_function_punt(argv->len, (const char *const*) argv->pdata, direction);
     2857  owl_ptr_array_free(argv, g_free);
     2858}
     2859
     2860void owl_function_punt(int argc, const char *const *argv, int direction)
    28212861{
    28222862  owl_filter *f;
    2823   owl_list *fl;
    2824   int i, j;
     2863  GPtrArray *fl;
     2864  int i;
    28252865  fl=owl_global_get_puntlist(&g);
    28262866
    28272867  /* first, create the filter */
    2828   owl_function_debugmsg("About to filter %s", filter);
    2829   f = owl_filter_new_fromstring("punt-filter", filter);
     2868  f = owl_filter_new("punt-filter", argc, argv);
    28302869  if (f == NULL) {
    28312870    owl_function_error("Error creating filter for zpunt");
     
    28342873
    28352874  /* Check for an identical filter */
    2836   j=owl_list_get_size(fl);
    2837   for (i=0; i<j; i++) {
    2838     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])) {
    28392877      owl_function_debugmsg("found an equivalent punt filter");
    28402878      /* if we're punting, then just silently bow out on this duplicate */
     
    28462884      /* if we're unpunting, then remove this filter from the puntlist */
    28472885      if (direction==1) {
    2848         owl_filter_delete(owl_list_get_element(fl, i));
    2849         owl_list_remove_element(fl, i);
     2886        owl_filter_delete(g_ptr_array_remove_index(fl, i));
    28502887        owl_filter_delete(f);
    28512888        return;
     
    28542891  }
    28552892
    2856   owl_function_debugmsg("punting");
    2857   /* If we're punting, add the filter to the global punt list */
    2858   if (direction==0) {
    2859     owl_list_append_element(fl, f);
    2860   }
     2893  if (direction == 0) {
     2894    owl_function_debugmsg("punting");
     2895    /* If we're punting, add the filter to the global punt list */
     2896    g_ptr_array_add(fl, f);
     2897  } else if (direction == 1) {
     2898    owl_function_makemsg("No matching punt filter");
     2899 }
    28612900}
    28622901
    28632902void owl_function_show_keymaps(void)
    28642903{
    2865   owl_list l;
     2904  GPtrArray *l;
    28662905  owl_fmtext fm;
    28672906  const owl_keymap *km;
    28682907  const owl_keyhandler *kh;
    2869   int i, numkm;
     2908  int i;
    28702909  const char *kmname;
    28712910
     
    28742913  owl_fmtext_append_bold(&fm, "Keymaps:   ");
    28752914  owl_fmtext_append_normal(&fm, "(use 'show keymap <name>' for details)\n");
    2876   owl_list_create(&l);
    2877   owl_keyhandler_get_keymap_names(kh, &l);
    2878   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);
    28792917  owl_fmtext_append_normal(&fm, "\n");
    28802918
    2881   numkm = owl_list_get_size(&l);
    2882   for (i=0; i<numkm; i++) {
    2883     kmname = owl_list_get_element(&l, i);
     2919  for (i = 0; i < l->len; i++) {
     2920    kmname = l->pdata[i];
    28842921    km = owl_keyhandler_get_keymap(kh, kmname);
    28852922    owl_fmtext_append_bold(&fm, "\n\n----------------------------------------------------------------------------------------------------\n\n");
     
    28892926 
    28902927  owl_function_popless_fmtext(&fm);
    2891   owl_list_cleanup(&l, g_free);
     2928  owl_ptr_array_free(l, g_free);
    28922929  owl_fmtext_cleanup(&fm);
    28932930}
    28942931
    2895 char *owl_function_keymap_summary(const char *name)
     2932CALLER_OWN char *owl_function_keymap_summary(const char *name)
    28962933{
    28972934  const owl_keymap *km
     
    29592996 
    29602997  if (viewsize==0) {
    2961     owl_function_error("No messages present");
     2998    owl_function_makemsg("No messages present");
    29622999    return;
    29633000  }
     
    29733010  /* bounds check */
    29743011  if (start>=viewsize || start<0) {
    2975     owl_function_error("No further matches found");
     3012    owl_function_makemsg("No further matches found");
    29763013    return;
    29773014  }
     
    29953032      i--;
    29963033    }
    2997     owl_function_mask_sigint(NULL);
    2998     if(owl_global_is_interrupted(&g)) {
    2999       owl_global_unset_interrupted(&g);
    3000       owl_function_unmask_sigint(NULL);
     3034    if (owl_global_take_interrupt(&g)) {
    30013035      owl_function_makemsg("Search interrupted!");
    30023036      owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    30033037      return;
    30043038    }
    3005     owl_function_unmask_sigint(NULL);
    30063039  }
    30073040  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    3008   owl_function_error("No matches found");
     3041  owl_function_makemsg("No matches found");
    30093042}
    30103043
    30113044/* strips formatting from ztext and returns the unformatted text.
    30123045 * caller is responsible for freeing. */
    3013 char *owl_function_ztext_stylestrip(const char *zt)
     3046CALLER_OWN char *owl_function_ztext_stylestrip(const char *zt)
    30143047{
    30153048  owl_fmtext fm;
     
    30343067#ifdef HAVE_LIBZEPHYR
    30353068  int x;
    3036   owl_list anyone;
     3069  GPtrArray *anyone;
    30373070  const char *user;
    30383071  char *tmp;
     
    30543087      idle=owl_buddy_get_idle_time(b);
    30553088      if (idle!=0) {
    3056         timestr=owl_util_minutes_to_timestr(idle);
     3089        timestr=owl_util_format_minutes(idle);
    30573090      } else {
    30583091        timestr=g_strdup("");
     
    30693102    } else {
    30703103      owl_fmtext_append_bold(&fm, "Zephyr users logged in:\n");
    3071       owl_list_create(&anyone);
    3072       ret=owl_zephyr_get_anyone_list(&anyone, filename);
    3073       if (ret) {
     3104      anyone = owl_zephyr_get_anyone_list(filename);
     3105      if (anyone == NULL) {
    30743106        if (errno == ENOENT) {
    30753107          owl_fmtext_append_normal(&fm, " You have not added any zephyr buddies.  Use the\n");
     
    30813113        }
    30823114      } else {
    3083         j=owl_list_get_size(&anyone);
    3084         for (i=0; i<j; i++) {
    3085           user=owl_list_get_element(&anyone, i);
     3115        for (i = 0; i < anyone->len; i++) {
     3116          user = anyone->pdata[i];
    30863117          ret=ZLocateUser(zstr(user), &numlocs, ZAUTH);
    30873118
    3088           owl_function_mask_sigint(NULL);
    3089           if(owl_global_is_interrupted(&g)) {
     3119          if (owl_global_take_interrupt(&g)) {
    30903120            interrupted = 1;
    3091             owl_global_unset_interrupted(&g);
    3092             owl_function_unmask_sigint(NULL);
    30933121            owl_function_makemsg("Interrupted!");
    30943122            break;
    30953123          }
    3096 
    3097           owl_function_unmask_sigint(NULL);
    30983124
    30993125          if (ret!=ZERR_NONE) {
     
    31203146        }
    31213147      }
    3122       owl_list_cleanup(&anyone, g_free);
     3148      owl_ptr_array_free(anyone, g_free);
    31233149    }
    31243150  }
     
    31973223    }
    31983224   
    3199     /* if it exited, fork & exec a new one */
     3225    /* if it exited, spawn a new one */
    32003226    if (owl_global_get_newmsgproc_pid(&g)==0) {
    3201       pid_t i;
    32023227      int myargc;
    3203       i=fork();
    3204       if (i) {
    3205         /* parent set the child's pid */
    3206         owl_global_set_newmsgproc_pid(&g, i);
    3207         owl_function_debugmsg("I'm the parent and I started a new newmsgproc with pid %i", i);
    3208       } else {
    3209         /* child exec's the program */
    3210         char **parsed;
    3211         parsed=owl_parseline(owl_global_get_newmsgproc(&g), &myargc);
    3212         if (myargc < 0) {
    3213           owl_function_debugmsg("Could not parse newmsgproc '%s': unbalanced quotes?", owl_global_get_newmsgproc(&g));
    3214         }
    3215         if (myargc <= 0) {
    3216           _exit(127);
    3217         }
    3218         owl_function_debugmsg("About to exec \"%s\" with %d arguments", parsed[0], myargc);
    3219        
    3220         execvp(parsed[0], parsed);
    3221        
    3222        
    3223         /* was there an error exec'ing? */
    3224         owl_function_debugmsg("Cannot run newmsgproc '%s': cannot exec '%s': %s",
    3225                               owl_global_get_newmsgproc(&g), parsed[0], strerror(errno));
    3226         _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        }
    32273247      }
     3248      g_strfreev(argv);
    32283249    }
    32293250  }
     
    32563277  filename=owl_global_get_startupfile(&g);
    32573278
    3258   /* delete earlier copies */
    3259   owl_util_file_deleteline(filename, buff, 1);
     3279  /* delete earlier copies, if the file exists */
     3280  if (g_file_test(filename, G_FILE_TEST_EXISTS))
     3281    owl_util_file_deleteline(filename, buff, 1);
    32603282
    32613283  file=fopen(filename, "a");
     
    33933415  char *buff;
    33943416
    3395   now=time(NULL);
    3396   date=g_strdup(ctime(&now));
    3397   date[strlen(date)-1]='\0';
     3417  now = time(NULL);
     3418  date = owl_util_format_time(localtime(&now));
    33983419
    33993420  buff = g_strdup_printf("%s %s", date, string);
     
    34363457{
    34373458#ifdef HAVE_LIBZEPHYR
    3438   int i, j;
    3439   owl_list anyone;
     3459  int i;
     3460  GPtrArray *anyone;
    34403461  GList **zaldlist;
    34413462  GList *zaldptr;
     
    34573478  *zaldlist = NULL;
    34583479
    3459   owl_list_create(&anyone);
    3460   owl_zephyr_get_anyone_list(&anyone, NULL);
    3461   j = owl_list_get_size(&anyone);
    3462   for (i = 0; i < j; i++) {
    3463     user = owl_list_get_element(&anyone, i);
    3464     zald = g_new(ZAsyncLocateData_t, 1);
    3465     if (ZRequestLocations(zstr(user), zald, UNACKED, ZAUTH) == ZERR_NONE) {
    3466       *zaldlist = g_list_append(*zaldlist, zald);
    3467     } else {
    3468       g_free(zald);
    3469     }
    3470   }
    3471 
    3472   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  }
    34733493#endif
    34743494}
    34753495
    3476 void owl_function_aimsearch_results(const char *email, owl_list *namelist)
     3496void owl_function_aimsearch_results(const char *email, GPtrArray *namelist)
    34773497{
    34783498  owl_fmtext fm;
    3479   int i, j;
     3499  int i;
    34803500
    34813501  owl_fmtext_init_null(&fm);
     
    34843504  owl_fmtext_append_normal(&fm, ":\n");
    34853505
    3486   j=owl_list_get_size(namelist);
    3487   for (i=0; i<j; i++) {
     3506  for (i = 0; i < namelist->len; i++) {
    34883507    owl_fmtext_append_normal(&fm, "  ");
    3489     owl_fmtext_append_normal(&fm, owl_list_get_element(namelist, i));
     3508    owl_fmtext_append_normal(&fm, namelist->pdata[i]);
    34903509    owl_fmtext_append_normal(&fm, "\n");
    34913510  }
     
    34983517{
    34993518     return COLORS;
    3500 }
    3501 
    3502 void owl_function_mask_sigint(sigset_t *oldmask) {
    3503   sigset_t intr;
    3504 
    3505   sigemptyset(&intr);
    3506   sigaddset(&intr, SIGINT);
    3507   sigprocmask(SIG_BLOCK, &intr, oldmask);
    3508 }
    3509 
    3510 void owl_function_unmask_sigint(sigset_t *oldmask) {
    3511   sigset_t intr;
    3512 
    3513   sigemptyset(&intr);
    3514   sigaddset(&intr, SIGINT);
    3515   sigprocmask(SIG_UNBLOCK, &intr, oldmask);
    35163519}
    35173520
  • global.c

    r47e0a6a 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)
     15  g_thread_init(NULL);
     16#endif
     17
     18  owl_select_init();
    1819
    1920  g->lines=LINES;
     
    4445  owl_dict_create(&(g->filters));
    4546  g->filterlist = NULL;
    46   owl_list_create(&(g->puntlist));
     47  g->puntlist = g_ptr_array_new();
    4748  g->messagequeue = g_queue_new();
    4849  owl_dict_create(&(g->styledict));
     
    5051  g->resizepending=0;
    5152  g->direction=OWL_DIRECTION_DOWNWARDS;
    52   g->zaway=0;
    53   if (has_colors()) {
    54     g->hascolors=1;
    55   }
    56   g->colorpairs=COLOR_PAIRS;
    5753  owl_fmtext_init_colorpair_mgr(&(g->cpmgr));
    5854  g->debug=OWL_DEBUG;
     
    6662  owl_history_init(&(g->msghist));
    6763  owl_history_init(&(g->cmdhist));
    68   owl_history_set_norepeats(&(g->cmdhist));
    6964  g->nextmsgid=0;
    7065
     
    8075  g->confdir = NULL;
    8176  g->startupfile = NULL;
    82   cd = g_strdup_printf("%s/%s", g->homedir, OWL_CONFIG_DIR);
     77  cd = g_build_filename(g->homedir, OWL_CONFIG_DIR, NULL);
    8378  owl_global_set_confdir(g, cd);
    8479  g_free(cd);
    8580
    86   owl_messagelist_create(&(g->msglist));
     81  g->msglist = owl_messagelist_new();
    8782
    8883  _owl_global_init_windows(g);
     
    9994
    10095  owl_errqueue_init(&(g->errqueue));
    101   g->got_err_signal=0;
    10296
    10397  owl_zbuddylist_create(&(g->zbuddies));
     
    107101
    108102  owl_message_init_fmtext_cache();
    109   owl_list_create(&(g->io_dispatch_list));
    110   owl_list_create(&(g->psa_list));
    111   g->timerlist = NULL;
    112   g->interrupted = FALSE;
    113103  g->kill_buffer = NULL;
     104
     105  g->interrupt_count = 0;
     106#if GLIB_CHECK_VERSION(2, 31, 0)
     107  g_mutex_init(&g->interrupt_lock);
     108#else
     109  g->interrupt_lock = g_mutex_new();
     110#endif
    114111}
    115112
     
    120117
    121118  /* Create the widgets */
    122   owl_mainwin_init(&(g->mw), g->mainpanel.recwin);
     119  g->mw = owl_mainwin_new(g->mainpanel.recwin);
    123120  owl_msgwin_init(&(g->msgwin), g->mainpanel.msgwin);
    124121  owl_sepbar_init(g->mainpanel.sepwin);
     
    176173/* Pops the current context from the context stack and returns it. Caller is
    177174 * responsible for freeing. */
    178 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{
    179177  owl_context *c;
    180178  if (!g->context_stack)
     
    251249/* windows */
    252250
    253 owl_mainwin *owl_global_get_mainwin(owl_global *g) {
    254   return(&(g->mw));
     251owl_mainwin *owl_global_get_mainwin(owl_global *g)
     252{
     253  return g->mw;
    255254}
    256255
     
    266265
    267266owl_messagelist *owl_global_get_msglist(owl_global *g) {
    268   return(&(g->msglist));
     267  return g->msglist;
    269268}
    270269
     
    348347
    349348void owl_global_set_resize_pending(owl_global *g) {
    350   g->resizepending=1;
     349  g->resizepending = true;
    351350}
    352351
     
    368367  g->confdir = g_strdup(cd);
    369368  g_free(g->startupfile);
    370   g->startupfile = g_strdup_printf("%s/startup", cd);
     369  g->startupfile = g_build_filename(cd, "startup", NULL);
    371370}
    372371
     
    448447  /* resize the screen.  If lines or cols is 0 use the terminal size */
    449448  if (!g->resizepending) return;
    450   g->resizepending = 0;
     449  g->resizepending = false;
    451450
    452451  owl_global_get_terminal_size(&g->lines, &g->cols);
     
    509508
    510509void owl_global_set_startupargs(owl_global *g, int argc, char **argv) {
    511   if (g->startupargs) g_free(g->startupargs);
     510  g_free(g->startupargs);
    512511  g->startupargs = g_strjoinv(" ", argv);
    513512}
     
    576575}
    577576
    578 /* has colors */
    579 
    580 int owl_global_get_hascolors(const owl_global *g) {
    581   if (g->hascolors) return(1);
    582   return(0);
    583 }
    584 
    585 /* color pairs */
    586 
    587 int owl_global_get_colorpairs(const owl_global *g) {
    588   return(g->colorpairs);
    589 }
    590 
    591577owl_colorpair_mgr *owl_global_get_colorpair_mgr(owl_global *g) {
    592578  return(&(g->cpmgr));
     
    595581/* puntlist */
    596582
    597 owl_list *owl_global_get_puntlist(owl_global *g) {
    598   return(&(g->puntlist));
     583GPtrArray *owl_global_get_puntlist(owl_global *g) {
     584  return g->puntlist;
    599585}
    600586
    601587int owl_global_message_is_puntable(owl_global *g, const owl_message *m) {
    602   const owl_list *pl;
    603   int i, j;
    604 
    605   pl=owl_global_get_puntlist(g);
    606   j=owl_list_get_size(pl);
    607   for (i=0; i<j; i++) {
    608     if (owl_filter_message_match(owl_list_get_element(pl, i), m)) return(1);
    609   }
    610   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;
    611596}
    612597
     
    693678}
    694679
    695 int owl_global_is_doaimevents(const owl_global *g)
    696 {
    697   if (g->aim_doprocessing) return(1);
    698   return(0);
     680bool owl_global_is_doaimevents(const owl_global *g)
     681{
     682  return g->aim_event_source != NULL;
    699683}
    700684
    701685void owl_global_set_doaimevents(owl_global *g)
    702686{
    703   g->aim_doprocessing=1;
     687  if (g->aim_event_source)
     688    return;
     689  g->aim_event_source = owl_aim_event_source_new(owl_global_get_aimsess(g));
     690  g_source_attach(g->aim_event_source, NULL);
    704691}
    705692
    706693void owl_global_set_no_doaimevents(owl_global *g)
    707694{
    708   g->aim_doprocessing=0;
     695  if (!g->aim_event_source)
     696    return;
     697  g_source_destroy(g->aim_event_source);
     698  g_source_unref(g->aim_event_source);
     699  g->aim_event_source = NULL;
    709700}
    710701
     
    735726 * necessary.
    736727 */
    737 owl_message *owl_global_messagequeue_popmsg(owl_global *g)
     728CALLER_OWN owl_message *owl_global_messagequeue_popmsg(owl_global *g)
    738729{
    739730  owl_message *out;
     
    764755}
    765756
    766 int owl_global_get_style_names(const owl_global *g, owl_list *l) {
    767   return 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);
    768760}
    769761
     
    824816}
    825817
    826 void owl_global_set_errsignal(owl_global *g, int signum, siginfo_t *siginfo)
    827 {
    828   g->got_err_signal = signum;
    829   if (siginfo) {
    830     g->err_signal_info = *siginfo;
    831   } else {
    832     siginfo_t si;
    833     memset(&si, 0, sizeof(si));
    834     g->err_signal_info = si;
    835   }
    836 }
    837 
    838 int owl_global_get_errsignal_and_clear(owl_global *g, siginfo_t *siginfo)
    839 {
    840   int signum;
    841   if (siginfo && g->got_err_signal) {
    842     *siginfo = g->err_signal_info;
    843   }
    844   signum = g->got_err_signal;
    845   g->got_err_signal = 0;
    846   return signum;
    847 }
    848 
    849 
    850818owl_zbuddylist *owl_global_get_zephyr_buddylist(owl_global *g)
    851819{
     
    871839{
    872840  return(&(g->startup_tio));
    873 }
    874 
    875 owl_list *owl_global_get_io_dispatch_list(owl_global *g)
    876 {
    877   return &(g->io_dispatch_list);
    878 }
    879 
    880 owl_list *owl_global_get_psa_list(owl_global *g)
    881 {
    882   return &(g->psa_list);
    883 }
    884 
    885 GList **owl_global_get_timerlist(owl_global *g)
    886 {
    887   return &(g->timerlist);
    888 }
    889 
    890 int owl_global_is_interrupted(const owl_global *g) {
    891   return g->interrupted;
    892 }
    893 
    894 void owl_global_set_interrupted(owl_global *g) {
    895   g->interrupted = 1;
    896 }
    897 
    898 void owl_global_unset_interrupted(owl_global *g) {
    899   g->interrupted = 0;
    900841}
    901842
     
    908849  } filters[] = {
    909850    { "personal",
    910       "isprivate ^true$ and ( not type ^zephyr$ or ( class ^message  ) )" },
     851      "isprivate ^true$ and ( not type ^zephyr$ or ( class ^message$ ) )" },
    911852    { "trash",
    912853      "class ^mail$ or opcode ^ping$ or type ^admin$ or ( not login ^none$ )" },
     
    915856    { "auto", "opcode ^auto$" },
    916857    { "login", "not login ^none$" },
    917     { "reply-lockout", "class ^noc or class ^mail$" },
     858    { "reply-lockout", "class ^mail$ or class ^filsrv$" },
    918859    { "out", "direction ^out$" },
    919860    { "aim", "type ^aim$" },
     
    965906  g->kill_buffer = g_strndup(kill, len);
    966907}
     908
     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
     918void owl_global_add_interrupt(owl_global *g) {
     919  /* TODO: This can almost certainly be done with atomic
     920   * operations. Whatever. */
     921  g_mutex_lock(owl_global_get_interrupt_lock(g));
     922  g->interrupt_count++;
     923  g_mutex_unlock(owl_global_get_interrupt_lock(g));
     924}
     925
     926bool owl_global_take_interrupt(owl_global *g) {
     927  bool ans = false;
     928  g_mutex_lock(owl_global_get_interrupt_lock(g));
     929  if (g->interrupt_count > 0) {
     930    ans = true;
     931    g->interrupt_count--;
     932  }
     933  g_mutex_unlock(owl_global_get_interrupt_lock(g));
     934  return ans;
     935}
  • 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

    rd07af84 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);
     
    6967void owl_keybinding_delete(owl_keybinding *kb)
    7068{
    71   if (kb->keys) g_free(kb->keys);
    72   if (kb->desc) g_free(kb->desc);
    73   if (kb->command) g_free(kb->command);
     69  g_free(kb->keys);
     70  g_free(kb->desc);
     71  g_free(kb->command);
    7472  g_free(kb);
    7573}
     
    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

    r47e0a6a rf271129  
    1 #include <string.h>
    21#include "owl.h"
    32
     
    98{
    109  if (!name || !desc) return(-1);
    11   if ((km->name = g_strdup(name)) == NULL) return(-1);
    12   if ((km->desc = g_strdup(desc)) == NULL) return(-1);
    13   if (0 != owl_list_create(&km->bindings)) return(-1);
     10  km->name = g_strdup(name);
     11  km->desc = g_strdup(desc);
     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);
     
    179173/* NOTE: keyhandler has private access to the internals of keymap */
    180174
    181 int owl_keyhandler_init(owl_keyhandler *kh)
    182 {
    183   if (0 != owl_dict_create(&kh->keymaps)) return(-1);
     175void owl_keyhandler_init(owl_keyhandler *kh)
     176{
     177  owl_dict_create(&kh->keymaps);
    184178  kh->active = NULL;
    185179  owl_keyhandler_reset(kh);
    186   return(0);
    187180}
    188181
     
    215208}
    216209
    217 void owl_keyhandler_get_keymap_names(const owl_keyhandler *kh, owl_list *l)
    218 {
    219   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);
    220213}
    221214
     
    275268   * keyhandler and keymap apart.  */
    276269  for (km=kh->active; km; km=km->parent) {
    277     for (i=owl_list_get_size(&km->bindings)-1; i>=0; i--) {
    278       kb = owl_list_get_element(&km->bindings, i);
     270    for (i = km->bindings->len-1; i >= 0; i--) {
     271      kb = km->bindings->pdata[i];
    279272      match = owl_keybinding_match(kb, kh);
    280273      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

    rfe3b017 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>
     3
     4typedef struct _owl_log_entry { /* noproto */
     5  char *filename;
     6  char *message;
     7} owl_log_entry;
     8
     9
     10static GMainContext *log_context;
     11static GMainLoop *log_loop;
     12static GThread *logging_thread;
    613
    714/* This is now the one function that should be called to log a
     
    7077}
    7178
    72 void owl_log_zephyr(const owl_message *m, FILE *file) {
    73     char *tmp;
    74     tmp=short_zuser(owl_message_get_sender(m));
    75     fprintf(file, "Class: %s Instance: %s", owl_message_get_class(m), owl_message_get_instance(m));
    76     if (strcmp(owl_message_get_opcode(m), "")) fprintf(file, " Opcode: %s", owl_message_get_opcode(m));
    77     fprintf(file, "\n");
    78     fprintf(file, "Time: %s Host: %s\n", owl_message_get_timestr(m), owl_message_get_hostname(m));
    79     fprintf(file, "From: %s <%s>\n\n", owl_message_get_zsig(m), tmp);
    80     fprintf(file, "%s\n\n", owl_message_get_body(m));
     79CALLER_OWN char *owl_log_zephyr(const owl_message *m)
     80{
     81    char *tmp = NULL;
     82    GString *buffer = NULL;
     83    buffer = g_string_new("");
     84    tmp = short_zuser(owl_message_get_sender(m));
     85    g_string_append_printf(buffer, "Class: %s Instance: %s",
     86                           owl_message_get_class(m),
     87                           owl_message_get_instance(m));
     88    if (strcmp(owl_message_get_opcode(m), "")) {
     89      g_string_append_printf(buffer, " Opcode: %s",
     90                             owl_message_get_opcode(m));
     91    }
     92    g_string_append_printf(buffer, "\n");
     93    g_string_append_printf(buffer, "Time: %s Host: %s\n",
     94                           owl_message_get_timestr(m),
     95                           owl_message_get_hostname(m));
     96    g_string_append_printf(buffer, "From: %s <%s>\n\n",
     97                           owl_message_get_zsig(m), tmp);
     98    g_string_append_printf(buffer, "%s\n\n", owl_message_get_body(m));
    8199    g_free(tmp);
    82 }
    83 
    84 void owl_log_aim(const owl_message *m, FILE *file) {
    85     fprintf(file, "From: <%s> To: <%s>\n", owl_message_get_sender(m), owl_message_get_recipient(m));
    86     fprintf(file, "Time: %s\n\n", owl_message_get_timestr(m));
    87     if (owl_message_is_login(m))
    88         fprintf(file, "LOGIN\n\n");
    89     else if (owl_message_is_logout(m))
    90         fprintf(file, "LOGOUT\n\n");
    91     else
    92         fprintf(file, "%s\n\n", owl_message_get_body(m));
    93 }
    94 
    95 void owl_log_jabber(const owl_message *m, FILE *file) {
    96     fprintf(file, "From: <%s> To: <%s>\n",owl_message_get_sender(m), owl_message_get_recipient(m));
    97     fprintf(file, "Time: %s\n\n", owl_message_get_timestr(m));
    98     fprintf(file, "%s\n\n",owl_message_get_body(m));
    99 }
    100 
    101 void owl_log_generic(const owl_message *m, FILE *file) {
    102     fprintf(file, "From: <%s> To: <%s>\n", owl_message_get_sender(m), owl_message_get_recipient(m));
    103     fprintf(file, "Time: %s\n\n", owl_message_get_timestr(m));
    104     fprintf(file, "%s\n\n", owl_message_get_body(m));
     100    return g_string_free(buffer, FALSE);
     101}
     102
     103CALLER_OWN char *owl_log_aim(const owl_message *m)
     104{
     105    GString *buffer = NULL;
     106    buffer = g_string_new("");
     107    g_string_append_printf(buffer, "From: <%s> To: <%s>\n",
     108                           owl_message_get_sender(m), owl_message_get_recipient(m));
     109    g_string_append_printf(buffer, "Time: %s\n\n",
     110                           owl_message_get_timestr(m));
     111    if (owl_message_is_login(m)) {
     112        g_string_append_printf(buffer, "LOGIN\n\n");
     113    } else if (owl_message_is_logout(m)) {
     114        g_string_append_printf(buffer, "LOGOUT\n\n");
     115    } else {
     116        g_string_append_printf(buffer, "%s\n\n", owl_message_get_body(m));
     117    }
     118    return g_string_free(buffer, FALSE);
     119}
     120
     121CALLER_OWN char *owl_log_jabber(const owl_message *m)
     122{
     123    GString *buffer = NULL;
     124    buffer = g_string_new("");
     125    g_string_append_printf(buffer, "From: <%s> To: <%s>\n",
     126                           owl_message_get_sender(m),
     127                           owl_message_get_recipient(m));
     128    g_string_append_printf(buffer, "Time: %s\n\n",
     129                           owl_message_get_timestr(m));
     130    g_string_append_printf(buffer, "%s\n\n", owl_message_get_body(m));
     131    return g_string_free(buffer, FALSE);
     132}
     133
     134CALLER_OWN char *owl_log_generic(const owl_message *m)
     135{
     136    GString *buffer;
     137    buffer = g_string_new("");
     138    g_string_append_printf(buffer, "From: <%s> To: <%s>\n",
     139                           owl_message_get_sender(m),
     140                           owl_message_get_recipient(m));
     141    g_string_append_printf(buffer, "Time: %s\n\n",
     142                           owl_message_get_timestr(m));
     143    g_string_append_printf(buffer, "%s\n\n",
     144                           owl_message_get_body(m));
     145    return g_string_free(buffer, FALSE);
     146}
     147
     148static void owl_log_error_main_thread(gpointer data)
     149{
     150  owl_function_error("%s", (const char*)data);
     151}
     152
     153static void owl_log_error(const char *message)
     154{
     155  char *data = g_strdup(message);
     156  owl_select_post_task(owl_log_error_main_thread,
     157                       data, g_free, g_main_context_default());
     158}
     159
     160static void owl_log_write_entry(gpointer data)
     161{
     162  owl_log_entry *msg = (owl_log_entry*)data;
     163  FILE *file = NULL;
     164  file = fopen(msg->filename, "a");
     165  if (!file) {
     166    owl_log_error("Unable to open file for logging");
     167    return;
     168  }
     169  fprintf(file, "%s", msg->message);
     170  fclose(file);
     171}
     172
     173static void owl_log_entry_free(void *data)
     174{
     175  owl_log_entry *msg = (owl_log_entry*)data;
     176  if (msg) {
     177    g_free(msg->message);
     178    g_free(msg->filename);
     179    g_free(msg);
     180  }
     181}
     182
     183void owl_log_enqueue_message(const char *buffer, const char *filename)
     184{
     185  owl_log_entry *log_msg = NULL;
     186  log_msg = g_new(owl_log_entry,1);
     187  log_msg->message = g_strdup(buffer);
     188  log_msg->filename = g_strdup(filename);
     189  owl_select_post_task(owl_log_write_entry, log_msg,
     190                       owl_log_entry_free, log_context);
    105191}
    106192
    107193void owl_log_append(const owl_message *m, const char *filename) {
    108     FILE *file;
    109     file=fopen(filename, "a");
    110     if (!file) {
    111         owl_function_error("Unable to open file for logging");
    112