Changeset 825953e


Ignore:
Timestamp:
Jun 22, 2013, 9:49:39 PM (11 years ago)
Author:
Edward Z. Yang <ezyang@mit.edu>
Parents:
96d80e9 (diff), 33501b2 (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 33501b25952236fb070096716ed9c78845cd7f62 into 96d80e9b4aa667605b9c786b0272e1ab04dfbe9b
Files:
37 added
39 deleted
75 edited

Legend:

Unmodified
Added
Removed
  • .gitignore

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

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

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

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

    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

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

    r33501b2 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     
     
    10641061  g_free(wrapmsg);
    10651062  g_free(nz_screenname);
     1063  g_free(realmsg);
    10661064
    10671065  return(1);
    10681066
    1069   owl_function_debugmsg("faimtest_parse_incoming_im_chan1: icbm: message: %s\n", realmsg);
    1070  
    1071   if (args->icbmflags & AIM_IMFLAGS_MULTIPART) {
    1072     aim_mpmsg_section_t *sec;
    1073     int z;
    1074 
    1075     owl_function_debugmsg("faimtest_parse_incoming_im_chan1: icbm: multipart: this message has %d parts\n", args->mpmsg.numparts);
    1076    
    1077     for (sec = args->mpmsg.parts, z = 0; sec; sec = sec->next, z++) {
    1078       if ((sec->charset == 0x0000) || (sec->charset == 0x0003) || (sec->charset == 0xffff)) {
    1079         owl_function_debugmsg("faimtest_parse_incoming_im_chan1: icbm: multipart:   part %d: charset 0x%04x, subset 0x%04x, msg = %s\n", z, sec->charset, sec->charsubset, sec->data);
    1080       } else {
    1081         owl_function_debugmsg("faimtest_parse_incoming_im_chan1: icbm: multipart:   part %d: charset 0x%04x, subset 0x%04x, binary or UNICODE data\n", z, sec->charset, sec->charsubset);
    1082       }
    1083     }
    1084   }
    1085  
    1086   if (args->icbmflags & AIM_IMFLAGS_HASICON) {
    1087     /* aim_send_im(sess, userinfo->sn, AIM_IMFLAGS_BUDDYREQ, "You have an icon"); */
    1088     owl_function_debugmsg("faimtest_parse_incoming_im_chan1: icbm: their icon: iconstamp = %ld, iconlen = 0x%08x, iconsum = 0x%04x\n", args->iconstamp, args->iconlen, args->iconsum);
    1089   }
    1090 
    1091   g_free(realmsg);
    1092 
    1093   return(1);
     1067  /* TODO: Multipart? See history from before 1.8 release. */
    10941068}
    10951069
     
    18521826      fd = event_source->fds->pdata[i];
    18531827      fd->fd = cur->fd;
    1854       fd->events |= G_IO_IN | G_IO_HUP | G_IO_ERR;
     1828      fd->events = G_IO_IN | G_IO_HUP | G_IO_ERR;
    18551829      if (cur->status & AIM_CONN_STATUS_INPROGRESS) {
    1856         /* Yes, we're checking writable sockets here. Without it, AIM
    1857            login is really slow. */
     1830        /* AIM login requires checking writable sockets. See aim_select. */
    18581831        fd->events |= G_IO_OUT;
    18591832      }
     
    18911864{
    18921865  owl_aim_event_source *event_source = (owl_aim_event_source*)source;
    1893   truncate_pollfd_list(event_source, 0);
    1894   g_ptr_array_free(event_source->fds, TRUE);
     1866  /* Don't remove the GPollFDs. We are being finalized, so they'll be removed
     1867   * for us. Moreover, glib will fire asserts if g_source_remove_poll is called
     1868   * on a source which has been destroyed (which occurs when g_source_remove is
     1869   * called on it). */
     1870  owl_ptr_array_free(event_source->fds, g_free);
    18951871}
    18961872
  • cmd.c

    rce68f23 rf271129  
    1 #include <stdio.h>
    2 #include <stdlib.h>
    3 #include <string.h>
    4 #include <unistd.h>
    51#include "owl.h"
    62
     
    260256  if (cmd->usage && *cmd->usage) {
    261257    s = cmd->usage;
    262     indent = owl_text_indent(s, OWL_TAB);
     258    indent = owl_text_indent(s, OWL_TAB, true);
    263259    owl_fmtext_append_bold(fm, "\nSYNOPSIS\n");
    264260    owl_fmtext_append_normal(fm, indent);
     
    274270  if (cmd->description && *cmd->description) {
    275271    s = cmd->description;
    276     indent = owl_text_indent(s, OWL_TAB);
     272    indent = owl_text_indent(s, OWL_TAB, true);
    277273    owl_fmtext_append_bold(fm, "\nDESCRIPTION\n");
    278274    owl_fmtext_append_normal(fm, indent);
  • commands.c

    refeec7f 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");
     
    21652161      myargv[i]=argv[i];
    21662162    }
    2167     owl_function_create_filter(argc, myargv);
    2168     owl_function_change_currentview_filter("owl-dynamic");
     2163    if (owl_function_create_filter(argc, myargv)) {
     2164      owl_function_change_currentview_filter("owl-dynamic");
     2165    }
    21692166    g_free(myargv);
    21702167    return NULL;
     
    21932190    if (!strcmp(argv[0], "-f")) {
    21942191      if (argc<2) {
    2195         owl_function_makemsg("Too few argments to the view command");
     2192        owl_function_makemsg("Too few arguments to the view command");
    21962193        return(NULL);
    21972194      }
     
    22052202    } else if (!strcmp(argv[0], "-s")) {
    22062203      if (argc<2) {
    2207         owl_function_makemsg("Too few argments to the view command");
     2204        owl_function_makemsg("Too few arguments to the view command");
    22082205        return(NULL);
    22092206      }
     
    22122209      argv+=2;
    22132210    } else {
    2214       owl_function_makemsg("Too few argments to the view command");
     2211      owl_function_makemsg("Too few arguments to the view command");
    22152212      return(NULL);
    22162213    }
     
    27992796    owl_history_store(hist, owl_editwin_get_text(e), false);
    28002797
     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);
    28012803  owl_global_pop_context(&g);
     2804
     2805  owl_editwin_do_callback(e, false);
     2806  owl_editwin_unref(e);
    28022807}
    28032808
     
    28592864  owl_global_pop_context(&g);
    28602865
    2861   owl_editwin_do_callback(e);
     2866  owl_editwin_do_callback(e, true);
    28622867  owl_editwin_unref(e);
    28632868}
  • 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

    rf2a96c0 re4b8f93  
    11dnl Process this file with autoconf to produce a configure script.
    2 AC_INIT([BarnOwl],[1.8dev],[bug-barnowl@mit.edu])
    3 AM_INIT_AUTOMAKE([1.7.0 -Wall -Wno-portability foreign])
     2AC_INIT([BarnOwl],[1.10dev],[bug-barnowl@mit.edu])
     3AM_INIT_AUTOMAKE([1.7.0 foreign std-options -Wall -Wno-portability])
     4AM_MAINTAINER_MODE([enable])
    45m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
    56
     
    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})
     
    109137AC_CHECK_LIB([perl], [perl_alloc],, AC_MSG_ERROR([No libperl found]))
    110138
     139AX_PROG_PERL_MODULES([AnyEvent],,
     140                     [AC_MSG_ERROR([cannot find perl module AnyEvent.])])
    111141AX_PROG_PERL_MODULES([Class::Accessor::Fast],,
    112142                     [AC_MSG_ERROR([cannot find perl module Class::Accessor::Fast.])])
     143AX_PROG_PERL_MODULES([ExtUtils::Depends],,
     144                     [AC_MSG_ERROR([cannot find perl module ExtUtils::Depends])])
     145AX_PROG_PERL_MODULES([Glib],,
     146                     [AC_MSG_ERROR([cannot find perl module Glib.])])
     147AX_PROG_PERL_MODULES([Module::Install::Base],,
     148                     [AC_MSG_ERROR([cannot find perl module Module::Install::Base])])
    113149AX_PROG_PERL_MODULES([PAR],,
    114150                     [AC_MSG_WARN([PAR.pm not found. Loadable modules will be disabled.])])
     
    125161   prefix="${ac_default_prefix}"
    126162fi
     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}"
    127168
    128169dnl Checks for typedefs, structures, and compiler characteristics.
     
    164205AC_REPLACE_FUNCS([memrchr])
    165206
     207AC_SUBST([abs_builddir])
     208AC_SUBST([abs_srcdir])
     209
    166210AC_CONFIG_FILES([Makefile compat/Makefile libfaim/Makefile perl/Makefile perl/modules/Makefile])
    167211AC_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

    r6829afc 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  }
     
    11511147{
    11521148  oe_excursion x;
    1153   gunichar ch;
     1149  gunichar ch = 0;
     1150  gunichar last_ch;
    11541151  int sentence;
    11551152
     
    11841181    }
    11851182
     1183    last_ch = ch;
    11861184    ch = owl_editwin_get_char_at_point(e);
    11871185
     
    12011199    }
    12021200
    1203     if(ch == '.' || ch == '!' || ch == '?')
     1201    if (ch == '.' || ch == '!' || ch == '?' ||
     1202        (ch == '"' && (last_ch == '.' || last_ch == '!' || last_ch == '?')))
    12041203      sentence = 1;
    12051204    else
  • 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

    r2560529 rf271129  
    11#include "owl.h"
    2 #include <stdlib.h>
    3 #include <string.h>
    42
    53/* initialize an fmtext with no data */
     
    186184static void _owl_fmtext_wcolor_set(WINDOW *w, short pair)
    187185{
     186  cchar_t background;
     187  wchar_t blank[2] = { ' ', 0 };
    188188  if (has_colors()) {
    189       wcolor_set(w,pair,NULL);
    190       wbkgdset(w, COLOR_PAIR(pair));
     189      wcolor_set(w, pair, NULL);
     190      /* Set the background with wbkgrndset so that we can handle color-pairs
     191       * past 256 on ncurses ABI 6 and later. */
     192      setcchar(&background, blank, 0, pair, NULL);
     193      wbkgrndset(w, &background);
    191194  }
    192195}
     
    686689         * but zwgc seems to be smarter about some screw cases than I am
    687690         */
     691        g_free(buff);
    688692        owl_fmtext_append_attr(f, "@", curattrs, curcolor, OWL_COLOR_DEFAULT);
    689693        txtptr++;
  • functions.c

    refeec7f 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
     
    410404  old_msg = g_strdup(owl_zwrite_get_message(z));
    411405
    412   zcrypt = g_strdup_printf("%s/zcrypt", owl_get_bindir());
    413   argv[0] = "zcrypt";
     406  zcrypt = g_build_filename(owl_get_bindir(), "zcrypt", NULL);
     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,
     
    12231216void G_GNUC_PRINTF(1, 2) owl_function_debugmsg(const char *fmt, ...)
    12241217{
     1218  char *tmpbuff;
    12251219  FILE *file;
    12261220  time_t now;
     
    12371231  now = time(NULL);
    12381232
    1239   fprintf(file, "[%d -  %.24s - %lds]: ",
    1240           (int) getpid(), ctime(&now), now - owl_global_get_starttime(&g));
     1233  tmpbuff = owl_util_format_time(localtime(&now));
     1234  fprintf(file, "[%d -  %s - %lds]: ",
     1235          (int) getpid(), tmpbuff, now - owl_global_get_starttime(&g));
     1236  g_free(tmpbuff);
    12411237  vfprintf(file, fmt, ap);
    12421238  putc('\n', file);
     
    13851381  owl_fmtext fm, attrfm;
    13861382  const owl_view *v;
     1383  char *time;
    13871384#ifdef HAVE_LIBZEPHYR
    13881385  const ZNotice_t *n;
     
    14151412  }
    14161413
    1417   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);
    14181417
    14191418  if (!owl_message_is_type_admin(m)) {
     
    14291428    owl_fmtext_appendf_normal(&fm, "  Opcode    : %s\n", owl_message_get_opcode(m));
    14301429#ifdef HAVE_LIBZEPHYR
    1431     if (owl_message_is_direction_in(m)) {
    1432       char *tmpbuff;
     1430    n = owl_message_get_notice(m);
     1431    if (n != NULL) {
     1432      char *tmpbuff, *tmpbuff2;
    14331433      int i, fields;
    1434 
    1435       n=owl_message_get_notice(m);
     1434      const char *f;
    14361435
    14371436      if (!owl_message_is_pseudo(m)) {
     
    14751474        owl_fmtext_appendf_normal(&fm, "  Fields    : %i\n", fields);
    14761475
    1477         for (i = 0; i < fields; i++) {
    1478           tmpbuff = owl_zephyr_get_field_as_utf8(n, i + 1);
    1479 
    1480           g_strdelimit(tmpbuff, "\n", '~');
    1481           g_strdelimit(tmpbuff, "\r", '!');
    1482 
    1483           owl_fmtext_appendf_normal(&fm, "  Field %i   : %s\n", i + 1, tmpbuff);
    1484           g_free(tmpbuff);
     1476        for (i = 0, f = owl_zephyr_first_raw_field(n); f != NULL;
     1477             i++, f = owl_zephyr_next_raw_field(n, f)) {
     1478          tmpbuff = owl_zephyr_field_as_utf8(n, f);
     1479          tmpbuff2 = owl_text_indent(tmpbuff, 14, false);
     1480          owl_fmtext_appendf_normal(&fm, "  Field %i   : %s\n", i + 1, tmpbuff2);
     1481          g_free(tmpbuff2);
     1482          g_free(tmpbuff);
    14851483        }
    1486         owl_fmtext_appendf_normal(&fm, "  Default Fm: %s\n", n->z_default_format);
     1484        tmpbuff = owl_text_indent(n->z_default_format, 14, false);
     1485        owl_fmtext_appendf_normal(&fm, "  Default Fm: %s\n", tmpbuff);
     1486        g_free(tmpbuff);
    14871487      }
    14881488
     
    17611761void owl_function_status(void)
    17621762{
     1763  char *tmpbuff;
    17631764  char buff[MAXPATHLEN+1];
    17641765  time_t start;
     
    17881789  owl_fmtext_append_normal(&fm, "\n");
    17891790
    1790   owl_fmtext_appendf_normal(&fm, "  Startup Time: %s", ctime(&start));
     1791  tmpbuff = owl_util_format_time(localtime(&start));
     1792  owl_fmtext_appendf_normal(&fm, "  Startup Time: %s\n", tmpbuff);
     1793  g_free(tmpbuff);
    17911794
    17921795  up=owl_global_get_runtime(&g);
     
    19411944}
    19421945
    1943 void owl_callback_command(owl_editwin *e)
    1944 {
     1946void owl_callback_command(owl_editwin *e, bool success)
     1947{
     1948  if (!success) return;
    19451949  char *rv;
    19461950  const char *line = owl_editwin_get_text(e);
     
    19531957}
    19541958
    1955 void owl_function_start_command(const char *line)
     1959owl_editwin *owl_function_start_command(const char *line)
    19561960{
    19571961  owl_editwin *tw;
     
    19681972  owl_global_push_context_obj(&g, ctx);
    19691973  owl_editwin_set_callback(tw, owl_callback_command);
    1970 }
    1971 
    1972 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)
    19731978{
    19741979  owl_editwin *tw;
     
    19851990}
    19861991
    1987 CALLER_OWN owl_editwin *owl_function_start_password(const char *line)
     1992owl_editwin *owl_function_start_password(const char *line)
    19881993{
    19891994  owl_editwin *tw;
     
    21262131
    21272132/* Create a new filter, or replace an existing one
    2128  * with a new definition.
     2133 * with a new definition. Returns true on success.
    21292134 */
    2130 void owl_function_create_filter(int argc, const char *const *argv)
     2135bool owl_function_create_filter(int argc, const char *const *argv)
    21312136{
    21322137  owl_filter *f;
     
    21362141  if (argc < 2) {
    21372142    owl_function_error("Wrong number of arguments to filter command");
    2138     return;
     2143    return false;
    21392144  }
    21402145
     
    21462151  if (!strcmp(argv[1], "all")) {
    21472152    owl_function_error("You may not change the 'all' filter.");
    2148     return;
     2153    return false;
    21492154  }
    21502155
     
    21542159    if (!f) {
    21552160      owl_function_error("The filter '%s' does not exist.", argv[1]);
    2156       return;
     2161      return false;
    21572162    }
    21582163    if (owl_util_string_to_color(argv[3])==OWL_COLOR_INVALID) {
    21592164      owl_function_error("The color '%s' is not available.", argv[3]);
    2160       return;
     2165      return false;
    21612166    }
    21622167    owl_filter_set_fgcolor(f, owl_util_string_to_color(argv[3]));
    21632168    owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    2164     return;
     2169    return false;
    21652170  }
    21662171  if (argc==4 && !strcmp(argv[2], "-b")) {
     
    21682173    if (!f) {
    21692174      owl_function_error("The filter '%s' does not exist.", argv[1]);
    2170       return;
     2175      return false;
    21712176    }
    21722177    if (owl_util_string_to_color(argv[3])==OWL_COLOR_INVALID) {
    21732178      owl_function_error("The color '%s' is not available.", argv[3]);
    2174       return;
     2179      return false;
    21752180    }
    21762181    owl_filter_set_bgcolor(f, owl_util_string_to_color(argv[3]));
    21772182    owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    2178     return;
     2183    return true;
    21792184  }
    21802185
     
    21822187  f = owl_filter_new(argv[1], argc-2, argv+2);
    21832188  if (f == NULL) {
    2184     owl_function_error("Invalid filter");
    2185     return;
     2189    owl_function_error("Invalid filter: %s", argv[1]);
     2190    return false;
    21862191  }
    21872192
     
    22042209  }
    22052210  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
     2211  return true;
    22062212}
    22072213
     
    24552461  /* if it already exists then go with it.  This lets users override */
    24562462  if (owl_global_get_filter(&g, filtname)) {
    2457     return(g_strdup(filtname));
     2463    return filtname;
    24582464  }
    24592465
     
    30813087      idle=owl_buddy_get_idle_time(b);
    30823088      if (idle!=0) {
    3083         timestr=owl_util_minutes_to_timestr(idle);
     3089        timestr=owl_util_format_minutes(idle);
    30843090      } else {
    30853091        timestr=g_strdup("");
     
    32263232      } else if (myargc > 0) {
    32273233        /* Spawn the child. */
    3228         pid_t pid;
     3234        GPid pid;
    32293235        GError *error = NULL;
    32303236        owl_function_debugmsg("About to exec \"%s\" with %d arguments", argv[0], myargc);
     
    34093415  char *buff;
    34103416
    3411   now=time(NULL);
    3412   date=g_strdup(ctime(&now));
    3413   date[strlen(date)-1]='\0';
     3417  now = time(NULL);
     3418  date = owl_util_format_time(localtime(&now));
    34143419
    34153420  buff = g_strdup_printf("%s %s", date, string);
     
    34743479
    34753480  anyone = owl_zephyr_get_anyone_list(NULL);
    3476   for (i = 0; i < anyone->len; i++) {
    3477     user = anyone->pdata[i];
    3478     zald = g_new(ZAsyncLocateData_t, 1);
    3479     if (ZRequestLocations(zstr(user), zald, UNACKED, ZAUTH) == ZERR_NONE) {
    3480       *zaldlist = g_list_append(*zaldlist, zald);
    3481     } else {
    3482       g_free(zald);
    3483     }
    3484   }
    3485 
    3486   owl_ptr_array_free(anyone, g_free);
     3481  if (anyone != NULL) {
     3482    for (i = 0; i < anyone->len; i++) {
     3483      user = anyone->pdata[i];
     3484      zald = g_new(ZAsyncLocateData_t, 1);
     3485      if (ZRequestLocations(zstr(user), zald, UNACKED, ZAUTH) == ZERR_NONE) {
     3486        *zaldlist = g_list_append(*zaldlist, zald);
     3487      } else {
     3488        g_free(zald);
     3489      }
     3490    }
     3491    owl_ptr_array_free(anyone, g_free);
     3492  }
    34873493#endif
    34883494}
  • global.c

    r16cf182d 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();
     
    7775  g->confdir = NULL;
    7876  g->startupfile = NULL;
    79   cd = g_strdup_printf("%s/%s", g->homedir, OWL_CONFIG_DIR);
     77  cd = g_build_filename(g->homedir, OWL_CONFIG_DIR, NULL);
    8078  owl_global_set_confdir(g, cd);
    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
     
    364367  g->confdir = g_strdup(cd);
    365368  g_free(g->startupfile);
    366   g->startupfile = g_strdup_printf("%s/startup", cd);
     369  g->startupfile = g_build_filename(cd, "startup", NULL);
    367370}
    368371
     
    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

    r6829afc 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 */
     
    224221    while (cc != NULL) {
    225222      temp = short_zuser(cc->data);
    226       filename = g_strdup_printf("%s/%s", logpath, temp);
     223      filename = g_build_filename(logpath, temp, NULL);
    227224      owl_log_append(m, filename);
    228225
     
    248245  }
    249246
    250   filename = g_strdup_printf("%s/%s", logpath, to);
     247  filename = g_build_filename(logpath, to, NULL);
    251248  owl_log_append(m, filename);
    252249  g_free(to);
    253250  g_free(filename);
    254251
    255   filename = g_strdup_printf("%s/all", logpath);
     252  filename = g_build_filename(logpath, "all", NULL);
    256253  owl_log_append(m, filename);
    257254  g_free(logpath);
     
    285282  /* expand ~ in path names */
    286283  logpath = owl_util_makepath(owl_global_get_logpath(&g));
    287   filename = g_strdup_printf("%s/%s", logpath, tobuff);
     284  filename = g_build_filename(logpath, tobuff, NULL);
    288285  msgbuf = g_string_new("");
    289286  g_string_printf(msgbuf, "ERROR (owl): %s\n%s\n", tobuff, text);
     
    294291  g_string_free(msgbuf, TRUE);
    295292
    296   filename = g_strdup_printf("%s/all", logpath);
     293  filename = g_build_filename(logpath, "all", NULL);
    297294  g_free(logpath);
    298295  msgbuf = g_string_new("");
     
    393390  if (personal) {
    394391    logpath = owl_util_makepath(owl_global_get_logpath(&g));
    395     filename = g_strdup_printf("%s/%s", logpath, from);
    396     allfilename = g_strdup_printf("%s/all", logpath);
     392    filename = g_build_filename(logpath, from, NULL);
     393    allfilename = g_build_filename(logpath, "all", NULL);
    397394    owl_log_append(m, allfilename);
    398395    g_free(allfilename);
    399396  } else {
    400397    logpath = owl_util_makepath(owl_global_get_classlogpath(&g));
    401     filename = g_strdup_printf("%s/%s", logpath, from);
     398    filename = g_build_filename(logpath, from, NULL);
    402399  }
    403400
     
    415412      temp = short_zuser(cc->data);
    416413      if (strcasecmp(temp, frombuff) != 0) {
    417         filename = g_strdup_printf("%s/%s", logpath, temp);
     414        filename = g_build_filename(logpath, temp, NULL);
    418415        owl_log_append(m, filename);
    419416        g_free(filename);
     
    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

    rf9df2f0 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();
    4642 
    4743  /* save the time */
    48   m->time=time(NULL);
    49   m->timestr=g_strdup(ctime(&(m->time)));
    50   m->timestr[strlen(m->timestr)-1]='\0';
     44  m->time = time(NULL);
     45  m->timestr = g_strdup(ctime(&m->time));
     46  m->timestr[strlen(m->timestr)-1] = '\0';
    5147
    5248  m->fmtext = NULL;
     
    125121    p = m->attributes->pdata[i];
    126122
    127     tmpbuff = g_strdup(owl_pair_get_value(p));
    128     g_strdelimit(tmpbuff, "\n", '~');
    129     g_strdelimit(tmpbuff, "\r", '!');
    130     buff = g_strdup_printf("  %-15.15s: %s\n", owl_pair_get_key(p), tmpbuff);
    131     g_free(tmpbuff);
     123    buff = g_strdup(owl_pair_get_value(p));
     124    if (buff) {
     125      tmpbuff = owl_text_indent(buff, 19, false);
     126      g_free(buff);
     127      buff = g_strdup_printf("  %-15.15s: %s\n", owl_pair_get_key(p), tmpbuff);
     128      g_free(tmpbuff);
     129    }
    132130
    133131    if(buff == NULL) {
     
    349347}
    350348
     349CALLER_OWN char *owl_message_format_time(const owl_message *m)
     350{
     351  return owl_util_format_time(localtime(&m->time));
     352}
     353
    351354void owl_message_set_type_admin(owl_message *m)
    352355{
     
    497500const ZNotice_t *owl_message_get_notice(const owl_message *m)
    498501{
    499   return(&(m->notice));
     502  return m->has_notice ? &m->notice : NULL;
    500503}
    501504#else
     
    788791  /* first save the full notice */
    789792  m->notice = *n;
     793  m->has_notice = true;
    790794
    791795  /* a little gross, we'll replace \r's with ' ' for now */
     
    794798  /* save the time, we need to nuke the string saved by message_init */
    795799  if (m->timestr) g_free(m->timestr);
    796   m->time=n->z_time.tv_sec;
    797   m->timestr=g_strdup(ctime(&(m->time)));
    798   m->timestr[strlen(m->timestr)-1]='\0';
     800  m->time = n->z_time.tv_sec;
     801  m->timestr = g_strdup(ctime(&m->time));
     802  m->timestr[strlen(m->timestr)-1] = '\0';
    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;
    884886    char *zcrypt;
    885887
    886     zcrypt = g_strdup_printf("%s/zcrypt", owl_get_bindir());
    887 
    888     rv = call_filter(zcrypt, argv, owl_message_get_body(m), &out, &status);
     888    zcrypt = g_build_filename(owl_get_bindir(), "zcrypt", NULL);
     889    argv[0] = zcrypt;
     890
     891    rv = call_filter(argv, owl_message_get_body(m), &out, &status);
    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

    rb8a3e00 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 */
     
    389382}
    390383
    391 #define CHECK_RESULT(s, syscall) \
     384#define OR_DIE(s, syscall)      \
    392385  G_STMT_START {                 \
    393     if ((syscall) != 0) {        \
     386    if ((syscall) == -1) {       \
    394387      perror((s));               \
    395388      exit(1);                   \
     
    402395  sigset_t sigset;
    403396  int ret, i;
    404   const int signals[] = { SIGABRT, SIGBUS, SIGCHLD, SIGFPE, SIGHUP, SIGILL,
    405                           SIGINT, SIGQUIT, SIGSEGV, SIGTERM, SIGWINCH };
     397  const int reset_signals[] = { SIGABRT, SIGBUS, SIGCHLD, SIGFPE, SIGILL,
     398                                SIGQUIT, SIGSEGV, };
     399  /* Don't bother resetting watched ones because owl_signal_init will. */
     400  const int watch_signals[] = { SIGWINCH, SIGTERM, SIGHUP, SIGINT, };
    406401
    407402  /* Sanitize our signals; the mask and dispositions from our parent
    408403   * aren't really useful. Signal list taken from equivalent code in
    409404   * Chromium. */
    410   CHECK_RESULT("sigemptyset", sigemptyset(&sigset));
     405  OR_DIE("sigemptyset", sigemptyset(&sigset));
    411406  if ((ret = pthread_sigmask(SIG_SETMASK, &sigset, NULL)) != 0) {
    412407    errno = ret;
    413408    perror("pthread_sigmask");
    414   }
    415   for (i = 0; i < G_N_ELEMENTS(signals); i++) {
    416     CHECK_RESULT("sigaction", sigaction(signals[i], &sig_default, NULL));
     409    exit(1);
     410  }
     411  for (i = 0; i < G_N_ELEMENTS(reset_signals); i++) {
     412    OR_DIE("sigaction", sigaction(reset_signals[i], &sig_default, NULL));
    417413  }
    418414
    419415  /* Turn off SIGPIPE; we check the return value of write. */
    420   CHECK_RESULT("sigaction", sigaction(SIGPIPE, &sig_ignore, NULL));
     416  OR_DIE("sigaction", sigaction(SIGPIPE, &sig_ignore, NULL));
    421417
    422418  /* Register some signals with the signal thread. */
    423   CHECK_RESULT("sigaddset", sigaddset(&sigset, SIGWINCH));
    424   CHECK_RESULT("sigaddset", sigaddset(&sigset, SIGTERM));
    425   CHECK_RESULT("sigaddset", sigaddset(&sigset, SIGHUP));
    426   CHECK_RESULT("sigaddset", sigaddset(&sigset, SIGINT));
    427   owl_signal_init(&sigset, sig_handler, NULL);
     419  owl_signal_init(watch_signals, G_N_ELEMENTS(watch_signals),
     420                  sig_handler, NULL);
    428421}
    429422
     
    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

    r16cf182d r6249a88f  
    1010#define INC_BARNOWL_OWL_H
    1111
    12 #include "config.h"
     12#include <config.h>
    1313
    1414#include "compat/compat.h"
     
    1818#ifndef OWL_PERL
    1919#define NCURSES_ENABLE_STDBOOL_H 1
    20 #include <curses.h>
    21 #include <panel.h>
     20#include <ncursesw/curses.h>
     21#include <ncursesw/panel.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
     
    7582
    7683#define OWL_CONFIG_DIR "/.owl"             /* this is relative to the user's home directory */
    77 #define OWL_STARTUP_FILE "/.owl/startup"   /* this is relative to the user's home directory */
    7884
    7985#define OWL_FMTEXT_ATTR_NONE      0
     
    207213/* OWL_CTRL is definied in kepress.c */
    208214
    209 #define LINE 2048
    210 
    211215#ifdef HAVE_LIBZEPHYR
    212216/* libzephyr doesn't use const, so we appease the type system with this kludge.
     
    231235  char *name;
    232236  int   type;  /* OWL_VARIABLE_* */
    233   void *pval_default;  /* for types other and string */
    234   int   ival_default;  /* for types int and bool     */
    235   const char *validsettings;    /* documentation of valid settings */
     237  char *default_str;            /* the default value as a string */
     238  char *validsettings;          /* documentation of valid settings */
    236239  char *summary;                /* summary of usage */
    237240  char *description;            /* detailed description */
    238   void *val;                    /* current value */
    239   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;
    240260                                /* returns 1 if newval is valid */
    241   int  (*set_fn)(struct _owl_variable *v, const void *newval);
     261  GCallback set_fn;
    242262                                /* sets the variable to a value
    243                                  * of the appropriate type.
    244                                  * unless documented, this
    245                                  * should make a copy.
    246                                  * returns 0 on success. */
    247   int  (*set_fromstring_fn)(struct _owl_variable *v, const char *newval);
    248                                 /* sets the variable to a value
    249                                  * of the appropriate type.
    250                                  * unless documented, this
    251                                  * should make a copy.
    252                                  * returns 0 on success. */
    253   const void *(*get_fn)(const struct _owl_variable *v);
    254                                 /* returns a reference to the current value.
    255                                  * WARNING:  this approach is hard to make
    256                                  * thread-safe... */
    257   CALLER_OWN char *(*get_tostring_fn)(const struct _owl_variable *v, const void *val);
    258                                 /* converts val to a string;
    259                                  * caller must free the result */
    260   void (*delete_fn)(struct _owl_variable *v);
    261                                 /* frees val as needed */
     263                                 * of the appropriate type.
     264                                 * unless documented, this
     265                                 * should make a copy.
     266                                 * returns 0 on success. */
    262267} owl_variable;
     268
    263269
    264270typedef struct _owl_input {
     
    352358  int direction;
    353359#ifdef HAVE_LIBZEPHYR
     360  bool has_notice;
    354361  ZNotice_t notice;
    355362#endif
     
    447454  char *name;
    448455  owl_filter *filter;
    449   owl_messagelist ml;
     456  owl_messagelist *ml;
    450457  const owl_style *style;
    451458  int cachedmsgid;
     
    528535
    529536typedef struct _owl_global {
    530   owl_mainwin mw;
     537  owl_mainwin *mw;
    531538  owl_popwin *pw;
    532539  owl_msgwin msgwin;
     
    546553  int curmsg_vert_offset;
    547554  owl_view current_view;
    548   owl_messagelist msglist;
     555  owl_messagelist *msglist;
    549556  WINDOW *input_pad;
    550557  owl_mainpanel mainpanel;
     
    591598  char *kill_buffer;
    592599  int interrupt_count;
     600#if GLIB_CHECK_VERSION(2, 31, 0)
     601  GMutex interrupt_lock;
     602#else
    593603  GMutex *interrupt_lock;
     604#endif
    594605} owl_global;
    595606
     
    597608extern owl_global g;
    598609
    599 #include "owl_prototypes.h"
     610#include <owl_prototypes.h>
    600611
    601612/* These were missing from the Zephyr includes before Zephyr 3. */
     
    605616#endif
    606617
     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
    607624#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)
  • perl/modules/Twitter/lib/BarnOwl/Module/Twitter/Handle.pm

    r7aa1fa5 r4ebbfbc  
    2929use BarnOwl;
    3030use BarnOwl::Message::Twitter;
    31 use POSIX qw(asctime);
     31use POSIX qw(strftime);
    3232
    3333use LWP::UserAgent;
     
    247247                       ($self->{cfg}->{account_nickname} ?
    248248                        "[$self->{cfg}->{account_nickname}]" : "") .
    249                         ": ratelimited until " . asctime(localtime($timeout)));
     249                        ": ratelimited until " . strftime('%c', localtime($timeout)));
    250250    } elsif(exists($ratelimit->{error})) {
    251251        $self->sleep(60*20);
  • perlconfig.c

    rce68f23 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;
     
    406340  /* Add the system lib path to @INC */
    407341  inc = get_av("INC", 0);
    408   path = g_strdup_printf("%s/lib", owl_get_datadir());
     342  path = g_build_filename(owl_get_datadir(), "lib", NULL);
    409343  av_unshift(inc, 1);
    410344  av_store(inc, 0, owl_new_sv(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

    rd427f08 rf271129  
    1 #include <string.h>
    21#include "owl.h"
    32
     
    1110{
    1211  int ret;
    13   char buff1[LINE];
     12  size_t errbuf_size;
     13  char *errbuf;
    1414  const char *ptr;
    1515 
     
    2626  ret=regcomp(&(re->re), ptr, REG_EXTENDED|REG_ICASE);
    2727  if (ret) {
    28     regerror(ret, NULL, buff1, LINE);
    29     owl_function_makemsg("Error in regular expression: %s", buff1);
     28    errbuf_size = regerror(ret, NULL, NULL, 0);
     29    errbuf = g_new(char, errbuf_size);
     30    regerror(ret, NULL, errbuf, errbuf_size);
     31    owl_function_error("Error in regular expression: %s", errbuf);
     32    g_free(errbuf);
    3033    g_free(re->string);
    3134    re->string=NULL;
  • runtests.sh

    r786a410 r5db8835  
    11#!/bin/sh
    2 SRCDIR=`dirname "${0}"`
    3 
    4 export BARNOWL_DATA_DIR="$SRCDIR/perl/"
    5 export BARNOWL_BIN_DIR="$SRCDIR/"
    6 
    7 HARNESS_PERL=./tester exec prove --failures t/
     2exec env HARNESS_PERL=./tester prove --failures "${srcdir:=$(dirname "$0")}/t/"
  • scripts/locker-build

    r401752a r055e366  
    8585    BARNOWL="/afs/sipb.mit.edu/project/barnowl/arch/$ATHENA_SYS"
    8686    export PKG_CONFIG_PATH="$BARNOWL/lib/pkgconfig"
     87    eval $("$BARNOWL/bin/barnowl-perl-config")
    8788
    8889    SUFFIX=
  • signal.c

    r1d21d9f ra7fac14  
    11#include <errno.h>
     2#include <glib.h>
    23#include <pthread.h>
    34#include <signal.h>
     
    1314static void *signal_thread_func(void *data);
    1415
    15 /* Initializes the signal thread to listen for 'set' on a dedicated
     16static void dummy_handler(int signum)
     17{
     18  /* Do nothing. This should never get called. It'd be nice to report the error
     19   * or something, but you can't have nice things in a signal handler. */
     20}
     21
     22#define OR_DIE(s, syscall)       \
     23  G_STMT_START {                 \
     24    if ((syscall) == -1) {       \
     25      perror((s));               \
     26      exit(1);                   \
     27    }                            \
     28  } G_STMT_END
     29
     30/* Initializes the signal thread to listen for 'signals' on a dedicated
    1631 * thread. 'callback' is called *on the signal thread* when a signal
    1732 * is received.
     
    1934 * This function /must/ be called before any other threads are
    2035 * created. (Otherwise the signals will not get blocked correctly.) */
    21 void owl_signal_init(const sigset_t *set, void (*callback)(const siginfo_t*, void*), void *data) {
     36void owl_signal_init(const int *signals, int num_signals, void (*callback)(const siginfo_t*, void*), void *data) {
     37  struct sigaction sig_dummy = { .sa_handler = dummy_handler };
    2238  int ret;
     39  int i;
    2340
    24   signal_set = *set;
    2541  signal_cb = callback;
    2642  signal_cbdata = data;
     43
     44  /* Stuff the signals into our sigset_t. Also assign all of them to a dummy
     45   * handler. Otherwise, if their default is SIG_IGN, they will get dropped if
     46   * delivered while processing. On Solaris, they will not get delivered at
     47   * all. */
     48  OR_DIE("sigemptyset", sigemptyset(&signal_set));
     49  for (i = 0; i < num_signals; i++) {
     50    OR_DIE("sigaddset", sigaddset(&signal_set, signals[i]));
     51    OR_DIE("sigaction", sigaction(signals[i], &sig_dummy, NULL));
     52  }
     53
    2754  /* Block these signals in all threads, so we can get them. */
    28   if ((ret = pthread_sigmask(SIG_BLOCK, set, NULL)) != 0) {
     55  if ((ret = pthread_sigmask(SIG_BLOCK, &signal_set, NULL)) != 0) {
    2956    errno = ret;
    3057    perror("pthread_sigmask");
     58    exit(1);
    3159  }
    3260  /* Spawn a dedicated thread to sigwait. */
  • style.c

    rd4927a7 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 {
     
    6566
    6667  /* indent and ensure ends with a newline */
    67   indent = owl_text_indent(body, OWL_TAB);
     68  indent = owl_text_indent(body, OWL_TAB, true);
    6869  curlen = strlen(indent);
    69   if (curlen==0 || indent[curlen-1] != '\n') {
    70     indent[curlen] = '\n';
    71     indent[curlen+1] = '\0';
     70  if (curlen == 0 || indent[curlen-1] != '\n') {
     71    char *tmp = indent;
     72    indent = g_strconcat(tmp, "\n", NULL);
     73    g_free(tmp);
    7274  }
    7375
  • 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");
  • t/completion.t

    r3001c11 re59d775  
    323323}
    324324
    325 mkpath("$tmpdir/.owl/",
    326        "$tmpdir/.owl/modules/",
    327        "$tmpdir/Public/",
    328        "$tmpdir/Private/",
    329        "$tmpdir/.ours",
    330        "$tmpdir/www",
    331      {mode => 0700});
     325mkpath(["$tmpdir/.owl/",
     326        "$tmpdir/.owl/modules/",
     327        "$tmpdir/Public/",
     328        "$tmpdir/Private/",
     329        "$tmpdir/.ours",
     330        "$tmpdir/www"],
     331       0, 0700);
    332332touch("$tmpdir/.zephyr.subs");
    333333touch("$tmpdir/wheee");
  • t/unicode.t

    r09ff1eb rf415f83  
    55use Encode;
    66
    7 BEGIN { bootstrap BarnOwl; };
     7use Test::More qw(no_plan);
    88
    9 use Test::More qw(no_plan);
     9use BarnOwl;
    1010
    1111my $unicode = "“hello”";
  • tester.c

    r14c9e05 r6a8b519  
    33#include "owl.h"
    44#undef WINDOW
    5 
    6 #include <errno.h>
    7 #include <unistd.h>
    8 #include <pwd.h>
     5#include "filterproc.h"
     6
    97#include <stdio.h>
    10 #include <stdlib.h>
    11 #include <string.h>
    12 #include <sys/types.h>
    138
    149#undef instr
    15 #include <curses.h>
     10#include <ncursesw/curses.h>
    1611
    1712owl_global g;
     
    2924int owl_smartfilter_regtest(void);
    3025int owl_history_regtest(void);
     26int call_filter_regtest(void);
    3127
    3228extern void owl_perl_xs_init(pTHX);
     
    119115  numfailures += owl_smartfilter_regtest();
    120116  numfailures += owl_history_regtest();
     117  numfailures += call_filter_regtest();
    121118  if (numfailures) {
    122119      fprintf(stderr, "# *** WARNING: %d failures total\n", numfailures);
     
    136133{
    137134  int numfailed=0;
    138   const char *home;
    139   char *s, *path;
    140   struct passwd *pw;
     135  char *path, *home;
    141136
    142137  printf("# BEGIN testing owl_util\n");
     
    227222                "\"");
    228223
    229   GString *g = g_string_new("");
    230   owl_string_appendf_quoted(g, "%q foo %q%q %s %", "hello", "world is", "can't");
     224  GString *quoted = g_string_new("");
     225  owl_string_appendf_quoted(quoted, "%q foo %q%q %s %", "hello", "world is", "can't");
    231226  FAIL_UNLESS("owl_string_appendf",
    232               !strcmp(g->str, "hello foo 'world is'\"can't\" %s %"));
    233   g_string_free(g, true);
    234 
    235 
    236   s = owl_util_baseclass("barnowl");
    237   FAIL_UNLESS("baseclass barnowl", !strcmp("barnowl", s));
    238   g_free(s);
    239   s = owl_util_baseclass("unbarnowl");
    240   FAIL_UNLESS("baseclass unbarnowl", !strcmp("barnowl", s));
    241   g_free(s);
    242   s = owl_util_baseclass("unununbarnowl.d.d");
    243   FAIL_UNLESS("baseclass unununbarnowl.d.d", !strcmp("barnowl", s));
    244   g_free(s);
    245   s = owl_util_baseclass("ununun.d.d");
    246   FAIL_UNLESS("baseclass ununun.d.d", !strcmp("", s));
    247   g_free(s);
    248   s = owl_util_baseclass("d.d.d.d");
    249   FAIL_UNLESS("baseclass d.d.d.d", !strcmp("d", s));
    250   g_free(s);
    251   s = owl_util_baseclass("n.d.d.d");
    252   FAIL_UNLESS("baseclass n.d.d.d", !strcmp("n", s));
    253   g_free(s);
    254   s = owl_util_baseclass("ununun.");
    255   FAIL_UNLESS("baseclass ununun.", !strcmp(".", s));
    256   g_free(s);
    257   s = owl_util_baseclass("unununu");
    258   FAIL_UNLESS("baseclass unununu", !strcmp("u", s));
    259   g_free(s);
    260 
    261 
    262   s = owl_util_makepath("foo/bar");
    263   FAIL_UNLESS("makepath foo/bar", !strcmp("foo/bar", s));
    264   g_free(s);
    265   s = owl_util_makepath("//foo///bar");
    266   FAIL_UNLESS("makepath //foo///bar", !strcmp("/foo/bar", s));
    267   g_free(s);
    268   s = owl_util_makepath("foo/~//bar/");
    269   FAIL_UNLESS("makepath foo/~//bar/", !strcmp("foo/~/bar/", s));
    270   g_free(s);
    271   s = owl_util_makepath("~thisuserhadreallybetternotexist/foobar/");
    272   FAIL_UNLESS("makepath ~thisuserhadreallybetternotexist/foobar/",
    273               !strcmp("~thisuserhadreallybetternotexist/foobar/", s));
    274   g_free(s);
    275 
    276   errno = 0;
    277   pw = getpwuid(getuid());
    278   if (pw) {
    279     home = pw->pw_dir;
    280   } else {
     227              !strcmp(quoted->str, "hello foo 'world is'\"can't\" %s %"));
     228  g_string_free(quoted, true);
     229
     230
     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/"));
     258
     259  home = g_strdup(owl_global_get_homedir(&g));
     260  CHECK_STR_AND_FREE("makepath ~",
     261                     home, owl_util_makepath("~"));
     262
     263  path = g_build_filename(home, "foo/bar/baz", NULL);
     264  CHECK_STR_AND_FREE("makepath ~///foo/bar//baz",
     265                     path, owl_util_makepath("~///foo/bar//baz"));
     266  g_free(path);
     267  g_free(home);
     268
     269  home = owl_util_homedir_for_user("root");
     270  if (home == NULL) {
    281271    /* Just make some noise so we notice. */
    282     home = "<WHAT>";
    283     fprintf(stderr, "getpwuid: %s", errno ? strerror(errno) : "No such user");
    284   }
    285   s = owl_util_makepath("~");
    286   FAIL_UNLESS("makepath ~", !strcmp(home, s));
    287   g_free(s);
    288 
    289   path = g_strconcat(home, "/foo/bar/baz", NULL);
    290   s = owl_util_makepath("~///foo/bar//baz");
    291   FAIL_UNLESS("makepath ~///foo/bar//baz", !strcmp(path, s));
    292   g_free(s);
     272    home = g_strdup("<WHAT>");
     273    fprintf(stderr, "owl_util_homedir_for_user failed");
     274  }
     275
     276  CHECK_STR_AND_FREE("makepath ~root",
     277                     home, owl_util_makepath("~root"));
     278
     279  path = g_build_filename(home, "foo/bar/baz", NULL);
     280  CHECK_STR_AND_FREE("makepath ~root///foo/bar//baz",
     281                     path, owl_util_makepath("~root///foo/bar//baz"));
    293282  g_free(path);
    294 
    295   errno = 0;
    296   pw = getpwnam("root");
    297   if (pw) {
    298     home = pw->pw_dir;
    299   } else {
    300     /* Just make some noise so we notice. */
    301     home = "<WHAT>";
    302     fprintf(stderr, "getpwnam: %s", errno ? strerror(errno) : "No such user");
    303   }
    304 
    305   s = owl_util_makepath("~root");
    306   FAIL_UNLESS("makepath ~root", !strcmp(home, s));
    307   g_free(s);
    308 
    309   path = g_strconcat(home, "/foo/bar/baz", NULL);
    310   s = owl_util_makepath("~root///foo/bar//baz");
    311   FAIL_UNLESS("makepath ~root///foo/bar//baz", !strcmp(path, s));
    312   g_free(s);
    313   g_free(path);
     283  g_free(home);
    314284
    315285  /* if (numfailed) printf("*** WARNING: failures encountered with owl_util\n"); */
     
    367337  int numfailed=0;
    368338  char *value;
    369   const void *v;
    370339
    371340  printf("# BEGIN testing owl_variable\n");
    372   FAIL_UNLESS("setup", 0==owl_variable_dict_setup(&vd));
     341  owl_variable_dict_setup(&vd);
    373342
    374343  FAIL_UNLESS("get bool var", NULL != (var = owl_variable_get_var(&vd, "rxping")));
     
    407376  FAIL_UNLESS("get int 7", 9 == owl_variable_get_int(var));
    408377
    409   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", "", "");
    410395  FAIL_UNLESS("get new string var", NULL != (var = owl_variable_get_var(&vd, "stringvar")));
    411   FAIL_UNLESS("get new string var", NULL != (v = owl_variable_get(var)));
    412396  FAIL_UNLESS("get new string val", !strcmp("testval", owl_variable_get_string(var)));
    413397  owl_variable_set_string(var, "new val");
    414398  FAIL_UNLESS("update string val", !strcmp("new val", owl_variable_get_string(var)));
    415399
    416   owl_variable_dict_newvar_int(&vd, "intvar", "", "", 47);
     400  owl_variable_dict_newvar_int(&vd, "intvar", 47, "", "");
    417401  FAIL_UNLESS("get new int var", NULL != (var = owl_variable_get_var(&vd, "intvar")));
    418   FAIL_UNLESS("get new int var", NULL != (v = owl_variable_get(var)));
    419402  FAIL_UNLESS("get new int val", 47 == owl_variable_get_int(var));
    420403  owl_variable_set_int(var, 17);
    421404  FAIL_UNLESS("update int val", 17 == owl_variable_get_int(var));
    422405
    423   owl_variable_dict_newvar_bool(&vd, "boolvar", "", "", 1);
     406  owl_variable_dict_newvar_bool(&vd, "boolvar", true, "", "");
    424407  FAIL_UNLESS("get new bool var", NULL != (var = owl_variable_get_var(&vd, "boolvar")));
    425   FAIL_UNLESS("get new bool var", NULL != (v = owl_variable_get(var)));
    426408  FAIL_UNLESS("get new bool val", owl_variable_get_bool(var));
    427409  owl_variable_set_bool_off(var);
    428410  FAIL_UNLESS("update bool val", !owl_variable_get_bool(var));
    429411
    430   owl_variable_dict_newvar_string(&vd, "nullstringvar", "", "", NULL);
     412  owl_variable_dict_newvar_string(&vd, "nullstringvar", NULL, "", "");
    431413  FAIL_UNLESS("get new string (NULL) var", NULL != (var = owl_variable_get_var(&vd, "nullstringvar")));
    432414  FAIL_UNLESS("get string (NULL)", NULL == (value = owl_variable_get_tostring(var)));
     
    435417  FAIL_UNLESS("get string (NULL) 2", NULL == (value = owl_variable_get_tostring(var)));
    436418  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));
    437425
    438426  owl_variable_dict_cleanup(&vd);
     
    529517  FAIL_UNLESS("DAG", (f5 = owl_filter_new_fromstring("dag", "filter f1 or filter f1")) != NULL);
    530518  owl_filter_delete(f5);
     519
     520  owl_message_cleanup(&m);
    531521
    532522  return 0;
     
    996986  return numfailed;
    997987}
     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

    r6829afc rf271129  
    1 #include <stdio.h>
    2 #include <string.h>
    3 #include <stdlib.h>
    4 #include <ctype.h>
    51#include "owl.h"
    62
    73/* Returns a copy of 'in' with each line indented 'n'
    84 * characters. Result must be freed with g_free. */
    9 CALLER_OWN char *owl_text_indent(const char *in, int n)
     5CALLER_OWN char *owl_text_indent(const char *in, int n, bool indent_first_line)
    106{
    117  const char *ptr1, *ptr2, *last;
    128  GString *out = g_string_new("");
    139  int i;
     10  bool indent_this_line = indent_first_line;
    1411
    1512  last=in+strlen(in)-1;
    1613  ptr1=in;
    1714  while (ptr1<=last) {
    18     for (i=0; i<n; i++) {
    19       g_string_append_c(out, ' ');
    20     }
     15    if (indent_this_line) {
     16      for (i = 0; i < n; i++) {
     17        g_string_append_c(out, ' ');
     18      }
     19    }
     20    indent_this_line = true;
    2121    ptr2=strchr(ptr1, '\n');
    2222    if (!ptr2) {
  • util.c

    rc0c48d14 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>
     
    3225}
    3326
     27CALLER_OWN char *owl_util_homedir_for_user(const char *name)
     28{
     29  int err;
     30  struct passwd pw_buf;
     31  struct passwd *pw;
     32
     33  char *pw_strbuf, *ret;
     34  long pw_strbuf_len = sysconf(_SC_GETPW_R_SIZE_MAX);
     35  if (pw_strbuf_len < 0) {
     36    /* If we really hate ourselves, we can be fancy and loop until we stop
     37     * getting ERANGE. For now just pick a random number. */
     38    owl_function_error("owl_util_homedir_for_user: Could not get _SC_GETPW_R_SIZE_MAX");
     39    pw_strbuf_len = 16384;
     40  }
     41  pw_strbuf = g_new0(char, pw_strbuf_len);
     42  err = getpwnam_r(name, &pw_buf, pw_strbuf, pw_strbuf_len, &pw);
     43  if (err) {
     44    owl_function_error("getpwuid_r: %s", strerror(err));
     45    /* Fall through; pw will be NULL. */
     46  }
     47  ret = pw ? g_strdup(pw->pw_dir) : NULL;
     48  g_free(pw_strbuf);
     49  return ret;
     50}
     51
    3452/* Return a "nice" version of the path.  Tilde expansion is done, and
    3553 * duplicate slashes are removed.  Caller must free the return.
     
    4260    /* Attempt tilde-expansion of the first component. Get the
    4361       tilde-prefix, which goes up to the next slash. */
    44     struct passwd *pw;
    4562    const char *end = strchr(in + 1, '/');
    4663    if (end == NULL)
    4764      end = in + strlen(in);
    4865
     66    /* Patch together a new path. Replace the ~ and tilde-prefix with
     67       the homedir, if available. */
    4968    if (end == in + 1) {
    50       /* My home directory. */
    51       pw = getpwuid(getuid());
     69      /* My home directory. Use the one in owl_global for consistency with
     70       * owl_zephyr_dotfile. */
     71      out = g_strconcat(owl_global_get_homedir(&g), end, NULL);
    5272    } else {
    5373      /* Someone else's home directory. */
    5474      char *user = g_strndup(in + 1, end - (in + 1));
    55       pw = getpwnam(user);
     75      char *home = owl_util_homedir_for_user(user);
     76      if (home) {
     77        out = g_strconcat(home, end, NULL);
     78      } else {
     79        out = g_strdup(in);
     80      }
     81      g_free(home);
    5682      g_free(user);
    5783    }
    58 
    59     /* Patch together a new path. Replace the ~ and tilde-prefix with
    60        the homedir. */
    61     if (pw) {
    62       out = g_strconcat(pw->pw_dir, end, NULL);
    63     } else {
    64       out = g_strdup(in);
    65     }
    6684  } else {
    67       out = g_strdup(in);
     85    out = g_strdup(in);
    6886  }
    6987
     
    244262CALLER_OWN char *owl_arg_quote(const char *arg)
    245263{
    246   GString *buf = g_string_new("");;
     264  GString *buf = g_string_new("");
    247265  owl_string_append_quoted_arg(buf, arg);
    248266  return g_string_free(buf, false);
    249267}
    250268
     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
    251283/* caller must free the return */
    252 CALLER_OWN char *owl_util_minutes_to_timestr(int in)
     284CALLER_OWN char *owl_util_format_minutes(int in)
    253285{
    254286  int days, hours;
     
    269301  }
    270302  return(out);
     303}
     304
     305CALLER_OWN char *owl_util_format_time(const struct tm *time)
     306{
     307  /* 32 chosen for first attempt because timestr will end up being
     308   * something like "Www Mmm dd hh:mm:ss AM yyyy UTC\0" */
     309  size_t timestr_size = 16;
     310  char *timestr = NULL;
     311  do {
     312    timestr_size *= 2;
     313    timestr = g_renew(char, timestr, timestr_size);
     314  } while (strftime(timestr, timestr_size, "%c", time) == 0);
     315  return timestr;
    271316}
    272317
     
    388433    if (!g_path_is_absolute(link_path)) {
    389434      char *last_dir = g_path_get_dirname(last_path);
    390       char *tmp = g_build_path(G_DIR_SEPARATOR_S,
    391                                last_dir,
    392                                link_path,
    393                                NULL);
     435      char *tmp = g_build_filename(last_dir, link_path, NULL);
    394436      g_free(last_dir);
    395437      g_free(link_path);
  • variable.c

    ra16d7e5 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,