Changeset 2323e49


Ignore:
Timestamp:
Jun 22, 2013, 9:49:34 PM (8 years ago)
Author:
David Benjamin <davidben@mit.edu>
Parents:
96d80e9 (diff), 15a7aee (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 15a7aeeea91ce9cd39eebe3f4e4205f307c78acf into 96d80e9b4aa667605b9c786b0272e1ab04dfbe9b
Files:
36 added
38 deleted
70 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

    r65ff3f4 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
    1401.8
    241 * Compute the home directory in zcrypt consistently with BarnOwl -davidben@mit.edu
  • Makefile.am

    rc266281 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)"' \
     
    3951
    4052CODELIST_SRCS=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 \
     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      mainpanel.c msgwin.c sepbar.c editcontext.c signal.c
     60     mainpanel.c msgwin.c sepbar.c editcontext.c signal.c closures.c
    4861
    49 NORMAL_SRCS = filterproc.c window.c windowcb.c
     62NORMAL_SRCS = filterproc.c filterproc.h window.c window.h windowcb.c
    5063
    5164BASE_SRCS = $(CODELIST_SRCS) $(NORMAL_SRCS)
    5265
    53 GEN_C = varstubs.c perlglue.c
    54 GEN_H = owl_prototypes.h
     66GEN_C = varstubs.c perlglue.c gmarshal_funcs.c
     67GEN_H = owl_prototypes.h owl_prototypes.h.new gmarshal_funcs.h
    5568
    5669BUILT_SOURCES = $(GEN_C) $(GEN_H)
     
    6578proto: owl_prototypes.h
    6679
    67 perlglue.c: perlglue.xs $(TYPEMAP)
    68         $(AM_V_GEN)perl $(XSUBPPDIR)/xsubpp $(XSUBPPFLAGS) -prototypes perlglue.xs > perlglue.c
     80perlglue.c: perlglue.xs typemap
     81        $(AM_V_GEN)perl $(XSUBPPDIR)/xsubpp $(XSUBPPFLAGS) -prototypes $< > $@
    6982
    7083varstubs.c: stubgen.pl variable.c
     
    7487        $(AM_V_GEN)perl $< $(sort $(filter-out $<,$+)) > $@
    7588
     89gmarshal_funcs.h: marshal_types
     90        glib-genmarshal --header $< > $@
     91gmarshal_funcs.c: marshal_types
     92        glib-genmarshal --body $< > $@
     93
    7694# For emacs flymake-mode
    7795check-syntax: proto
    7896        $(COMPILE) -Wall -Wextra -pedantic -fsyntax-only $(CHK_SOURCES)
    7997
    80 install-data-local:
    81         $(mkinstalldirs) ${DESTDIR}${pkgdatadir}/lib
    82         (cd perl/lib && tar -cf - . ) | (cd ${DESTDIR}${pkgdatadir}/lib && tar -xf - )
    83 
    84 do_transform = $(shell echo '$(1)' | sed '$(transform)')
    85 install-exec-hook:
    86         mv -f $(DESTDIR)$(bindir)/$(call do_transform,barnowl.bin) \
    87               $(DESTDIR)$(bindir)/$(call do_transform,barnowl)
     98CLEANFILES = $(BUILT_SOURCES) $(noinst_SCRIPTS) $(check_SCRIPTS)
     99EXTRA_DIST = \
     100    autogen.sh \
     101    barnowl-wrapper.in \
     102    codelist.pl \
     103    doc/code.txt \
     104    doc/owl-window.txt \
     105    doc/releasing-barnowl.txt \
     106    examples \
     107    marshal_types \
     108    perlglue.xs \
     109    scripts \
     110    stubgen.pl \
     111    typemap
    88112
    89113SUBDIRS = compat libfaim perl
  • README

    rb711711 r1c22155  
    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:
     
    2021AnyEvent
    2122Class::Accessor
     23ExtUtils::Depends
    2224Glib
     25Module::Install
    2326PAR
    2427
     
    2629We plan to soon add targets to the Makefile to check for and install
    2730these for you.
     31
     32The Facebook module requires:
     33
     34Any::Moose
     35AnyEvent::HTTP
     36DateTime
     37DateTime::Format::Strptime
     38JSON
     39MIME::Base64::URLSafe
     40Ouch
     41URI
     42URI::Encode
    2843
    2944The IRC module requires:
     
    3651Authen::SASL::Perl
    3752IO::Socket::SSL
    38 Digest::SHA1
     53Digest::SHA
    3954
    4055The Twitter module requires:
  • aim.c

    r3234121 r8258ea5  
    1 #include <stdio.h>
    2 #include <stdio.h>
    3 #include <sys/stat.h>
    41#include "owl.h"
    52
     
    710707{
    711708  aim_clientready(sess, fr->conn);
    712   owl_function_debugmsg("conninitdone_admin: initializtion done for admin connection");
     709  owl_function_debugmsg("conninitdone_admin: initialization done for admin connection");
    713710  return(1);
    714711}
     
    839836  params = va_arg(ap, struct aim_icbmparameters *);
    840837  va_end(ap);
    841  
    842   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",
    843840                       params->maxchan, params->flags, params->maxmsglen, ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, params->minmsginterval);
    844841     
  • barnowl-wrapper.in

    • Property mode changed from 100755 to 100644
    rf5f6ec0 ra223b6b  
    11#!/bin/sh
    22# This is a wrapper script to point BARNOWL_DATA_DIR at the source dir
    3 # if we're running from a build tree. barnowl.bin is the actual built
     3# if we're running from a build tree. bin/barnowl is the actual built
    44# binary.
    55
    6 SRCDIR=`dirname "${0}"`
    7 EXE="$0.bin"
     6EXE="@abs_builddir@/bin/$(basename "$0")"
    87
    98if test ! -x "$EXE"; then
     
    1211fi
    1312
    14 BARNOWL_DATA_DIR="$SRCDIR/perl/"
    15 BARNOWL_BIN_DIR="$SRCDIR/"
     13BARNOWL_DATA_DIR="@abs_srcdir@/perl"
     14BARNOWL_BIN_DIR="@abs_builddir@"
    1615export BARNOWL_DATA_DIR
    1716export BARNOWL_BIN_DIR
  • cmd.c

    r14be3a5 rf271129  
    1 #include <stdio.h>
    2 #include <stdlib.h>
    3 #include <string.h>
    4 #include <unistd.h>
    51#include "owl.h"
    62
  • commands.c

    r287c634 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)" */
     
    10096  OWLCMD_ARGS("unbindkey", owl_command_unbindkey, OWL_CTX_ANY,
    10197              "removes a binding in a keymap",
    102               "bindkey <keymap> <keyseq>",
     98              "unbindkey <keymap> <keyseq>",
    10399              "Removes a binding of a key sequence within a keymap.\n"
    104100              "Use 'show keymaps' to see the existing keymaps.\n"
     
    10371033  OWLCMD_ARGS_CTX("popless:start-search", owl_viewwin_command_start_search, OWL_CTX_POPLESS,
    10381034                  "starts a command line to search for particular string",
    1039                   "popless:start-search [-r] [inital-value]",
     1035                  "popless:start-search [-r] [initial-value]",
    10401036                  "Initializes the command-line to search for initial-value. If\n"
    10411037                  "-r is used, the search will be performed backwards.\n\n"
     
    16081604  if (v == NULL) {
    16091605    if (!silent) owl_function_error("Unknown variable '%s'", var);
    1610   } else if (requirebool && owl_variable_get_type(v) != OWL_VARIABLE_BOOL) {
     1606  } else if (requirebool && !v->takes_on_off) {
    16111607    if (!silent) owl_function_error("Variable '%s' is not a boolean", var);
    16121608  } else {
     
    16371633  if (v == NULL) {
    16381634    if (!silent) owl_function_error("Unknown variable '%s'", var);
    1639   } else if (owl_variable_get_type(v) != OWL_VARIABLE_BOOL) {
     1635  } else if (!v->takes_on_off) {
    16401636    if (!silent) owl_function_error("Variable '%s' is not a boolean", var);
    16411637  } else {
     
    17821778
    17831779  if (argc < 3) {
    1784     owl_function_makemsg("Usage: bindkey <keymap> <binding>");
     1780    owl_function_makemsg("Usage: unbindkey <keymap> <binding>");
    17851781    return NULL;
    17861782  }
     
    19891985  }
    19901986  /* check for a zwrite -m */
    1991   z = owl_zwrite_new(buff);
     1987  z = owl_zwrite_new(argc, argv);
    19921988  if (!z) {
    19931989    owl_function_error("Error in zwrite arguments");
     
    21942190    if (!strcmp(argv[0], "-f")) {
    21952191      if (argc<2) {
    2196         owl_function_makemsg("Too few argments to the view command");
     2192        owl_function_makemsg("Too few arguments to the view command");
    21972193        return(NULL);
    21982194      }
     
    22062202    } else if (!strcmp(argv[0], "-s")) {
    22072203      if (argc<2) {
    2208         owl_function_makemsg("Too few argments to the view command");
     2204        owl_function_makemsg("Too few arguments to the view command");
    22092205        return(NULL);
    22102206      }
     
    22132209      argv+=2;
    22142210    } else {
    2215       owl_function_makemsg("Too few argments to the view command");
     2211      owl_function_makemsg("Too few arguments to the view command");
    22162212      return(NULL);
    22172213    }
     
    28002796    owl_history_store(hist, owl_editwin_get_text(e), false);
    28012797
     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);
    28022803  owl_global_pop_context(&g);
     2804
     2805  owl_editwin_do_callback(e, false);
     2806  owl_editwin_unref(e);
    28032807}
    28042808
     
    28602864  owl_global_pop_context(&g);
    28612865
    2862   owl_editwin_do_callback(e);
     2866  owl_editwin_do_callback(e, true);
    28632867  owl_editwin_unref(e);
    28642868}
  • 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

    r883502d re4b8f93  
    11dnl Process this file with autoconf to produce a configure script.
    2 AC_INIT([BarnOwl],[1.9dev],[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
     
    910AC_PROG_CC
    1011AC_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)
    1129
    1230AC_ARG_WITH([stack-protector],
     
    4159
    4260AS_IF([test "x$with_zephyr" != xno],
    43   [AS_IF([test "x$with_krb4" != "xno"],
     61  [have_krb4=no
     62
     63   AS_IF([test "x$with_krb4" != "xno"],
    4464   [AC_MSG_CHECKING([for Kerberos IV])
    4565    AS_IF([krb5-config krb4 --libs >/dev/null 2>&1],
    4666      [AC_MSG_RESULT([yes])
     67       have_krb4=yes
    4768       AC_DEFINE([HAVE_KERBEROS_IV], [1], [Define if you have kerberos IV])
    4869       AM_CFLAGS="${AM_CFLAGS} `krb5-config krb4 --cflags`"
     
    5172      [AC_MSG_RESULT([no])
    5273       AS_IF([test "x$with_krb4" = "xyes"],
    53              [AC_MSG_ERROR([Kerberos IV requested but not found])])
    54        PKG_CHECK_MODULES([LIBCRYPTO], [libcrypto])
    55        AM_CFLAGS="${AM_CFLAGS} ${LIBCRYPTO_CFLAGS}"
    56        LIBS="${LIBS} ${LIBCRYPTO_LIBS}"
    57      ])])
     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
    5886   AC_CHECK_LIB([zephyr], [ZGetSender],
    5987   [LIBS="$LIBS -lzephyr"
     
    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})
     
    113141AX_PROG_PERL_MODULES([Class::Accessor::Fast],,
    114142                     [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])])
    115145AX_PROG_PERL_MODULES([Glib],,
    116146                     [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])])
    117149AX_PROG_PERL_MODULES([PAR],,
    118150                     [AC_MSG_WARN([PAR.pm not found. Loadable modules will be disabled.])])
     
    129161   prefix="${ac_default_prefix}"
    130162fi
     163
     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}"
    131168
    132169dnl Checks for typedefs, structures, and compiler characteristics.
     
    168205AC_REPLACE_FUNCS([memrchr])
    169206
     207AC_SUBST([abs_builddir])
     208AC_SUBST([abs_srcdir])
     209
    170210AC_CONFIG_FILES([Makefile compat/Makefile libfaim/Makefile perl/Makefile perl/modules/Makefile])
    171211AC_OUTPUT
  • context.c

    r6829afc rf271129  
    1 #include <string.h>
    21#include "owl.h"
    32
  • dict.c

    rce68f23 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
  • doc/barnowl.1

    rbad4496 r8135737  
    3535.TP
    3636\fB\-c\fP, \fB\-\-config\-file\fP=\fIFILE\fP
    37 Specify an alternate config file for \fBBarnOwl\fP to use.  By default,
    38 \fBBarnOwl\fP uses \fI~/.barnowlconf\fP if it exists, and \fI~/.owlconf\fP otherwise.
     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.)
     42
     43By default, \fBBarnOwl\fP uses the first of \fI~/.owl/init.pl\fP,
     44\fI~/.barnowlconf\fP, or \fI~/.owlconf\fP that exists.
    3945
    4046.TP
  • editcontext.c

    r6829afc rf271129  
    11#include "owl.h"
    2 
    32#include <assert.h>
    43
  • editwin.c

    rf661cee 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;
     
    224220}
    225221
    226 void owl_editwin_set_callback(owl_editwin *e, void (*cb)(owl_editwin*))
     222void owl_editwin_set_callback(owl_editwin *e, void (*cb)(owl_editwin *, bool))
    227223{
    228224  e->callback = cb;
    229225}
    230226
    231 void (*owl_editwin_get_callback(owl_editwin *e))(owl_editwin*)
     227void (*owl_editwin_get_callback(owl_editwin *e))(owl_editwin *, bool)
    232228{
    233229  return e->callback;
     
    252248}
    253249
    254 void owl_editwin_do_callback(owl_editwin *e) {
    255   void (*cb)(owl_editwin*);
    256   cb=owl_editwin_get_callback(e);
    257   if(!cb) {
     250void owl_editwin_do_callback(owl_editwin *e, bool success)
     251{
     252  void (*cb)(owl_editwin *, bool);
     253  cb = owl_editwin_get_callback(e);
     254  if (!cb) {
    258255    owl_function_error("Internal error: No editwin callback!");
    259256  } else {
    260     /* owl_function_error("text: |%s|", owl_editwin_get_text(e)); */
    261     cb(e);
     257    cb(e, success);
    262258  }
    263259}
     
    623619
    624620  if (!g_utf8_validate(s, -1, NULL)) {
    625     owl_function_debugmsg("owl_editwin_insert_string: received non-utf-8 string.");
     621    owl_function_debugmsg("owl_editwin_insert_string: received non-UTF-8 string.");
    626622    return 0;
    627623  }
  • filter.c

    r2560529 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) {
     
    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, " ");
  • filterproc.c

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

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

    r7abfcf2 rf271129  
    11#include "owl.h"
    2 #include <stdlib.h>
    3 #include <string.h>
    42
    53/* initialize an fmtext with no data */
  • functions.c

    r15a7aee 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"
    156
    167CALLER_OWN char *owl_function_command(const char *cmdbuff)
     
    213204
    214205  /* do followlast if necessary */
    215   if (owl_global_should_followlast(&g)) owl_function_lastmsg_noredisplay();
     206  if (owl_global_should_followlast(&g)) owl_function_lastmsg();
    216207
    217208  /* redisplay etc. */
     
    225216void owl_function_add_outgoing_zephyrs(const owl_zwrite *z)
    226217{
    227   if (z->cc || owl_zwrite_get_numrecips(z) == 0) {
     218  if (z->cc && owl_zwrite_is_personal(z)) {
    228219    /* create the message */
    229220    owl_message *m = g_new(owl_message, 1);
     
    234225    int i;
    235226    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
    236232      /* create the message */
    237       owl_message *m = g_new(owl_message, 1);
     233      m = g_new(owl_message, 1);
    238234      owl_message_create_from_zwrite(m, z, owl_zwrite_get_message(z), i);
    239235
     
    281277}
    282278
    283 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)
    284280{
    285281  owl_editwin *e;
     
    295291  g_free(s);
    296292
    297   owl_editwin_set_cbdata(e, data, cleanup);
    298   owl_editwin_set_callback(e, callback);
    299293  ctx = owl_editcontext_new(OWL_CTX_EDITMULTI, e, "editmulti",
    300294                            owl_global_deactivate_editcontext, &g);
    301295  owl_global_push_context_obj(&g, ctx);
    302 
     296  return e;
    303297}
    304298
     
    318312void owl_function_zwrite_setup(owl_zwrite *z)
    319313{
     314  owl_editwin *e;
    320315  /* send a ping if necessary */
    321316  if (owl_global_is_txping(&g)) {
     
    325320
    326321  owl_function_write_setup("zephyr");
    327   owl_function_start_edit_win(z->zwriteline,
    328                               &owl_callback_zwrite,
    329                               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);
    330325}
    331326
    332327void owl_function_aimwrite_setup(const char *to)
    333328{
     329  owl_editwin *e;
    334330  /* TODO: We probably actually want an owl_aimwrite object like
    335331   * owl_zwrite. */
    336332  char *line = g_strdup_printf("aimwrite %s", to);
    337333  owl_function_write_setup("message");
    338   owl_function_start_edit_win(line,
    339                               &owl_callback_aimwrite,
    340                               g_strdup(to),
    341                               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);
    342337  g_free(line);
    343338}
     
    345340void owl_function_loopwrite_setup(void)
    346341{
     342  owl_editwin *e;
    347343  owl_function_write_setup("message");
    348   owl_function_start_edit_win("loopwrite",
    349                               &owl_callback_loopwrite,
    350                               NULL, NULL);
    351 }
    352 
    353 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;
    354351  owl_zwrite *z = owl_editwin_get_cbdata(e);
    355352  owl_function_zwrite(z, owl_editwin_get_text(e));
     
    381378  owl_function_makemsg("Waiting for ack...");
    382379
    383   /* If it's personal */
    384   if (owl_zwrite_is_personal(z)) {
    385     /* create the outgoing message */
    386     owl_function_add_outgoing_zephyrs(z);
    387   }
     380  /* create the outgoing message */
     381  owl_function_add_outgoing_zephyrs(z);
    388382}
    389383#else
     
    411405
    412406  zcrypt = g_build_filename(owl_get_bindir(), "zcrypt", NULL);
    413   argv[0] = "zcrypt";
     407  argv[0] = zcrypt;
    414408  argv[1] = "-E";
    415409  argv[2] = "-c"; argv[3] = owl_zwrite_get_class(z);
     
    417411  argv[6] = NULL;
    418412
    419   rv = call_filter(zcrypt, argv, owl_zwrite_get_message(z), &cryptmsg, &status);
     413  rv = call_filter(argv, owl_zwrite_get_message(z), &cryptmsg, &status);
    420414
    421415  g_free(zcrypt);
     
    435429  owl_function_makemsg("Waiting for ack...");
    436430
    437   /* If it's personal */
    438   if (owl_zwrite_is_personal(z)) {
    439     /* Create the outgoing message. Restore the un-crypted message for display. */
    440     owl_zwrite_set_message_raw(z, old_msg);
    441     owl_function_add_outgoing_zephyrs(z);
    442   }
    443 
    444   /* 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. */
    445436  g_free(cryptmsg);
    446 }
    447 
    448 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;
    449443  char *to = owl_editwin_get_cbdata(e);
    450444  owl_function_aimwrite(to, owl_editwin_get_text(e), true);
     
    510504}
    511505
    512 void owl_callback_loopwrite(owl_editwin *e) {
     506void owl_callback_loopwrite(owl_editwin *e, bool success)
     507{
     508  if (!success) return;
    513509  owl_function_loopwrite(owl_editwin_get_text(e));
    514510}
     
    817813}
    818814
    819 void owl_function_lastmsg_noredisplay(void)
     815void owl_function_lastmsg(void)
    820816{
    821817  int oldcurmsg, curmsg;
     
    835831    owl_global_set_curmsg(&g, curmsg+1);
    836832  }
    837   /* owl_mainwin_redisplay(owl_global_get_mainwin(&g)); */
     833  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    838834  owl_global_set_direction_downwards(&g);
    839 }
    840 
    841 void owl_function_lastmsg(void)
    842 {
    843   owl_function_lastmsg_noredisplay();
    844   owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 
    845835}
    846836
     
    865855void owl_function_unsuball(void)
    866856{
    867   unsuball();
    868   owl_function_makemsg("Unsubscribed from all messages.");
     857  if (unsuball())
     858    owl_function_makemsg("Unsubscribed from all messages.");
    869859}
    870860
     
    881871void owl_function_loadsubs(const char *file)
    882872{
    883   int ret, ret2;
    884   const char *foo;
     873  int ret, ret2, ret3;
    885874  char *path;
    886875
     
    894883
    895884  /* for backwards compatibility for now */
    896   ret2=owl_zephyr_loaddefaultsubs();
     885  ret2 = owl_zephyr_loaddefaultsubs();
     886  ret3 = owl_zephyr_loadbarnowldefaultsubs();
    897887
    898888  if (!owl_context_is_interactive(owl_global_get_context(&g))) return;
    899889
    900   foo=file?file:"file";
    901   if (ret==0 && ret2==0) {
     890  if (ret == 0 && ret2 == 0 && ret3 == 0) {
    902891    if (!file) {
    903892      owl_function_makemsg("Subscribed to messages.");
     
    905894      owl_function_makemsg("Subscribed to messages from %s", file);
    906895    }
    907   } else if (ret==-1) {
    908     owl_function_error("Could not read %s", foo);
    909   } else {
     896  } else if (ret == -1) {
     897    owl_function_error("Could not read %s", file ? file : "file");
     898  } else if (ret2 == -1) {
    910899    owl_function_error("Error subscribing to messages");
     900  } else {
     901    owl_function_error("Error subscribing to instanced personals");
    911902  }
    912903}
     
    927918}
    928919
    929 void owl_callback_aimlogin(owl_editwin *e) {
     920void owl_callback_aimlogin(owl_editwin *e, bool success)
     921{
     922  if (!success) return;
    930923  char *user = owl_editwin_get_cbdata(e);
    931924  owl_function_aimlogin(user,
     
    12381231  now = time(NULL);
    12391232
    1240   tmpbuff = owl_util_time_to_timestr(localtime(&now));
     1233  tmpbuff = owl_util_format_time(localtime(&now));
    12411234  fprintf(file, "[%d -  %s - %lds]: ",
    12421235          (int) getpid(), tmpbuff, now - owl_global_get_starttime(&g));
     
    13881381  owl_fmtext fm, attrfm;
    13891382  const owl_view *v;
     1383  char *time;
    13901384#ifdef HAVE_LIBZEPHYR
    13911385  const ZNotice_t *n;
     
    14181412  }
    14191413
    1420   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);
    14211417
    14221418  if (!owl_message_is_type_admin(m)) {
     
    14321428    owl_fmtext_appendf_normal(&fm, "  Opcode    : %s\n", owl_message_get_opcode(m));
    14331429#ifdef HAVE_LIBZEPHYR
    1434     if (owl_message_is_direction_in(m)) {
     1430    n = owl_message_get_notice(m);
     1431    if (n != NULL) {
    14351432      char *tmpbuff, *tmpbuff2;
    14361433      int i, fields;
    1437 
    1438       n=owl_message_get_notice(m);
     1434      const char *f;
    14391435
    14401436      if (!owl_message_is_pseudo(m)) {
     
    14781474        owl_fmtext_appendf_normal(&fm, "  Fields    : %i\n", fields);
    14791475
    1480         for (i = 0; i < fields; i++) {
    1481           tmpbuff = owl_zephyr_get_field_as_utf8(n, i + 1);
     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);
    14821479          tmpbuff2 = owl_text_indent(tmpbuff, 14, false);
    14831480          owl_fmtext_appendf_normal(&fm, "  Field %i   : %s\n", i + 1, tmpbuff2);
     
    17921789  owl_fmtext_append_normal(&fm, "\n");
    17931790
    1794   tmpbuff = owl_util_time_to_timestr(localtime(&start));
     1791  tmpbuff = owl_util_format_time(localtime(&start));
    17951792  owl_fmtext_appendf_normal(&fm, "  Startup Time: %s\n", tmpbuff);
    17961793  g_free(tmpbuff);
     
    19471944}
    19481945
    1949 void owl_callback_command(owl_editwin *e)
    1950 {
     1946void owl_callback_command(owl_editwin *e, bool success)
     1947{
     1948  if (!success) return;
    19511949  char *rv;
    19521950  const char *line = owl_editwin_get_text(e);
     
    19591957}
    19601958
    1961 void owl_function_start_command(const char *line)
     1959owl_editwin *owl_function_start_command(const char *line)
    19621960{
    19631961  owl_editwin *tw;
     
    19741972  owl_global_push_context_obj(&g, ctx);
    19751973  owl_editwin_set_callback(tw, owl_callback_command);
    1976 }
    1977 
    1978 CALLER_OWN owl_editwin *owl_function_start_question(const char *line)
     1974  return tw;
     1975}
     1976
     1977owl_editwin *owl_function_start_question(const char *line)
    19791978{
    19801979  owl_editwin *tw;
     
    19911990}
    19921991
    1993 CALLER_OWN owl_editwin *owl_function_start_password(const char *line)
     1992owl_editwin *owl_function_start_password(const char *line)
    19941993{
    19951994  owl_editwin *tw;
     
    21882187  f = owl_filter_new(argv[1], argc-2, argv+2);
    21892188  if (f == NULL) {
    2190     owl_function_error("Invalid filter");
     2189    owl_function_error("Invalid filter: %s", argv[1]);
    21912190    return false;
    21922191  }
     
    30883087      idle=owl_buddy_get_idle_time(b);
    30893088      if (idle!=0) {
    3090         timestr=owl_util_minutes_to_timestr(idle);
     3089        timestr=owl_util_format_minutes(idle);
    30913090      } else {
    30923091        timestr=g_strdup("");
     
    34173416
    34183417  now = time(NULL);
    3419   date = owl_util_time_to_timestr(localtime(&now));
     3418  date = owl_util_format_time(localtime(&now));
    34203419
    34213420  buff = g_strdup_printf("%s %s", date, string);
  • global.c

    rdde1b4d r6383920  
     1#include "owl.h"
    12#include <stdio.h>
    2 #include <unistd.h>
    3 #include <stdlib.h>
    4 #include <string.h>
    5 #include <netdb.h>
    6 #include <termios.h>
    73#include <sys/ioctl.h>
    8 #include <time.h>
    9 #include "owl.h"
    104
    115static void _owl_global_init_windows(owl_global *g);
     
    159  const char *homedir;
    1610
     11#if !GLIB_CHECK_VERSION(2, 35, 0)
    1712  g_type_init();
     13#endif
     14#if !GLIB_CHECK_VERSION(2, 31, 0)
    1815  g_thread_init(NULL);
     16#endif
    1917
    2018  owl_select_init();
     
    8179  g_free(cd);
    8280
    83   owl_messagelist_create(&(g->msglist));
     81  g->msglist = owl_messagelist_new();
    8482
    8583  _owl_global_init_windows(g);
     
    106104
    107105  g->interrupt_count = 0;
     106#if GLIB_CHECK_VERSION(2, 31, 0)
     107  g_mutex_init(&g->interrupt_lock);
     108#else
    108109  g->interrupt_lock = g_mutex_new();
     110#endif
    109111}
    110112
     
    115117
    116118  /* Create the widgets */
    117   owl_mainwin_init(&(g->mw), g->mainpanel.recwin);
     119  g->mw = owl_mainwin_new(g->mainpanel.recwin);
    118120  owl_msgwin_init(&(g->msgwin), g->mainpanel.msgwin);
    119121  owl_sepbar_init(g->mainpanel.sepwin);
     
    247249/* windows */
    248250
    249 owl_mainwin *owl_global_get_mainwin(owl_global *g) {
    250   return(&(g->mw));
     251owl_mainwin *owl_global_get_mainwin(owl_global *g)
     252{
     253  return g->mw;
    251254}
    252255
     
    262265
    263266owl_messagelist *owl_global_get_msglist(owl_global *g) {
    264   return(&(g->msglist));
     267  return g->msglist;
    265268}
    266269
     
    846849  } filters[] = {
    847850    { "personal",
    848       "isprivate ^true$ and ( not type ^zephyr$ or ( class ^message  ) )" },
     851      "isprivate ^true$ and ( not type ^zephyr$ or ( class ^message$ ) )" },
    849852    { "trash",
    850853      "class ^mail$ or opcode ^ping$ or type ^admin$ or ( not login ^none$ )" },
     
    853856    { "auto", "opcode ^auto$" },
    854857    { "login", "not login ^none$" },
    855     { "reply-lockout", "class ^noc or class ^mail$" },
     858    { "reply-lockout", "class ^mail$ or class ^filsrv$" },
    856859    { "out", "direction ^out$" },
    857860    { "aim", "type ^aim$" },
     
    904907}
    905908
     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
    906918void owl_global_add_interrupt(owl_global *g) {
    907919  /* TODO: This can almost certainly be done with atomic
    908920   * operations. Whatever. */
    909   g_mutex_lock(g->interrupt_lock);
     921  g_mutex_lock(owl_global_get_interrupt_lock(g));
    910922  g->interrupt_count++;
    911   g_mutex_unlock(g->interrupt_lock);
     923  g_mutex_unlock(owl_global_get_interrupt_lock(g));
    912924}
    913925
    914926bool owl_global_take_interrupt(owl_global *g) {
    915927  bool ans = false;
    916   g_mutex_lock(g->interrupt_lock);
     928  g_mutex_lock(owl_global_get_interrupt_lock(g));
    917929  if (g->interrupt_count > 0) {
    918930    ans = true;
    919931    g->interrupt_count--;
    920932  }
    921   g_mutex_unlock(g->interrupt_lock);
     933  g_mutex_unlock(owl_global_get_interrupt_lock(g));
    922934  return ans;
    923935}
  • help.c

    r820e852 r8258ea5  
    11#include "owl.h"
    2 #include <string.h>
    32
    43void owl_help(void)
     
    7473     "    : , M-x       Enter command mode\n"
    7574     "\n"
    76      "    /             Foward search\n"
     75     "    /             Forward search\n"
    7776     "    ?             Reverse search\n"
    7877     "\n\n"
     
    108107     "    unsuball      Unsubscribe from all zephyr classes\n"
    109108     "    load-subs     Load zephyr subscriptions from a file\n"
    110      "    zpunt         Supress messages from a zephyr triplet\n"
     109     "    zpunt         Suppress messages from a zephyr triplet\n"
    111110     "    zlog          Send a login or logout notification\n"
    112111     "    zlist         Print a list of zephyr buddies logged in\n"
  • keybinding.c

    r6829afc rf271129  
    1 #include <ctype.h>
    2 #include <string.h>
    31#include "owl.h"
    42
  • keymap.c

    rce68f23 rf271129  
    1 #include <string.h>
    21#include "owl.h"
    32
  • keypress.c

    r2560529 rf271129  
    1 #include <ctype.h>
    2 #include <string.h>
    31#include "owl.h"
    42
  • libfaim/Makefile.am

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

    rdde1b4d r0792d99  
    11#include "owl.h"
    2 #include <stdlib.h>
    3 #include <string.h>
    4 #include <ctype.h>
    5 #include <sys/param.h>
     2#include <stdio.h>
    63
    74typedef struct _owl_log_entry { /* noproto */
     
    432429static gpointer owl_log_thread_func(gpointer data)
    433430{
    434   log_context = g_main_context_new();
    435431  log_loop = g_main_loop_new(log_context, FALSE);
    436432  g_main_loop_run(log_loop);
     
    440436void owl_log_init(void)
    441437{
     438  log_context = g_main_context_new();
     439#if GLIB_CHECK_VERSION(2, 31, 0)
     440  logging_thread = g_thread_new("logging",
     441                                owl_log_thread_func,
     442                                NULL);
     443#else
    442444  GError *error = NULL;
    443445  logging_thread = g_thread_create(owl_log_thread_func,
     
    451453    exit(1);
    452454  }
     455#endif
    453456 
    454457}
  • m4/ax_cflags_warn_all.m4

    r378ede7 re9b4a2c  
    2525#    - $3 action-if-found : add value to shellvariable
    2626#    - $4 action-if-not-found : nothing
     27#
     28#   NOTE: These macros depend on AX_APPEND_FLAG.
    2729#
    2830# LICENSE
     
    5759#   exception to the GPL to apply to your modified version as well.
    5860
    59 #serial 10
     61#serial 14
    6062
    61 AC_DEFUN([AX_CFLAGS_WARN_ALL],[dnl
    62 AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl
    63 AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_warn_all])dnl
     63AC_DEFUN([AX_FLAGS_WARN_ALL],[dnl
     64AS_VAR_PUSHDEF([FLAGS],[_AC_LANG_PREFIX[]FLAGS])dnl
     65AS_VAR_PUSHDEF([VAR],[ac_cv_[]_AC_LANG_ABBREV[]flags_warn_all])dnl
    6466AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings],
    6567VAR,[VAR="no, unknown"
    66  AC_LANG_PUSH([C])
    67  ac_save_[]FLAGS="$[]FLAGS"
    68 for ac_arg dnl
    69 in "-pedantic  % -Wall"       dnl   GCC
    70    "-xstrconst % -v"          dnl Solaris C
    71    "-std1      % -verbose -w0 -warnprotos" dnl Digital Unix
    72    "-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX
    73    "-ansi -ansiE % -fullwarn" dnl IRIX
    74    "+ESlit     % +w1"         dnl HP-UX C
    75    "-Xc        % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10)
    76    "-h conform % -h msglevel 2" dnl Cray C (Unicos)
    77    #
    78 do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
    79    AC_COMPILE_IFELSE([AC_LANG_PROGRAM],
    80                      [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
    81 done
    82  FLAGS="$ac_save_[]FLAGS"
    83  AC_LANG_POP([C])
    84 ])
    85 case ".$VAR" in
    86      .ok|.ok,*) m4_ifvaln($3,$3) ;;
    87    .|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[
    88         AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])
    89                       m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])]) ;;
    90    *) m4_ifvaln($3,$3,[
    91    if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
    92    then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
    93    else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
    94                       m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
    95    fi ]) ;;
    96 esac
    97 AS_VAR_POPDEF([VAR])dnl
    98 AS_VAR_POPDEF([FLAGS])dnl
    99 ])
    100 
    101 dnl the only difference - the LANG selection... and the default FLAGS
    102 
    103 AC_DEFUN([AX_CXXFLAGS_WARN_ALL],[dnl
    104 AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl
    105 AS_VAR_PUSHDEF([VAR],[ax_cv_cxxflags_warn_all])dnl
    106 AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings],
    107 VAR,[VAR="no, unknown"
    108  AC_LANG_PUSH([C++])
    109  ac_save_[]FLAGS="$[]FLAGS"
    110 for ac_arg dnl
    111 in "-pedantic  % -Wall"       dnl   GCC
    112    "-xstrconst % -v"          dnl Solaris C
    113    "-std1      % -verbose -w0 -warnprotos" dnl Digital Unix
    114    "-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX
    115    "-ansi -ansiE % -fullwarn" dnl IRIX
    116    "+ESlit     % +w1"         dnl HP-UX C
    117    "-Xc        % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10)
    118    "-h conform % -h msglevel 2" dnl Cray C (Unicos)
    119    #
    120 do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
    121    AC_COMPILE_IFELSE([AC_LANG_PROGRAM],
    122                      [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
    123 done
    124  FLAGS="$ac_save_[]FLAGS"
    125  AC_LANG_POP([C++])
    126 ])
    127 case ".$VAR" in
    128      .ok|.ok,*) m4_ifvaln($3,$3) ;;
    129    .|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[
    130         AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])
    131                       m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])]) ;;
    132    *) m4_ifvaln($3,$3,[
    133    if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
    134    then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
    135    else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
    136                       m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
    137    fi ]) ;;
    138 esac
    139 AS_VAR_POPDEF([VAR])dnl
    140 AS_VAR_POPDEF([FLAGS])dnl
    141 ])
    142 
    143 dnl the only difference - the LANG selection... and the default FLAGS
    144 
    145 AC_DEFUN([AX_FCFLAGS_WARN_ALL],[dnl
    146 AS_VAR_PUSHDEF([FLAGS],[FCFLAGS])dnl
    147 AS_VAR_PUSHDEF([VAR],[ax_cv_fcflags_warn_all])dnl
    148 AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings],
    149 VAR,[VAR="no, unknown"
    150  AC_LANG_PUSH([Fortran])
    151  ac_save_[]FLAGS="$[]FLAGS"
     68ac_save_[]FLAGS="$[]FLAGS"
    15269for ac_arg dnl
    15370in "-warn all  % -warn all"   dnl Intel
     
    16582                     [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
    16683done
    167  FLAGS="$ac_save_[]FLAGS"
    168  AC_LANG_POP([Fortran])
     84FLAGS="$ac_save_[]FLAGS"
    16985])
     86AS_VAR_POPDEF([FLAGS])dnl
     87AC_REQUIRE([AX_APPEND_FLAG])
    17088case ".$VAR" in
    17189     .ok|.ok,*) m4_ifvaln($3,$3) ;;
    172    .|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[
    173         AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])
    174                       m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])]) ;;
    175    *) m4_ifvaln($3,$3,[
    176    if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
    177    then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
    178    else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
    179                       m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
    180    fi ]) ;;
     90   .|.no|.no,*) m4_default($4,[m4_ifval($2,[AX_APPEND_FLAG([$2], [$1])])]) ;;
     91   *) m4_default($3,[AX_APPEND_FLAG([$VAR], [$1])]) ;;
    18192esac
    18293AS_VAR_POPDEF([VAR])dnl
    183 AS_VAR_POPDEF([FLAGS])dnl
    184 ])
    185 
     94])dnl AX_FLAGS_WARN_ALL
    18695dnl  implementation tactics:
    18796dnl   the for-argument contains a list of options. The first part of
     
    194103dnl   delimiter. A non-option comment can be given after "%%" marks
    195104dnl   which will be shown but not added to the respective C/CXXFLAGS.
     105
     106AC_DEFUN([AX_CFLAGS_WARN_ALL],[dnl
     107AC_LANG_PUSH([C])
     108AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4])
     109AC_LANG_POP([C])
     110])
     111
     112AC_DEFUN([AX_CXXFLAGS_WARN_ALL],[dnl
     113AC_LANG_PUSH([C++])
     114AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4])
     115AC_LANG_POP([C++])
     116])
     117
     118AC_DEFUN([AX_FCFLAGS_WARN_ALL],[dnl
     119AC_LANG_PUSH([Fortran])
     120AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4])
     121AC_LANG_POP([Fortran])
     122])
  • m4/pkg.m4

    r650fb2c r13a39ae8  
    158158fi[]dnl
    159159])# PKG_CHECK_MODULES
     160
     161
     162# PKG_INSTALLDIR(DIRECTORY)
     163# -------------------------
     164# Substitutes the variable pkgconfigdir as the location where a module
     165# should install pkg-config .pc files. By default the directory is
     166# $libdir/pkgconfig, but the default can be changed by passing
     167# DIRECTORY. The user can override through the --with-pkgconfigdir
     168# parameter.
     169AC_DEFUN([PKG_INSTALLDIR],
     170[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
     171m4_pushdef([pkg_description],
     172    [pkg-config installation directory @<:@]pkg_default[@:>@])
     173AC_ARG_WITH([pkgconfigdir],
     174    [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
     175    [with_pkgconfigdir=]pkg_default)
     176AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
     177m4_popdef([pkg_default])
     178m4_popdef([pkg_description])
     179]) dnl PKG_INSTALLDIR
     180
     181
     182# PKG_NOARCH_INSTALLDIR(DIRECTORY)
     183# -------------------------
     184# Substitutes the variable noarch_pkgconfigdir as the location where a
     185# module should install arch-independent pkg-config .pc files. By
     186# default the directory is $datadir/pkgconfig, but the default can be
     187# changed by passing DIRECTORY. The user can override through the
     188# --with-noarch-pkgconfigdir parameter.
     189AC_DEFUN([PKG_NOARCH_INSTALLDIR],
     190[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
     191m4_pushdef([pkg_description],
     192    [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
     193AC_ARG_WITH([noarch-pkgconfigdir],
     194    [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
     195    [with_noarch_pkgconfigdir=]pkg_default)
     196AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
     197m4_popdef([pkg_default])
     198m4_popdef([pkg_description])
     199]) dnl PKG_NOARCH_INSTALLDIR
     200
     201
     202# PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
     203# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
     204# -------------------------------------------
     205# Retrieves the value of the pkg-config variable for the given module.
     206AC_DEFUN([PKG_CHECK_VAR],
     207[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
     208AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
     209
     210_PKG_CONFIG([$1], [variable="][$3]["], [$2])
     211AS_VAR_COPY([$1], [pkg_cv_][$1])
     212
     213AS_VAR_IF([$1], [""], [$5], [$4])dnl
     214])# PKG_CHECK_VAR
  • mainwin.c

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

    r4ebbfbc r2354e9a  
    1 #include <stdlib.h>
    2 #include <unistd.h>
    3 #include <string.h>
    4 #include <sys/socket.h>
    5 #include <netdb.h>
    6 #include <sys/types.h>
    7 #include <sys/socket.h>
    8 #include <netinet/in.h>
    9 #include <arpa/inet.h>
    10 #include <time.h>
    111#include "owl.h"
    122#include "filterproc.h"
     3#include <sys/socket.h>
     4#include <arpa/inet.h>
    135
    146static owl_fmtext_cache fmtext_cache[OWL_FMTEXT_CACHE_SIZE];
     
    4234  m->delete=0;
    4335
     36#ifdef HAVE_LIBZEPHYR
     37  m->has_notice = false;
     38#endif
     39
    4440  owl_message_set_hostname(m, "");
    4541  m->attributes = g_ptr_array_new();
     
    4743  /* save the time */
    4844  m->time = time(NULL);
    49   m->timestr = owl_util_time_to_timestr(localtime(&m->time));
     45  m->timestr = g_strdup(ctime(&m->time));
     46  m->timestr[strlen(m->timestr)-1] = '\0';
    5047
    5148  m->fmtext = NULL;
     
    350347}
    351348
     349CALLER_OWN char *owl_message_format_time(const owl_message *m)
     350{
     351  return owl_util_format_time(localtime(&m->time));
     352}
     353
    352354void owl_message_set_type_admin(owl_message *m)
    353355{
     
    498500const ZNotice_t *owl_message_get_notice(const owl_message *m)
    499501{
    500   return(&(m->notice));
     502  return m->has_notice ? &m->notice : NULL;
    501503}
    502504#else
     
    789791  /* first save the full notice */
    790792  m->notice = *n;
     793  m->has_notice = true;
    791794
    792795  /* a little gross, we'll replace \r's with ' ' for now */
     
    796799  if (m->timestr) g_free(m->timestr);
    797800  m->time = n->z_time.tv_sec;
    798   m->timestr = owl_util_time_to_timestr(localtime(&m->time));
     801  m->timestr = g_strdup(ctime(&m->time));
     802  m->timestr[strlen(m->timestr)-1] = '\0';
    799803
    800804  /* set other info */
     
    832836
    833837 
    834   /* set the "isprivate" attribute if it's a private zephyr.
    835    ``private'' means recipient is non-empty and doesn't start wit
    836    `@' */
    837   if (*n->z_recipient && *n->z_recipient != '@') {
     838  /* set the "isprivate" attribute if it's a private zephyr. */
     839  if (owl_zwrite_recip_is_personal(n->z_recipient)) {
    838840    owl_message_set_isprivate(m);
    839841  }
     
    873875  if (owl_global_is_zcrypt(&g) && !strcasecmp(n->z_opcode, "crypt")) {
    874876    const char *argv[] = {
    875       "zcrypt",
     877      NULL,
    876878      "-D",
    877879      "-c", owl_message_get_class(m),
     
    879881      NULL
    880882    };
    881     char *out;
     883    char *out = NULL;
    882884    int rv;
    883885    int status;
     
    885887
    886888    zcrypt = g_build_filename(owl_get_bindir(), "zcrypt", NULL);
    887 
    888     rv = call_filter(zcrypt, argv, owl_message_get_body(m), &out, &status);
     889    argv[0] = zcrypt;
     890
     891    rv = call_filter(argv, owl_message_get_body(m), &out, &status);
    889892    g_free(zcrypt);
    890893
     
    895898      }
    896899      owl_message_set_body(m, out);
    897       g_free(out);
    898     } else if(out) {
    899       g_free(out);
    900     }
     900    } else {
     901      /* Replace the opcode. Otherwise the UI and other bits of code think the
     902       * message was encrypted. */
     903      owl_message_set_opcode(m, "failed-decrypt");
     904    }
     905    g_free(out);
    901906  }
    902907
     
    10041009  owl_pair *p;
    10051010#ifdef HAVE_LIBZEPHYR   
    1006   if (owl_message_is_type_zephyr(m) && owl_message_is_direction_in(m)) {
     1011  if (m->has_notice) {
    10071012    ZFreeNotice(&(m->notice));
    10081013  }
  • messagelist.c

    refeec7f r219f52c  
    11#include "owl.h"
    2 #include <stdlib.h>
    3 #include <string.h>
    42
    5 void owl_messagelist_create(owl_messagelist *ml)
     3CALLER_OWN owl_messagelist *owl_messagelist_new(void)
    64{
     5  owl_messagelist *ml = g_new(owl_messagelist, 1);
    76  ml->list = g_ptr_array_new();
     7  return ml;
    88}
    99
    10 void owl_messagelist_cleanup(owl_messagelist *ml, bool free_messages)
     10void owl_messagelist_delete(owl_messagelist *ml, bool free_messages)
    1111{
    1212  if (free_messages)
    1313    g_ptr_array_foreach(ml->list, (GFunc)owl_message_delete, NULL);
    1414  g_ptr_array_free(ml->list, true);
     15  g_free(ml);
    1516}
    1617
  • owl.c

    ra7fac14 r499224d  
    77 */
    88
     9#include "owl.h"
    910#include <stdio.h>
    10 #include <unistd.h>
    1111#include <getopt.h>
    12 #include <stdlib.h>
    13 #include <string.h>
    14 #include <signal.h>
    15 #include <time.h>
    16 #include <sys/param.h>
    17 #include <sys/types.h>
    18 #include <sys/time.h>
    19 #include <termios.h>
    2012#include <sys/stat.h>
    2113#include <locale.h>
    22 #include "owl.h"
    23 
     14#include <unistd.h>
    2415
    2516#if OWL_STDERR_REDIR
     
    4334} owl_options;
    4435
    45 void usage(void)
     36void usage(FILE *file)
    4637{
    47   fprintf(stderr, "Barnowl version %s\n", OWL_VERSION_STRING);
    48   fprintf(stderr, "Usage: barnowl [-n] [-d] [-D] [-v] [-h] [-c <configfile>] [-s <confdir>] [-t <ttyname>]\n");
    49   fprintf(stderr, "  -n,--no-subs        don't load zephyr subscriptions\n");
    50   fprintf(stderr, "  -d,--debug          enable debugging\n");
    51   fprintf(stderr, "  -v,--version        print the Barnowl version number and exit\n");
    52   fprintf(stderr, "  -h,--help           print this help message\n");
    53   fprintf(stderr, "  -c,--config-file    specify an alternate config file\n");
    54   fprintf(stderr, "  -s,--config-dir     specify an alternate config dir (default ~/.owl)\n");
    55   fprintf(stderr, "  -t,--tty            set the tty name\n");
     38  fprintf(file, "Barnowl version %s\n", OWL_VERSION_STRING);
     39  fprintf(file, "Usage: barnowl [-n] [-d] [-D] [-v] [-h] [-c <configfile>] [-s <confdir>] [-t <ttyname>]\n");
     40  fprintf(file, "  -n,--no-subs        don't load zephyr subscriptions\n");
     41  fprintf(file, "  -d,--debug          enable debugging\n");
     42  fprintf(file, "  -v,--version        print the Barnowl version number and exit\n");
     43  fprintf(file, "  -h,--help           print this help message\n");
     44  fprintf(file, "  -s,--config-dir     specify an alternate config dir (default ~/.owl)\n");
     45  fprintf(file, "  -c,--config-file    specify an alternate config file (default ~/.owl/init.pl)\n");
     46  fprintf(file, "  -t,--tty            set the tty name\n");
    5647}
    5748
     
    9283      exit(0);
    9384    case 'h':
     85      usage(stdout);
     86      exit(0);
    9487    default:
    95       usage();
     88      usage(stderr);
    9689      exit(1);
    9790    }
     
    272265    /* follow the last message if we're supposed to */
    273266    if (followlast)
    274       owl_function_lastmsg_noredisplay();
     267      owl_function_lastmsg();
    275268
    276269    /* do the newmsgproc thing */
     
    437430  if (0 != pipe(pipefds)) {
    438431    perror("pipe");
    439     owl_function_debugmsg("stderr_replace: pipe FAILED\n");
     432    owl_function_debugmsg("stderr_replace: pipe FAILED");
    440433    return -1;
    441434  }
    442     owl_function_debugmsg("stderr_replace: pipe: %d,%d\n", pipefds[0], pipefds[1]);
    443   if (-1 == dup2(pipefds[1], 2 /*stderr*/)) {
    444     owl_function_debugmsg("stderr_replace: dup2 FAILED (%s)\n", strerror(errno));
     435    owl_function_debugmsg("stderr_replace: pipe: %d,%d", pipefds[0], pipefds[1]);
     436  if (-1 == dup2(pipefds[1], STDERR_FILENO)) {
     437    owl_function_debugmsg("stderr_replace: dup2 FAILED (%s)", strerror(errno));
    445438    perror("dup2");
    446439    return -1;
     
    524517#if OWL_STDERR_REDIR
    525518  /* Do this only after we've started curses up... */
    526   owl_function_debugmsg("startup: doing stderr redirection");
    527   channel = g_io_channel_unix_new(stderr_replace());
    528   g_io_add_watch(channel, G_IO_IN | G_IO_HUP | G_IO_ERR, &stderr_redirect_handler, NULL);
    529   g_io_channel_unref(channel);
     519  if (isatty(STDERR_FILENO)) {
     520    owl_function_debugmsg("startup: doing stderr redirection");
     521    channel = g_io_channel_unix_new(stderr_replace());
     522    g_io_add_watch(channel, G_IO_IN | G_IO_HUP | G_IO_ERR, &stderr_redirect_handler, NULL);
     523    g_io_channel_unref(channel);
     524  }
    530525#endif
    531526
     
    595590  );
    596591
     592  owl_function_debugmsg("startup: setting context interactive");
     593
     594  owl_global_pop_context(&g);
     595  owl_global_push_context(&g, OWL_CTX_INTERACTIVE|OWL_CTX_RECV, NULL, "recv", NULL);
     596
    597597  /* process the startup file */
    598598  owl_function_debugmsg("startup: processing startup file");
     
    606606      owl_function_error("No such style: %s", owl_global_get_default_style(&g));
    607607
    608   owl_function_debugmsg("startup: setting context interactive");
    609 
    610   owl_global_pop_context(&g);
    611   owl_global_push_context(&g, OWL_CTX_INTERACTIVE|OWL_CTX_RECV, NULL, "recv", NULL);
    612 
    613608  source = owl_window_redraw_source_new();
    614609  g_source_attach(source, NULL);
  • owl.h

    rcbc8657 r6249a88f  
    1010#define INC_BARNOWL_OWL_H
    1111
    12 #include "config.h"
     12#include <config.h>
    1313
    1414#include "compat/compat.h"
     
    2222#endif
    2323#include <sys/param.h>
     24#include <sys/types.h>
     25#include <ctype.h>
     26#include <errno.h>
    2427#include <EXTERN.h>
     28#include <fcntl.h>
    2529#include <netdb.h>
    2630#include <regex.h>
    2731#include <time.h>
    2832#include <signal.h>
     33#include <stdlib.h>
     34#include <string.h>
    2935#include <termios.h>
     36#include <unistd.h>
    3037#include "libfaim/aim.h"
    3138#include <wchar.h>
    32 #include "glib.h"
     39#include <glib.h>
    3340#ifdef HAVE_LIBZEPHYR
    3441#include <zephyr/zephyr.h>
     
    4047/* Perl and curses don't play nice. */
    4148#ifdef OWL_PERL
    42 typedef void WINDOW;
    43 typedef void PANEL;
     49typedef struct _owl_fake_WINDOW WINDOW;
     50typedef struct _owl_fake_PANEL PANEL;
    4451/* logout is defined in FreeBSD. */
    4552#define logout logout_
     
    5057#include "XSUB.h"
    5158#else
    52 typedef void SV;
    53 typedef void AV;
    54 typedef void HV;
     59typedef struct _owl_fake_SV SV;
     60typedef struct _owl_fake_AV AV;
     61typedef struct _owl_fake_HV HV;
    5562#endif
    5663
     
    228235  char *name;
    229236  int   type;  /* OWL_VARIABLE_* */
    230   void *pval_default;  /* for types other and string */
    231   int   ival_default;  /* for types int and bool     */
    232   const char *validsettings;    /* documentation of valid settings */
     237  char *default_str;            /* the default value as a string */
     238  char *validsettings;          /* documentation of valid settings */
    233239  char *summary;                /* summary of usage */
    234240  char *description;            /* detailed description */
    235   void *val;                    /* current value */
    236   int  (*validate_fn)(const struct _owl_variable *v, const void *newval);
     241  bool takes_on_off;            /* allow passing on/off in argument-less set/unset */
     242  GClosure *set_fromstring_fn;
     243                                /* sets the variable to a value
     244                                 * of the appropriate type.
     245                                 * unless documented, this
     246                                 * should make a copy.
     247                                 * returns 0 on success. */
     248  GClosure *get_tostring_fn;
     249                                /* converts val to a string;
     250                                 * caller must free the result */
     251
     252  /* These are only valid for OWL_VARIABLE_{INT,BOOL,STRING} */
     253  GValue val;                   /* current value, if default get_fn/set_fn */
     254
     255  GCallback get_fn;
     256                                /* returns a reference to the current value.
     257                                 * WARNING:  this approach is hard to make
     258                                 * thread-safe... */
     259  GCallback validate_fn;
    237260                                /* returns 1 if newval is valid */
    238   int  (*set_fn)(struct _owl_variable *v, const void *newval);
     261  GCallback set_fn;
    239262                                /* sets the variable to a value
    240                                  * of the appropriate type.
    241                                  * unless documented, this
    242                                  * should make a copy.
    243                                  * returns 0 on success. */
    244   int  (*set_fromstring_fn)(struct _owl_variable *v, const char *newval);
    245                                 /* sets the variable to a value
    246                                  * of the appropriate type.
    247                                  * unless documented, this
    248                                  * should make a copy.
    249                                  * returns 0 on success. */
    250   const void *(*get_fn)(const struct _owl_variable *v);
    251                                 /* returns a reference to the current value.
    252                                  * WARNING:  this approach is hard to make
    253                                  * thread-safe... */
    254   CALLER_OWN char *(*get_tostring_fn)(const struct _owl_variable *v, const void *val);
    255                                 /* converts val to a string;
    256                                  * caller must free the result */
    257   void (*delete_fn)(struct _owl_variable *v);
    258                                 /* frees val as needed */
     263                                 * of the appropriate type.
     264                                 * unless documented, this
     265                                 * should make a copy.
     266                                 * returns 0 on success. */
    259267} owl_variable;
     268
    260269
    261270typedef struct _owl_input {
     
    349358  int direction;
    350359#ifdef HAVE_LIBZEPHYR
     360  bool has_notice;
    351361  ZNotice_t notice;
    352362#endif
     
    444454  char *name;
    445455  owl_filter *filter;
    446   owl_messagelist ml;
     456  owl_messagelist *ml;
    447457  const owl_style *style;
    448458  int cachedmsgid;
     
    525535
    526536typedef struct _owl_global {
    527   owl_mainwin mw;
     537  owl_mainwin *mw;
    528538  owl_popwin *pw;
    529539  owl_msgwin msgwin;
     
    543553  int curmsg_vert_offset;
    544554  owl_view current_view;
    545   owl_messagelist msglist;
     555  owl_messagelist *msglist;
    546556  WINDOW *input_pad;
    547557  owl_mainpanel mainpanel;
     
    588598  char *kill_buffer;
    589599  int interrupt_count;
     600#if GLIB_CHECK_VERSION(2, 31, 0)
     601  GMutex interrupt_lock;
     602#else
    590603  GMutex *interrupt_lock;
     604#endif
    591605} owl_global;
    592606
     
    594608extern owl_global g;
    595609
    596 #include "owl_prototypes.h"
     610#include <owl_prototypes.h>
    597611
    598612/* These were missing from the Zephyr includes before Zephyr 3. */
     
    602616#endif
    603617
     618/* We have to dynamically bind these ourselves */
     619extern gboolean (*gvalue_from_sv) (GValue * value, SV * sv);
     620extern SV * (*sv_from_gvalue) (const GValue * value);
     621extern GClosure * (*perl_closure_new) (SV * callback, SV * data, gboolean swap);
     622
     623
    604624#endif /* INC_BARNOWL_OWL_H */
  • owl_perl.h

    rb8a3e00 r92ffd89  
    22#define INC_BARNOWL_OWL_PERL_H
    33
    4 #define OWL_PERL_VOID_CALL (void)POPs;
     4#include <stdio.h>
     5
     6/*
     7 * This macro defines a convenience wrapper around the boilerplate
     8 * of pushing char * arguments on to the stack for perl calling.
     9 *
     10 * Arguments are
     11 * * i     - the counter variable to use, which must be declared prior
     12 *           to calling this macro
     13 * * argc  - the number of arguments
     14 * * argv  - an array of char*s, of length at least argc; the arguments
     15 *           to push on to the stack
     16 */
     17#define OWL_PERL_PUSH_ARGS(i, argc, argv) { \
     18  for (i = 0; i < argc; i++) { \
     19    XPUSHs(sv_2mortal(owl_new_sv(argv[i]))); \
     20  } \
     21}
    522
    623/*
    724 * This macro defines a convenience wrapper around the boilerplate of
    8  * calling a method on a perl object (SV*) from C.
     25 * the perlcall methods.
    926 *
    1027 * Arguments are
    11  * * obj    - the SV* to call the method on
    12  * * meth   - a char* method name
    13  * * args   - a code block responsible for pushing args (other than the object)
    14  * * err    - a string with a %s format specifier to log in case of error
    15  * * fatalp - if true, perl errors terminate BarnOwl
    16  * * ret    - a code block executed if the call succeeded
     28 * * call       - the line of code to make the perl call
     29 * * args       - a code block responsible for pushing args
     30 * * err        - a string with a %s format specifier to log in case of error
     31 * * fatalp     - if true, perl errors terminate BarnOwl
     32 * * discardret - should be true if no return is expected
     33 *                (if the call is passed the flag G_DISCARD or G_VOID)
     34 * * ret        - a code block executed if the call succeeded
    1735 *
    1836 * See also: `perldoc perlcall', `perldoc perlapi'
    1937 */
    20 #define OWL_PERL_CALL_METHOD(obj, meth, args, err, fatalp, ret) { \
    21     int count; \
    22     dSP; \
    23     ENTER; \
    24     SAVETMPS; \
    25     PUSHMARK(SP); \
    26     XPUSHs(obj); \
    27     {args} \
    28     PUTBACK; \
    29     \
    30     count = call_method(meth, G_SCALAR|G_EVAL); \
    31     \
    32     SPAGAIN; \
    33     \
    34     if(count != 1) { \
    35       fprintf(stderr, "perl returned wrong count: %d\n", count); \
    36       abort();                                                   \
     38#define OWL_PERL_CALL(call, args, err, fatalp, discardret, ret) { \
     39  int count; \
     40  dSP; \
     41  \
     42  ENTER; \
     43  SAVETMPS; \
     44  \
     45  PUSHMARK(SP); \
     46  {args} \
     47  PUTBACK; \
     48  \
     49  count = call; \
     50  \
     51  SPAGAIN; \
     52  \
     53  if (!discardret && count != 1) { \
     54    croak("Perl returned wrong count: %d\n", count); \
     55  } \
     56  \
     57  if (SvTRUE(ERRSV)) { \
     58    if (fatalp) { \
     59      fprintf(stderr, err, SvPV_nolen(ERRSV)); \
     60      exit(-1); \
     61    } else { \
     62      owl_function_error(err, SvPV_nolen(ERRSV)); \
     63      if (!discardret) (void)POPs; \
     64      sv_setsv(ERRSV, &PL_sv_undef); \
    3765    } \
    38     if (SvTRUE(ERRSV)) { \
    39       if(fatalp) { \
    40         printf(err, SvPV_nolen(ERRSV)); \
    41         exit(-1); \
    42       } else { \
    43         owl_function_error(err, SvPV_nolen(ERRSV)); \
    44         (void)POPs; \
    45         sv_setsv(ERRSV, &PL_sv_undef); \
    46       } \
    47     } else { \
    48       ret; \
    49     } \
    50     PUTBACK; \
    51     FREETMPS; \
    52     LEAVE; \
     66  } else if (!discardret) { \
     67    ret; \
     68  } \
     69  PUTBACK; \
     70  FREETMPS; \
     71  LEAVE; \
    5372}
    5473
  • perl/Makefile.am

    r10557e6 ra870319  
    11SUBDIRS = modules
     2nobase_dist_pkgdata_DATA = \
     3        lib/BarnOwl.pm \
     4        lib/BarnOwl/Complete/AIM.pm \
     5        lib/BarnOwl/Complete/Client.pm \
     6        lib/BarnOwl/Complete/Filter.pm \
     7        lib/BarnOwl/Complete/Zephyr.pm \
     8        lib/BarnOwl/Completion.pm \
     9        lib/BarnOwl/Completion/Context.pm \
     10        lib/BarnOwl/Completion/Util.pm \
     11        lib/BarnOwl/Editwin.pm \
     12        lib/BarnOwl/Help.pm \
     13        lib/BarnOwl/Hook.pm \
     14        lib/BarnOwl/Hooks.pm \
     15        lib/BarnOwl/MainLoopCompatHook.pm \
     16        lib/BarnOwl/Message.pm \
     17        lib/BarnOwl/Message/AIM.pm \
     18        lib/BarnOwl/Message/Admin.pm \
     19        lib/BarnOwl/Message/Generic.pm \
     20        lib/BarnOwl/Message/Loopback.pm \
     21        lib/BarnOwl/Message/Zephyr.pm \
     22        lib/BarnOwl/ModuleLoader.pm \
     23        lib/BarnOwl/Parse.pm \
     24        lib/BarnOwl/Style.pm \
     25        lib/BarnOwl/Style/Basic.pm \
     26        lib/BarnOwl/Style/Default.pm \
     27        lib/BarnOwl/Style/Legacy.pm \
     28        lib/BarnOwl/Style/OneLine.pm \
     29        lib/BarnOwl/Timer.pm \
     30        lib/BarnOwl/Zephyr.pm \
     31        lib/Module/Install/BarnOwl.pm
  • perl/lib/BarnOwl.pm

    ra130fc5 r1ced34f  
    55
    66use base qw(Exporter);
    7 our @EXPORT_OK = qw(command getcurmsg getnumcols getidletime
     7our @EXPORT_OK = qw(command getcurmsg getnumcols getnumlines getidletime
    88                    zephyr_getsender zephyr_getrealm zephyr_zwrite
    99                    zephyr_stylestrip zephyr_smartstrip_user zephyr_getsubs
    1010                    queue_message admin_message
     11                    start_edit
    1112                    start_question start_password start_edit_win
    1213                    get_data_dir get_config_dir popless_text popless_ztext
    1314                    error debug
    1415                    create_style getnumcolors wordwrap
     16                    message_matches_filter
    1517                    add_dispatch remove_dispatch
    1618                    add_io_dispatch remove_io_dispatch
    1719                    new_command
    1820                    new_variable_int new_variable_bool new_variable_string
     21                    new_variable_enum
    1922                    quote redisplay);
    2023our %EXPORT_TAGS = (all => \@EXPORT_OK);
     
    9295command line, and C<MESSAGE> is the zephyr body to send.
    9396
     97=cut
     98
     99sub zephyr_zwrite {
     100    my ($command, $message) = @_;
     101    my $ret = BarnOwl::Internal::zephyr_zwrite($command, $message);
     102    die "Error sending zephyr" unless $ret == 0;
     103}
     104
    94105=head2 ztext_stylestrip STRING
    95106
     
    105116Enqueue a message in the BarnOwl message list, logging it and
    106117processing it appropriately. C<MESSAGE> should be an instance of
    107 BarnOwl::Message or a subclass.  Returns the queued message.  This
    108 is useful for, e.g., deleting a message from the message list.
     118BarnOwl::Message or a subclass.
    109119
    110120=head2 admin_message HEADER BODY
     
    112122Display a BarnOwl B<Admin> message, with the given header and body.
    113123
     124=head2 start_edit %ARGS
     125
     126Displays a prompt on the screen and lets the user enter text,
     127and calls a callback when the editwin is closed.
     128
     129C<%ARGS> must contain the following keys:
     130
     131=over 4
     132
     133=item prompt
     134
     135The line to display on the screen
     136
     137=item type
     138
     139One of:
     140
     141=over 4
     142
     143=item edit_win
     144
     145Displays the prompt on a line of its own and opens the edit_win.
     146
     147=item question
     148
     149Displays prompt on the screen and lets the user enter a line of
     150text.
     151
     152=item password
     153
     154Like question, but echoes the user's input as C<*>s when they
     155input.
     156
     157=back
     158
     159=item callback
     160
     161A Perl subroutine that is called when the user closes the edit_win.
     162C<CALLBACK> gets called with two parameters: the text the user entered,
     163and a C<SUCCESS> boolean parameter which is false if the user canceled
     164the edit_win and true otherwise.
     165
     166=back
     167
    114168=head2 start_question PROMPT CALLBACK
    115169
    116 Displays C<PROMPT> on the screen and lets the user enter a line of
    117 text, and calls C<CALLBACK>, which must be a perl subroutine
    118 reference, with the text the user entered
    119 
    120170=head2 start_password PROMPT CALLBACK
    121171
    122 Like C<start_question>, but echoes the user's input as C<*>s when they
    123 input.
    124 
    125172=head2 start_edit_win PROMPT CALLBACK
    126173
    127 Like C<start_question>, but displays C<PROMPT> on a line of its own
    128 and opens the editwin. If the user cancels the edit win, C<CALLBACK>
    129 is not invoked.
     174Roughly equivalent to C<start_edit> called with the appropriate parameters.
     175C<CALLBACK> is only called on success, for compatibility.
     176
     177These are deprecated wrappers around L<BarnOwl::start_edit>, and should not
     178be uesd in new code.
     179
     180=cut
     181
     182sub start_edit {
     183    my %args = (@_);
     184    BarnOwl::Internal::start_edit($args{type}, $args{prompt}, $args{callback});
     185}
     186
     187sub start_question {
     188    my ($prompt, $callback) = @_;
     189    BarnOwl::start_edit(type => 'question', prompt => $prompt, callback => sub {
     190            my ($text, $success) = @_;
     191            $callback->($text) if $success;
     192        });
     193}
     194
     195sub start_password {
     196    my ($prompt, $callback) = @_;
     197    BarnOwl::start_edit(type => 'password', prompt => $prompt, callback => sub {
     198            my ($text, $success) = @_;
     199            $callback->($text) if $success;
     200        });
     201}
     202
     203sub start_edit_win {
     204    my ($prompt, $callback) = @_;
     205    BarnOwl::start_edit(type => 'edit_win', prompt => $prompt, callback => sub {
     206            my ($text, $success) = @_;
     207            $callback->($text) if $success;
     208        });
     209}
    130210
    131211=head2 get_data_dir
     
    160240
    161241Returns the number of colors this BarnOwl is capable of displaying
     242
     243=head2 message_matches_filter MESSAGE FILTER_NAME [QUIET = 0]
     244
     245Returns 1 if C<FILTER_NAME> is the name of a valid filter, and
     246C<MESSAGE> matches that filter.  Returns 0 otherwise.  If
     247C<QUIET> is false, this method displays an error message if
     248if C<FILTER_NAME> does not name a valid filter.
    162249
    163250=head2 add_dispatch FD CALLBACK
     
    259346our @all_commands;
    260347
    261 if(!$configfile && -f $ENV{HOME} . "/.barnowlconf") {
    262     $configfile = $ENV{HOME} . "/.barnowlconf";
    263 }
    264 $configfile ||= $ENV{HOME}."/.owlconf";
     348if(!$configfile) {
     349    if (-f get_config_dir() . "/init.pl") {
     350        $configfile = get_config_dir() . "/init.pl";
     351    } elsif (-f $ENV{HOME} . "/.barnowlconf") {
     352        $configfile = $ENV{HOME} . "/.barnowlconf";
     353    } else {
     354        $configfile = $ENV{HOME}."/.owlconf";
     355    }
     356}
    265357
    266358# populate global variable space for legacy owlconf files
     
    319411=head2 new_variable_string NAME [{ARGS}]
    320412
    321 Add a new owl variable, either an int, a bool, or a string, with the
     413=head2 new_variable_enum NAME [{ARGS}]
     414
     415Add a new owl variable, either an int, a bool, a string, or an enum with the
    322416specified name.
    323417
    324 ARGS can optionally contain the following keys:
     418For new_variable_enum, ARGS is required to contain a validsettings key pointing
     419to an array reference. For all four, it can optionally contain the following
     420keys:
    325421
    326422=over 4
     
    340436=back
    341437
     438In addition, new_variable_string optionally accepts a string validsettings
     439parameter, in case people want to set it to "<path>".
     440
    342441=cut
    343442
    344443sub new_variable_int {
    345     unshift @_, \&BarnOwl::Internal::new_variable_int, 0;
    346     goto \&_new_variable;
     444    my ($name, $args) = @_;
     445    my $storage = defined($args->{default}) ? $args->{default} : 0;
     446    BarnOwl::new_variable_full($name, {
     447            %{$args},
     448            get_tostring => sub { "$storage" },
     449            set_fromstring => sub {
     450                die "Expected integer" unless $_[0] =~ /^-?[0-9]+$/;
     451                $storage = 0 + $_[0];
     452            },
     453            validsettings => "<int>",
     454            takes_on_off => 0,
     455        });
    347456}
    348457
    349458sub new_variable_bool {
    350     unshift @_, \&BarnOwl::Internal::new_variable_bool, 0;
    351     goto \&_new_variable;
     459    my ($name, $args) = @_;
     460    my $storage = defined($args->{default}) ? $args->{default} : 0;
     461    BarnOwl::new_variable_full($name, {
     462            %{$args},
     463            get_tostring => sub { $storage ? "on" : "off" },
     464            set_fromstring => sub {
     465                die "Valid settings are on/off" unless $_[0] eq "on" || $_[0] eq "off";
     466                $storage = $_[0] eq "on";
     467            },
     468            validsettings => "on,off",
     469            takes_on_off => 1,
     470        });
    352471}
    353472
    354473sub new_variable_string {
    355     unshift @_, \&BarnOwl::Internal::new_variable_string, "";
    356     goto \&_new_variable;
    357 }
    358 
    359 sub _new_variable {
    360     my $func = shift;
    361     my $default_default = shift;
     474    my ($name, $args) = @_;
     475    my $storage = defined($args->{default}) ? $args->{default} : "";
     476    BarnOwl::new_variable_full($name, {
     477            # Allow people to override this one if they /reaaally/ want to for
     478            # some reason. Though we still reserve the right to interpret this
     479            # value in interesting ways for tab-completion purposes.
     480            validsettings => "<string>",
     481            %{$args},
     482            get_tostring => sub { $storage },
     483            set_fromstring => sub { $storage = $_[0]; },
     484            takes_on_off => 0,
     485        });
     486}
     487
     488sub new_variable_enum {
     489    my ($name, $args) = @_;
     490
     491    # Gather the valid settings.
     492    die "validsettings is required" unless defined($args->{validsettings});
     493    my %valid;
     494    map { $valid{$_} = 1 } @{$args->{validsettings}};
     495
     496    my $storage = (defined($args->{default}) ?
     497                   $args->{default} :
     498                   $args->{validsettings}->[0]);
     499    BarnOwl::new_variable_full($name, {
     500            %{$args},
     501            get_tostring => sub { $storage },
     502            set_fromstring => sub {
     503                die "Invalid input" unless $valid{$_[0]};
     504                $storage = $_[0];
     505            },
     506            validsettings => join(",", @{$args->{validsettings}})
     507        });
     508}
     509
     510=head2 new_variable_full NAME {ARGS}
     511
     512Create a variable, in full generality. The keyword arguments have types below:
     513
     514 get_tostring : ()  -> string
     515 set_fromstring : string -> int
     516 -- optional --
     517 summary : string
     518 description : string
     519 validsettings : string
     520 takes_on_off : int
     521
     522The get/set functions are required. Note that the caller manages storage for the
     523variable. get_tostring/set_fromstring both convert AND store the value.
     524set_fromstring dies on failure.
     525
     526If the variable takes parameters 'on' and 'off' (i.e. is boolean-looking), set
     527takes_on_off to 1. This makes :set VAR and :unset VAR work. set_fromstring will
     528be called with those arguments.
     529
     530=cut
     531
     532sub new_variable_full {
    362533    my $name = shift;
    363534    my $args = shift || {};
    364535    my %args = (
    365         summary     => "",
     536        summary => "",
    366537        description => "",
    367         default     => $default_default,
     538        takes_on_off => 0,
     539        validsettings => "<string>",
    368540        %{$args});
    369     $func->($name, $args{default}, $args{summary}, $args{description});
     541
     542    die "get_tostring required" unless $args{get_tostring};
     543    die "set_fromstring required" unless $args{set_fromstring};
     544
     545    # Strip off the bogus dummy argument. Aargh perl-Glib.
     546    my $get_tostring_fn = sub { $args{get_tostring}->() };
     547    my $set_fromstring_fn = sub {
     548      my ($dummy, $val) = @_;
     549      # Translate from user-supplied die-on-failure callback to expected
     550      # non-zero on error. Less of a nuisance than interacting with ERRSV.
     551      eval { $args{set_fromstring}->($val) };
     552      # TODO: Consider changing B::I::new_variable to expect string|NULL with
     553      # string as the error message. That can then be translated to a GError in
     554      # owl_variable_set_fromstring. For now the string is ignored.
     555      return ($@ ? -1 : 0);
     556    };
     557
     558    BarnOwl::Internal::new_variable($name, $args{summary}, $args{description}, $args{validsettings},
     559                                    $args{takes_on_off}, $get_tostring_fn, $set_fromstring_fn, undef);
    370560}
    371561
  • perl/lib/BarnOwl/Complete/Client.pm

    r58f4fb2 r4626016  
    2020
    2121my %show = (
    22     information => undef,
    2322    colors      => undef,
    2423    commands    => undef,
     
    205204BarnOwl::Completion::register_completer(set     => \&complete_set);
    206205BarnOwl::Completion::register_completer(unset   => \&complete_set);
    207 BarnOwl::Completion::register_completer(startup => \&complete_startup);
     206BarnOwl::Completion::register_completer(startup   => \&complete_startup);
     207BarnOwl::Completion::register_completer(unstartup => \&complete_startup);
    208208BarnOwl::Completion::register_completer(bindkey => \&complete_bindkey);
    209209BarnOwl::Completion::register_completer(print   => \&complete_print);
  • perl/lib/BarnOwl/Complete/Zephyr.pm

    r3e8625f re6e7842  
    6464BarnOwl::Completion::register_completer(viewuser  => \&complete_viewuser);
    6565BarnOwl::Completion::register_completer(vu        => \&complete_viewuser);
     66BarnOwl::Completion::register_completer(viewperson => \&complete_viewuser);
     67BarnOwl::Completion::register_completer(vp        => \&complete_viewuser);
    6668
    6769BarnOwl::Completion::register_completer(unsub     => \&complete_unsub);
  • perl/lib/BarnOwl/Message.pm

    ra130fc5 r0adbce1  
    5151sub is_ping     { return 0; }
    5252sub is_mail     { return 0; }
    53 sub is_personal { return shift->is_private; }
     53sub is_personal { return BarnOwl::message_matches_filter(shift, "personal"); }
    5454sub class       { return undef; }
    5555sub instance    { return undef; }
  • perl/lib/BarnOwl/Message/Zephyr.pm

    redd0be7 r0adbce1  
    5151    my ($m) = @_;
    5252    return undef if (!$m->is_loginout);
     53    return undef if (!defined($m->fields));
    5354    return $m->fields->[2];
    5455}
     
    5758    my ($m) = @_;
    5859    return undef if (!$m->is_loginout);
     60    return undef if (!defined($m->fields));
    5961    return $m->fields->[0];
    6062}
     
    6365
    6466sub is_ping     { return (lc(shift->opcode) eq "ping"); }
    65 
    66 sub is_personal {
    67     my ($m) = @_;
    68     return ((lc($m->class) eq "message")
    69             && $m->is_private);
    70 }
    7167
    7268sub is_mail {
     
    171167        $class = $self->class;
    172168        $instance = $self->instance;
    173         if ($self->recipient eq '*' || $self->recipient eq '') {
    174             $to = '';
    175         } elsif ($self->recipient =~ /^@/) {
     169        if ($self->recipient eq '' || $self->recipient =~ /^@/) {
    176170            $to = $self->recipient;
    177171        } else {
  • perl/lib/BarnOwl/ModuleLoader.pm

    rf544216 rf34728b  
    127127}
    128128
     129sub complete_module_name {
     130    return sort(keys %modules);
     131}
     132
    129133sub register_keybindings {
    130134    BarnOwl::new_command('reload-modules', sub {BarnOwl::ModuleLoader->reload}, {
     
    138142                           description => q{Reloads a single module located in ~/.owl/modules or the system modules directory}
    139143                          });
     144
     145    BarnOwl::Completion::register_completer('reload-module', \&complete_module_name);
    140146}
    141147
  • perl/lib/BarnOwl/Style/Default.pm

    r5738650 r732d5c0  
    113113        }
    114114        $header .= '@b{' . maybe($m->pretty_sender) . '}';
     115        if (defined($m->realm) && $m->realm ne BarnOwl::zephyr_getrealm()) {
     116            $header .= ' {' . $self->humanize($m->realm, 1) . '}';
     117        }
    115118    }
    116119
  • perl/lib/BarnOwl/Zephyr.pm

    rdf569c5 r53151d4  
    1212use BarnOwl::Hook;
    1313
    14 my $zephyrStartup = BarnOwl::Hook->new;
     14our $zephyrStartup = BarnOwl::Hook->new;
    1515
    1616sub _zephyr_startup {
  • perl/lib/Module/Install/BarnOwl.pm

    rb8a3e00 re4b8f93  
    4141    my $class = ref $self;
    4242
     43    my $srcdir = $ENV{BARNOWL_SRCDIR} || '.';
     44
    4345    $self->name("BarnOwl-Module-$name");
    44     $self->all_from("lib/BarnOwl/Module/$name.pm");
     46    $self->all_from("$srcdir/lib/BarnOwl/Module/$name.pm");
     47    $self->makemaker_args(PMLIBDIRS => ["$srcdir/lib"],
     48                          PMLIBPARENTDIRS => ["$srcdir/lib"]);
    4549
    4650    $self->postamble(<<"END_MAKEFILE");
    4751
    4852# --- $class section:
     53
     54BARNOWL_SRCDIR = $srcdir
     55export BARNOWL_SRCDIR
    4956
    5057$name.par: pm_to_blib
  • perl/modules/IRC/lib/BarnOwl/Module/IRC.pm

    rb8a3e00 r731e921  
    2323use Getopt::Long;
    2424use Encode;
     25use Text::Wrap;
    2526
    2627our $VERSION = 0.02;
     
    6566        description => 'If set, each (space-separated) message type ' .
    6667        'provided will be hidden and ignored if received.'
     68       });
     69
     70    BarnOwl::new_variable_int('irc:max-message-length', {
     71        default     => 450,
     72        summary     => 'Split messages to at most this many characters.' .
     73                       "If non-positive, don't split messages",
     74        description => 'If set to a positive number, any paragraph in an ' .
     75                       'IRC message will be split after this many characters.'
    6776       });
    6877
     
    427436    @msgs = split "\n\n", $fullbody;
    428437    map { tr/\n/ / } @msgs;
     438    # split each body at irc:max-message-length characters, if that number
     439    # is positive.  Only split at space boundaries.  Start counting a-fresh
     440    # at the beginning of each paragraph
     441    my $max_len = BarnOwl::getvar('irc:max-message-length');
     442    if ($max_len > 0) {
     443        local($Text::Wrap::columns) = $max_len;
     444        @msgs = split "\n", wrap("", "", join "\n", @msgs);
     445    }
    429446    for my $body (@msgs) {
    430447        if ($body =~ /^\/me (.*)/) {
     
    598615        }
    599616
    600         if(!$channel &&
     617        if(!defined($channel) &&
    601618           ($flags & CHANNEL_ARG) &&
    602619           !($flags & CHANNEL_OPTIONAL)) {
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm

    rb8a3e00 r8258ea5  
    320320              . "configure [<muc>]\n"
    321321              . "            Configures a MUC.\n"
    322               . "            Necessary to initalize a new MUC.\n"
     322              . "            Necessary to initialize a new MUC.\n"
    323323              . "            At present, only the default configuration is supported.\n"
    324324              . "            The MUC is taken from the current message if not supplied.\n\n"
     
    14821482}
    14831483
     1484sub complete_jabberlogout {
     1485    my $ctx = shift;
     1486    if($ctx->word == 1) {
     1487        return ("-A", complete_account() );
     1488    } else {
     1489        return ();
     1490    }
     1491}
     1492
    14841493BarnOwl::Completion::register_completer(jwrite => sub { BarnOwl::Module::Jabber::complete_jwrite(@_) });
     1494BarnOwl::Completion::register_completer(jabberlogout => sub { BarnOwl::Module::Jabber::complete_jabberlogout(@_) });
    14851495
    148614961;
  • perl/modules/Jabber/lib/Net/Jabber/Component.pm

    rc2bed55 ra8c55b5  
    220220    $self->{STREAM}->SetCallBacks(node=>undef);
    221221
    222     $self->Send("<handshake>".Digest::SHA1::sha1_hex($self->{SESSION}->{id}.$args{secret})."</handshake>");
     222    $self->Send("<handshake>".Digest::SHA::sha1_hex($self->{SESSION}->{id}.$args{secret})."</handshake>");
    223223    my $handshake = $self->Process();
    224224
  • perl/modules/Jabber/lib/Net/Jabber/Key.pm

    rc2bed55 ra8c55b5  
    104104    $self->{CACHE} = {};
    105105
    106     if (eval "require Digest::SHA1")
     106    if (eval "require Digest::SHA")
    107107    {
    108108        $self->{DIGEST} = 1;
    109         Digest::SHA1->import(qw(sha1 sha1_hex sha1_base64));
     109        Digest::SHA->import(qw(sha1 sha1_hex sha1_base64));
    110110    }
    111111    else
    112112    {
    113         print "ERROR:  You cannot use Key.pm unless you have Digest::SHA1 installed.\n";
     113        print "ERROR:  You cannot use Key.pm unless you have Digest::SHA installed.\n";
    114114        exit(0);
    115115    }
     
    132132
    133133    my $string = $$.time.rand(1000000);
    134     $string = Digest::SHA1::sha1_hex($string);
     134    $string = Digest::SHA::sha1_hex($string);
    135135    $self->{DEBUG}->Log1("Generate: key($string)");
    136136    return $string;
  • perl/modules/Jabber/lib/Net/XMPP.pm

    rc2bed55 ra8c55b5  
    213213use Time::Local;
    214214use Carp;
    215 use Digest::SHA1;
     215use Digest::SHA;
    216216use Authen::SASL;
    217217use MIME::Base64;
  • perl/modules/Jabber/lib/Net/XMPP/Protocol.pm

    r7f33c18 ra8c55b5  
    18491849    if ($authType eq "zerok")
    18501850    {
    1851         my $hashA = Digest::SHA1::sha1_hex($password);
    1852         $args{hash} = Digest::SHA1::sha1_hex($hashA.$token);
     1851        my $hashA = Digest::SHA::sha1_hex($password);
     1852        $args{hash} = Digest::SHA::sha1_hex($hashA.$token);
    18531853
    18541854        for (1..$sequence)
    18551855        {
    1856             $args{hash} = Digest::SHA1::sha1_hex($args{hash});
     1856            $args{hash} = Digest::SHA::sha1_hex($args{hash});
    18571857        }
    18581858    }
     
    18681868    if ($authType eq "digest")
    18691869    {
    1870         $args{digest} = Digest::SHA1::sha1_hex($self->GetStreamID().$password);
     1870        $args{digest} = Digest::SHA::sha1_hex($self->GetStreamID().$password);
    18711871    }
    18721872
  • perl/modules/Makefile.am

    r1fd469d4 re4b8f93  
    1 MODULES = Jabber IRC WordWrap Twitter
     1MODULES = Jabber IRC WordWrap Twitter Facebook
    22
    3 EXTRA_DIST = $(MODULES:=/Makefile.PL) $(MODULES:=/inc) $(MODULES:=/lib)
     3EXTRA_DIST = $(MODULES:=/Makefile.PL) $(MODULES:=/lib)
     4EXTRA_DIST += \
     5    Facebook/README \
     6    Twitter/README \
     7    Twitter/twitter.example
    48
    59all-local: $(MODULES)
     
    711        (cd $* && $(MAKE) $*.par)
    812
     13BARNOWL_PERL := $(shell which perl) -I$(abs_srcdir)/../lib
     14
    915MODULES_MAKEFILE = $(MODULES:=/Makefile)
    10 $(MODULES_MAKEFILE): %/Makefile: %/Makefile.PL
    11         $(AM_V_GEN)(cd $* && perl -I../../lib Makefile.PL)
     16$(MODULES_MAKEFILE): %/Makefile: %/Makefile.PL ../lib/Module/Install/BarnOwl.pm
     17        $(AM_V_GEN)test -d $* || mkdir $*
     18        $(AM_V_at)test $(srcdir) = . || $(LN_S) $(abs_srcdir)/$*/Makefile.PL $*/Makefile.PL
     19        $(AM_V_at)(cd $* && BARNOWL_SRCDIR='$(abs_srcdir)/$*' && export BARNOWL_SRCDIR && $(BARNOWL_PERL) Makefile.PL 'PERL=$(BARNOWL_PERL)')
    1220
    1321MODULES_CLEAN = $(MODULES:%=clean_%)
    1422clean-local: $(MODULES_CLEAN)
    1523$(MODULES_CLEAN): clean_%:
    16         (cd $* && (test ! -f Makefile || $(MAKE) clean))
     24        (cd $* && { test ! -f Makefile || $(MAKE) realclean; })
     25        rm -f $*/$*.par
     26        rm -rf $*/inc
     27        test $(srcdir) = . || rm -f $*/Makefile.PL
    1728
    1829MODULES_INSTALL = $(MODULES:%=module_install_%)
     
    2334        ${INSTALL_DATA} $*/$*.par ${DESTDIR}${pkgdatadir}/modules/$*.par
    2435
     36uninstall-local:
     37        rm -f $(MODULES:%=${DESTDIR}${pkgdatadir}/modules/%.par)
     38
    2539.PHONY: $(MODULES) $(MODULES_CLEAN) $(MODULES_INSTALL)
  • perlconfig.c

    rdde1b4d r96d80e9  
    1 #include <stdio.h>
    2 #include <stdlib.h>
    3 #include <string.h>
    4 #include <sys/types.h>
    5 #include <sys/stat.h>
    6 #include <errno.h>
    71#define OWL_PERL
    82#include "owl.h"
     3#include <stdio.h>
    94
    105extern XS(boot_BarnOwl);
     
    8075  const char *type;
    8176  char *ptr, *utype, *blessas;
    82   int i, j;
     77  const char *f;
     78  int i;
    8379  const owl_pair *pair;
    8480  const owl_filter *wrap;
     
    9692                                      owl_new_sv(owl_message_get_##field(m)), 0)
    9793
    98   if (owl_message_is_type_zephyr(m)
    99       && owl_message_is_direction_in(m)) {
     94  if (owl_message_is_type_zephyr(m) && owl_message_is_direction_in(m)) {
    10095    /* Handle zephyr-specific fields... */
    101     AV *av_zfields;
    102 
    103     av_zfields = newAV();
    104     j=owl_zephyr_get_num_fields(owl_message_get_notice(m));
    105     for (i=0; i<j; i++) {
    106       ptr=owl_zephyr_get_field_as_utf8(owl_message_get_notice(m), i+1);
    107       av_push(av_zfields, owl_new_sv(ptr));
    108       g_free(ptr);
     96    AV *av_zfields = newAV();
     97    if (owl_message_get_notice(m)) {
     98      for (f = owl_zephyr_first_raw_field(owl_message_get_notice(m)); f != NULL;
     99           f = owl_zephyr_next_raw_field(owl_message_get_notice(m), f)) {
     100        ptr = owl_zephyr_field_as_utf8(owl_message_get_notice(m), f);
     101        av_push(av_zfields, owl_new_sv(ptr));
     102        g_free(ptr);
     103      }
     104      (void)hv_store(h, "auth", strlen("auth"),
     105                     owl_new_sv(owl_zephyr_get_authstr(owl_message_get_notice(m))), 0);
     106    } else {
     107      /* Incoming zephyrs without a ZNotice_t are pseudo-logins. To appease
     108       * existing styles, put in bogus 'auth' and 'fields' keys. */
     109      (void)hv_store(h, "auth", strlen("auth"), owl_new_sv("NO"), 0);
    109110    }
    110111    (void)hv_store(h, "fields", strlen("fields"), newRV_noinc((SV*)av_zfields), 0);
    111 
    112     (void)hv_store(h, "auth", strlen("auth"),
    113                    owl_new_sv(owl_zephyr_get_authstr(owl_message_get_notice(m))),0);
    114112  }
    115113
     
    178176   message2hashref and hashref2message. Currently we lose
    179177   zephyr-specific properties stored in the ZNotice_t
    180 
    181    This has been somewhat addressed, but is still not lossless.
    182178 */
    183179CALLER_OWN owl_message *owl_perlconfig_hashref2message(SV *msg)
     
    225221      owl_message_set_attribute(m, "adminheader", "");
    226222  }
    227 #ifdef HAVE_LIBZEPHYR
    228   if (owl_message_is_type_zephyr(m)) {
    229     ZNotice_t *n = &(m->notice);
    230     n->z_kind = ACKED;
    231     n->z_port = 0;
    232     n->z_auth = ZAUTH_NO;
    233     n->z_checked_auth = 0;
    234     n->z_class = zstr(owl_message_get_class(m));
    235     n->z_class_inst = zstr(owl_message_get_instance(m));
    236     n->z_opcode = zstr(owl_message_get_opcode(m));
    237     n->z_sender = zstr(owl_message_get_sender(m));
    238     n->z_recipient = zstr(owl_message_get_recipient(m));
    239     n->z_default_format = zstr("[zephyr created from perl]");
    240     n->z_multinotice = zstr("[zephyr created from perl]");
    241     n->z_num_other_fields = 0;
    242     n->z_message = g_strdup_printf("%s%c%s", owl_message_get_zsig(m), '\0', owl_message_get_body(m));
    243     n->z_message_len = strlen(owl_message_get_zsig(m)) + strlen(owl_message_get_body(m)) + 1;
    244   }
    245 #endif
    246223  return m;
    247224}
     
    251228CALLER_OWN char *owl_perlconfig_call_with_message(const char *subname, const owl_message *m)
    252229{
    253   dSP ;
    254   int count;
    255   SV *msgref, *srv;
    256   char *out;
    257  
    258   ENTER ;
    259   SAVETMPS;
    260  
    261   PUSHMARK(SP) ;
     230  SV *msgref, *rv;
     231  char *out = NULL;
     232
    262233  msgref = owl_perlconfig_message2hashref(m);
    263   XPUSHs(sv_2mortal(msgref));
    264   PUTBACK ;
    265  
    266   count = call_pv(subname, G_SCALAR|G_EVAL);
    267  
    268   SPAGAIN ;
    269 
    270   if (SvTRUE(ERRSV)) {
    271     owl_function_error("Perl Error: '%s'", SvPV_nolen(ERRSV));
    272     /* and clear the error */
    273     sv_setsv (ERRSV, &PL_sv_undef);
    274   }
    275 
    276   if (count != 1) {
    277     fprintf(stderr, "bad perl!  no biscuit!  returned wrong count!\n");
    278     abort();
    279   }
    280 
    281   srv = POPs;
    282 
    283   if (srv) {
    284     out = g_strdup(SvPV_nolen(srv));
    285   } else {
    286     out = NULL;
    287   }
    288  
    289   PUTBACK ;
    290   FREETMPS ;
    291   LEAVE ;
    292 
     234
     235  OWL_PERL_CALL((call_pv(subname, G_SCALAR|G_EVAL))
     236                ,
     237                XPUSHs(sv_2mortal(msgref));
     238                ,
     239                "Perl Error: '%s'"
     240                ,
     241                false
     242                ,
     243                false
     244                ,
     245                rv = POPs;
     246                if (rv && SvPOK(rv))
     247                  out = g_strdup(SvPV_nolen(rv));
     248                );
    293249  return out;
    294250}
     
    300256CALLER_OWN char *owl_perlconfig_message_call_method(const owl_message *m, const char *method, int argc, const char **argv)
    301257{
    302   dSP;
    303   unsigned int count, i;
    304   SV *msgref, *srv;
    305   char *out;
     258  SV *msgref, *rv;
     259  char *out = NULL;
     260  int i;
    306261
    307262  msgref = owl_perlconfig_message2hashref(m);
    308263
    309   ENTER;
    310   SAVETMPS;
    311 
    312   PUSHMARK(SP);
    313   XPUSHs(sv_2mortal(msgref));
    314   for(i=0;i<argc;i++) {
    315     XPUSHs(sv_2mortal(owl_new_sv(argv[i])));
    316   }
    317   PUTBACK;
    318 
    319   count = call_method(method, G_SCALAR|G_EVAL);
    320 
    321   SPAGAIN;
    322 
    323   if(count != 1) {
    324     fprintf(stderr, "perl returned wrong count %u\n", count);
    325     abort();
    326   }
    327 
    328   if (SvTRUE(ERRSV)) {
    329     owl_function_error("Error: '%s'", SvPV_nolen(ERRSV));
    330     /* and clear the error */
    331     sv_setsv (ERRSV, &PL_sv_undef);
    332   }
    333 
    334   srv = POPs;
    335 
    336   if (srv) {
    337     out = g_strdup(SvPV_nolen(srv));
    338   } else {
    339     out = NULL;
    340   }
    341 
    342   PUTBACK;
    343   FREETMPS;
    344   LEAVE;
    345 
     264  OWL_PERL_CALL(call_method(method, G_SCALAR|G_EVAL)
     265                ,
     266                XPUSHs(sv_2mortal(msgref));
     267                OWL_PERL_PUSH_ARGS(i, argc, argv);
     268                ,
     269                "Perl Error: '%s'"
     270                ,
     271                false
     272                ,
     273                false
     274                ,
     275                rv = POPs;
     276                if (rv && SvPOK(rv))
     277                  out = g_strdup(SvPV_nolen(rv));
     278                );
    346279  return out;
    347280}
     
    354287  char *err;
    355288  const char *args[4] = {"", "-e", "0;", NULL};
     289  const char *dlerr;
    356290  AV *inc;
    357291  char *path;
     
    411345  g_free(path);
    412346
     347  /* Load up perl-Glib. */
     348  eval_pv("use Glib;", FALSE);
     349
     350  /* Now, before BarnOwl tries to use them, get the relevant function pointers out. */
     351  dlerr = owl_closure_init();
     352  if (dlerr) {
     353    return g_strdup(dlerr);
     354  }
     355
     356  /* And now it's safe to import BarnOwl. */
    413357  eval_pv("use BarnOwl;", FALSE);
    414358
     
    482426void owl_perlconfig_new_command(const char *name)
    483427{
    484   dSP;
    485 
    486   ENTER;
    487   SAVETMPS;
    488 
    489   PUSHMARK(SP);
    490   XPUSHs(sv_2mortal(owl_new_sv(name)));
    491   PUTBACK;
    492 
    493   call_pv("BarnOwl::Hooks::_new_command", G_VOID|G_EVAL);
    494 
    495   SPAGAIN;
    496 
    497   if(SvTRUE(ERRSV)) {
    498     owl_function_error("%s", SvPV_nolen(ERRSV));
    499   }
    500 
    501   FREETMPS;
    502   LEAVE;
     428  OWL_PERL_CALL(call_pv("BarnOwl::Hooks::_new_command", G_VOID|G_EVAL);
     429                ,
     430                XPUSHs(sv_2mortal(owl_new_sv(name)));
     431                ,
     432                "Perl Error: '%s'"
     433                ,
     434                false
     435                ,
     436                true
     437                ,
     438                );
     439}
     440
     441CALLER_OWN char *owl_perlconfig_perl_call(const char *method, int argc, const char *const *argv)
     442{
     443  SV *rv;
     444  char *out = NULL;
     445  int i;
     446  OWL_PERL_CALL(call_pv(method, G_SCALAR|G_EVAL)
     447                ,
     448                OWL_PERL_PUSH_ARGS(i, argc, argv);
     449                ,
     450                "Perl Error: '%s'"
     451                ,
     452                false
     453                ,
     454                false
     455                ,
     456                rv = POPs;
     457                if (rv && SvPOK(rv))
     458                  out = g_strdup(SvPV_nolen(rv));
     459                );
     460  return out;
     461}
     462
     463int owl_perlconfig_perl_call_int(const char *method, int argc, const char *const *argv)
     464{
     465  SV *rv;
     466  int ret = -1;
     467  int i;
     468  OWL_PERL_CALL(call_pv(method, G_SCALAR|G_EVAL)
     469                ,
     470                OWL_PERL_PUSH_ARGS(i, argc, argv);
     471                ,
     472                "Perl Error: '%s'"
     473                ,
     474                false
     475                ,
     476                false
     477                ,
     478                rv = POPs;
     479                if (rv && SvIOK(rv))
     480                  ret = SvIV(rv);
     481                );
     482  return ret;
     483}
     484
     485bool owl_perlconfig_perl_call_bool(const char *method, int argc, const char *const *argv)
     486{
     487  SV *rv;
     488  bool ret = false;
     489  int i;
     490  OWL_PERL_CALL(call_pv(method, G_SCALAR|G_EVAL)
     491                ,
     492                OWL_PERL_PUSH_ARGS(i, argc, argv);
     493                ,
     494                "Perl Error: '%s'"
     495                ,
     496                false
     497                ,
     498                false
     499                ,
     500                rv = POPs;
     501                if (rv)
     502                  ret = SvTRUE(rv);
     503                );
     504  return ret;
     505}
     506
     507void owl_perlconfig_perl_call_norv(const char *method, int argc, const char *const *argv)
     508{
     509  int i;
     510  OWL_PERL_CALL(call_pv(method, G_DISCARD|G_EVAL)
     511                ,
     512                OWL_PERL_PUSH_ARGS(i, argc, argv);
     513                ,
     514                "Perl Error: '%s'"
     515                ,
     516                false
     517                ,
     518                true
     519                ,
     520                );
    503521}
    504522
     
    506524CALLER_OWN char *owl_perlconfig_perlcmd(const owl_cmd *cmd, int argc, const char *const *argv)
    507525{
    508   int i, count;
    509   char * ret = NULL;
    510   SV *rv;
    511   dSP;
    512 
    513   ENTER;
    514   SAVETMPS;
    515 
    516   PUSHMARK(SP);
    517   for(i=0;i<argc;i++) {
    518     XPUSHs(sv_2mortal(owl_new_sv(argv[i])));
    519   }
    520   PUTBACK;
    521 
    522   count = call_sv(cmd->cmd_perl, G_SCALAR|G_EVAL);
    523 
    524   SPAGAIN;
    525 
    526   if(SvTRUE(ERRSV)) {
    527     owl_function_error("%s", SvPV_nolen(ERRSV));
    528     (void)POPs;
    529   } else {
    530     if(count != 1)
    531       croak("Perl command %s returned more than one value!", cmd->name);
    532     rv = POPs;
    533     if(SvTRUE(rv)) {
    534       ret = g_strdup(SvPV_nolen(rv));
    535     }
    536   }
    537 
    538   FREETMPS;
    539   LEAVE;
    540 
    541   return ret;
     526  int i;
     527  SV* rv;
     528  char *out = NULL;
     529
     530  OWL_PERL_CALL(call_sv(cmd->cmd_perl, G_SCALAR|G_EVAL)
     531                ,
     532                OWL_PERL_PUSH_ARGS(i, argc, argv);
     533                ,
     534                "Perl Error: '%s'"
     535                ,
     536                false
     537                ,
     538                false
     539                ,
     540                rv = POPs;
     541                if (rv && SvPOK(rv))
     542                  out = g_strdup(SvPV_nolen(rv));
     543                );
     544  return out;
    542545}
    543546
     
    547550}
    548551
    549 void owl_perlconfig_edit_callback(owl_editwin *e)
     552void owl_perlconfig_edit_callback(owl_editwin *e, bool success)
    550553{
    551554  SV *cb = owl_editwin_get_cbdata(e);
    552   SV *text;
    553   dSP;
    554 
    555   if(cb == NULL) {
     555  SV *text = owl_new_sv(owl_editwin_get_text(e));
     556
     557  if (cb == NULL) {
    556558    owl_function_error("Perl callback is NULL!");
    557559    return;
    558560  }
    559   text = owl_new_sv(owl_editwin_get_text(e));
    560 
    561   ENTER;
    562   SAVETMPS;
    563 
    564   PUSHMARK(SP);
    565   XPUSHs(sv_2mortal(text));
    566   PUTBACK;
    567  
    568   call_sv(cb, G_DISCARD|G_EVAL);
    569 
    570   if(SvTRUE(ERRSV)) {
    571     owl_function_error("%s", SvPV_nolen(ERRSV));
    572   }
    573 
    574   FREETMPS;
    575   LEAVE;
     561
     562  OWL_PERL_CALL(call_sv(cb, G_DISCARD|G_EVAL)
     563                ,
     564                XPUSHs(sv_2mortal(text));
     565                XPUSHs(sv_2mortal(newSViv(success)));
     566                ,
     567                "Perl Error: '%s'"
     568                ,
     569                false
     570                ,
     571                true
     572                ,
     573                );
    576574}
    577575
  • perlglue.xs

    ra130fc5 r1ced34f  
    11/* -*- mode: c; indent-tabs-mode: t; c-basic-offset: 8 -*- */
    2 #ifdef HAVE_LIBZEPHYR
    3 #include <zephyr/zephyr.h>
    4 #endif
    5 #include <EXTERN.h>
    6 
    72#define OWL_PERL
    83#include "owl.h"
     
    7267        OUTPUT:
    7368                RETVAL
    74                
     69
     70int
     71getnumlines()
     72        CODE:
     73                RETVAL = owl_global_get_lines(&g);
     74        OUTPUT:
     75                RETVAL
     76
    7577time_t
    7678getidletime()
     
    9395        OUTPUT:
    9496                RETVAL
    95 
    96 void
    97 zephyr_zwrite(cmd,msg)
    98         const char *cmd
    99         const char *msg
    100         PREINIT:
    101                 int i;
    102         CODE:
    103                 i = owl_zwrite_create_and_send_from_line(cmd, msg);
    10497
    10598const utf8 *
     
    170163        {
    171164                owl_function_adminmsg(header, body);           
    172         }
    173 
    174 void
    175 start_question(line, callback)
    176         const char *line
    177         SV *callback
    178         PREINIT:
    179                 owl_editwin *e;
    180         CODE:
    181         {
    182                 if(!SV_IS_CODEREF(callback))
    183                         croak("Callback must be a subref");
    184 
    185                 e = owl_function_start_question(line);
    186 
    187                 owl_editwin_set_cbdata(e,
    188                                        newSVsv(callback),
    189                                        owl_perlconfig_dec_refcnt);
    190                 owl_editwin_set_callback(e, owl_perlconfig_edit_callback);
    191         }
    192 
    193 void
    194 start_password(line, callback)
    195         const char *line
    196         SV *callback
    197         PREINIT:
    198                 owl_editwin *e;
    199         CODE:
    200         {
    201                 if(!SV_IS_CODEREF(callback))
    202                         croak("Callback must be a subref");
    203 
    204                 e = owl_function_start_password(line);
    205 
    206                 owl_editwin_set_cbdata(e,
    207                                        newSVsv(callback),
    208                                        owl_perlconfig_dec_refcnt);
    209                 owl_editwin_set_callback(e, owl_perlconfig_edit_callback);
    210         }
    211 
    212 void
    213 start_edit_win(line, callback)
    214         const char *line
    215         SV *callback
    216         CODE:
    217         {
    218                 if(!SV_IS_CODEREF(callback))
    219                         croak("Callback must be a subref");
    220 
    221                 owl_function_start_edit_win(line,
    222                                             owl_perlconfig_edit_callback,
    223                                             newSVsv(callback),
    224                                             owl_perlconfig_dec_refcnt);
    225165        }
    226166
     
    315255                }
    316256        }
     257
     258bool
     259message_matches_filter(message, filter_name, quiet = false)
     260        SV *message
     261        const char *filter_name
     262        bool quiet
     263        PREINIT:
     264                owl_message *m;
     265                const owl_filter *f;
     266        CODE:
     267        {
     268                if (!SvROK(message) || SvTYPE(SvRV(message)) != SVt_PVHV) {
     269                        croak("Usage: BarnOwl::message_matches_filter($message, $filter_name[, $quiet])");
     270                }
     271
     272                m = owl_perlconfig_hashref2message(message);
     273                f = owl_global_get_filter(&g, filter_name);
     274                if (!f && !quiet) {
     275                        owl_function_error("%s filter is not defined", filter_name);
     276                }
     277                RETVAL = f && owl_filter_message_match(f, m);
     278        }
     279        OUTPUT:
     280                RETVAL
     281        CLEANUP:
     282                owl_message_delete(m);
    317283
    318284const utf8 *
     
    462428           }
    463429
    464 void
    465 new_variable_string(name, ival, summ, desc)
    466         const char * name
    467         const char * ival
    468         const char * summ
    469         const char * desc
    470         CODE:
    471         owl_variable_dict_newvar_string(owl_global_get_vardict(&g),
    472                                         name,
    473                                         summ,
    474                                         desc,
    475                                         ival);
    476 
    477 void
    478 new_variable_int(name, ival, summ, desc)
    479         const char * name
    480         int ival
    481         const char * summ
    482         const char * desc
    483         CODE:
    484         owl_variable_dict_newvar_int(owl_global_get_vardict(&g),
    485                                      name,
    486                                      summ,
    487                                      desc,
    488                                      ival);
    489 
    490 void
    491 new_variable_bool(name, ival, summ, desc)
    492         const char * name
    493         int ival
    494         const char * summ
    495         const char * desc
    496         CODE:
    497         owl_variable_dict_newvar_bool(owl_global_get_vardict(&g),
    498                                       name,
    499                                       summ,
    500                                       desc,
    501                                       ival);
     430
     431MODULE = BarnOwl                PACKAGE = BarnOwl::Internal
     432
     433void
     434new_variable(name, summary, description, validsettings, takes_on_off, get_tostring_fn, set_fromstring_fn, data)
     435    const char *name
     436    const char *summary
     437    const char *description
     438    const char *validsettings
     439    int takes_on_off
     440    SV *get_tostring_fn
     441    SV *set_fromstring_fn
     442    SV *data
     443    CODE:
     444{
     445        /* data is somewhat redundant given we can create closures, but oh
     446         * well. Might be convenient sometimes. */
     447        if(!SV_IS_CODEREF(get_tostring_fn)) {
     448                croak("To-string function must be a coderef!");
     449        }
     450        if(!SV_IS_CODEREF(set_fromstring_fn)) {
     451                croak("From-string function must be a coderef!");
     452        }
     453
     454        owl_variable_dict_newvar_other(owl_global_get_vardict(&g),
     455                                       name, summary, description, validsettings, takes_on_off,
     456                                       perl_closure_new(get_tostring_fn, data, false),
     457                                       perl_closure_new(set_fromstring_fn, data, false));
     458}
     459
     460void
     461start_edit(edit_type, line, callback)
     462        const char *edit_type
     463        const char *line
     464        SV *callback
     465        PREINIT:
     466                owl_editwin *e;
     467        CODE:
     468        {
     469                if (!SV_IS_CODEREF(callback))
     470                        croak("Callback must be a subref");
     471
     472                if (!strcmp(edit_type, "question"))
     473                        e = owl_function_start_question(line);
     474                else if (!strcmp(edit_type, "password"))
     475                        e = owl_function_start_password(line);
     476                else if (!strcmp(edit_type, "edit_win"))
     477                        e = owl_function_start_edit_win(line);
     478                else
     479                        croak("edit_type must be one of 'password', 'question', 'edit_win', not '%s'", edit_type);
     480
     481                owl_editwin_set_cbdata(e, newSVsv(callback), owl_perlconfig_dec_refcnt);
     482                owl_editwin_set_callback(e, owl_perlconfig_edit_callback);
     483        }
     484
     485int
     486zephyr_zwrite(cmd,msg)
     487        const char *cmd
     488        const char *msg
     489        CODE:
     490                RETVAL = owl_zwrite_create_and_send_from_line(cmd, msg);
     491        OUTPUT:
     492                RETVAL
    502493
    503494MODULE = BarnOwl                PACKAGE = BarnOwl::Editwin
  • regex.c

    rcbc8657 rf271129  
    1 #include <string.h>
    21#include "owl.h"
    32
  • runtests.sh

    rf6ab6ee r5db8835  
    11#!/bin/sh
    2 exec env HARNESS_PERL=./tester prove --failures t/
     2exec env HARNESS_PERL=./tester prove --failures "${srcdir:=$(dirname "$0")}/t/"
  • style.c

    r14be3a5 r92ffd89  
    2323{
    2424  SV *sv = NULL;
    25   OWL_PERL_CALL_METHOD(s->perlobj,
    26                        "description",
    27                        ;,
    28                        "Error in style_get_description: %s",
    29                        0,
    30                        sv = SvREFCNT_inc(POPs);
    31                        );
    32   if(sv) {
     25  OWL_PERL_CALL(call_method("description", G_SCALAR|G_EVAL),
     26                XPUSHs(s->perlobj);,
     27                "Error in style_get_description: %s",
     28                0,
     29                false,
     30                sv = SvREFCNT_inc(POPs);
     31                );
     32  if (sv) {
    3333    return SvPV_nolen(sv_2mortal(sv));
    3434  } else {
     
    5050 
    5151  /* Call the perl object */
    52   OWL_PERL_CALL_METHOD(s->perlobj,
    53                        "format_message",
    54                        XPUSHs(sv_2mortal(owl_perlconfig_message2hashref(m)));,
    55                        "Error in format_message: %s",
    56                        0,
    57                        sv = SvREFCNT_inc(POPs);
    58                        );
     52  OWL_PERL_CALL(call_method("format_message", G_SCALAR|G_EVAL),
     53                XPUSHs(s->perlobj);
     54                XPUSHs(sv_2mortal(owl_perlconfig_message2hashref(m)));,
     55                "Error in format_message: %s",
     56                0,
     57                false,
     58                sv = SvREFCNT_inc(POPs);
     59                );
    5960
    60   if(sv) {
     61  if (sv) {
    6162    body = SvPV_nolen(sv);
    6263  } else {
  • t/00-core-tests.t

    r95414bf r5db8835  
    11#!/usr/bin/env perl
    2 use File::Basename;
    3 system(dirname($0) . "/../tester", "--builtin");
     2system("./tester", "--builtin");
  • tester.c

    r67e5ba36 r6a8b519  
    33#include "owl.h"
    44#undef WINDOW
    5 
    6 #include <unistd.h>
     5#include "filterproc.h"
     6
    77#include <stdio.h>
    8 #include <stdlib.h>
    9 #include <string.h>
    108
    119#undef instr
     
    2624int owl_smartfilter_regtest(void);
    2725int owl_history_regtest(void);
     26int call_filter_regtest(void);
    2827
    2928extern void owl_perl_xs_init(pTHX);
     
    116115  numfailures += owl_smartfilter_regtest();
    117116  numfailures += owl_history_regtest();
     117  numfailures += call_filter_regtest();
    118118  if (numfailures) {
    119119      fprintf(stderr, "# *** WARNING: %d failures total\n", numfailures);
     
    133133{
    134134  int numfailed=0;
    135   char *s, *path, *home;
     135  char *path, *home;
    136136
    137137  printf("# BEGIN testing owl_util\n");
     
    229229
    230230
    231   s = owl_util_baseclass("barnowl");
    232   FAIL_UNLESS("baseclass barnowl", !strcmp("barnowl", s));
    233   g_free(s);
    234   s = owl_util_baseclass("unbarnowl");
    235   FAIL_UNLESS("baseclass unbarnowl", !strcmp("barnowl", s));
    236   g_free(s);
    237   s = owl_util_baseclass("unununbarnowl.d.d");
    238   FAIL_UNLESS("baseclass unununbarnowl.d.d", !strcmp("barnowl", s));
    239   g_free(s);
    240   s = owl_util_baseclass("ununun.d.d");
    241   FAIL_UNLESS("baseclass ununun.d.d", !strcmp("", s));
    242   g_free(s);
    243   s = owl_util_baseclass("d.d.d.d");
    244   FAIL_UNLESS("baseclass d.d.d.d", !strcmp("d", s));
    245   g_free(s);
    246   s = owl_util_baseclass("n.d.d.d");
    247   FAIL_UNLESS("baseclass n.d.d.d", !strcmp("n", s));
    248   g_free(s);
    249   s = owl_util_baseclass("ununun.");
    250   FAIL_UNLESS("baseclass ununun.", !strcmp(".", s));
    251   g_free(s);
    252   s = owl_util_baseclass("unununu");
    253   FAIL_UNLESS("baseclass unununu", !strcmp("u", s));
    254   g_free(s);
    255 
    256 
    257   s = owl_util_makepath("foo/bar");
    258   FAIL_UNLESS("makepath foo/bar", !strcmp("foo/bar", s));
    259   g_free(s);
    260   s = owl_util_makepath("//foo///bar");
    261   FAIL_UNLESS("makepath //foo///bar", !strcmp("/foo/bar", s));
    262   g_free(s);
    263   s = owl_util_makepath("foo/~//bar/");
    264   FAIL_UNLESS("makepath foo/~//bar/", !strcmp("foo/~/bar/", s));
    265   g_free(s);
    266   s = owl_util_makepath("~thisuserhadreallybetternotexist/foobar/");
    267   FAIL_UNLESS("makepath ~thisuserhadreallybetternotexist/foobar/",
    268               !strcmp("~thisuserhadreallybetternotexist/foobar/", s));
    269   g_free(s);
     231  CHECK_STR_AND_FREE("baseclass barnowl",
     232                     "barnowl", owl_util_baseclass("barnowl"));
     233  CHECK_STR_AND_FREE("baseclass unbarnowl",
     234                     "barnowl", owl_util_baseclass("unbarnowl"));
     235  CHECK_STR_AND_FREE("baseclass unununbarnowl.d.d",
     236                     "barnowl", owl_util_baseclass("unununbarnowl.d.d"));
     237  CHECK_STR_AND_FREE("baseclass ununun.d.d",
     238                     "", owl_util_baseclass("ununun.d.d"));
     239  CHECK_STR_AND_FREE("baseclass d.d.d.d",
     240                     "d", owl_util_baseclass("d.d.d.d"));
     241  CHECK_STR_AND_FREE("baseclass n.d.d.d",
     242                     "n", owl_util_baseclass("n.d.d.d"));
     243  CHECK_STR_AND_FREE("baseclass ununun.",
     244                     ".", owl_util_baseclass("ununun."));
     245  CHECK_STR_AND_FREE("baseclass unununu",
     246                     "u", owl_util_baseclass("unununu"));
     247
     248
     249  CHECK_STR_AND_FREE("makepath foo/bar",
     250                     "foo/bar", owl_util_makepath("foo/bar"));
     251  CHECK_STR_AND_FREE("makepath //foo///bar",
     252                     "/foo/bar", owl_util_makepath("//foo///bar"));
     253  CHECK_STR_AND_FREE("makepath foo/~//bar/",
     254                     "foo/~/bar/", owl_util_makepath("foo/~//bar/"));
     255  CHECK_STR_AND_FREE("makepath ~thisuserhadreallybetternotexist/foobar/",
     256                     "~thisuserhadreallybetternotexist/foobar/",
     257                     owl_util_makepath("~thisuserhadreallybetternotexist/foobar/"));
    270258
    271259  home = g_strdup(owl_global_get_homedir(&g));
    272   s = owl_util_makepath("~");
    273   FAIL_UNLESS("makepath ~", !strcmp(home, s));
    274   g_free(s);
     260  CHECK_STR_AND_FREE("makepath ~",
     261                     home, owl_util_makepath("~"));
    275262
    276263  path = g_build_filename(home, "foo/bar/baz", NULL);
    277   s = owl_util_makepath("~///foo/bar//baz");
    278   FAIL_UNLESS("makepath ~///foo/bar//baz", !strcmp(path, s));
    279   g_free(s);
     264  CHECK_STR_AND_FREE("makepath ~///foo/bar//baz",
     265                     path, owl_util_makepath("~///foo/bar//baz"));
    280266  g_free(path);
    281267  g_free(home);
     
    288274  }
    289275
    290   s = owl_util_makepath("~root");
    291   FAIL_UNLESS("makepath ~root", !strcmp(home, s));
    292   g_free(s);
     276  CHECK_STR_AND_FREE("makepath ~root",
     277                     home, owl_util_makepath("~root"));
    293278
    294279  path = g_build_filename(home, "foo/bar/baz", NULL);
    295   s = owl_util_makepath("~root///foo/bar//baz");
    296   FAIL_UNLESS("makepath ~root///foo/bar//baz", !strcmp(path, s));
    297   g_free(s);
     280  CHECK_STR_AND_FREE("makepath ~root///foo/bar//baz",
     281                     path, owl_util_makepath("~root///foo/bar//baz"));
    298282  g_free(path);
    299283  g_free(home);
     
    353337  int numfailed=0;
    354338  char *value;
    355   const void *v;
    356339
    357340  printf("# BEGIN testing owl_variable\n");
    358   FAIL_UNLESS("setup", 0==owl_variable_dict_setup(&vd));
     341  owl_variable_dict_setup(&vd);
    359342
    360343  FAIL_UNLESS("get bool var", NULL != (var = owl_variable_get_var(&vd, "rxping")));
     
    393376  FAIL_UNLESS("get int 7", 9 == owl_variable_get_int(var));
    394377
    395   owl_variable_dict_newvar_string(&vd, "stringvar", "", "", "testval");
     378  FAIL_UNLESS("get enum var", NULL != (var = owl_variable_get_var(&vd, "scrollmode")));
     379  FAIL_UNLESS("get enum", OWL_SCROLLMODE_NORMAL == owl_variable_get_int(var));
     380  FAIL_UNLESS("get enum as string",
     381              !strcmp((value = owl_variable_get_tostring(var)), "normal"));
     382  g_free(value);
     383  FAIL_UNLESS("set enum 1", 0 == owl_variable_set_int(var, OWL_SCROLLMODE_TOP));
     384  FAIL_UNLESS("get enum 1", OWL_SCROLLMODE_TOP == owl_variable_get_int(var));
     385  FAIL_UNLESS("set enum 2a", -1 == owl_variable_set_int(var, -1));
     386  FAIL_UNLESS("set enum 2b", -1 == owl_variable_set_int(var, OWL_SCROLLMODE_PAGEDCENTER + 1));
     387  FAIL_UNLESS("get enum 2", OWL_SCROLLMODE_TOP == owl_variable_get_int(var));
     388  FAIL_UNLESS("set enum 3", 0 == owl_variable_set_fromstring(var, "center", 0));
     389  FAIL_UNLESS("get enum 4", OWL_SCROLLMODE_CENTER == owl_variable_get_int(var));
     390  FAIL_UNLESS("set enum 5", -1 == owl_variable_set_fromstring(var, "bogus", 0));
     391  FAIL_UNLESS("set enum 6", -1 == owl_variable_set_fromstring(var, "", 0));
     392  FAIL_UNLESS("get enum 7", OWL_SCROLLMODE_CENTER == owl_variable_get_int(var));
     393
     394  owl_variable_dict_newvar_string(&vd, "stringvar", "testval", "", "");
    396395  FAIL_UNLESS("get new string var", NULL != (var = owl_variable_get_var(&vd, "stringvar")));
    397   FAIL_UNLESS("get new string var", NULL != (v = owl_variable_get(var)));
    398396  FAIL_UNLESS("get new string val", !strcmp("testval", owl_variable_get_string(var)));
    399397  owl_variable_set_string(var, "new val");
    400398  FAIL_UNLESS("update string val", !strcmp("new val", owl_variable_get_string(var)));
    401399
    402   owl_variable_dict_newvar_int(&vd, "intvar", "", "", 47);
     400  owl_variable_dict_newvar_int(&vd, "intvar", 47, "", "");
    403401  FAIL_UNLESS("get new int var", NULL != (var = owl_variable_get_var(&vd, "intvar")));
    404   FAIL_UNLESS("get new int var", NULL != (v = owl_variable_get(var)));
    405402  FAIL_UNLESS("get new int val", 47 == owl_variable_get_int(var));
    406403  owl_variable_set_int(var, 17);
    407404  FAIL_UNLESS("update int val", 17 == owl_variable_get_int(var));
    408405
    409   owl_variable_dict_newvar_bool(&vd, "boolvar", "", "", 1);
     406  owl_variable_dict_newvar_bool(&vd, "boolvar", true, "", "");
    410407  FAIL_UNLESS("get new bool var", NULL != (var = owl_variable_get_var(&vd, "boolvar")));
    411   FAIL_UNLESS("get new bool var", NULL != (v = owl_variable_get(var)));
    412408  FAIL_UNLESS("get new bool val", owl_variable_get_bool(var));
    413409  owl_variable_set_bool_off(var);
    414410  FAIL_UNLESS("update bool val", !owl_variable_get_bool(var));
    415411
    416   owl_variable_dict_newvar_string(&vd, "nullstringvar", "", "", NULL);
     412  owl_variable_dict_newvar_string(&vd, "nullstringvar", NULL, "", "");
    417413  FAIL_UNLESS("get new string (NULL) var", NULL != (var = owl_variable_get_var(&vd, "nullstringvar")));
    418414  FAIL_UNLESS("get string (NULL)", NULL == (value = owl_variable_get_tostring(var)));
     
    421417  FAIL_UNLESS("get string (NULL) 2", NULL == (value = owl_variable_get_tostring(var)));
    422418  g_free(value);
     419
     420  owl_variable_dict_newvar_enum(&vd, "enumvar", 0, "", "", "a,b,c,d");
     421  FAIL_UNLESS("get new enum var", NULL != (var = owl_variable_get_var(&vd, "enumvar")));
     422  FAIL_UNLESS("get new enum val", 0 == owl_variable_get_int(var));
     423  owl_variable_set_fromstring(var, "c", 0);
     424  FAIL_UNLESS("update enum val", 2 == owl_variable_get_int(var));
    423425
    424426  owl_variable_dict_cleanup(&vd);
     
    515517  FAIL_UNLESS("DAG", (f5 = owl_filter_new_fromstring("dag", "filter f1 or filter f1")) != NULL);
    516518  owl_filter_delete(f5);
     519
     520  owl_message_cleanup(&m);
    517521
    518522  return 0;
     
    982986  return numfailed;
    983987}
     988
     989int call_filter_regtest(void)
     990{
     991  int numfailed = 0;
     992  int ret;
     993  char *out = NULL;
     994  int status;
     995
     996  printf("# BEGIN testing call_filter\n");
     997
     998  const char *cat_argv[] = { "cat", NULL };
     999  ret = call_filter(cat_argv, "Mangos!", &out, &status);
     1000  FAIL_UNLESS("call_filter cat", (ret == 0 &&
     1001                                  status == 0 &&
     1002                                  strcmp(out, "Mangos!") == 0));
     1003  g_free(out); out = NULL;
     1004
     1005  ret = call_filter(cat_argv, "", &out, &status);
     1006  FAIL_UNLESS("call_filter cat", (ret == 0 &&
     1007                                  status == 0 &&
     1008                                  strcmp(out, "") == 0));
     1009  g_free(out); out = NULL;
     1010
     1011  ret = call_filter(cat_argv, NULL, &out, &status);
     1012  FAIL_UNLESS("call_filter cat", (ret == 0 &&
     1013                                  status == 0 &&
     1014                                  strcmp(out, "") == 0));
     1015  g_free(out); out = NULL;
     1016
     1017  printf("# END testing call_filter (%d failures)\n", numfailed);
     1018  return numfailed;
     1019}
  • text.c

    r14be3a5 rf271129  
    1 #include <stdio.h>
    2 #include <string.h>
    3 #include <stdlib.h>
    4 #include <ctype.h>
    51#include "owl.h"
    62
  • util.c

    r4ebbfbc r7b89e8c  
    11#include "owl.h"
    2 #include <stdlib.h>
    3 #include <string.h>
    4 #include <unistd.h>
    5 #include <ctype.h>
    62#include <pwd.h>
    73#include <sys/stat.h>
    8 #include <sys/types.h>
    9 #include <assert.h>
    104#include <stdarg.h>
    11 #include <glib.h>
    125#include <glib/gstdio.h>
    136#include <glib-object.h>
     
    269262CALLER_OWN char *owl_arg_quote(const char *arg)
    270263{
    271   GString *buf = g_string_new("");;
     264  GString *buf = g_string_new("");
    272265  owl_string_append_quoted_arg(buf, arg);
    273266  return g_string_free(buf, false);
    274267}
    275268
     269/* Returns a quoted version of argv. owl_parseline on the result should give
     270 * back the input. */
     271CALLER_OWN char *owl_argv_quote(int argc, const char *const *argv)
     272{
     273  int i;
     274  GString *buf = g_string_new("");
     275  for (i = 0; i < argc; i++) {
     276    if (i > 0)
     277      g_string_append_c(buf, ' ');
     278    owl_string_append_quoted_arg(buf, argv[i]);
     279  }
     280  return g_string_free(buf, false);
     281}
     282
    276283/* caller must free the return */
    277 CALLER_OWN char *owl_util_minutes_to_timestr(int in)
     284CALLER_OWN char *owl_util_format_minutes(int in)
    278285{
    279286  int days, hours;
     
    296303}
    297304
    298 CALLER_OWN char *owl_util_time_to_timestr(const struct tm *time)
     305CALLER_OWN char *owl_util_format_time(const struct tm *time)
    299306{
    300307  /* 32 chosen for first attempt because timestr will end up being
  • variable.c

    r6f7d4f6 r9d4dfdc  
     1#include "owl.h"
    12#include <stdio.h>
    2 #include <stdlib.h>
    3 #include <string.h>
    4 #include <unistd.h>
    5 #include <ctype.h>
    6 #include "owl.h"
    7 
    8 #define OWLVAR_BOOL(name,default,summary,description) \
    9         { g_strdup(name), OWL_VARIABLE_BOOL, NULL, default, "on,off", g_strdup(summary), g_strdup(description), NULL, \
    10         NULL, NULL, NULL, NULL, NULL, NULL }
    11 
    12 #define OWLVAR_BOOL_FULL(name,default,summary,description,validate,set,get) \
    13         { g_strdup(name), OWL_VARIABLE_BOOL, NULL, default, "on,off", g_strdup(summary), g_strdup(description), NULL, \
    14         validate, set, NULL, get, NULL, NULL }
    15 
    16 #define OWLVAR_INT(name,default,summary,description) \
    17         { g_strdup(name), OWL_VARIABLE_INT, NULL, default, "<int>", g_strdup(summary), g_strdup(description), NULL, \
    18         NULL, NULL, NULL, NULL, NULL, NULL }
     3#include "gmarshal_funcs.h"
     4
     5/* TODO(davidben): When we can require 2.30 and up, remove this. */
     6#ifndef G_VALUE_INIT
     7#define G_VALUE_INIT { 0, { { 0 } } }
     8#endif
     9
     10typedef const char *(*get_string_t)(const owl_variable *);
     11typedef int (*get_int_t)(const owl_variable *);
     12typedef bool (*get_bool_t)(const owl_variable *);
     13
     14typedef int (*set_string_t)(owl_variable *, const char *);
     15typedef int (*set_int_t)(owl_variable *, int);
     16typedef int (*set_bool_t)(owl_variable *, bool);
     17
     18typedef int (*validate_string_t)(const owl_variable *, const char *);
     19typedef int (*validate_int_t)(const owl_variable *, int);
     20typedef int (*validate_bool_t)(const owl_variable *, bool);
     21
     22static void owl_variable_dict_newvar_bool_full(owl_vardict *vd,
     23                                               const char *name,
     24                                               bool default_val,
     25                                               const char *summary,
     26                                               const char *description,
     27                                               validate_bool_t validate_fn,
     28                                               set_bool_t set_fn,
     29                                               get_bool_t get_fn);
     30
     31static void owl_variable_dict_newvar_string_full(owl_vardict *vd,
     32                                                 const char *name,
     33                                                 const char *default_val,
     34                                                 const char *summary,
     35                                                 const char *description,
     36                                                 const char *validsettings,
     37                                                 validate_string_t validate_fn,
     38                                                 set_string_t set_fn,
     39                                                 get_string_t get_fn);
     40
     41static void owl_variable_dict_newvar_int_full(owl_vardict *vd,
     42                                              const char *name,
     43                                              int default_val,
     44                                              const char *summary,
     45                                              const char *description,
     46                                              const char *validsettings,
     47                                              validate_int_t validate_fn,
     48                                              set_int_t set_fn,
     49                                              get_int_t get_fn);
     50
     51static void owl_variable_dict_newvar_enum_full(owl_vardict *vd,
     52                                               const char *name,
     53                                               int default_val,
     54                                               const char *summary,
     55                                               const char *description,
     56                                               const char *validsettings,
     57                                               validate_int_t validate_fn,
     58                                               set_int_t set_fn,
     59                                               get_int_t get_fn);
     60
     61#define OWLVAR_BOOL(name, default, summary, description) \
     62        owl_variable_dict_newvar_bool(vd, name, default, summary, description)
     63
     64#define OWLVAR_BOOL_FULL(name, default, summary, description, validate, set, get) \
     65        owl_variable_dict_newvar_bool_full(vd, name, default, summary, description, \
     66                                           validate, set, get)
     67
     68#define OWLVAR_INT(name, default, summary, description) \
     69        owl_variable_dict_newvar_int(vd, name, default, summary, description)
    1970
    2071#define OWLVAR_INT_FULL(name,default,summary,description,validset,validate,set,get) \
    21         { g_strdup(name), OWL_VARIABLE_INT, NULL, default, validset, g_strdup(summary), g_strdup(description), NULL, \
    22         validate, set, NULL, get, NULL, NULL }
    23 
    24 #define OWLVAR_PATH(name,default,summary,description) \
    25         { g_strdup(name), OWL_VARIABLE_STRING, g_strdup(default), 0, "<path>", g_strdup(summary), g_strdup(description),  NULL, \
    26         NULL, NULL, NULL, NULL, NULL, NULL }
    27 
    28 #define OWLVAR_STRING(name,default,summary,description) \
    29         { g_strdup(name), OWL_VARIABLE_STRING, g_strdup(default), 0, "<string>", g_strdup(summary), g_strdup(description), NULL, \
    30         NULL, NULL, NULL, NULL, NULL, NULL }
    31 
    32 #define OWLVAR_STRING_FULL(name,default,validset,summary,description,validate,set,get) \
    33         { g_strdup(name), OWL_VARIABLE_STRING, g_strdup(default), 0, validset, g_strdup(summary), g_strdup(description), NULL, \
    34         validate, set, NULL, get, NULL, NULL }
     72        owl_variable_dict_newvar_int_full(vd, name, default, summary, description, \
     73                                          validset, validate, set, get)
     74
     75#define OWLVAR_PATH(name, default, summary, description) \
     76        owl_variable_dict_newvar_path(vd, name, default, summary, description)
     77
     78#define OWLVAR_STRING(name, default, summary, description) \
     79        owl_variable_dict_newvar_string(vd, name, default, summary, description)
     80
     81#define OWLVAR_STRING_FULL(name, default, validset, summary, description, validate, set, get) \
     82        owl_variable_dict_newvar_string_full(vd, name, default, summary, description, \
     83                                             validset, validate, set, get)
    3584
    3685/* enums are really integers, but where validset is a comma-separated
    3786 * list of strings which can be specified.  The tokens, starting at 0,
    3887 * correspond to the values that may be specified. */
    39 #define OWLVAR_ENUM(name,default,summary,description,validset) \
    40         { g_strdup(name), OWL_VARIABLE_INT, NULL, default, validset, g_strdup(summary), g_strdup(description), NULL, \
    41         owl_variable_enum_validate, \
    42         NULL, owl_variable_enum_set_fromstring, \
    43         NULL, owl_variable_enum_get_tostring, \
    44         NULL }
     88#define OWLVAR_ENUM(name, default, summary, description, validset) \
     89        owl_variable_dict_newvar_enum(vd, name, default, summary, description, validset)
    4590
    4691#define OWLVAR_ENUM_FULL(name,default,summary,description,validset,validate, set, get) \
    47         { g_strdup(name), OWL_VARIABLE_INT, NULL, default, validset, g_strdup(summary), g_strdup(description), NULL, \
    48         validate, \
    49         set, owl_variable_enum_set_fromstring, \
    50         get, owl_variable_enum_get_tostring, \
    51         NULL }
    52 
    53 int owl_variable_add_defaults(owl_vardict *vd)
    54 {
    55   owl_variable variables_to_init[] = {
    56 
     92        owl_variable_dict_newvar_enum_full(vd, name, default, summary, description, \
     93                                           validset, validate, set, get)
     94
     95void owl_variable_add_defaults(owl_vardict *vd)
     96{
    5797  OWLVAR_STRING( "personalbell" /* %OwlVarStub */, "off",
    5898                 "ring the terminal bell when personal messages are received",
    5999                 "Can be set to 'on', 'off', or the name of a filter which\n"
    60                  "messages need to match in order to ring the bell"),
     100                 "messages need to match in order to ring the bell");
    61101
    62102  OWLVAR_BOOL( "bell" /* %OwlVarStub */, 1,
    63                "enable / disable the terminal bell", "" ),
     103               "enable / disable the terminal bell", "" );
    64104
    65105  OWLVAR_BOOL_FULL( "debug" /* %OwlVarStub */, OWL_DEBUG,
     
    67107                    "If set to 'on', debugging messages are logged to the\n"
    68108                    "file specified by the debugfile variable.\n",
    69                     NULL, owl_variable_debug_set, NULL),
     109                    NULL, owl_variable_debug_set, NULL);
    70110
    71111  OWLVAR_BOOL( "startuplogin" /* %OwlVarStub */, 1,
    72                "send a login message when BarnOwl starts", "" ),
     112               "send a login message when BarnOwl starts", "" );
    73113
    74114  OWLVAR_BOOL( "shutdownlogout" /* %OwlVarStub */, 1,
    75                "send a logout message when BarnOwl exits", "" ),
     115               "send a logout message when BarnOwl exits", "" );
    76116
    77117  OWLVAR_BOOL( "rxping" /* %OwlVarStub */, 0,
    78                "display received pings", "" ),
     118               "display received pings", "" );
    79119
    80120  OWLVAR_BOOL( "txping" /* %OwlVarStub */, 1,
    81                "send pings", "" ),
     121               "send pings", "" );
    82122
    83123  OWLVAR_BOOL( "sepbar_disable" /* %OwlVarStub */, 0,
    84                "disable printing information in the separator bar", "" ),
     124               "disable printing information in the separator bar", "" );
    85125
    86126  OWLVAR_BOOL( "smartstrip" /* %OwlVarStub */, 1,
    87                "strip kerberos instance for reply", ""),
     127               "strip kerberos instance for reply", "");
    88128
    89129  OWLVAR_BOOL( "newlinestrip" /* %OwlVarStub */, 1,
    90                "strip leading and trailing newlines", ""),
     130               "strip leading and trailing newlines", "");
    91131
    92132  OWLVAR_BOOL( "displayoutgoing" /* %OwlVarStub */, 1,
    93                "display outgoing messages", "" ),
     133               "display outgoing messages", "" );
    94134
    95135  OWLVAR_BOOL( "loginsubs" /* %OwlVarStub */, 1,
    96                "load logins from .anyone on startup", "" ),
     136               "load logins from .anyone on startup", "" );
    97137
    98138  OWLVAR_BOOL( "logging" /* %OwlVarStub */, 0,
     
    101141               "logged in the directory specified\n"
    102142               "by the 'logpath' variable.  The filename in that\n"
    103                "directory is derived from the sender of the message.\n" ),
     143               "directory is derived from the sender of the message.\n" );
    104144
    105145  OWLVAR_BOOL( "classlogging" /* %OwlVarStub */, 0,
     
    109149               "by the 'classlogpath' variable.\n"
    110150               "The filename in that directory is derived from\n"
    111                "the name of the class to which the message was sent.\n" ),
     151               "the name of the class to which the message was sent.\n" );
    112152
    113153  OWLVAR_ENUM( "loggingdirection" /* %OwlVarStub */, OWL_LOGGING_DIRECTION_BOTH,
     
    118158               "is selected both incoming and outgoing messages are\n"
    119159               "logged.",
    120                "both,in,out"),
    121 
    122   OWLVAR_BOOL( "colorztext" /* %OwlVarStub */, 1,
    123                "allow @color() in zephyrs to change color",
    124                "Note that only messages received after this variable\n"
    125                "is set will be affected." ),
     160               "both,in,out");
     161
     162  OWLVAR_BOOL_FULL( "colorztext" /* %OwlVarStub */, 1,
     163                    "allow @color() in zephyrs to change color",
     164                    NULL, NULL, owl_variable_colorztext_set, NULL);
    126165
    127166  OWLVAR_BOOL( "fancylines" /* %OwlVarStub */, 1,
     
    129168               "If turned off, dashes, pipes and pluses will be used\n"
    130169               "to draw lines on the screen.  Useful when the terminal\n"
    131                "is causing problems" ),
     170               "is causing problems" );
    132171
    133172  OWLVAR_BOOL( "zcrypt" /* %OwlVarStub */, 1,
    134173               "Do automatic zcrypt processing",
    135                "" ),
     174               "" );
    136175
    137176  OWLVAR_BOOL_FULL( "pseudologins" /* %OwlVarStub */, 0,
     
    141180                    "but sent no login message, or a user is not present that sent no\n"
    142181                    "logout message, a pseudo login or logout message will be created\n",
    143                     NULL, owl_variable_pseudologins_set, NULL),
     182                    NULL, owl_variable_pseudologins_set, NULL);
    144183
    145184  OWLVAR_BOOL( "ignorelogins" /* %OwlVarStub */, 0,
     
    147186               "When this is enabled, BarnOwl will print login and logout notifications\n"
    148187               "for AIM, zephyr, or other protocols.  If disabled BarnOwl will not print\n"
    149                "login or logout notifications.\n"),
     188               "login or logout notifications.\n");
    150189
    151190  OWLVAR_STRING( "logfilter" /* %OwlVarStub */, "",
     
    156195                 "variables like logging, classlogging, loglogins, loggingdirection,\n"
    157196                 "etc.  If you want this variable to control all logging, make sure\n"
    158                  "all other logging variables are in their default state.\n"),
     197                 "all other logging variables are in their default state.\n");
    159198
    160199  OWLVAR_BOOL( "loglogins" /* %OwlVarStub */, 0,
     
    162201               "When this is enabled, BarnOwl will log login and logout notifications\n"
    163202               "for AIM, zephyr, or other protocols.  If disabled BarnOwl will not print\n"
    164                "login or logout notifications.\n"),
     203               "login or logout notifications.\n");
    165204
    166205  OWLVAR_ENUM_FULL( "disable-ctrl-d" /* %OwlVarStub:lockout_ctrld */, 1,
    167206                    "don't send zephyrs on C-d",
    168                     "If set to 'off', C-d won't send a zephyr from the edit\n"
    169                     "window.  If set to 'on', C-d will always send a zephyr\n"
     207                    "If set to 'on', C-d won't send a zephyr from the edit\n"
     208                    "window.  If set to 'off', C-d will always send a zephyr\n"
    170209                    "being composed in the edit window.  If set to 'middle',\n"
    171210                    "C-d will only ever send a zephyr if the cursor is at\n"
     
    174213                    "in the editmulti keymap.\n",
    175214                    "off,middle,on",
    176                     NULL, owl_variable_disable_ctrl_d_set, NULL),
     215                    NULL, owl_variable_disable_ctrl_d_set, NULL);
    177216
    178217  OWLVAR_PATH( "logpath" /* %OwlVarStub */, "~/zlog/people",
    179218               "path for logging personal zephyrs",
    180219               "Specifies a directory which must exist.\n"
    181                "Files will be created in the directory for each sender.\n"),
     220               "Files will be created in the directory for each sender.\n");
    182221
    183222  OWLVAR_PATH( "classlogpath" /* %OwlVarStub:classlogpath */, "~/zlog/class",
    184223               "path for logging class zephyrs",
    185224               "Specifies a directory which must exist.\n"
    186                "Files will be created in the directory for each class.\n"),
     225               "Files will be created in the directory for each class.\n");
    187226
    188227  OWLVAR_PATH( "debug_file" /* %OwlVarStub */, OWL_DEBUG_FILE,
    189228               "path for logging debug messages when debugging is enabled",
    190229               "This file will be logged to if 'debug' is set to 'on'.\n"
    191                "BarnOwl will append a dot and the current process's pid to the filename."),
     230               "BarnOwl will append a dot and the current process's pid to the filename.");
    192231 
    193232  OWLVAR_PATH( "zsigproc" /* %OwlVarStub:zsigproc */, NULL,
     
    197236               "See the documentation for 'zsig' for more information about\n"
    198237               "how the outgoing zsig is chosen."
    199                ),
     238               );
    200239
    201240  OWLVAR_PATH( "newmsgproc" /* %OwlVarStub:newmsgproc */, NULL,
     
    203242               "The named program will be run when BarnOwl receives new\n"
    204243               "messages.  It will not be run again until the first\n"
    205                "instance exits"),
     244               "instance exits");
    206245
    207246  OWLVAR_STRING( "zsender" /* %OwlVarStub */, "",
     
    210249         "zephyrs.  If this is unset, it will use your Kerberos\n"
    211250         "principal. Note that customizing the sender name will\n"
    212          "cause your zephyrs to be sent unauthenticated."),
     251         "cause your zephyrs to be sent unauthenticated.");
    213252
    214253  OWLVAR_STRING( "zsigfunc" /* %OwlVarStub */, "BarnOwl::default_zephyr_signature()",
     
    217256                 "explicit zsig.  The default setting implements the policy\n"
    218257                 "described in the documentation for the 'zsig' variable.\n"
    219                  "See also BarnOwl::random_zephyr_signature().\n"),
     258                 "See also BarnOwl::random_zephyr_signature().\n");
    220259
    221260  OWLVAR_STRING( "zsig" /* %OwlVarStub */, "",
     
    224263                 "unset, 'zsigproc' will be run to generate a zsig. If that is\n"
    225264                 "also unset, the 'zwrite-signature' zephyr variable will be\n"
    226                  "used instead.\n"),
     265                 "used instead.\n");
    227266
    228267  OWLVAR_STRING( "appendtosepbar" /* %OwlVarStub */, "",
     
    230269                 "The sepbar is the bar separating the top and bottom\n"
    231270                 "of the BarnOwl screen.  Any string specified here will\n"
    232                  "be displayed on the right of the sepbar\n"),
     271                 "be displayed on the right of the sepbar\n");
    233272
    234273  OWLVAR_BOOL( "zaway" /* %OwlVarStub */, 0,
    235                "turn zaway on or off", "" ),
     274               "turn zaway on or off", "" );
    236275
    237276  OWLVAR_STRING( "zaway_msg" /* %OwlVarStub */,
    238277                 OWL_DEFAULT_ZAWAYMSG,
    239                  "zaway msg for responding to zephyrs when away", "" ),
     278                 "zaway msg for responding to zephyrs when away", "" );
    240279
    241280  OWLVAR_STRING( "zaway_msg_default" /* %OwlVarStub */,
    242281                 OWL_DEFAULT_ZAWAYMSG,
    243                  "default zaway message", "" ),
     282                 "default zaway message", "" );
    244283
    245284  OWLVAR_BOOL_FULL( "aaway" /* %OwlVarStub */, 0,
    246285                    "Set AIM away status",
    247286                    "",
    248                     NULL, owl_variable_aaway_set, NULL),
     287                    NULL, owl_variable_aaway_set, NULL);
    249288
    250289  OWLVAR_STRING( "aaway_msg" /* %OwlVarStub */,
    251290                 OWL_DEFAULT_AAWAYMSG,
    252                  "AIM away msg for responding when away", "" ),
     291                 "AIM away msg for responding when away", "" );
    253292
    254293  OWLVAR_STRING( "aaway_msg_default" /* %OwlVarStub */,
    255294                 OWL_DEFAULT_AAWAYMSG,
    256                  "default AIM away message", "" ),
     295                 "default AIM away message", "" );
    257296
    258297  OWLVAR_STRING( "view_home" /* %OwlVarStub */, "all",
    259298                 "home view to switch to after 'X' and 'V'",
    260                  "SEE ALSO: view, filter\n" ),
     299                 "SEE ALSO: view, filter\n" );
    261300
    262301  OWLVAR_STRING( "alert_filter" /* %OwlVarStub */, "none",
    263302                 "filter on which to trigger alert actions",
    264                  "" ),
     303                 "" );
    265304
    266305  OWLVAR_STRING( "alert_action" /* %OwlVarStub */, "nop",
    267306                 "BarnOwl command to execute for alert actions",
    268                  "" ),
     307                 "" );
    269308
    270309  OWLVAR_STRING_FULL( "tty" /* %OwlVarStub */, "", "<string>", "tty name for zephyr location", "",
    271                       NULL, owl_variable_tty_set, NULL),
     310                      NULL, owl_variable_tty_set, NULL);
    272311
    273312  OWLVAR_STRING( "default_style" /* %OwlVarStub */, "default",
     
    280319                 "   perl     - legacy perl interface\n"
    281320                 "\nSEE ALSO: style, show styles, view -s <style>\n"
    282                  ),
     321                 );
    283322
    284323
     
    287326                 "This specifies the maximum number of columns for M-q to fill text\n"
    288327                 "to.  If set to 0, M-q will wrap to the width of the window, and\n"
    289                  "values less than 0 disable M-q entirely.\n"),
     328                 "values less than 0 disable M-q entirely.\n");
    290329
    291330  OWLVAR_INT(    "edit:maxwrapcols" /* %OwlVarStub:edit_maxwrapcols */, 70,
     
    296335                 "\n"
    297336                 "As a courtesy to recipients, it is recommended that outgoing\n"
    298                  "Zephyr messages be no wider than 70 columns.\n"),
     337                 "Zephyr messages be no wider than 70 columns.\n");
    299338
    300339  OWLVAR_INT( "aim_ignorelogin_timer" /* %OwlVarStub */, 15,
     
    303342              "AIM login before allowing the receipt of AIM login notifications.\n"
    304343              "By default this is set to 15.  If you would like to view login\n"
    305               "notifications of buddies as soon as you login, set it to 0 instead."),
     344              "notifications of buddies as soon as you login, set it to 0 instead.");
    306345
    307346             
     
    316355                   owl_variable_typewinsize_set,
    317356                   NULL /* use default for get */
    318                    ),
     357                   );
    319358
    320359  OWLVAR_INT( "typewindelta" /* %OwlVarStub */, 0,
     
    326365           "typewinsize to 1.\n\n"
    327366           "This works a lot better with a non-default scrollmode;\n"
    328            "try :set scrollmode pagedcenter.\n"),
     367           "try :set scrollmode pagedcenter.\n");
    329368
    330369  OWLVAR_ENUM( "scrollmode" /* %OwlVarStub */, OWL_SCROLLMODE_NORMAL,
     
    355394               "                 the screen will be paged up or down and\n"
    356395               "                 the cursor will be near the center.\n",
    357                "normal,top,neartop,center,paged,pagedcenter" ),
     396               "normal,top,neartop,center,paged,pagedcenter" );
    358397
    359398  OWLVAR_BOOL( "narrow-related" /* %OwlVarStub:narrow_related */, 1,
    360399               "Make smartnarrow use broader filters",
    361                "Causes smartfiler to narrow to messages \"related\" to \n"
     400               "Causes smartfilter to narrow to messages \"related\" to \n"
    362401               "the current message, as well as ones to the same place.\n\n"
    363402               "for Zephyr, this controls whether to narrow to e.g. class-help or\n"
    364403               "class-help.d alone, or to related-class-help, which includes\n"
    365                "help, unhelp, help.d, etc.\n\nDefault is true (include unclasses, etc.).\n" ),
     404               "help, unhelp, help.d, etc.\n\nDefault is true (include unclasses, etc.).\n" );
    366405
    367406  OWLVAR_BOOL( "_followlast" /* %OwlVarStub */, 0,
     
    370409               "continue to follow the last message if this is set.\n"
    371410               "Note that this is currently risky as you might accidentally\n"
    372                "delete a message right as it came in.\n" ),
     411               "delete a message right as it came in.\n" );
    373412
    374413  OWLVAR_STRING_FULL( "default_exposure" /* %OwlVarStub */, "",
     
    379418                      "~/.zephyr.vars.\n"
    380419                      "See the description of exposure for the values this can be.",
    381                       NULL, owl_variable_default_exposure_set, owl_variable_default_exposure_get ),
     420                      NULL, owl_variable_default_exposure_set, owl_variable_default_exposure_get );
    382421
    383422  OWLVAR_STRING_FULL( "exposure" /* %OwlVarStub */, "",
     
    435474                      "                     personal subscriptions will be entered for the\n"
    436475                      "                     user.\n",
    437                       NULL, owl_variable_exposure_set, NULL /* use default for get */ ),
    438 
    439   /* This MUST be last... */
    440   { NULL, 0, NULL, 0, NULL, NULL, NULL, NULL,
    441     NULL, NULL, NULL, NULL, NULL, NULL }
    442 
    443   };
    444 
    445   int ret = owl_variable_dict_add_from_list(vd, variables_to_init);
    446   owl_variable *var;
    447   for (var = variables_to_init; var->name != NULL; var++)
    448     owl_variable_cleanup(var);
    449   return ret;
     476                      NULL, owl_variable_exposure_set, NULL /* use default for get */ );
    450477}
    451478
     
    457484/* commonly useful */
    458485
    459 int owl_variable_int_validate_gt0(const owl_variable *v, const void *newval)
    460 {
    461   if (newval == NULL) return(0);
    462   else if (*(const int*)newval < 1) return(0);
    463   else return (1);
    464 }
    465 
    466 int owl_variable_int_validate_positive(const owl_variable *v, const void *newval)
    467 {
    468   if (newval == NULL) return(0);
    469   else if (*(const int*)newval < 0) return(0);
    470   else return (1);
     486int owl_variable_int_validate_gt0(const owl_variable *v, int newval)
     487{
     488  return !(newval < 1);
     489}
     490
     491int owl_variable_int_validate_positive(const owl_variable *v, int newval)
     492{
     493  return !(newval < 0);
    471494}
    472495
    473496/* typewinsize */
    474 int owl_variable_typewinsize_set(owl_variable *v, const void *newval)
     497int owl_variable_typewinsize_set(owl_variable *v, int newval)
    475498{
    476499  int rv;
     
    481504
    482505/* debug (cache value in g->debug) */
    483 int owl_variable_debug_set(owl_variable *v, const void *newval)
    484 {
    485   if (newval && (*(const int*)newval == 1 || *(const int*)newval == 0)) {
    486     g.debug = *(const int*)newval;
     506int owl_variable_debug_set(owl_variable *v, bool newval)
     507{
     508  g.debug = newval;
     509  return owl_variable_bool_set_default(v, newval);
     510}
     511
     512/* When 'aaway' is changed, need to notify the AIM server */
     513int owl_variable_aaway_set(owl_variable *v, bool newval)
     514{
     515  if (newval) {
     516    owl_aim_set_awaymsg(owl_global_get_aaway_msg(&g));
     517  } else {
     518    owl_aim_set_awaymsg("");
    487519  }
    488520  return owl_variable_bool_set_default(v, newval);
    489521}
    490522
    491 /* When 'aaway' is changed, need to notify the AIM server */
    492 int owl_variable_aaway_set(owl_variable *v, const void *newval)
    493 {
     523int owl_variable_colorztext_set(owl_variable *v, bool newval)
     524{
     525  int ret = owl_variable_bool_set_default(v, newval);
     526  /* flush the format cache so that we see the update, but only if we're done initializing BarnOwl */
     527  if (owl_global_get_msglist(&g) != NULL)
     528    owl_messagelist_invalidate_formats(owl_global_get_msglist(&g));
     529  if (owl_global_get_mainwin(&g) != NULL) {
     530    owl_function_calculate_topmsg(OWL_DIRECTION_DOWNWARDS);
     531    owl_mainwin_redisplay(owl_global_get_mainwin(&g));
     532  }
     533  return ret;
     534}
     535
     536int owl_variable_pseudologins_set(owl_variable *v, bool newval)
     537{
     538  static guint timer = 0;
    494539  if (newval) {
    495     if (*(const int*)newval == 1) {
    496       owl_aim_set_awaymsg(owl_global_get_aaway_msg(&g));
    497     } else if (*(const int*)newval == 0) {
    498       owl_aim_set_awaymsg("");
     540    owl_function_zephyr_buddy_check(0);
     541    if (timer == 0) {
     542      timer = g_timeout_add_seconds(180, owl_zephyr_buddycheck_timer, NULL);
     543    }
     544  } else {
     545    if (timer != 0) {
     546      g_source_remove(timer);
     547      timer = 0;
    499548    }
    500549  }
     
    502551}
    503552
    504 int owl_variable_pseudologins_set(owl_variable *v, const void *newval)
    505 {
    506   static guint timer = 0;
    507   if (newval) {
    508     if (*(const int*)newval == 1) {
    509       owl_function_zephyr_buddy_check(0);
    510       if (timer == 0) {
    511         timer = g_timeout_add_seconds(180, owl_zephyr_buddycheck_timer, NULL);
    512       }
    513     } else {
    514       if (timer != 0) {
    515         g_source_remove(timer);
    516         timer = 0;
    517       }
    518     }
    519   }
    520   return owl_variable_bool_set_default(v, newval);
    521 }
    522 
    523553/* note that changing the value of this will clobber
    524554 * any user setting of this */
    525 int owl_variable_disable_ctrl_d_set(owl_variable *v, const void *newval)
    526 {
    527   if (newval && !owl_context_is_startup(owl_global_get_context(&g))) {
    528     if (*(const int*)newval == 2) {
     555int owl_variable_disable_ctrl_d_set(owl_variable *v, int newval)
     556{
     557  if (!owl_context_is_startup(owl_global_get_context(&g))) {
     558    if (newval == 2) {
    529559      owl_function_command_norv("bindkey editmulti C-d command edit:delete-next-char");
    530     } else if (*(const int*)newval == 1) {
     560    } else if (newval == 1) {
    531561      owl_function_command_norv("bindkey editmulti C-d command edit:done-or-delete");
    532562    } else {
     
    534564    }
    535565  } 
    536   return owl_variable_int_set_default(v, newval); 
    537 }
    538 
    539 int owl_variable_tty_set(owl_variable *v, const void *newval)
     566  return owl_variable_int_set_default(v, newval);
     567}
     568
     569int owl_variable_tty_set(owl_variable *v, const char *newval)
    540570{
    541571  owl_zephyr_set_locationinfo(g_get_host_name(), newval);
    542   return(owl_variable_string_set_default(v, newval));
    543 }
    544 
    545 int owl_variable_default_exposure_set(owl_variable *v, const void *newval)
     572  return owl_variable_string_set_default(v, newval);
     573}
     574
     575int owl_variable_default_exposure_set(owl_variable *v, const char *newval)
    546576{
    547577  return owl_zephyr_set_default_exposure(newval);
    548578}
    549579
    550 const void *owl_variable_default_exposure_get(const owl_variable *v)
     580const char *owl_variable_default_exposure_get(const owl_variable *v)
    551581{
    552582  return owl_zephyr_get_default_exposure();
    553583}
    554584
    555 int owl_variable_exposure_set(owl_variable *v, const void *newval)
     585int owl_variable_exposure_set(owl_variable *v, const char *newval)
    556586{
    557587  int ret = owl_zephyr_set_exposure(newval);
     
    565595/**************************************************************************/
    566596
    567 int owl_variable_dict_setup(owl_vardict *vd) {
     597void owl_variable_dict_setup(owl_vardict *vd) {
    568598  owl_dict_create(vd);
    569   return owl_variable_add_defaults(vd);
    570 }
    571 
    572 int owl_variable_dict_add_from_list(owl_vardict *vd, owl_variable *variables_to_init)
    573 {
    574   owl_variable *var, *cur;
    575   for (var = variables_to_init; var->name != NULL; var++) {
    576     cur = g_new(owl_variable, 1);
    577     *cur = *var;
    578     /* strdup all the strings so we can delete them consistently. */
    579     cur->name = g_strdup(var->name);
    580     cur->summary = g_strdup(var->summary);
    581     cur->description = g_strdup(var->description);
    582     switch (cur->type) {
    583     case OWL_VARIABLE_OTHER:
    584       cur->set_fn(cur, cur->pval_default);
    585       break;
    586     case OWL_VARIABLE_STRING:
    587       if (!cur->validate_fn)
    588         cur->validate_fn = owl_variable_string_validate_default;
    589       if (!cur->set_fn)
    590         cur->set_fn = owl_variable_string_set_default;
    591       if (!cur->set_fromstring_fn)
    592         cur->set_fromstring_fn = owl_variable_string_set_fromstring_default;
    593       if (!cur->get_fn)
    594         cur->get_fn = owl_variable_get_default;
    595       if (!cur->get_tostring_fn)
    596         cur->get_tostring_fn = owl_variable_string_get_tostring_default;     
    597       if (!cur->delete_fn)
    598         cur->delete_fn = owl_variable_delete_default;
    599       cur->pval_default = g_strdup(var->pval_default);
    600       cur->set_fn(cur, cur->pval_default);
    601       break;
    602     case OWL_VARIABLE_BOOL:
    603       if (!cur->validate_fn)
    604         cur->validate_fn = owl_variable_bool_validate_default;
    605       if (!cur->set_fn)
    606         cur->set_fn = owl_variable_bool_set_default;
    607       if (!cur->set_fromstring_fn)
    608         cur->set_fromstring_fn = owl_variable_bool_set_fromstring_default;
    609       if (!cur->get_fn)
    610         cur->get_fn = owl_variable_get_default;
    611       if (!cur->get_tostring_fn)
    612         cur->get_tostring_fn = owl_variable_bool_get_tostring_default;     
    613       if (!cur->delete_fn)
    614         cur->delete_fn = owl_variable_delete_default;
    615       cur->val = g_new(int, 1);
    616       cur->set_fn(cur, &cur->ival_default);
    617       break;
    618     case OWL_VARIABLE_INT:
    619       if (!cur->validate_fn)
    620         cur->validate_fn = owl_variable_int_validate_default;
    621       if (!cur->set_fn)
    622         cur->set_fn = owl_variable_int_set_default;
    623       if (!cur->set_fromstring_fn)
    624         cur->set_fromstring_fn = owl_variable_int_set_fromstring_default;
    625       if (!cur->get_fn)
    626         cur->get_fn = owl_variable_get_default;
    627       if (!cur->get_tostring_fn)
    628         cur->get_tostring_fn = owl_variable_int_get_tostring_default;     
    629       if (!cur->delete_fn)
    630         cur->delete_fn = owl_variable_delete_default;
    631       cur->val = g_new(int, 1);
    632       cur->set_fn(cur, &cur->ival_default);
    633       break;
    634     default:
    635       fprintf(stderr, "owl_variable_setup: invalid variable type\n");
    636       return(-2);
    637     }
    638     owl_dict_insert_element(vd, cur->name, cur, NULL);
    639   }
    640   return 0;
     599  owl_variable_add_defaults(vd);
     600}
     601
     602CALLER_OWN GClosure *owl_variable_make_closure(owl_variable *v,
     603                                               GCallback fn,
     604                                               GClosureMarshal marshal) {
     605  GClosure *closure = g_cclosure_new_swap(fn, v, NULL);
     606  g_closure_set_marshal(closure,marshal);
     607  g_closure_ref(closure);
     608  g_closure_sink(closure);
     609  return closure;
    641610}
    642611
    643612void owl_variable_dict_add_variable(owl_vardict * vardict,
    644613                                    owl_variable * var) {
     614  char *oldvalue = NULL;
     615  owl_variable *oldvar = owl_variable_get_var(vardict, var->name);
     616  /* Save the old value as a string. */
     617  if (oldvar) {
     618    oldvalue = owl_variable_get_tostring(oldvar);
     619  }
    645620  owl_dict_insert_element(vardict, var->name, var, (void (*)(void *))owl_variable_delete);
    646 }
    647 
    648 CALLER_OWN owl_variable *owl_variable_newvar(const char *name, const char *summary, const char *description)
    649 {
    650   owl_variable * var = g_new0(owl_variable, 1);
     621  /* Restore the old value. */
     622  if (oldvalue) {
     623    owl_variable_set_fromstring(var, oldvalue, 0);
     624    g_free(oldvalue);
     625  }
     626}
     627
     628static owl_variable *owl_variable_newvar(int type, const char *name, const char *summary, const char *description, const char *validsettings) {
     629  owl_variable *var = g_new0(owl_variable, 1);
     630  var->type = type;
    651631  var->name = g_strdup(name);
    652632  var->summary = g_strdup(summary);
    653633  var->description = g_strdup(description);
     634  var->validsettings = g_strdup(validsettings);
    654635  return var;
    655636}
    656637
    657 void owl_variable_update(owl_variable *var, const char *summary, const char *desc) {
    658   g_free(var->summary);
    659   var->summary = g_strdup(summary);
    660   g_free(var->description);
    661   var->description = g_strdup(desc);
    662 }
    663 
    664 void owl_variable_dict_newvar_string(owl_vardict *vd, const char *name, const char *summ, const char *desc, const char *initval)
    665 {
    666   owl_variable *old = owl_variable_get_var(vd, name);
    667   if (old && owl_variable_get_type(old) == OWL_VARIABLE_STRING) {
    668     owl_variable_update(old, summ, desc);
    669     g_free(old->pval_default);
    670     old->pval_default = g_strdup(initval);
    671   } else {
    672     owl_variable * var = owl_variable_newvar(name, summ, desc);
    673     var->type = OWL_VARIABLE_STRING;
    674     var->validsettings = "<string>";
    675     var->pval_default = g_strdup(initval);
    676     var->set_fn = owl_variable_string_set_default;
    677     var->set_fromstring_fn = owl_variable_string_set_fromstring_default;
    678     var->get_fn = owl_variable_get_default;
    679     var->get_tostring_fn = owl_variable_string_get_tostring_default;
    680     var->delete_fn = owl_variable_delete_default;
    681     var->set_fn(var, initval);
    682     owl_variable_dict_add_variable(vd, var);
    683   }
    684 }
    685 
    686 void owl_variable_dict_newvar_int(owl_vardict *vd, const char *name, const char *summ, const char *desc, int initval)
    687 {
    688   owl_variable *old = owl_variable_get_var(vd, name);
    689   if (old && owl_variable_get_type(old) == OWL_VARIABLE_INT) {
    690     owl_variable_update(old, summ, desc);
    691     old->ival_default = initval;
    692   } else {
    693     owl_variable * var = owl_variable_newvar(name, summ, desc);
    694     var->type = OWL_VARIABLE_INT;
    695     var->validsettings = "<int>";
    696     var->ival_default = initval;
    697     var->validate_fn = owl_variable_int_validate_default;
    698     var->set_fn = owl_variable_int_set_default;
    699     var->set_fromstring_fn = owl_variable_int_set_fromstring_default;
    700     var->get_fn = owl_variable_get_default;
    701     var->get_tostring_fn = owl_variable_int_get_tostring_default;
    702     var->delete_fn = owl_variable_delete_default;
    703     var->val = g_new(int, 1);
    704     var->set_fn(var, &initval);
    705     owl_variable_dict_add_variable(vd, var);
    706   }
    707 }
    708 
    709 void owl_variable_dict_newvar_bool(owl_vardict *vd, const char *name, const char *summ, const char *desc, int initval)
    710 {
    711   owl_variable *old = owl_variable_get_var(vd, name);
    712   if (old && owl_variable_get_type(old) == OWL_VARIABLE_BOOL) {
    713     owl_variable_update(old, summ, desc);
    714