Changes in / [2e42098:0071c88]


Ignore:
Files:
41 added
38 deleted
77 edited

Legend:

Unmodified
Added
Removed
  • .gitignore

    r7834bb5 rf93cc34  
    1 # Generated by autoreconf
     1*.a
     2*.o
     3*.par
     4*~
     5.#*
     6.*.swp
     7.deps
     8META.yml
     9Makefile
    210Makefile.in
    3 /aclocal.m4
    4 /autom4te.cache/
    5 /compile
    6 /config.h.in
    7 /config.h.in~
    8 /configure
    9 /depcomp
    10 /install-sh
    11 /missing
    12 /test-driver
    13 
    14 # Generated by configure
    15 Makefile
    16 .deps/
    17 /config.cache
    18 /config.h
    19 /config.log
    20 /config.status
    21 /stamp-h1
    22 
    23 # Generated by make
    24 *.o
    25 *.a
    26 /BUILD_VERSION.mk
    27 /barnowl
    28 /bin/
    29 /gmarshal_funcs.c
    30 /gmarshal_funcs.h
    31 /owl_prototypes.h
    32 /owl_prototypes.h.new
    33 /perlglue.c
    34 /varstubs.c
    35 /version.c
    36 /version.c.new
    37 /zcrypt
    38 
    39 # Generated by make check
    40 /runtests.sh.log
    41 /runtests.sh.trs
    42 /test-suite.log
    43 /tester
    44 
    45 # Generated by make tags et al.
    46 ID
     11Makefile.old
    4712TAGS
    48 tags
    49 /GPATH
    50 /GRTAGS
    51 /GSYMS
    52 /GTAGS
    53 /cscope.files
    54 /cscope.in.out
    55 /cscope.out
    56 /cscope.po.out
     13\#*#
     14aclocal.m4
     15autom4te.cache
     16barnowl.bin
     17tester.bin
     18zcrypt
     19blib
     20config.cache
     21config.h
     22config.h.in
     23config.log
     24config.status
     25configure
     26core
     27depcomp
     28install-sh
     29jabber.log
     30missing
     31owl_prototypes.h
     32owl_prototypes.h.new
     33perlglue.c
     34perlwrap.c
     35pm_to_blib
     36stamp-h1
     37varstubs.c
  • AUTHORS

    r80c0fc7 r1d2c4c3  
    33
    44The following people have provided patches or other contributions:
     5  Sam Hartman
    56  Alex Vandiver
    6   Kevin Chen
    7   Arun Tharuvai
    8   Sam Hartman
     7  Geoffrey Thomas
    98  Derrick Brashear
    109  David Glasser
     10  Matthew Goldstein
     11  Arun Tharuvai
     12  Kevin Chen
    1113  Eric Price
    12   Matthew Goldstein
    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
    3414
    35 BarnOwl is based on code from Owl, which was originally primarily
     15BarnOwl is based on code from Owl, which was originally primarly
    3616written by James Kretchmar.  Erik Nygren also made substantial
    37 contributions and improvements to the program.
     17contributions and improvemnts to the program.
    3818
    39 The following people provided patches and other technical support for
     19The following people provided patches and other techincal support for
    4020Owl:
    4121
     
    5030  Mark Eichin
    5131
    52 Mark Eichin is also maintaining the Debian package of Owl.
     32Mark Eichin is also maintaining the debian package of Owl.
    5333
    5434The following people helped with beta testing the earliest versions of
  • COPYING

    rccc182c rb03c714  
    549549
    550550That's all there is to it!
    551 
    552 ======================================================================
    553 
    554 Files under perl/modules/Facebook/lib/Facebook are copyright (c) 2010 Plain
    555 Black Corporation.
    556 
    557 This software is copyright (c) 2010 by Plain Black Corporation.
    558 
    559 This is free software; you can redistribute it and/or modify it under
    560 the same terms as the Perl 5 programming language system itself.
    561 
    562 Terms of the Perl programming language system itself
    563 
    564 a) 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
    567 b) the "Artistic License"
    568 
    569 --- The GNU General Public License, Version 1, February 1989 ---
    570 
    571 This software is Copyright (c) 2010 by Plain Black Corporation.
    572 
    573 This 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
    589 at the mercy of those companies.  By contrast, our General Public
    590 License is intended to guarantee your freedom to share and change free
    591 software--to make sure the software is free for all its users.  The
    592 General Public License applies to the Free Software Foundation's
    593 software and to any other program whose authors commit to using it.
    594 You can use it for your programs, too.
    595 
    596   When we speak of free software, we are referring to freedom, not
    597 price.  Specifically, the General Public License is designed to make
    598 sure that you have the freedom to give away or sell copies of free
    599 software, that you receive source code or can get it if you want it,
    600 that you can change the software or use pieces of it in new free
    601 programs; and that you know you can do these things.
    602 
    603   To protect your rights, we need to make restrictions that forbid
    604 anyone to deny you these rights or to ask you to surrender the rights.
    605 These restrictions translate to certain responsibilities for you if you
    606 distribute copies of the software, or if you modify it.
    607 
    608   For example, if you distribute copies of a such a program, whether
    609 gratis or for a fee, you must give the recipients all the rights that
    610 you have.  You must make sure that they, too, receive or can get the
    611 source 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,
    615 distribute and/or modify the software.
    616 
    617   Also, for each author's protection and ours, we want to make certain
    618 that everyone understands that there is no warranty for this free
    619 software.  If the software is modified by someone else and passed on, we
    620 want its recipients to know that what they have is not the original, so
    621 that any problems introduced by others will not reflect on the original
    622 authors' reputations.
    623 
    624   The precise terms and conditions for copying, distribution and
    625 modification 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
    631 contains a notice placed by the copyright holder saying it may be
    632 distributed under the terms of this General Public License.  The
    633 "Program", below, refers to any such program or work, and a "work based
    634 on the Program" means either the Program or any work containing the
    635 Program or a portion of it, either verbatim or with modifications.  Each
    636 licensee is addressed as "you".
    637 
    638   1. You may copy and distribute verbatim copies of the Program's source
    639 code as you receive it, in any medium, provided that you conspicuously and
    640 appropriately publish on each copy an appropriate copyright notice and
    641 disclaimer of warranty; keep intact all the notices that refer to this
    642 General Public License and to the absence of any warranty; and give any
    643 other recipients of the Program a copy of this General Public License
    644 along with the Program.  You may charge a fee for the physical act of
    645 transferring a copy.
    646 
    647   2. You may modify your copy or copies of the Program or any portion of
    648 it, and copy and distribute such modifications under the terms of Paragraph
    649 1 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 
    674 Mere aggregation of another independent work with the Program (or its
    675 derivative) on a volume of a storage or distribution medium does not bring
    676 the other work under the scope of these terms.
    677 
    678   3. You may copy and distribute the Program (or a portion or derivative of
    679 it, under Paragraph 2) in object code or executable form under the terms of
    680 Paragraphs 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 
    697 Source code for a work means the preferred form of the work for making
    698 modifications to it.  For an executable file, complete source code means
    699 all the source code for all modules it contains; but, as a special
    700 exception, it need not include source code for modules which are standard
    701 libraries that accompany the operating system on which the executable
    702 file runs, or for standard header files or definitions files that
    703 accompany that operating system.
    704 
    705   4. You may not copy, modify, sublicense, distribute or transfer the
    706 Program except as expressly provided under this General Public License.
    707 Any attempt otherwise to copy, modify, sublicense, distribute or transfer
    708 the Program is void, and will automatically terminate your rights to use
    709 the Program under this License.  However, parties who have received
    710 copies, or rights to use copies, from you under this General Public
    711 License will not have their licenses terminated so long as such parties
    712 remain in full compliance.
    713 
    714   5. By copying, distributing or modifying the Program (or any work based
    715 on the Program) you indicate your acceptance of this license to do so,
    716 and all its terms and conditions.
    717 
    718   6. Each time you redistribute the Program (or any work based on the
    719 Program), the recipient automatically receives a license from the original
    720 licensor to copy, distribute or modify the Program subject to these
    721 terms and conditions.  You may not impose any further restrictions on the
    722 recipients' exercise of the rights granted herein.
    723 
    724   7. The Free Software Foundation may publish revised and/or new versions
    725 of the General Public License from time to time.  Such new versions will
    726 be similar in spirit to the present version, but may differ in detail to
    727 address new problems or concerns.
    728 
    729 Each version is given a distinguishing version number.  If the Program
    730 specifies a version number of the license which applies to it and "any
    731 later version", you have the option of following the terms and conditions
    732 either of that version or of any later version published by the Free
    733 Software Foundation.  If the Program does not specify a version number of
    734 the license, you may choose any version ever published by the Free Software
    735 Foundation.
    736 
    737   8. If you wish to incorporate parts of the Program into other free
    738 programs whose distribution conditions are different, write to the author
    739 to ask for permission.  For software which is copyrighted by the Free
    740 Software Foundation, write to the Free Software Foundation; we sometimes
    741 make exceptions for this.  Our decision will be guided by the two goals
    742 of preserving the free status of all derivatives of our free software and
    743 of 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
    748 FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
    749 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
    750 PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
    751 OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    752 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
    753 TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
    754 PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
    755 REPAIR OR CORRECTION.
    756 
    757   10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
    758 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
    759 REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
    760 INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
    761 OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
    762 TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
    763 YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
    764 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
    765 POSSIBILITY 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
    772 possible use to humanity, the best way to achieve this is to make it
    773 free software which everyone can redistribute and change under these
    774 terms.
    775 
    776   To do so, attach the following notices to the program.  It is safest to
    777 attach them to the start of each source file to most effectively convey
    778 the 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 
    799 Also add information on how to contact you by electronic and paper mail.
    800 
    801 If the program is interactive, make it output a short notice like this
    802 when 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 
    809 The hypothetical commands `show w' and `show c' should show the
    810 appropriate parts of the General Public License.  Of course, the
    811 commands you use may be called something other than `show w' and `show
    812 c'; they could even be mouse-clicks or menu items--whatever suits your
    813 program.
    814 
    815 You should also get your employer (if you work as a programmer) or your
    816 school, if any, to sign a "copyright disclaimer" for the program, if
    817 necessary.  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 
    826 That's all there is to it!
    827 
    828 
    829 --- The Artistic License 1.0 ---
    830 
    831 This software is Copyright (c) 2010 by Plain Black Corporation.
    832 
    833 This is free software, licensed under:
    834 
    835   The Artistic License 1.0
    836 
    837 The Artistic License
    838 
    839 Preamble
    840 
    841 The intent of this document is to state the conditions under which a Package
    842 may be copied, such that the Copyright Holder maintains some semblance of
    843 artistic control over the development of the package, while giving the users of
    844 the package the right to use and distribute the Package in a more-or-less
    845 customary fashion, plus the right to make reasonable modifications.
    846 
    847 Definitions:
    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 
    867 1. You may make and give away verbatim copies of the source form of the
    868 Standard Version of this Package without restriction, provided that you
    869 duplicate all of the original copyright notices and associated disclaimers.
    870 
    871 2. You may apply bug fixes, portability fixes and other modifications derived
    872 from the Public Domain or from the Copyright Holder. A Package modified in such
    873 a way shall still be considered the Standard Version.
    874 
    875 3. You may otherwise modify your copy of this Package in any way, provided that
    876 you insert a prominent notice in each changed file stating how and when you
    877 changed 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 
    894 4. You may distribute the programs of this Package in object code or executable
    895 form, 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 
    912 5. You may charge a reasonable copying fee for any distribution of this
    913 Package.  You may charge any fee you choose for support of this Package. You
    914 may not charge a fee for this Package itself. However, you may distribute this
    915 Package in aggregate with other (possibly commercial) programs as part of a
    916 larger (possibly commercial) software distribution provided that you do not
    917 advertise this Package as a product of your own.
    918 
    919 6. The scripts and library files supplied as input to or produced as output
    920 from the programs of this Package do not automatically fall under the copyright
    921 of this Package, but belong to whomever generated them, and may be sold
    922 commercially, and may be aggregated with this Package.
    923 
    924 7. C or perl subroutines supplied by you and linked into this Package shall not
    925 be considered part of this Package.
    926 
    927 8. The name of the Copyright Holder may not be used to endorse or promote
    928 products derived from this software without specific prior written permission.
    929 
    930 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
    931 WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
    932 MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
    933 
    934 The End
  • ChangeLog

    r6f87658 r65ff3f4  
    1 1.9
    2  * Update Jabber module for Net::DNS changes -james2vegas@aim.com
    3  * Update and make configurable the Zephyr default format -adehnert@mit.edu
    4  * Fix a crash when zcrypt fails -andersk@mit.edu
    5  * Fix building with OpenSSL before 0.9.8 -andersk@mit.edu
    6  * Make :loadsubs reload instanced personals too -davidben@mit.edu
    7  * Make Perl zephyr_zwrite call die() when it fails -jgross@mit.edu
    8  * Tell gpg calls from zcrypt to ignore ~/.gnupg -andersk@mit.edu
    9  * Replace outgoing zephyr default format with a small URL -geofft@mit.edu
    10  * Add getnumlines() to perl interface -asedeno@mit.edu
    11  * Include names of invalid filters on filter errors -adehnert@mit.edu
    12  * Don't incorrectly mark decryption failures as decrypted -davidben@mit.edu
    13  * Hide the default cursor when possible -davidben@mit.edu
    14  * Complete viewperson and vp as viewuser and vu -davidben@mit.edu
    15  * Set z_charset = ZCHARSET_UTF_8 -andersk@mit.edu
    16  * Allow zsender spoofing on cross-realm classes -andersk@mit.edu
    17  * Append the realm to the zsender if missing -andersk@mit.edu
    18  * Redisplay on setting colorztext -jgross@mit.edu
    19  * Rename default config file to .owl/init.pl -kevinr@free-dissociation.com
    20  * Add completion for jabberlogout -adehnert@mit.edu
    21  * Switch to interactive context before sourcing the startup file -davidben@mit.edu
    22  * Add completion for reload-module -adehnert@mit.edu
    23  * editwin callback for canceling the editwin -jgross@mit.edu
    24  * Fix dirtying windows inside a redraw handler -davidben@mit.edu
    25  * Facebook module -ezyang@mit.edu
    26  * Complete unstartup command just like startup command -jgross@mit.edu
    27  * Fix the description of disable-ctrl-d -jgross@mit.edu
    28  * Use wbkgrndset instead of wbkgdset in _owl_fmtext_wcolor_set -davidben@mit.edu
    29  * Show the time zone in :info -jgross@mit.edu
    30  * Treat [!.?]" as end of sentence in edit:fill-paragraph -jgross@mit.edu
    31  * Correctly display multiline fields in :info -jgross@mit.edu
    32 
    33 1.8.1
    34  * Only add outgoing messages for personal part of half-personal messages -andersk@mit.edu
    35  * Don’t write CC: line on zwrite -C '' -andersk@mit.edu
    36  * Don’t send public pings on zwrite '' or zwrite @REALM -andersk@mit.edu
    37  * Don’t treat zwrite '' as personal -andersk@mit.edu
    38  * Stop pretending to support zwrite * -andersk@mit.edu
    39  * Show foreign realms on non-personal zephyrs like Owl did -andersk@mit.edu
    40  * Fix memory leak in zcrypt -davidben@mit.edu
    41  * Don't attempt to switch filters in :view -d if invalid -davidben@mit.edu
    42  * Fixed typo in unbindkey usage error -rileyb@mit.edu
    43  * Fix bug generating filter text in 256-color mode -asedeno@mit.edu
    44  * Remove ^noc from reply-lockout -geofft@mit.edu
    45  * Avoid quadratic loops when receiving zephyrs -andersk@mit.edu
    46  * Fix hang on empty zcrypt messages -adehnert@MIT.EDU
    47 
    4811.8
    492 * Compute the home directory in zcrypt consistently with BarnOwl -davidben@mit.edu
     
    329282 * Support --program-{prefix,suffix,transform}. -nelhage
    330283 * Send instanced pings and give useful error messages -adehnert
    331  * Add <message,*,%me%> to default BarnOwl subs. -adehnert
     284 * Add <message,*,%me%> to default Barnowl subs. -adehnert
    332285 * Maintain instance when using shift-R on personals -adehnert
    333286 * Improve handling of outgoing instanced personals -adehnert
  • Makefile.am

    rca1fb26a rc266281  
    11ACLOCAL_AMFLAGS = -I m4
    22
    3 GIT_DESCRIPTION := $(if $(wildcard $(srcdir)/.git),$(shell cd $(srcdir) && git describe --match='barnowl-*' HEAD 2>/dev/null))
    4 VERSION = $(if $(GIT_DESCRIPTION),$(GIT_DESCRIPTION:barnowl-%=%),@VERSION@)
    5 -include BUILD_VERSION.mk
     3GIT_DESCRIPTION := $(if $(wildcard .git),$(shell git describe --match='barnowl-*' HEAD 2>/dev/null))
     4GIT_FLAGS := $(if $(GIT_DESCRIPTION),-DGIT_VERSION=$(GIT_DESCRIPTION:barnowl-%=%))
    65
    7 FORCE:
    8 BUILD_VERSION.mk: $(if $(filter-out $(BUILD_VERSION),$(VERSION)),FORCE)
    9         echo 'BUILD_VERSION = $(VERSION)' > $@
    10 
    11 bin_PROGRAMS = bin/barnowl
     6bin_PROGRAMS = barnowl.bin
    127if ENABLE_ZCRYPT
    138bin_PROGRAMS += zcrypt
    149endif
    1510
    16 zcrypt_SOURCES = zcrypt.c filterproc.c version.c
     11zcrypt_SOURCES = zcrypt.c filterproc.c
    1712
    18 check_PROGRAMS = bin/tester
    19 dist_check_DATA = t
    20 dist_check_SCRIPTS = runtests.sh
     13check_PROGRAMS = tester.bin
    2114
    22 noinst_SCRIPTS = barnowl
    23 check_SCRIPTS = tester
     15barnowl_bin_SOURCES = $(BASE_SRCS) \
     16     owl.h owl_perl.h config.h \
     17     owl.c \
     18     $(GEN_C) $(GEN_H)
    2419
    25 barnowl tester: %: barnowl-wrapper.in bin/% Makefile
    26         sed \
    27             -e 's,[@]abs_srcdir[@],$(abs_srcdir),g' \
    28             -e 's,[@]abs_builddir[@],$(abs_builddir),g' \
    29             $< > $@
    30         chmod +x $@
     20man_MANS = doc/barnowl.1
     21doc_DATA = doc/intro.txt doc/advanced.txt
    3122
    32 bin_barnowl_SOURCES = $(BASE_SRCS) \
    33      owl.h owl_perl.h \
    34      owl.c
    35 nodist_bin_barnowl_SOURCES = $(GEN_C) $(GEN_H)
     23barnowl_bin_LDADD = compat/libcompat.a libfaim/libfaim.a
    3624
    37 dist_man_MANS = doc/barnowl.1
    38 dist_doc_DATA = doc/intro.txt doc/advanced.txt
     25tester_bin_SOURCES = $(BASE_SRCS) \
     26     owl.h owl_perl.h config.h \
     27     $(GEN_C) $(GEN_H) \
     28     tester.c
    3929
    40 bin_barnowl_LDADD = compat/libcompat.a libfaim/libfaim.a
    41 
    42 bin_tester_SOURCES = $(BASE_SRCS) \
    43      owl.h owl_perl.h \
    44      tester.c
    45 nodist_bin_tester_SOURCES = $(GEN_C) $(GEN_H)
    46 
    47 bin_tester_LDADD = compat/libcompat.a libfaim/libfaim.a
     30tester_bin_LDADD = compat/libcompat.a libfaim/libfaim.a
    4831
    4932TESTS=runtests.sh
    5033
    51 AM_CPPFLAGS = \
     34AM_CPPFLAGS = -I$(top_srcdir)/ \
    5235           -I$(top_srcdir)/libfaim/ \
    5336           -DDATADIR='"$(pkgdatadir)"' \
    54            -DBINDIR='"$(bindir)"'
     37           -DBINDIR='"$(bindir)"' \
     38           $(GIT_FLAGS)
    5539
    5640CODELIST_SRCS=message.c mainwin.c popwin.c zephyr.c messagelist.c \
    57      commands.c global.c text.c fmtext.c editwin.c \
    58      util.c logging.c \
     41     commands.c global.c text.c fmtext.c editwin.c util.c logging.c \
    5942     perlconfig.c keys.c functions.c zwrite.c viewwin.c help.c filter.c \
    6043     regex.c history.c view.c dict.c variable.c filterelement.c pair.c \
     
    6245     aim.c buddy.c buddylist.c style.c errqueue.c \
    6346     zbuddylist.c popexec.c select.c wcwidth.c \
    64      mainpanel.c msgwin.c sepbar.c editcontext.c signal.c closures.c
     47     mainpanel.c msgwin.c sepbar.c editcontext.c signal.c
    6548
    66 NORMAL_SRCS = filterproc.c filterproc.h window.c window.h windowcb.c
     49NORMAL_SRCS = filterproc.c window.c windowcb.c
    6750
    6851BASE_SRCS = $(CODELIST_SRCS) $(NORMAL_SRCS)
    6952
    70 GEN_C = varstubs.c perlglue.c gmarshal_funcs.c version.c version.c.new
    71 GEN_H = owl_prototypes.h owl_prototypes.h.new gmarshal_funcs.h
     53GEN_C = varstubs.c perlglue.c
     54GEN_H = owl_prototypes.h
    7255
    73 BUILT_SOURCES = $(GEN_H)
     56BUILT_SOURCES = $(GEN_C) $(GEN_H)
    7457
    7558# Only copy file into place if file.new is different
    76 owl_prototypes.h version.c: %: %.new
     59%: %.new
    7760        @diff -U0 $@ $< || { \
    7861         test -f $@ && echo '$@ changed!'; \
     
    8265proto: owl_prototypes.h
    8366
    84 perlglue.c: perlglue.xs typemap
    85         $(AM_V_GEN)perl $(XSUBPPDIR)/xsubpp $(XSUBPPFLAGS) -prototypes $< > $@
     67perlglue.c: perlglue.xs $(TYPEMAP)
     68        $(AM_V_GEN)perl $(XSUBPPDIR)/xsubpp $(XSUBPPFLAGS) -prototypes perlglue.xs > perlglue.c
    8669
    8770varstubs.c: stubgen.pl variable.c
     
    9174        $(AM_V_GEN)perl $< $(sort $(filter-out $<,$+)) > $@
    9275
    93 version.c.new: Makefile BUILD_VERSION.mk
    94         $(AM_V_GEN)echo 'const char *version = "$(VERSION)";' > $@
    95 
    96 gmarshal_funcs.h: marshal_types
    97         glib-genmarshal --header $< > $@
    98 gmarshal_funcs.c: marshal_types
    99         glib-genmarshal --body $< > $@
    100 
    10176# For emacs flymake-mode
    10277check-syntax: proto
    10378        $(COMPILE) -Wall -Wextra -pedantic -fsyntax-only $(CHK_SOURCES)
    10479
    105 CLEANFILES = $(BUILT_SOURCES) $(GEN_C) $(noinst_SCRIPTS) $(check_SCRIPTS) BUILD_VERSION.mk
    106 EXTRA_DIST = \
    107     autogen.sh \
    108     barnowl-wrapper.in \
    109     codelist.pl \
    110     doc/code.txt \
    111     doc/owl-window.txt \
    112     doc/releasing-barnowl.txt \
    113     examples \
    114     marshal_types \
    115     perlglue.xs \
    116     scripts \
    117     stubgen.pl \
    118     typemap
     80install-data-local:
     81        $(mkinstalldirs) ${DESTDIR}${pkgdatadir}/lib
     82        (cd perl/lib && tar -cf - . ) | (cd ${DESTDIR}${pkgdatadir}/lib && tar -xf - )
     83
     84do_transform = $(shell echo '$(1)' | sed '$(transform)')
     85install-exec-hook:
     86        mv -f $(DESTDIR)$(bindir)/$(call do_transform,barnowl.bin) \
     87              $(DESTDIR)$(bindir)/$(call do_transform,barnowl)
    11988
    12089SUBDIRS = compat libfaim perl
  • README

    r1c22155 rb711711  
    1010following CPAN modules:
    1111
    12 Facebook::Graph
    1312Net::Jabber
    1413Net::XMPP
    1514XML::Stream
    1615
    17 Some have been modified slightly for the needs of this project.
     16They have been modified slightly for the needs of this project.
    1817
    1918BarnOwl currently requires the following perl modules off of CPAN:
     
    2120AnyEvent
    2221Class::Accessor
    23 ExtUtils::Depends
    2422Glib
    25 Module::Install
    2623PAR
    2724
     
    2926We plan to soon add targets to the Makefile to check for and install
    3027these for you.
    31 
    32 The Facebook module requires:
    33 
    34 Any::Moose
    35 AnyEvent::HTTP
    36 DateTime
    37 DateTime::Format::Strptime
    38 JSON
    39 MIME::Base64::URLSafe
    40 Ouch
    41 URI
    42 URI::Encode
    4328
    4429The IRC module requires:
     
    5136Authen::SASL::Perl
    5237IO::Socket::SSL
    53 Digest::SHA
     38Digest::SHA1
    5439
    5540The Twitter module requires:
  • aim.c

    r7dcef03 rf271129  
    707707{
    708708  aim_clientready(sess, fr->conn);
    709   owl_function_debugmsg("conninitdone_admin: initialization done for admin connection");
     709  owl_function_debugmsg("conninitdone_admin: initializtion done for admin connection");
    710710  return(1);
    711711}
     
    836836  params = va_arg(ap, struct aim_icbmparameters *);
    837837  va_end(ap);
    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",
     838 
     839  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",
    840840                       params->maxchan, params->flags, params->maxmsglen, ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, params->minmsginterval);
    841841     
     
    10491049  wrapmsg=owl_text_wordwrap(stripmsg, 70);
    10501050  nz_screenname=owl_aim_normalize_screenname(userinfo->sn);
    1051   m=g_slice_new(owl_message);
     1051  m=g_new(owl_message, 1);
    10521052  owl_message_create_aim(m,
    10531053                         nz_screenname,
  • buddy.c

    r7dcef03 rd4927a7  
    7272{
    7373  owl_buddy_cleanup(b);
    74   g_slice_free(owl_buddy, b);
     74  g_free(b);
    7575}
  • buddylist.c

    r7dcef03 r3cdd6d2  
    1111{
    1212  owl_buddy *b;
    13   b=g_slice_new(owl_buddy);
     13  b=g_new(owl_buddy, 1);
    1414 
    1515  owl_buddy_create(b, OWL_PROTOCOL_AIM, screenname);
     
    5050
    5151    /* if not, create the login message */
    52     m=g_slice_new(owl_message);
     52    m=g_new(owl_message, 1);
    5353    owl_message_create_aim(m,
    5454                           screenname,
     
    6969
    7070  if (owl_buddylist_is_aim_buddy_loggedin(bl, screenname)) {
    71     m=g_slice_new(owl_message);
     71    m=g_new(owl_message, 1);
    7272    owl_message_create_aim(m,
    7373                           screenname,
  • cmd.c

    r7dcef03 rf271129  
    3535void owl_cmddict_add_alias(owl_cmddict *cd, const char *alias_from, const char *alias_to) {
    3636  owl_cmd *cmd;
    37   cmd = g_slice_new(owl_cmd);
     37  cmd = g_new(owl_cmd, 1);
    3838  owl_cmd_create_alias(cmd, alias_from, alias_to);
    3939  owl_perlconfig_new_command(cmd->name);
     
    4242
    4343int owl_cmddict_add_cmd(owl_cmddict *cd, const owl_cmd * cmd) {
    44   owl_cmd * newcmd = g_slice_new(owl_cmd);
     44  owl_cmd * newcmd = g_new(owl_cmd, 1);
    4545  if(owl_cmd_create_from_template(newcmd, cmd) < 0) {
    46     g_slice_free(owl_cmd, newcmd);
     46    g_free(newcmd);
    4747    return -1;
    4848  }
     
    141141{
    142142  owl_cmd_cleanup(cmd);
    143   g_slice_free(owl_cmd, cmd);
     143  g_free(cmd);
    144144}
    145145
  • commands.c

    rca1fb26a rf271129  
    9696  OWLCMD_ARGS("unbindkey", owl_command_unbindkey, OWL_CTX_ANY,
    9797              "removes a binding in a keymap",
    98               "unbindkey <keymap> <keyseq>",
     98              "bindkey <keymap> <keyseq>",
    9999              "Removes a binding of a key sequence within a keymap.\n"
    100100              "Use 'show keymaps' to see the existing keymaps.\n"
     
    479479
    480480  OWLCMD_ARGS("away", owl_command_away, OWL_CTX_INTERACTIVE,
    481               "Set, enable or disable all away messages",
     481              "Set, enable or disable both AIM and zephyr away messages",
    482482              "away [ on | off | toggle ]\n"
    483483              "away <message>",
    484               "Turn on or off all away messages.  If\n"
     484              "Turn on or off the AIM and zephyr away message.  If\n"
    485485              "'message' is specified turn them on with that message,\n"
    486486              "otherwise use the default.\n"
     487              "\n"
     488              "This command really just runs the 'aaway' and 'zaway'\n"
     489              "commands together\n"
    487490              "\n"
    488491              "SEE ALSO: aaway, zaway"),
     
    10301033  OWLCMD_ARGS_CTX("popless:start-search", owl_viewwin_command_start_search, OWL_CTX_POPLESS,
    10311034                  "starts a command line to search for particular string",
    1032                   "popless:start-search [-r] [initial-value]",
     1035                  "popless:start-search [-r] [inital-value]",
    10331036                  "Initializes the command-line to search for initial-value. If\n"
    10341037                  "-r is used, the search will be performed backwards.\n\n"
     
    11141117void owl_command_version(void)
    11151118{
    1116   owl_function_makemsg("BarnOwl version %s", version);
     1119  owl_function_makemsg("BarnOwl version %s", OWL_VERSION_STRING);
    11171120}
    11181121
     
    15281531char *owl_command_away(int argc, const char *const *argv, const char *buff)
    15291532{
    1530   bool away_off;
    1531   const char *message = NULL;
    1532 
    1533   if (argc == 1 ||
    1534       (argc == 2 && !strcmp(argv[1], "on"))) {
    1535     away_off = false;
     1533  if ((argc==1) ||
     1534      ((argc==2) && !strcmp(argv[1], "on"))) {
    15361535    owl_global_set_aaway_msg(&g, owl_global_get_aaway_msg_default(&g));
    15371536    owl_global_set_zaway_msg(&g, owl_global_get_zaway_msg_default(&g));
    1538   } else if (argc == 2 && !strcmp(argv[1], "off")) {
    1539     away_off = true;
    1540   } else if (argc == 2 && !strcmp(argv[1], "toggle")) {
    1541     away_off = owl_function_is_away();
    1542   } else {
    1543     away_off = false;
    1544     message = skiptokens(buff, 1);
    1545   }
    1546 
    1547   if (away_off) {
     1537    owl_function_aaway_on();
     1538    owl_function_zaway_on();
     1539    owl_function_makemsg("Away messages set.");
     1540    return NULL;
     1541  }
     1542
     1543  if (argc==2 && !strcmp(argv[1], "off")) {
    15481544    owl_function_aaway_off();
    15491545    owl_function_zaway_off();
    1550     owl_perlconfig_perl_call_norv("BarnOwl::Hooks::_away_off", 0, NULL);
    1551     owl_function_makemsg("Away messages off.");
    1552   } else if (message != NULL) {
    1553     owl_global_set_aaway_msg(&g, message);
    1554     owl_global_set_zaway_msg(&g, message);
    1555     owl_function_aaway_on();
    1556     owl_function_zaway_on();
    1557     owl_perlconfig_perl_call_norv("BarnOwl::Hooks::_away_on", 1, &message);
    1558     owl_function_makemsg("Away messages set (%s).", message);
    1559   } else {
    1560     owl_function_aaway_on();
    1561     owl_function_zaway_on();
    1562     owl_perlconfig_perl_call_norv("BarnOwl::Hooks::_away_on", 0, NULL);
    1563     owl_function_makemsg("Away messages set.");
    1564   }
    1565 
     1546    return NULL;
     1547  }
     1548
     1549  if (argc==2 && !strcmp(argv[1], "toggle")) {
     1550    /* if either one is on, turn it off, otherwise toggle both (turn
     1551     *  them both on)
     1552     */
     1553    if (!owl_global_is_zaway(&g) && !owl_global_is_aaway(&g)) {
     1554      owl_function_aaway_toggle();
     1555      owl_function_zaway_toggle();
     1556      owl_function_makemsg("Away messages set.");
     1557    } else {
     1558      if (owl_global_is_zaway(&g)) owl_function_zaway_toggle();
     1559      if (owl_global_is_aaway(&g)) owl_function_aaway_toggle();
     1560      owl_function_makemsg("Away messages off.");
     1561    }
     1562    return NULL;
     1563  }
     1564
     1565  buff = skiptokens(buff, 1);
     1566  owl_global_set_aaway_msg(&g, buff);
     1567  owl_global_set_zaway_msg(&g, buff);
     1568  owl_function_aaway_on();
     1569  owl_function_zaway_on();
     1570  owl_function_makemsg("Away messages set.");
    15661571  return NULL;
    15671572}
     
    15991604  if (v == NULL) {
    16001605    if (!silent) owl_function_error("Unknown variable '%s'", var);
    1601   } else if (requirebool && !v->takes_on_off) {
     1606  } else if (requirebool && owl_variable_get_type(v) != OWL_VARIABLE_BOOL) {
    16021607    if (!silent) owl_function_error("Variable '%s' is not a boolean", var);
    16031608  } else {
     
    16281633  if (v == NULL) {
    16291634    if (!silent) owl_function_error("Unknown variable '%s'", var);
    1630   } else if (!v->takes_on_off) {
     1635  } else if (owl_variable_get_type(v) != OWL_VARIABLE_BOOL) {
    16311636    if (!silent) owl_function_error("Variable '%s' is not a boolean", var);
    16321637  } else {
     
    17731778
    17741779  if (argc < 3) {
    1775     owl_function_makemsg("Usage: unbindkey <keymap> <binding>");
     1780    owl_function_makemsg("Usage: bindkey <keymap> <binding>");
    17761781    return NULL;
    17771782  }
     
    19801985  }
    19811986  /* check for a zwrite -m */
    1982   z = owl_zwrite_new(argc, argv);
     1987  z = owl_zwrite_new(buff);
    19831988  if (!z) {
    19841989    owl_function_error("Error in zwrite arguments");
     
    21852190    if (!strcmp(argv[0], "-f")) {
    21862191      if (argc<2) {
    2187         owl_function_makemsg("Too few arguments to the view command");
     2192        owl_function_makemsg("Too few argments to the view command");
    21882193        return(NULL);
    21892194      }
     
    21972202    } else if (!strcmp(argv[0], "-s")) {
    21982203      if (argc<2) {
    2199         owl_function_makemsg("Too few arguments to the view command");
     2204        owl_function_makemsg("Too few argments to the view command");
    22002205        return(NULL);
    22012206      }
     
    22042209      argv+=2;
    22052210    } else {
    2206       owl_function_makemsg("Too few arguments to the view command");
     2211      owl_function_makemsg("Too few argments to the view command");
    22072212      return(NULL);
    22082213    }
     
    27912796    owl_history_store(hist, owl_editwin_get_text(e), false);
    27922797
    2793   /* Take a reference to the editwin, so that it survives the pop
    2794    * context. TODO: We should perhaps refcount or otherwise protect
    2795    * the context so that, even if a command pops a context, the
    2796    * context itself will last until the command returns. */
    2797   owl_editwin_ref(e);
    27982798  owl_global_pop_context(&g);
    2799 
    2800   owl_editwin_do_callback(e, false);
    2801   owl_editwin_unref(e);
    28022799}
    28032800
     
    28592856  owl_global_pop_context(&g);
    28602857
    2861   owl_editwin_do_callback(e, true);
     2858  owl_editwin_do_callback(e);
    28622859  owl_editwin_unref(e);
    28632860}
  • compat/Makefile.am

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

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

    r77dfeb1 r883502d  
    11dnl Process this file with autoconf to produce a configure script.
    2 AC_INIT([BarnOwl],[1.10dev],[bug-barnowl@mit.edu])
    3 AM_INIT_AUTOMAKE([1.7.0 foreign std-options -Wall -Wno-portability])
    4 AM_MAINTAINER_MODE([enable])
     2AC_INIT([BarnOwl],[1.9dev],[bug-barnowl@mit.edu])
     3AM_INIT_AUTOMAKE([1.7.0 -Wall -Wno-portability foreign])
    54m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
    65
     
    109AC_PROG_CC
    1110AC_PROG_CC_C99
    12 AC_PROG_LN_S
    13 
    14 AC_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'])
    25 AC_DEFINE_UNQUOTED(
    26     [ZEPHYR_DEFAULT_FORMAT], ["$zephyr_default_format"],
    27     [Value for the default format zephyrgram field]
    28 )
    2911
    3012AC_ARG_WITH([stack-protector],
     
    5941
    6042AS_IF([test "x$with_zephyr" != xno],
    61   [have_krb4=no
    62 
    63    AS_IF([test "x$with_krb4" != "xno"],
     43  [AS_IF([test "x$with_krb4" != "xno"],
    6444   [AC_MSG_CHECKING([for Kerberos IV])
    6545    AS_IF([krb5-config krb4 --libs >/dev/null 2>&1],
    6646      [AC_MSG_RESULT([yes])
    67        have_krb4=yes
    6847       AC_DEFINE([HAVE_KERBEROS_IV], [1], [Define if you have kerberos IV])
    6948       AM_CFLAGS="${AM_CFLAGS} `krb5-config krb4 --cflags`"
     
    7251      [AC_MSG_RESULT([no])
    7352       AS_IF([test "x$with_krb4" = "xyes"],
    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 
     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     ])])
    8658   AC_CHECK_LIB([zephyr], [ZGetSender],
    8759   [LIBS="$LIBS -lzephyr"
     
    11890dnl Find the location of perl XSUBPP
    11991AC_MSG_CHECKING(for the perl xsubpp precompiler)
    120 XSUBPPDIR="`cd "$srcdir" && perl -MExtUtils::MakeMaker -e 'print ExtUtils::MakeMaker->new({NAME => qw(owl)})->tool_xsubpp;' | grep \^XSUBPPDIR | sed -e 's/XSUBPPDIR = //g;'`"
     92XSUBPPDIR="`(perl -MExtUtils::MakeMaker -e 'print ExtUtils::MakeMaker->new({NAME => qw(owl)})->tool_xsubpp;') | grep \^XSUBPPDIR | sed -e 's/XSUBPPDIR = //g;'`"
    12193if test -n "${XSUBPPDIR}"; then
    12294   AC_MSG_RESULT(${XSUBPPDIR})
     
    141113AX_PROG_PERL_MODULES([Class::Accessor::Fast],,
    142114                     [AC_MSG_ERROR([cannot find perl module Class::Accessor::Fast.])])
    143 AX_PROG_PERL_MODULES([ExtUtils::Depends],,
    144                      [AC_MSG_ERROR([cannot find perl module ExtUtils::Depends])])
    145115AX_PROG_PERL_MODULES([Glib],,
    146116                     [AC_MSG_ERROR([cannot find perl module Glib.])])
    147 AX_PROG_PERL_MODULES([Module::Install::Base],,
    148                      [AC_MSG_ERROR([cannot find perl module Module::Install::Base])])
    149117AX_PROG_PERL_MODULES([PAR],,
    150118                     [AC_MSG_WARN([PAR.pm not found. Loadable modules will be disabled.])])
     
    161129   prefix="${ac_default_prefix}"
    162130fi
    163 
    164 dnl Add CFLAGS for glib-perl
    165 GLIB_PERL_CFLAGS=`perl -MExtUtils::Depends -e 'my $e = ExtUtils::Depends->new("BarnOwl","Glib"); my %h = $e->get_makefile_vars; print $h{"INC"}'`
    166 AC_MSG_NOTICE([Adding glib-perl CFLAGS ${GLIB_PERL_CFLAGS}])
    167 AM_CFLAGS="${GLIB_PERL_CFLAGS} ${AM_CFLAGS}"
    168131
    169132dnl Checks for typedefs, structures, and compiler characteristics.
     
    187150dnl Define __EXTENSIONS__ for strcasecmp on Solaris.
    188151AM_CFLAGS="$AM_CFLAGS -D__EXTENSIONS__"
    189 dnl Define _XOPEN_SOURCE_EXTENDED for some features in ncurses,
    190 dnl including cchar_t.  This should not be necessary with
    191 dnl _XOPEN_SOURCE=600, but some versions of ncurses
    192 dnl apparently still need it.
    193 AM_CFLAGS="$AM_CFLAGS -D_XOPEN_SOURCE_EXTENDED"
    194152
    195153AC_SUBST([AM_CFLAGS])
     
    210168AC_REPLACE_FUNCS([memrchr])
    211169
    212 AC_SUBST([abs_builddir])
    213 AC_SUBST([abs_srcdir])
    214 
    215170AC_CONFIG_FILES([Makefile compat/Makefile libfaim/Makefile perl/Makefile perl/modules/Makefile])
    216171AC_OUTPUT
  • context.c

    r7dcef03 rf271129  
    1010  if (!(mode & OWL_CTX_MODE_BITS))
    1111    mode |= OWL_CTX_INTERACTIVE;
    12   c = g_slice_new0(owl_context);
     12  c = g_new0(owl_context, 1);
    1313  c->mode = mode;
    1414  c->data = data;
     
    7171  if (ctx->delete_cb)
    7272    ctx->delete_cb(ctx);
    73   g_slice_free(owl_context, ctx);
     73  g_free(ctx);
    7474}
  • doc/barnowl.1

    r8135737 rbad4496  
    3535.TP
    3636\fB\-c\fP, \fB\-\-config\-file\fP=\fIFILE\fP
    37 Specify an alternate config file for \fBBarnOwl\fP to use.  The config file is
    38 an arbitrary Perl script evaluated in the \fImain\fP package, and if it
    39 overrides the \fIBarnOwl::startup\fP method that is run when \fBBarnOwl\fP
    40 starts.  (Compare \fI~/.owl/startup\fP, which contains \fBBarnOwl\fP commands
    41 that are run at startup after the config file is loaded.)
    42 
    43 By default, \fBBarnOwl\fP uses the first of \fI~/.owl/init.pl\fP,
    44 \fI~/.barnowlconf\fP, or \fI~/.owlconf\fP that exists.
     37Specify 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.
    4539
    4640.TP
  • doc/releasing-barnowl.txt

    rd995ff3 r5f08dbe  
    1616  - [ ] Do a locker build (See DOING A LOCKER BUILD)
    1717  - [ ] Update configure.ac on master to bump the version to 1.(N+1)dev
    18   - [ ] Add the barnowl-1.(N+1)dev git tag
    1918  - [ ] Push git git:
    2019   - [ ] The RC commit
    2120   - [ ] The configure.ac change on master
    2221   - [ ] A release-1.N branch pointing at the RC commit
    23    - [ ] the new git tags
    24   - [ ] Update debian/changelog on the launchpad build using `dch -v 1.(N+1)`
    25    - [ ] bzr branch lp:~barnowl/barnowl/packaging && cd packaging && dch -v 1.(N+1)
    26    - [ ] Add relevant changelog entries such as "New upstream release" or
    27          "Placeholder version number for daily builds."; fix your name and email
    28          if necessary
    29    - [ ] bzr commit && bzr push
    3022  - [ ] Copy tarball into /mit/barnowl/web_scripts/dist
    3123  - [ ] Send mail announcing the RC to barnowl-dev@mit.edu
     
    3931* DOING THE ACTUAL RELEASE
    4032  - [ ] Update the changelog and configure.ac for barnowl 1.N
    41   - [ ] Copy the changelog changes to the master branch
    4233  - [ ] run ./scripts/do-release
    4334  - [ ] Do the locker build
  • editwin.c

    r7dcef03 rf271129  
    3333  oe_excursion *excursions;
    3434
    35   void (*callback)(struct _owl_editwin *e, bool success);
     35  void (*callback)(struct _owl_editwin*);
    3636  void (*destroy_cbdata)(void *);
    3737  void *cbdata;
     
    6868static CALLER_OWN owl_editwin *owl_editwin_allocate(void)
    6969{
    70   owl_editwin *e = g_slice_new0(owl_editwin);
     70  owl_editwin *e = g_new0(owl_editwin, 1);
    7171  e->refcount = 1;
    7272  return e;
     
    8787  oe_destroy_cbdata(e);
    8888
    89   g_slice_free(owl_editwin, e);
     89  g_free(e);
    9090}
    9191
     
    220220}
    221221
    222 void owl_editwin_set_callback(owl_editwin *e, void (*cb)(owl_editwin *, bool))
     222void owl_editwin_set_callback(owl_editwin *e, void (*cb)(owl_editwin*))
    223223{
    224224  e->callback = cb;
    225225}
    226226
    227 void (*owl_editwin_get_callback(owl_editwin *e))(owl_editwin *, bool)
     227void (*owl_editwin_get_callback(owl_editwin *e))(owl_editwin*)
    228228{
    229229  return e->callback;
     
    248248}
    249249
    250 void 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) {
     250void owl_editwin_do_callback(owl_editwin *e) {
     251  void (*cb)(owl_editwin*);
     252  cb=owl_editwin_get_callback(e);
     253  if(!cb) {
    255254    owl_function_error("Internal error: No editwin callback!");
    256255  } else {
    257     cb(e, success);
     256    /* owl_function_error("text: |%s|", owl_editwin_get_text(e)); */
     257    cb(e);
    258258  }
    259259}
     
    373373owl_editwin_excursion *owl_editwin_begin_excursion(owl_editwin *e)
    374374{
    375   owl_editwin_excursion *x = g_slice_new(owl_editwin_excursion);
     375  owl_editwin_excursion *x = g_new(owl_editwin_excursion, 1);
    376376  oe_save_excursion(e, x);
    377377  return x;
     
    381381{
    382382  oe_restore_excursion(e, x);
    383   g_slice_free(owl_editwin_excursion, x);
     383  g_free(x);
    384384}
    385385
     
    619619
    620620  if (!g_utf8_validate(s, -1, NULL)) {
    621     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.");
    622622    return 0;
    623623  }
  • filter.c

    r7dcef03 rf271129  
    1818  owl_filter *f;
    1919
    20   f = g_slice_new(owl_filter);
     20  f = g_new(owl_filter, 1);
    2121
    2222  f->name=g_strdup(name);
     
    6969  if(!argc) return NULL;
    7070
    71   fe = g_slice_new(owl_filterelement);
     71  fe = g_new(owl_filterelement, 1);
    7272  owl_filterelement_create(fe);
    7373
     
    114114err:
    115115  owl_filterelement_cleanup(fe);
    116   g_slice_free(owl_filterelement, fe);
     116  g_free(fe);
    117117  return NULL;
    118118}
     
    124124
    125125  op1 = owl_filter_parse_primitive_expression(argc-i, argv+i, &skip);
     126  i += skip;
    126127  if(!op1) goto err;
    127   i += skip;
    128128
    129129  while(i < argc) {
     
    132132    op2 = owl_filter_parse_primitive_expression(argc-i-1, argv+i+1, &skip);
    133133    if(!op2) goto err;
    134     tmp = g_slice_new(owl_filterelement);
     134    tmp = g_new(owl_filterelement, 1);
    135135    if(!strcasecmp(argv[i], "and")) {
    136136      owl_filterelement_create_and(tmp, op1, op2);
     
    152152  if(op1) {
    153153    owl_filterelement_cleanup(op1);
    154     g_slice_free(owl_filterelement, op1);
     154    g_free(op1);
    155155  }
    156156  return NULL;
     
    219219    }
    220220    else {
    221       g_string_append_printf(out, "%i",f->bgcolor);
     221      g_string_append_printf(out, "%i",f->fgcolor);
    222222    }
    223223    g_string_append(out, " ");
     
    262262  if (f->root) {
    263263    owl_filterelement_cleanup(f->root);
    264     g_slice_free(owl_filterelement, f->root);
     264    g_free(f->root);
    265265  }
    266266  if (f->name)
    267267    g_free(f->name);
    268   g_slice_free(owl_filter, f);
    269 }
     268  g_free(f);
     269}
  • filterelement.c

    r7dcef03 r7756dde  
    328328  if (fe->left) {
    329329    owl_filterelement_cleanup(fe->left);
    330     g_slice_free(owl_filterelement, fe->left);
     330    g_free(fe->left);
    331331  }
    332332  if (fe->right) {
    333333    owl_filterelement_cleanup(fe->right);
    334     g_slice_free(owl_filterelement, fe->right);
     334    g_free(fe->right);
    335335  }
    336336  owl_regex_cleanup(&(fe->re));
  • filterproc.c

    r7155955 rf271129  
    1 #include "filterproc.h"
     1#include "owl.h"
    22#include <sys/wait.h>
    3 #include <fcntl.h>
    4 #include <glib.h>
    53#include <poll.h>
    6 #include <string.h>
    7 #include <unistd.h>
    84
    9 /* Even in case of error, send_receive is responsible for closing wfd
    10  * (to EOF the child) and rfd (for consistency). */
    11 static int send_receive(int rfd, int wfd, const char *out, char **in)
     5int send_receive(int rfd, int wfd, const char *out, char **in)
    126{
    137  GString *str = g_string_new("");
     
    2418  fds[1].fd = wfd;
    2519  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   }
    3220
    3321  while(1) {
     
    5240      }
    5341      if(!out || !*out || fds[1].revents & (POLLERR | POLLHUP)) {
    54         close(wfd); wfd = -1;
     42        close(wfd);
    5543        out = NULL;
    5644      }
     
    6856  }
    6957
    70   if (wfd >= 0) close(wfd);
    71   close(rfd);
    7258  *in = g_string_free(str, err < 0);
    7359  return err;
    7460}
    7561
    76 int call_filter(const char *const *argv, const char *in, char **out, int *status)
     62int call_filter(const char *prog, const char *const *argv, const char *in, char **out, int *status)
    7763{
    78   int err;
    79   GPid child_pid;
    80   int child_stdin, child_stdout;
     64  int err = 0;
     65  pid_t pid;
     66  int rfd[2];
     67  int wfd[2];
    8168
    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;
     69  if((err = pipe(rfd))) goto out;
     70  if((err = pipe(wfd))) goto out_close_rfd;
     71
     72  pid = fork();
     73  if(pid < 0) {
     74    err = pid;
     75    goto out_close_all;
     76  }
     77  if(pid) {
     78    /* parent */
     79    close(rfd[1]);
     80    close(wfd[0]);
     81    err = send_receive(rfd[0], wfd[1], in, out);
     82    if(err == 0) {
     83      waitpid(pid, status, 0);
     84    }
     85  } else {
     86    /* child */
     87    close(rfd[0]);
     88    close(wfd[1]);
     89    dup2(rfd[1], 1);
     90    dup2(wfd[0], 0);
     91    close(rfd[1]);
     92    close(wfd[0]);
     93
     94    if(execvp(prog, (char *const *)argv)) {
     95      _exit(-1);
     96    }
    8997  }
    9098
    91   err = send_receive(child_stdout, child_stdin, in, out);
    92   if (err == 0) {
    93     waitpid(child_pid, status, 0);
    94   }
     99 out_close_all:
     100  close(wfd[0]);
     101  close(wfd[1]);
     102 out_close_rfd:
     103  close(rfd[0]);
     104  close(rfd[1]);
     105 out:
    95106  return err;
    96107}
  • filterproc.h

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

    r7dcef03 r0071c88  
    115115void owl_function_show_license(void)
    116116{
    117   char *text = g_strdup_printf(
    118     "BarnOwl version %s\n"
     117  const char *text;
     118
     119  text=""
     120    "BarnOwl version " OWL_VERSION_STRING "\n"
    119121    "Copyright (c) 2006-2011 The BarnOwl Developers. All rights reserved.\n"
    120122    "Copyright (c) 2004 James Kretchmar. All rights reserved.\n"
     
    153155    "WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n"
    154156    "OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN\n"
    155     "IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n",
    156     version);
     157    "IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n";
    157158  owl_function_popless_text(text);
    158   g_free(text);
    159159}
    160160
     
    196196  owl_message *m;
    197197
    198   m=g_slice_new(owl_message);
     198  m=g_new(owl_message, 1);
    199199  owl_message_create_admin(m, header, body);
    200200 
     
    204204
    205205  /* do followlast if necessary */
    206   if (owl_global_should_followlast(&g)) owl_function_lastmsg();
     206  if (owl_global_should_followlast(&g)) owl_function_lastmsg_noredisplay();
    207207
    208208  /* redisplay etc. */
     
    216216void owl_function_add_outgoing_zephyrs(const owl_zwrite *z)
    217217{
    218   if (z->cc && owl_zwrite_is_personal(z)) {
     218  if (z->cc || owl_zwrite_get_numrecips(z) == 0) {
    219219    /* create the message */
    220     owl_message *m = g_slice_new(owl_message);
     220    owl_message *m = g_new(owl_message, 1);
    221221    owl_message_create_from_zwrite(m, z, owl_zwrite_get_message(z), 0);
    222222
     
    225225    int i;
    226226    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 
    232227      /* create the message */
    233       m = g_slice_new(owl_message);
     228      owl_message *m = g_new(owl_message, 1);
    234229      owl_message_create_from_zwrite(m, z, owl_zwrite_get_message(z), i);
    235230
     
    251246  if (!owl_global_is_aimloggedin(&g)) return(NULL);
    252247 
    253   m=g_slice_new(owl_message);
     248  m=g_new(owl_message, 1);
    254249  owl_message_create_aim(m,
    255250                         owl_global_get_aim_screenname(&g),
     
    270265
    271266  /* create the message */
    272   m=g_slice_new(owl_message);
     267  m=g_new(owl_message, 1);
    273268  owl_message_create_loopback(m, body);
    274269  owl_message_set_direction_out(m);
     
    277272}
    278273
    279 owl_editwin *owl_function_start_edit_win(const char *line)
     274void owl_function_start_edit_win(const char *line, void (*callback)(owl_editwin *), void *data, void (*cleanup)(void *))
    280275{
    281276  owl_editwin *e;
     
    291286  g_free(s);
    292287
     288  owl_editwin_set_cbdata(e, data, cleanup);
     289  owl_editwin_set_callback(e, callback);
    293290  ctx = owl_editcontext_new(OWL_CTX_EDITMULTI, e, "editmulti",
    294291                            owl_global_deactivate_editcontext, &g);
    295292  owl_global_push_context_obj(&g, ctx);
    296   return e;
     293
    297294}
    298295
     
    312309void owl_function_zwrite_setup(owl_zwrite *z)
    313310{
    314   owl_editwin *e;
    315311  /* send a ping if necessary */
    316312  if (owl_global_is_txping(&g)) {
     
    320316
    321317  owl_function_write_setup("zephyr");
    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);
     318  owl_function_start_edit_win(z->zwriteline,
     319                              &owl_callback_zwrite,
     320                              z, (void(*)(void*))owl_zwrite_delete);
    325321}
    326322
    327323void owl_function_aimwrite_setup(const char *to)
    328324{
    329   owl_editwin *e;
    330325  /* TODO: We probably actually want an owl_aimwrite object like
    331326   * owl_zwrite. */
    332327  char *line = g_strdup_printf("aimwrite %s", to);
    333328  owl_function_write_setup("message");
    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);
     329  owl_function_start_edit_win(line,
     330                              &owl_callback_aimwrite,
     331                              g_strdup(to),
     332                              g_free);
    337333  g_free(line);
    338334}
     
    340336void owl_function_loopwrite_setup(void)
    341337{
    342   owl_editwin *e;
    343338  owl_function_write_setup("message");
    344   e = owl_function_start_edit_win("loopwrite");
    345   owl_editwin_set_callback(e, &owl_callback_loopwrite);
    346 }
    347 
    348 void owl_callback_zwrite(owl_editwin *e, bool success)
    349 {
    350   if (!success) return;
     339  owl_function_start_edit_win("loopwrite",
     340                              &owl_callback_loopwrite,
     341                              NULL, NULL);
     342}
     343
     344void owl_callback_zwrite(owl_editwin *e) {
    351345  owl_zwrite *z = owl_editwin_get_cbdata(e);
    352346  owl_function_zwrite(z, owl_editwin_get_text(e));
     
    378372  owl_function_makemsg("Waiting for ack...");
    379373
    380   /* create the outgoing message */
    381   owl_function_add_outgoing_zephyrs(z);
     374  /* If it's personal */
     375  if (owl_zwrite_is_personal(z)) {
     376    /* create the outgoing message */
     377    owl_function_add_outgoing_zephyrs(z);
     378  }
    382379}
    383380#else
     
    405402
    406403  zcrypt = g_build_filename(owl_get_bindir(), "zcrypt", NULL);
    407   argv[0] = zcrypt;
     404  argv[0] = "zcrypt";
    408405  argv[1] = "-E";
    409406  argv[2] = "-c"; argv[3] = owl_zwrite_get_class(z);
     
    411408  argv[6] = NULL;
    412409
    413   rv = call_filter(argv, owl_zwrite_get_message(z), &cryptmsg, &status);
     410  rv = call_filter(zcrypt, argv, owl_zwrite_get_message(z), &cryptmsg, &status);
    414411
    415412  g_free(zcrypt);
     
    429426  owl_function_makemsg("Waiting for ack...");
    430427
    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. */
     428  /* If it's personal */
     429  if (owl_zwrite_is_personal(z)) {
     430    /* Create the outgoing message. Restore the un-crypted message for display. */
     431    owl_zwrite_set_message_raw(z, old_msg);
     432    owl_function_add_outgoing_zephyrs(z);
     433  }
     434
     435  /* free the zwrite */
    436436  g_free(cryptmsg);
    437   g_free(old_msg);
    438 }
    439 
    440 void owl_callback_aimwrite(owl_editwin *e, bool success)
    441 {
    442   if (!success) return;
     437}
     438
     439void owl_callback_aimwrite(owl_editwin *e) {
    443440  char *to = owl_editwin_get_cbdata(e);
    444441  owl_function_aimwrite(to, owl_editwin_get_text(e), true);
     
    504501}
    505502
    506 void owl_callback_loopwrite(owl_editwin *e, bool success)
    507 {
    508   if (!success) return;
     503void owl_callback_loopwrite(owl_editwin *e) {
    509504  owl_function_loopwrite(owl_editwin_get_text(e));
    510505}
     
    516511  /* create a message and put it on the message queue.  This simulates
    517512   * an incoming message */
    518   min=g_slice_new(owl_message);
     513  min=g_new(owl_message, 1);
    519514  mout=owl_function_make_outgoing_loopback(msg);
    520515
     
    813808}
    814809
    815 void owl_function_lastmsg(void)
     810void owl_function_lastmsg_noredisplay(void)
    816811{
    817812  int oldcurmsg, curmsg;
     
    831826    owl_global_set_curmsg(&g, curmsg+1);
    832827  }
    833   owl_mainwin_redisplay(owl_global_get_mainwin(&g));
     828  /* owl_mainwin_redisplay(owl_global_get_mainwin(&g)); */
    834829  owl_global_set_direction_downwards(&g);
     830}
     831
     832void owl_function_lastmsg(void)
     833{
     834  owl_function_lastmsg_noredisplay();
     835  owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 
    835836}
    836837
     
    855856void owl_function_unsuball(void)
    856857{
    857   if (unsuball())
    858     owl_function_makemsg("Unsubscribed from all messages.");
     858  unsuball();
     859  owl_function_makemsg("Unsubscribed from all messages.");
    859860}
    860861
     
    871872void owl_function_loadsubs(const char *file)
    872873{
    873   int ret, ret2, ret3;
     874  int ret, ret2;
     875  const char *foo;
    874876  char *path;
    875877
     
    883885
    884886  /* for backwards compatibility for now */
    885   ret2 = owl_zephyr_loaddefaultsubs();
    886   ret3 = owl_zephyr_loadbarnowldefaultsubs();
     887  ret2=owl_zephyr_loaddefaultsubs();
    887888
    888889  if (!owl_context_is_interactive(owl_global_get_context(&g))) return;
    889890
    890   if (ret == 0 && ret2 == 0 && ret3 == 0) {
     891  foo=file?file:"file";
     892  if (ret==0 && ret2==0) {
    891893    if (!file) {
    892894      owl_function_makemsg("Subscribed to messages.");
     
    894896      owl_function_makemsg("Subscribed to messages from %s", file);
    895897    }
    896   } else if (ret == -1) {
    897     owl_function_error("Could not read %s", file ? file : "file");
    898   } else if (ret2 == -1) {
     898  } else if (ret==-1) {
     899    owl_function_error("Could not read %s", foo);
     900  } else {
    899901    owl_function_error("Error subscribing to messages");
    900   } else {
    901     owl_function_error("Error subscribing to instanced personals");
    902902  }
    903903}
     
    918918}
    919919
    920 void owl_callback_aimlogin(owl_editwin *e, bool success)
    921 {
    922   if (!success) return;
     920void owl_callback_aimlogin(owl_editwin *e) {
    923921  char *user = owl_editwin_get_cbdata(e);
    924922  owl_function_aimlogin(user,
     
    991989  /* owl_aim_set_awaymsg(""); */
    992990  owl_function_makemsg("AIM away off");
    993 }
    994 
    995 bool owl_function_is_away(void)
    996 {
    997   return owl_global_is_zaway(&g) ||
    998          owl_global_is_aaway(&g) ||
    999          owl_perlconfig_perl_call_bool("BarnOwl::Hooks::_get_is_away", 0, NULL);
    1000991}
    1001992
     
    13591350void owl_function_about(void)
    13601351{
    1361   char *text = g_strdup_printf(
    1362     "This is BarnOwl version %s.\n\n"
     1352  owl_function_popless_text(
     1353    "This is BarnOwl version " OWL_VERSION_STRING ".\n\n"
    13631354    "BarnOwl is a fork of the Owl zephyr client, written and\n"
    13641355    "maintained by Alejandro Sedeno and Nelson Elhage at the\n"
     
    13791370    "This program is free software. You can redistribute it and/or\n"
    13801371    "modify under the terms of the Sleepycat License. Use the \n"
    1381       "':show license' command to display the full license\n",
    1382       version);
    1383   owl_function_popless_text(text);
    1384   g_free(text);
     1372    "':show license' command to display the full license\n"
     1373  );
    13851374}
    13861375
     
    14411430      char *tmpbuff, *tmpbuff2;
    14421431      int i, fields;
    1443       const char *f;
    14441432
    14451433      if (!owl_message_is_pseudo(m)) {
     
    14721460        owl_fmtext_append_normal(&fm, "\n");
    14731461        owl_fmtext_appendf_normal(&fm, "  Port      : %i\n", ntohs(n->z_port));
    1474         owl_fmtext_appendf_normal(&fm, "  Charset   : %s\n", owl_zephyr_get_charsetstr(n));
    14751462        owl_fmtext_appendf_normal(&fm, "  Auth      : %s\n", owl_zephyr_get_authstr(n));
    14761463
     
    14841471        owl_fmtext_appendf_normal(&fm, "  Fields    : %i\n", fields);
    14851472
    1486         for (i = 0, f = owl_zephyr_first_raw_field(n); f != NULL;
    1487              i++, f = owl_zephyr_next_raw_field(n, f)) {
    1488           tmpbuff = owl_zephyr_field_as_utf8(n, f);
     1473        for (i = 0; i < fields; i++) {
     1474          tmpbuff = owl_zephyr_get_field_as_utf8(n, i + 1);
    14891475          tmpbuff2 = owl_text_indent(tmpbuff, 14, false);
    14901476          owl_fmtext_appendf_normal(&fm, "  Field %i   : %s\n", i + 1, tmpbuff2);
     
    17841770
    17851771  owl_fmtext_append_normal(&fm, "  Version: ");
    1786   owl_fmtext_append_normal(&fm, version);
     1772  owl_fmtext_append_normal(&fm, OWL_VERSION_STRING);
    17871773  owl_fmtext_append_normal(&fm, "\n");
    17881774
     
    19541940}
    19551941
    1956 void owl_callback_command(owl_editwin *e, bool success)
    1957 {
    1958   if (!success) return;
     1942void owl_callback_command(owl_editwin *e)
     1943{
    19591944  char *rv;
    19601945  const char *line = owl_editwin_get_text(e);
     
    19671952}
    19681953
    1969 owl_editwin *owl_function_start_command(const char *line)
     1954void owl_function_start_command(const char *line)
    19701955{
    19711956  owl_editwin *tw;
     
    19821967  owl_global_push_context_obj(&g, ctx);
    19831968  owl_editwin_set_callback(tw, owl_callback_command);
    1984   return tw;
    1985 }
    1986 
    1987 owl_editwin *owl_function_start_question(const char *line)
     1969}
     1970
     1971CALLER_OWN owl_editwin *owl_function_start_question(const char *line)
    19881972{
    19891973  owl_editwin *tw;
     
    20001984}
    20011985
    2002 owl_editwin *owl_function_start_password(const char *line)
     1986CALLER_OWN owl_editwin *owl_function_start_password(const char *line)
    20031987{
    20041988  owl_editwin *tw;
     
    21972181  f = owl_filter_new(argv[1], argc-2, argv+2);
    21982182  if (f == NULL) {
    2199     owl_function_error("Invalid filter: %s", argv[1]);
     2183    owl_function_error("Invalid filter");
    22002184    return false;
    22012185  }
     
    34823466  while (zaldptr) {
    34833467    ZFreeALD(zaldptr->data);
    3484     g_slice_free(ZAsyncLocateData_t, zaldptr->data);
     3468    g_free(zaldptr->data);
    34853469    zaldptr = g_list_next(zaldptr);
    34863470  }
     
    34923476    for (i = 0; i < anyone->len; i++) {
    34933477      user = anyone->pdata[i];
    3494       zald = g_slice_new(ZAsyncLocateData_t);
     3478      zald = g_new(ZAsyncLocateData_t, 1);
    34953479      if (ZRequestLocations(zstr(user), zald, UNACKED, ZAUTH) == ZERR_NONE) {
    34963480        *zaldlist = g_list_append(*zaldlist, zald);
    34973481      } else {
    3498         g_slice_free(ZAsyncLocateData_t, zald);
     3482        g_free(zald);
    34993483      }
    35003484    }
  • global.c

    r7dcef03 r9078f69  
    99  const char *homedir;
    1010
    11 #if !GLIB_CHECK_VERSION(2, 35, 0)
    1211  g_type_init();
    13 #endif
    14 #if !GLIB_CHECK_VERSION(2, 31, 0)
    1512  g_thread_init(NULL);
    16 #endif
    1713
    1814  owl_select_init();
     
    5652  g->starttime=time(NULL); /* assumes we call init only a start time */
    5753  g->lastinputtime=g->starttime;
    58   g->last_wakeup_time = g->starttime;
    5954  g->newmsgproc_pid=0;
    6055 
     
    8075  g_free(cd);
    8176
    82   g->msglist = owl_messagelist_new();
     77  owl_messagelist_create(&(g->msglist));
    8378
    8479  _owl_global_init_windows(g);
     
    105100
    106101  g->interrupt_count = 0;
    107 #if GLIB_CHECK_VERSION(2, 31, 0)
    108   g_mutex_init(&g->interrupt_lock);
    109 #else
    110102  g->interrupt_lock = g_mutex_new();
    111 #endif
    112103}
    113104
     
    118109
    119110  /* Create the widgets */
    120   g->mw = owl_mainwin_new(g->mainpanel.recwin);
     111  owl_mainwin_init(&(g->mw), g->mainpanel.recwin);
    121112  owl_msgwin_init(&(g->msgwin), g->mainpanel.msgwin);
    122113  owl_sepbar_init(g->mainpanel.sepwin);
     
    250241/* windows */
    251242
    252 owl_mainwin *owl_global_get_mainwin(owl_global *g)
    253 {
    254   return g->mw;
     243owl_mainwin *owl_global_get_mainwin(owl_global *g) {
     244  return(&(g->mw));
    255245}
    256246
     
    266256
    267257owl_messagelist *owl_global_get_msglist(owl_global *g) {
    268   return g->msglist;
     258  return(&(g->msglist));
    269259}
    270260
     
    485475}
    486476
    487 void owl_global_wakeup(owl_global *g)
    488 {
    489   if (time(NULL) - g->last_wakeup_time >= 1) {
    490     g_free(owl_perlconfig_execute("BarnOwl::Hooks::_wakeup()"));
    491     g->last_wakeup_time = time(NULL);
    492   }
    493 }
    494 
    495477/* viewwin */
    496478
     
    553535  e->g->filterlist = g_list_remove(e->g->filterlist, e->f);
    554536  owl_filter_delete(e->f);
    555   g_slice_free(owl_global_filter_ent, e);
     537  g_free(e);
    556538}
    557539
    558540void owl_global_add_filter(owl_global *g, owl_filter *f) {
    559   owl_global_filter_ent *e = g_slice_new(owl_global_filter_ent);
     541  owl_global_filter_ent *e = g_new(owl_global_filter_ent, 1);
    560542  e->g = g;
    561543  e->f = f;
     
    858840  } filters[] = {
    859841    { "personal",
    860       "isprivate ^true$ and ( not type ^zephyr$ or ( class ^message$ ) )" },
     842      "isprivate ^true$ and ( not type ^zephyr$ or ( class ^message  ) )" },
    861843    { "trash",
    862844      "class ^mail$ or opcode ^ping$ or type ^admin$ or ( not login ^none$ )" },
     
    865847    { "auto", "opcode ^auto$" },
    866848    { "login", "not login ^none$" },
    867     { "reply-lockout", "class ^mail$ or class ^filsrv$" },
     849    { "reply-lockout", "class ^mail$" },
    868850    { "out", "direction ^out$" },
    869851    { "aim", "type ^aim$" },
     
    916898}
    917899
    918 static GMutex *owl_global_get_interrupt_lock(owl_global *g)
    919 {
    920 #if GLIB_CHECK_VERSION(2, 31, 0)
    921   return &g->interrupt_lock;
    922 #else
    923   return g->interrupt_lock;
    924 #endif
    925 }
    926 
    927900void owl_global_add_interrupt(owl_global *g) {
    928901  /* TODO: This can almost certainly be done with atomic
    929902   * operations. Whatever. */
    930   g_mutex_lock(owl_global_get_interrupt_lock(g));
     903  g_mutex_lock(g->interrupt_lock);
    931904  g->interrupt_count++;
    932   g_mutex_unlock(owl_global_get_interrupt_lock(g));
     905  g_mutex_unlock(g->interrupt_lock);
    933906}
    934907
    935908bool owl_global_take_interrupt(owl_global *g) {
    936909  bool ans = false;
    937   g_mutex_lock(owl_global_get_interrupt_lock(g));
     910  g_mutex_lock(g->interrupt_lock);
    938911  if (g->interrupt_count > 0) {
    939912    ans = true;
    940913    g->interrupt_count--;
    941914  }
    942   g_mutex_unlock(owl_global_get_interrupt_lock(g));
     915  g_mutex_unlock(g->interrupt_lock);
    943916  return ans;
    944917}
  • help.c

    r8258ea5 rf271129  
    7373     "    : , M-x       Enter command mode\n"
    7474     "\n"
    75      "    /             Forward search\n"
     75     "    /             Foward search\n"
    7676     "    ?             Reverse search\n"
    7777     "\n\n"
     
    107107     "    unsuball      Unsubscribe from all zephyr classes\n"
    108108     "    load-subs     Load zephyr subscriptions from a file\n"
    109      "    zpunt         Suppress messages from a zephyr triplet\n"
     109     "    zpunt         Supress messages from a zephyr triplet\n"
    110110     "    zlog          Send a login or logout notification\n"
    111111     "    zlist         Print a list of zephyr buddies logged in\n"
  • keybinding.c

    r7dcef03 rf271129  
    1414CALLER_OWN owl_keybinding *owl_keybinding_new(const char *keyseq, const char *command, void (*function_fn)(void), const char *desc)
    1515{
    16   owl_keybinding *kb = g_slice_new(owl_keybinding);
     16  owl_keybinding *kb = g_new(owl_keybinding, 1);
    1717
    1818  owl_function_debugmsg("owl_keybinding_init: creating binding for <%s> with desc: <%s>", keyseq, desc);
    1919  if (command && function_fn) {
    20     g_slice_free(owl_keybinding, kb);
     20    g_free(kb);
    2121    return NULL;
    2222  } else if (command && !function_fn) {
     
    2929
    3030  if (owl_keybinding_make_keys(kb, keyseq) != 0) {
    31     g_slice_free(owl_keybinding, kb);
     31    g_free(kb);
    3232    return NULL;
    3333  }
     
    7070  g_free(kb->desc);
    7171  g_free(kb->command);
    72   g_slice_free(owl_keybinding, kb);
     72  g_free(kb);
    7373}
    7474
  • keymap.c

    r7dcef03 rf271129  
    189189{
    190190  owl_keymap *km;
    191   km = g_slice_new(owl_keymap);
     191  km = g_new(owl_keymap, 1);
    192192  owl_keymap_init(km, name, desc, default_fn, prealways_fn, postalways_fn);
    193193  owl_keyhandler_add_keymap(kh, km);
  • libfaim/Makefile.am

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

    r7dcef03 rf271129  
    177177    g_free(msg->message);
    178178    g_free(msg->filename);
    179     g_slice_free(owl_log_entry, msg);
     179    g_free(msg);
    180180  }
    181181}
     
    184184{
    185185  owl_log_entry *log_msg = NULL;
    186   log_msg = g_slice_new(owl_log_entry);
     186  log_msg = g_new(owl_log_entry,1);
    187187  log_msg->message = g_strdup(buffer);
    188188  log_msg->filename = g_strdup(filename);
     
    266266   * owl_log_shouldlog_message(void)
    267267   */
    268   m = g_slice_new(owl_message);
     268  m = g_new(owl_message, 1);
    269269  /* recip_index = 0 because there can only be one recipient anyway */
    270270  owl_message_create_from_zwrite(m, zw, text, 0);
     
    429429static gpointer owl_log_thread_func(gpointer data)
    430430{
     431  log_context = g_main_context_new();
    431432  log_loop = g_main_loop_new(log_context, FALSE);
    432433  g_main_loop_run(log_loop);
     
    436437void owl_log_init(void)
    437438{
    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
    444439  GError *error = NULL;
    445440  logging_thread = g_thread_create(owl_log_thread_func,
     
    453448    exit(1);
    454449  }
    455 #endif
    456450 
    457451}
  • m4/ax_cflags_warn_all.m4

    re9b4a2c r378ede7  
    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.
    2927#
    3028# LICENSE
     
    5957#   exception to the GPL to apply to your modified version as well.
    6058
    61 #serial 14
     59#serial 10
    6260
    63 AC_DEFUN([AX_FLAGS_WARN_ALL],[dnl
    64 AS_VAR_PUSHDEF([FLAGS],[_AC_LANG_PREFIX[]FLAGS])dnl
    65 AS_VAR_PUSHDEF([VAR],[ac_cv_[]_AC_LANG_ABBREV[]flags_warn_all])dnl
     61AC_DEFUN([AX_CFLAGS_WARN_ALL],[dnl
     62AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl
     63AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_warn_all])dnl
    6664AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings],
    6765VAR,[VAR="no, unknown"
    68 ac_save_[]FLAGS="$[]FLAGS"
     66 AC_LANG_PUSH([C])
     67 ac_save_[]FLAGS="$[]FLAGS"
     68for ac_arg dnl
     69in "-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   #
     78do 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])
     81done
     82 FLAGS="$ac_save_[]FLAGS"
     83 AC_LANG_POP([C])
     84])
     85case ".$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 ]) ;;
     96esac
     97AS_VAR_POPDEF([VAR])dnl
     98AS_VAR_POPDEF([FLAGS])dnl
     99])
     100
     101dnl the only difference - the LANG selection... and the default FLAGS
     102
     103AC_DEFUN([AX_CXXFLAGS_WARN_ALL],[dnl
     104AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl
     105AS_VAR_PUSHDEF([VAR],[ax_cv_cxxflags_warn_all])dnl
     106AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings],
     107VAR,[VAR="no, unknown"
     108 AC_LANG_PUSH([C++])
     109 ac_save_[]FLAGS="$[]FLAGS"
     110for ac_arg dnl
     111in "-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   #
     120do 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])
     123done
     124 FLAGS="$ac_save_[]FLAGS"
     125 AC_LANG_POP([C++])
     126])
     127case ".$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 ]) ;;
     138esac
     139AS_VAR_POPDEF([VAR])dnl
     140AS_VAR_POPDEF([FLAGS])dnl
     141])
     142
     143dnl the only difference - the LANG selection... and the default FLAGS
     144
     145AC_DEFUN([AX_FCFLAGS_WARN_ALL],[dnl
     146AS_VAR_PUSHDEF([FLAGS],[FCFLAGS])dnl
     147AS_VAR_PUSHDEF([VAR],[ax_cv_fcflags_warn_all])dnl
     148AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings],
     149VAR,[VAR="no, unknown"
     150 AC_LANG_PUSH([Fortran])
     151 ac_save_[]FLAGS="$[]FLAGS"
    69152for ac_arg dnl
    70153in "-warn all  % -warn all"   dnl Intel
     
    82165                     [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
    83166done
    84 FLAGS="$ac_save_[]FLAGS"
     167 FLAGS="$ac_save_[]FLAGS"
     168 AC_LANG_POP([Fortran])
    85169])
    86 AS_VAR_POPDEF([FLAGS])dnl
    87 AC_REQUIRE([AX_APPEND_FLAG])
    88170case ".$VAR" in
    89171     .ok|.ok,*) m4_ifvaln($3,$3) ;;
    90    .|.no|.no,*) m4_default($4,[m4_ifval($2,[AX_APPEND_FLAG([$2], [$1])])]) ;;
    91    *) m4_default($3,[AX_APPEND_FLAG([$VAR], [$1])]) ;;
     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 ]) ;;
    92181esac
    93182AS_VAR_POPDEF([VAR])dnl
    94 ])dnl AX_FLAGS_WARN_ALL
     183AS_VAR_POPDEF([FLAGS])dnl
     184])
     185
    95186dnl  implementation tactics:
    96187dnl   the for-argument contains a list of options. The first part of
     
    103194dnl   delimiter. A non-option comment can be given after "%%" marks
    104195dnl   which will be shown but not added to the respective C/CXXFLAGS.
    105 
    106 AC_DEFUN([AX_CFLAGS_WARN_ALL],[dnl
    107 AC_LANG_PUSH([C])
    108 AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4])
    109 AC_LANG_POP([C])
    110 ])
    111 
    112 AC_DEFUN([AX_CXXFLAGS_WARN_ALL],[dnl
    113 AC_LANG_PUSH([C++])
    114 AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4])
    115 AC_LANG_POP([C++])
    116 ])
    117 
    118 AC_DEFUN([AX_FCFLAGS_WARN_ALL],[dnl
    119 AC_LANG_PUSH([Fortran])
    120 AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4])
    121 AC_LANG_POP([Fortran])
    122 ])
  • m4/pkg.m4

    r13a39ae8 r650fb2c  
    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.
    169 AC_DEFUN([PKG_INSTALLDIR],
    170 [m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
    171 m4_pushdef([pkg_description],
    172     [pkg-config installation directory @<:@]pkg_default[@:>@])
    173 AC_ARG_WITH([pkgconfigdir],
    174     [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
    175     [with_pkgconfigdir=]pkg_default)
    176 AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
    177 m4_popdef([pkg_default])
    178 m4_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.
    189 AC_DEFUN([PKG_NOARCH_INSTALLDIR],
    190 [m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
    191 m4_pushdef([pkg_description],
    192     [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
    193 AC_ARG_WITH([noarch-pkgconfigdir],
    194     [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
    195     [with_noarch_pkgconfigdir=]pkg_default)
    196 AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
    197 m4_popdef([pkg_default])
    198 m4_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.
    206 AC_DEFUN([PKG_CHECK_VAR],
    207 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
    208 AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
    209 
    210 _PKG_CONFIG([$1], [variable="][$3]["], [$2])
    211 AS_VAR_COPY([$1], [pkg_cv_][$1])
    212 
    213 AS_VAR_IF([$1], [""], [$5], [$4])dnl
    214 ])# PKG_CHECK_VAR
  • mainwin.c

    r7dcef03 r099597c  
    44static void owl_mainwin_resized(owl_window *w, void *user_data);
    55
    6 CALLER_OWN owl_mainwin *owl_mainwin_new(owl_window *window)
     6void owl_mainwin_init(owl_mainwin *mw, owl_window *window)
    77{
    8   owl_mainwin *mw = g_slice_new(owl_mainwin);
    98  mw->curtruncated=0;
    109  mw->lastdisplayed=-1;
     
    1716  /* For now, we do not bother with connecting up dependencies; that'll be a
    1817   * future refactor of the mainwin */
    19 
    20   return mw;
    2118}
    2219
  • message.c

    r7dcef03 r0071c88  
    7070
    7171  if(pair ==  NULL) {
    72     pair = g_slice_new(owl_pair);
     72    pair = g_new(owl_pair, 1);
    7373    owl_pair_create(pair, attrname, NULL);
    7474    g_ptr_array_add(m->attributes, pair);
     
    836836
    837837 
    838   /* set the "isprivate" attribute if it's a private zephyr. */
    839   if (owl_zwrite_recip_is_personal(n->z_recipient)) {
     838  /* set the "isprivate" attribute if it's a private zephyr.
     839   ``private'' means recipient is non-empty and doesn't start wit
     840   `@' */
     841  if (*n->z_recipient && *n->z_recipient != '@') {
    840842    owl_message_set_isprivate(m);
    841843  }
     
    875877  if (owl_global_is_zcrypt(&g) && !strcasecmp(n->z_opcode, "crypt")) {
    876878    const char *argv[] = {
    877       NULL,
     879      "zcrypt",
    878880      "-D",
    879881      "-c", owl_message_get_class(m),
     
    881883      NULL
    882884    };
    883     char *out = NULL;
     885    char *out;
    884886    int rv;
    885887    int status;
     
    887889
    888890    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);
     891
     892    rv = call_filter(zcrypt, argv, owl_message_get_body(m), &out, &status);
    892893    g_free(zcrypt);
    893894
     
    898899      }
    899900      owl_message_set_body(m, out);
    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);
     901      g_free(out);
     902    } else if(out) {
     903      g_free(out);
     904    }
    906905  }
    907906
     
    10191018    p = m->attributes->pdata[i];
    10201019    g_free(owl_pair_get_value(p));
    1021     g_slice_free(owl_pair, p);
     1020    g_free(p);
    10221021  }
    10231022
     
    10301029{
    10311030  owl_message_cleanup(m);
    1032   g_slice_free(owl_message, m);
    1033 }
     1031  g_free(m);
     1032}
  • messagelist.c

    r7dcef03 rf271129  
    11#include "owl.h"
    22
    3 CALLER_OWN owl_messagelist *owl_messagelist_new(void)
     3void owl_messagelist_create(owl_messagelist *ml)
    44{
    5   owl_messagelist *ml = g_slice_new(owl_messagelist);
    65  ml->list = g_ptr_array_new();
    7   return ml;
    86}
    97
    10 void owl_messagelist_delete(owl_messagelist *ml, bool free_messages)
     8void owl_messagelist_cleanup(owl_messagelist *ml, bool free_messages)
    119{
    1210  if (free_messages)
    1311    g_ptr_array_foreach(ml->list, (GFunc)owl_message_delete, NULL);
    1412  g_ptr_array_free(ml->list, true);
    15   g_slice_free(owl_messagelist, ml);
    1613}
    1714
  • owl.c

    r441fd42 rf271129  
    1212#include <sys/stat.h>
    1313#include <locale.h>
    14 #include <unistd.h>
    1514
    1615#if OWL_STDERR_REDIR
     
    3433} owl_options;
    3534
    36 void usage(FILE *file)
     35void usage(void)
    3736{
    38   fprintf(file, "BarnOwl version %s\n", version);
    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");
     37  fprintf(stderr, "Barnowl version %s\n", OWL_VERSION_STRING);
     38  fprintf(stderr, "Usage: barnowl [-n] [-d] [-D] [-v] [-h] [-c <configfile>] [-s <confdir>] [-t <ttyname>]\n");
     39  fprintf(stderr, "  -n,--no-subs        don't load zephyr subscriptions\n");
     40  fprintf(stderr, "  -d,--debug          enable debugging\n");
     41  fprintf(stderr, "  -v,--version        print the Barnowl version number and exit\n");
     42  fprintf(stderr, "  -h,--help           print this help message\n");
     43  fprintf(stderr, "  -c,--config-file    specify an alternate config file\n");
     44  fprintf(stderr, "  -s,--config-dir     specify an alternate config dir (default ~/.owl)\n");
     45  fprintf(stderr, "  -t,--tty            set the tty name\n");
    4746}
    4847
     
    8079      break;
    8180    case 'v':
    82       printf("This is BarnOwl version %s\n", version);
     81      printf("This is BarnOwl version %s\n", OWL_VERSION_STRING);
    8382      exit(0);
    8483    case 'h':
    85       usage(stdout);
    86       exit(0);
    8784    default:
    88       usage(stderr);
     85      usage();
    8986      exit(1);
    9087    }
     
    265262    /* follow the last message if we're supposed to */
    266263    if (followlast)
    267       owl_function_lastmsg();
     264      owl_function_lastmsg_noredisplay();
    268265
    269266    /* do the newmsgproc thing */
     
    289286
    290287  owl_global_set_lastinputtime(&g, time(NULL));
    291   owl_global_wakeup(&g);
    292288  ret = owl_keyhandler_process(owl_global_get_keyhandler(&g), j);
    293289  if (ret!=0 && ret!=1) {
     
    431427  if (0 != pipe(pipefds)) {
    432428    perror("pipe");
    433     owl_function_debugmsg("stderr_replace: pipe FAILED");
     429    owl_function_debugmsg("stderr_replace: pipe FAILED\n");
    434430    return -1;
    435431  }
    436     owl_function_debugmsg("stderr_replace: pipe: %d,%d", pipefds[0], pipefds[1]);
    437   if (-1 == dup2(pipefds[1], STDERR_FILENO)) {
    438     owl_function_debugmsg("stderr_replace: dup2 FAILED (%s)", strerror(errno));
     432    owl_function_debugmsg("stderr_replace: pipe: %d,%d\n", pipefds[0], pipefds[1]);
     433  if (-1 == dup2(pipefds[1], 2 /*stderr*/)) {
     434    owl_function_debugmsg("stderr_replace: dup2 FAILED (%s)\n", strerror(errno));
    439435    perror("dup2");
    440436    return -1;
     
    518514#if OWL_STDERR_REDIR
    519515  /* Do this only after we've started curses up... */
    520   if (isatty(STDERR_FILENO)) {
    521     owl_function_debugmsg("startup: doing stderr redirection");
    522     channel = g_io_channel_unix_new(stderr_replace());
    523     g_io_add_watch(channel, G_IO_IN | G_IO_HUP | G_IO_ERR, &stderr_redirect_handler, NULL);
    524     g_io_channel_unref(channel);
    525   }
     516  owl_function_debugmsg("startup: doing stderr redirection");
     517  channel = g_io_channel_unix_new(stderr_replace());
     518  g_io_add_watch(channel, G_IO_IN | G_IO_HUP | G_IO_ERR, &stderr_redirect_handler, NULL);
     519  g_io_channel_unref(channel);
    526520#endif
    527521
     
    578572  /* welcome message */
    579573  owl_function_debugmsg("startup: creating splash message");
    580   char *welcome = g_strdup_printf(
     574  owl_function_adminmsg("",
    581575    "-----------------------------------------------------------------------\n"
    582     "Welcome to BarnOwl version %s.\n"
     576    "Welcome to BarnOwl version " OWL_VERSION_STRING ".\n"
    583577    "To see a quick introduction, type ':show quickstart'.                  \n"
    584578    "Press 'h' for on-line help.                                            \n"
     
    588582    "                                                                 OvO   \n"
    589583    "Please report any bugs or suggestions to bug-barnowl@mit.edu    (   )  \n"
    590     "-----------------------------------------------------------------m-m---\n",
    591     version);
    592   owl_function_adminmsg("", welcome);
    593   g_free(welcome);
    594 
    595   owl_function_debugmsg("startup: setting context interactive");
    596 
    597   owl_global_pop_context(&g);
    598   owl_global_push_context(&g, OWL_CTX_INTERACTIVE|OWL_CTX_RECV, NULL, "recv", NULL);
     584    "-----------------------------------------------------------------m-m---\n"
     585  );
    599586
    600587  /* process the startup file */
     
    609596      owl_function_error("No such style: %s", owl_global_get_default_style(&g));
    610597
     598  owl_function_debugmsg("startup: setting context interactive");
     599
     600  owl_global_pop_context(&g);
     601  owl_global_push_context(&g, OWL_CTX_INTERACTIVE|OWL_CTX_RECV, NULL, "recv", NULL);
     602
    611603  source = owl_window_redraw_source_new();
    612604  g_source_attach(source, NULL);
  • owl.h

    rca1fb26a rb9517cf  
    1010#define INC_BARNOWL_OWL_H
    1111
    12 #include <config.h>
     12#include "config.h"
    1313
    1414#include "compat/compat.h"
     
    4747/* Perl and curses don't play nice. */
    4848#ifdef OWL_PERL
    49 typedef struct _owl_fake_WINDOW WINDOW;
    50 typedef struct _owl_fake_PANEL PANEL;
     49typedef void WINDOW;
     50typedef void PANEL;
    5151/* logout is defined in FreeBSD. */
    5252#define logout logout_
     
    5757#include "XSUB.h"
    5858#else
    59 typedef struct _owl_fake_SV SV;
    60 typedef struct _owl_fake_AV AV;
    61 typedef struct _owl_fake_HV HV;
     59typedef void SV;
     60typedef void AV;
     61typedef void HV;
    6262#endif
    6363
    6464#include "window.h"
    6565
    66 extern const char *version;
     66#ifndef OWL_VERSION_STRING
     67#ifdef  GIT_VERSION
     68#define stringify(x)       __stringify(x)
     69#define __stringify(x)     #x
     70#define OWL_VERSION_STRING stringify(GIT_VERSION)
     71#else
     72#define OWL_VERSION_STRING PACKAGE_VERSION
     73#endif
     74#endif /* !OWL_VERSION_STRING */
    6775
    6876/* Feature that is being tested to redirect stderr through a pipe.
     
    227235  char *name;
    228236  int   type;  /* OWL_VARIABLE_* */
    229   char *default_str;            /* the default value as a string */
    230   char *validsettings;          /* documentation of valid settings */
     237  void *pval_default;  /* for types other and string */
     238  int   ival_default;  /* for types int and bool     */
     239  const char *validsettings;    /* documentation of valid settings */
    231240  char *summary;                /* summary of usage */
    232241  char *description;            /* detailed description */
    233   bool takes_on_off;            /* allow passing on/off in argument-less set/unset */
    234   GClosure *set_fromstring_fn;
     242  void *val;                    /* current value */
     243  int  (*validate_fn)(const struct _owl_variable *v, const void *newval);
     244                                /* returns 1 if newval is valid */
     245  int  (*set_fn)(struct _owl_variable *v, const void *newval);
    235246                                /* sets the variable to a value
    236                                  * of the appropriate type.
    237                                  * unless documented, this
    238                                  * should make a copy.
    239                                  * returns 0 on success. */
    240   GClosure *get_tostring_fn;
     247                                 * of the appropriate type.
     248                                 * unless documented, this
     249                                 * should make a copy.
     250                                 * returns 0 on success. */
     251  int  (*set_fromstring_fn)(struct _owl_variable *v, const char *newval);
     252                                /* sets the variable to a value
     253                                 * of the appropriate type.
     254                                 * unless documented, this
     255                                 * should make a copy.
     256                                 * returns 0 on success. */
     257  const void *(*get_fn)(const struct _owl_variable *v);
     258                                /* returns a reference to the current value.
     259                                 * WARNING:  this approach is hard to make
     260                                 * thread-safe... */
     261  CALLER_OWN char *(*get_tostring_fn)(const struct _owl_variable *v, const void *val);
    241262                                /* converts val to a string;
    242                                  * caller must free the result */
    243 
    244   /* These are only valid for OWL_VARIABLE_{INT,BOOL,STRING} */
    245   GValue val;                   /* current value, if default get_fn/set_fn */
    246 
    247   GCallback get_fn;
    248                                 /* returns a reference to the current value.
    249                                  * WARNING:  this approach is hard to make
    250                                  * thread-safe... */
    251   GCallback validate_fn;
    252                                 /* returns 1 if newval is valid */
    253   GCallback set_fn;
    254                                 /* sets the variable to a value
    255                                  * of the appropriate type.
    256                                  * unless documented, this
    257                                  * should make a copy.
    258                                  * returns 0 on success. */
     263                                 * caller must free the result */
     264  void (*delete_fn)(struct _owl_variable *v);
     265                                /* frees val as needed */
    259266} owl_variable;
    260 
    261267
    262268typedef struct _owl_input {
     
    446452  char *name;
    447453  owl_filter *filter;
    448   owl_messagelist *ml;
     454  owl_messagelist ml;
    449455  const owl_style *style;
    450456  int cachedmsgid;
     
    527533
    528534typedef struct _owl_global {
    529   owl_mainwin *mw;
     535  owl_mainwin mw;
    530536  owl_popwin *pw;
    531537  owl_msgwin msgwin;
     
    545551  int curmsg_vert_offset;
    546552  owl_view current_view;
    547   owl_messagelist *msglist;
     553  owl_messagelist msglist;
    548554  WINDOW *input_pad;
    549555  owl_mainpanel mainpanel;
     
    563569  time_t starttime;
    564570  time_t lastinputtime;
    565   time_t last_wakeup_time;
    566571  char *startupargs;
    567572  int nextmsgid;
     
    591596  char *kill_buffer;
    592597  int interrupt_count;
    593 #if GLIB_CHECK_VERSION(2, 31, 0)
    594   GMutex interrupt_lock;
    595 #else
    596598  GMutex *interrupt_lock;
    597 #endif
    598599} owl_global;
    599600
     
    601602extern owl_global g;
    602603
    603 #include <owl_prototypes.h>
     604#include "owl_prototypes.h"
    604605
    605606/* These were missing from the Zephyr includes before Zephyr 3. */
     
    609610#endif
    610611
    611 /* We have to dynamically bind these ourselves */
    612 extern gboolean (*gvalue_from_sv) (GValue * value, SV * sv);
    613 extern SV * (*sv_from_gvalue) (const GValue * value);
    614 extern GClosure * (*perl_closure_new) (SV * callback, SV * data, gboolean swap);
    615 
    616 
    617612#endif /* INC_BARNOWL_OWL_H */
  • owl_perl.h

    r92ffd89 rf271129  
    44#include <stdio.h>
    55
    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 }
     6#define OWL_PERL_VOID_CALL (void)POPs;
    227
    238/*
    249 * This macro defines a convenience wrapper around the boilerplate of
    25  * the perlcall methods.
     10 * calling a method on a perl object (SV*) from C.
    2611 *
    2712 * Arguments are
    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
     13 * * obj    - the SV* to call the method on
     14 * * meth   - a char* method name
     15 * * args   - a code block responsible for pushing args (other than the object)
     16 * * err    - a string with a %s format specifier to log in case of error
     17 * * fatalp - if true, perl errors terminate BarnOwl
     18 * * ret    - a code block executed if the call succeeded
    3519 *
    3620 * See also: `perldoc perlcall', `perldoc perlapi'
    3721 */
    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); \
     22#define OWL_PERL_CALL_METHOD(obj, meth, args, err, fatalp, ret) { \
     23    int count; \
     24    dSP; \
     25    ENTER; \
     26    SAVETMPS; \
     27    PUSHMARK(SP); \
     28    XPUSHs(obj); \
     29    {args} \
     30    PUTBACK; \
     31    \
     32    count = call_method(meth, G_SCALAR|G_EVAL); \
     33    \
     34    SPAGAIN; \
     35    \
     36    if(count != 1) { \
     37      fprintf(stderr, "perl returned wrong count: %d\n", count); \
     38      abort();                                                   \
     39    } \
     40    if (SvTRUE(ERRSV)) { \
     41      if(fatalp) { \
     42        printf(err, SvPV_nolen(ERRSV)); \
     43        exit(-1); \
     44      } else { \
     45        owl_function_error(err, SvPV_nolen(ERRSV)); \
     46        (void)POPs; \
     47        sv_setsv(ERRSV, &PL_sv_undef); \
     48      } \
    6149    } else { \
    62       owl_function_error(err, SvPV_nolen(ERRSV)); \
    63       if (!discardret) (void)POPs; \
    64       sv_setsv(ERRSV, &PL_sv_undef); \
     50      ret; \
    6551    } \
    66   } else if (!discardret) { \
    67     ret; \
    68   } \
    69   PUTBACK; \
    70   FREETMPS; \
    71   LEAVE; \
     52    PUTBACK; \
     53    FREETMPS; \
     54    LEAVE; \
    7255}
    7356
  • perl/Makefile.am

    ra870319 r10557e6  
    11SUBDIRS = modules
    2 nobase_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

    recd4edf ra130fc5  
    55
    66use base qw(Exporter);
    7 our @EXPORT_OK = qw(command getcurmsg getnumcols getnumlines getidletime
    8                     register_idle_watcher unregister_idle_watcher
     7our @EXPORT_OK = qw(command getcurmsg getnumcols getidletime
    98                    zephyr_getsender zephyr_getrealm zephyr_zwrite
    109                    zephyr_stylestrip zephyr_smartstrip_user zephyr_getsubs
    1110                    queue_message admin_message
    12                     start_edit
    1311                    start_question start_password start_edit_win
    1412                    get_data_dir get_config_dir popless_text popless_ztext
    1513                    error debug
    1614                    create_style getnumcolors wordwrap
    17                     message_matches_filter
    1815                    add_dispatch remove_dispatch
    1916                    add_io_dispatch remove_io_dispatch
    2017                    new_command
    2118                    new_variable_int new_variable_bool new_variable_string
    22                     new_variable_enum
    2319                    quote redisplay);
    2420our %EXPORT_TAGS = (all => \@EXPORT_OK);
     
    4743
    4844use List::Util qw(max);
    49 use Tie::RefHash;
    5045
    5146=head1 NAME
     
    9792command line, and C<MESSAGE> is the zephyr body to send.
    9893
    99 =cut
    100 
    101 sub zephyr_zwrite {
    102     my ($command, $message) = @_;
    103     my $ret = BarnOwl::Internal::zephyr_zwrite($command, $message);
    104     die "Error sending zephyr" unless $ret == 0;
    105 }
    106 
    10794=head2 ztext_stylestrip STRING
    10895
     
    118105Enqueue a message in the BarnOwl message list, logging it and
    119106processing it appropriately. C<MESSAGE> should be an instance of
    120 BarnOwl::Message or a subclass.
     107BarnOwl::Message or a subclass.  Returns the queued message.  This
     108is useful for, e.g., deleting a message from the message list.
    121109
    122110=head2 admin_message HEADER BODY
     
    124112Display a BarnOwl B<Admin> message, with the given header and body.
    125113
    126 =head2 start_edit %ARGS
    127 
    128 Displays a prompt on the screen and lets the user enter text,
    129 and calls a callback when the editwin is closed.
    130 
    131 C<%ARGS> must contain the following keys:
    132 
    133 =over 4
    134 
    135 =item prompt
    136 
    137 The line to display on the screen
    138 
    139 =item type
    140 
    141 One of:
    142 
    143 =over 4
    144 
    145 =item edit_win
    146 
    147 Displays the prompt on a line of its own and opens the edit_win.
    148 
    149 =item question
    150 
    151 Displays prompt on the screen and lets the user enter a line of
    152 text.
    153 
    154 =item password
    155 
    156 Like question, but echoes the user's input as C<*>s when they
     114=head2 start_question PROMPT CALLBACK
     115
     116Displays C<PROMPT> on the screen and lets the user enter a line of
     117text, and calls C<CALLBACK>, which must be a perl subroutine
     118reference, with the text the user entered
     119
     120=head2 start_password PROMPT CALLBACK
     121
     122Like C<start_question>, but echoes the user's input as C<*>s when they
    157123input.
    158124
    159 =back
    160 
    161 =item callback
    162 
    163 A Perl subroutine that is called when the user closes the edit_win.
    164 C<CALLBACK> gets called with two parameters: the text the user entered,
    165 and a C<SUCCESS> boolean parameter which is false if the user canceled
    166 the edit_win and true otherwise.
    167 
    168 =back
    169 
    170 =head2 start_question PROMPT CALLBACK
    171 
    172 =head2 start_password PROMPT CALLBACK
    173 
    174125=head2 start_edit_win PROMPT CALLBACK
    175126
    176 Roughly equivalent to C<start_edit> called with the appropriate parameters.
    177 C<CALLBACK> is only called on success, for compatibility.
    178 
    179 These are deprecated wrappers around L<BarnOwl::start_edit>, and should not
    180 be uesd in new code.
    181 
    182 =cut
    183 
    184 sub start_edit {
    185     my %args = (@_);
    186     BarnOwl::Internal::start_edit($args{type}, $args{prompt}, $args{callback});
    187 }
    188 
    189 sub start_question {
    190     my ($prompt, $callback) = @_;
    191     BarnOwl::start_edit(type => 'question', prompt => $prompt, callback => sub {
    192             my ($text, $success) = @_;
    193             $callback->($text) if $success;
    194         });
    195 }
    196 
    197 sub start_password {
    198     my ($prompt, $callback) = @_;
    199     BarnOwl::start_edit(type => 'password', prompt => $prompt, callback => sub {
    200             my ($text, $success) = @_;
    201             $callback->($text) if $success;
    202         });
    203 }
    204 
    205 sub start_edit_win {
    206     my ($prompt, $callback) = @_;
    207     BarnOwl::start_edit(type => 'edit_win', prompt => $prompt, callback => sub {
    208             my ($text, $success) = @_;
    209             $callback->($text) if $success;
    210         });
    211 }
     127Like C<start_question>, but displays C<PROMPT> on a line of its own
     128and opens the editwin. If the user cancels the edit win, C<CALLBACK>
     129is not invoked.
    212130
    213131=head2 get_data_dir
     
    242160
    243161Returns the number of colors this BarnOwl is capable of displaying
    244 
    245 =head2 message_matches_filter MESSAGE FILTER_NAME [QUIET = 0]
    246 
    247 Returns 1 if C<FILTER_NAME> is the name of a valid filter, and
    248 C<MESSAGE> matches that filter.  Returns 0 otherwise.  If
    249 C<QUIET> is false, this method displays an error message if
    250 if C<FILTER_NAME> does not name a valid filter.
    251162
    252163=head2 add_dispatch FD CALLBACK
     
    348259our @all_commands;
    349260
    350 if(!$configfile) {
    351     if (-f get_config_dir() . "/init.pl") {
    352         $configfile = get_config_dir() . "/init.pl";
    353     } elsif (-f $ENV{HOME} . "/.barnowlconf") {
    354         $configfile = $ENV{HOME} . "/.barnowlconf";
    355     } else {
    356         $configfile = $ENV{HOME}."/.owlconf";
    357     }
    358 }
     261if(!$configfile && -f $ENV{HOME} . "/.barnowlconf") {
     262    $configfile = $ENV{HOME} . "/.barnowlconf";
     263}
     264$configfile ||= $ENV{HOME}."/.owlconf";
    359265
    360266# populate global variable space for legacy owlconf files
     
    413319=head2 new_variable_string NAME [{ARGS}]
    414320
    415 =head2 new_variable_enum NAME [{ARGS}]
    416 
    417 Add a new owl variable, either an int, a bool, a string, or an enum with the
     321Add a new owl variable, either an int, a bool, or a string, with the
    418322specified name.
    419323
    420 For new_variable_enum, ARGS is required to contain a validsettings key pointing
    421 to an array reference. For all four, it can optionally contain the following
    422 keys:
     324ARGS can optionally contain the following keys:
    423325
    424326=over 4
     
    438340=back
    439341
    440 In addition, new_variable_string optionally accepts a string validsettings
    441 parameter, in case people want to set it to "<path>".
    442 
    443342=cut
    444343
    445344sub new_variable_int {
    446     my ($name, $args) = @_;
    447     my $storage = defined($args->{default}) ? $args->{default} : 0;
    448     BarnOwl::new_variable_full($name, {
    449             %{$args},
    450             get_tostring => sub { "$storage" },
    451             set_fromstring => sub {
    452                 die "Expected integer" unless $_[0] =~ /^-?[0-9]+$/;
    453                 $storage = 0 + $_[0];
    454             },
    455             validsettings => "<int>",
    456             takes_on_off => 0,
    457         });
     345    unshift @_, \&BarnOwl::Internal::new_variable_int, 0;
     346    goto \&_new_variable;
    458347}
    459348
    460349sub new_variable_bool {
    461     my ($name, $args) = @_;
    462     my $storage = defined($args->{default}) ? $args->{default} : 0;
    463     BarnOwl::new_variable_full($name, {
    464             %{$args},
    465             get_tostring => sub { $storage ? "on" : "off" },
    466             set_fromstring => sub {
    467                 die "Valid settings are on/off" unless $_[0] eq "on" || $_[0] eq "off";
    468                 $storage = $_[0] eq "on";
    469             },
    470             validsettings => "on,off",
    471             takes_on_off => 1,
    472         });
     350    unshift @_, \&BarnOwl::Internal::new_variable_bool, 0;
     351    goto \&_new_variable;
    473352}
    474353
    475354sub new_variable_string {
    476     my ($name, $args) = @_;
    477     my $storage = defined($args->{default}) ? $args->{default} : "";
    478     BarnOwl::new_variable_full($name, {
    479             # Allow people to override this one if they /reaaally/ want to for
    480             # some reason. Though we still reserve the right to interpret this
    481             # value in interesting ways for tab-completion purposes.
    482             validsettings => "<string>",
    483             %{$args},
    484             get_tostring => sub { $storage },
    485             set_fromstring => sub { $storage = $_[0]; },
    486             takes_on_off => 0,
    487         });
    488 }
    489 
    490 sub new_variable_enum {
    491     my ($name, $args) = @_;
    492 
    493     # Gather the valid settings.
    494     die "validsettings is required" unless defined($args->{validsettings});
    495     my %valid;
    496     map { $valid{$_} = 1 } @{$args->{validsettings}};
    497 
    498     my $storage = (defined($args->{default}) ?
    499                    $args->{default} :
    500                    $args->{validsettings}->[0]);
    501     BarnOwl::new_variable_full($name, {
    502             %{$args},
    503             get_tostring => sub { $storage },
    504             set_fromstring => sub {
    505                 die "Invalid input" unless $valid{$_[0]};
    506                 $storage = $_[0];
    507             },
    508             validsettings => join(",", @{$args->{validsettings}})
    509         });
    510 }
    511 
    512 =head2 new_variable_full NAME {ARGS}
    513 
    514 Create a variable, in full generality. The keyword arguments have types below:
    515 
    516  get_tostring : ()  -> string
    517  set_fromstring : string -> int
    518  -- optional --
    519  summary : string
    520  description : string
    521  validsettings : string
    522  takes_on_off : int
    523 
    524 The get/set functions are required. Note that the caller manages storage for the
    525 variable. get_tostring/set_fromstring both convert AND store the value.
    526 set_fromstring dies on failure.
    527 
    528 If the variable takes parameters 'on' and 'off' (i.e. is boolean-looking), set
    529 takes_on_off to 1. This makes :set VAR and :unset VAR work. set_fromstring will
    530 be called with those arguments.
    531 
    532 =cut
    533 
    534 sub new_variable_full {
     355    unshift @_, \&BarnOwl::Internal::new_variable_string, "";
     356    goto \&_new_variable;
     357}
     358
     359sub _new_variable {
     360    my $func = shift;
     361    my $default_default = shift;
    535362    my $name = shift;
    536363    my $args = shift || {};
    537364    my %args = (
    538         summary => "",
     365        summary     => "",
    539366        description => "",
    540         takes_on_off => 0,
    541         validsettings => "<string>",
     367        default     => $default_default,
    542368        %{$args});
    543 
    544     die "get_tostring required" unless $args{get_tostring};
    545     die "set_fromstring required" unless $args{set_fromstring};
    546 
    547     # Strip off the bogus dummy argument. Aargh perl-Glib.
    548     my $get_tostring_fn = sub { $args{get_tostring}->() };
    549     my $set_fromstring_fn = sub {
    550       my ($dummy, $val) = @_;
    551       # Translate from user-supplied die-on-failure callback to expected
    552       # non-zero on error. Less of a nuisance than interacting with ERRSV.
    553       eval { $args{set_fromstring}->($val) };
    554       # TODO: Consider changing B::I::new_variable to expect string|NULL with
    555       # string as the error message. That can then be translated to a GError in
    556       # owl_variable_set_fromstring. For now the string is ignored.
    557       return ($@ ? -1 : 0);
    558     };
    559 
    560     BarnOwl::Internal::new_variable($name, $args{summary}, $args{description}, $args{validsettings},
    561                                     $args{takes_on_off}, $get_tostring_fn, $set_fromstring_fn, undef);
     369    $func->($name, $args{default}, $args{summary}, $args{description});
    562370}
    563371
     
    795603}
    796604
    797 =head3 register_idle_watcher %ARGS
    798 
    799 Call a callback whenever the amount of time the user becomes idle or comes
    800 back from being idle.
    801 
    802 You must include the following parameters:
    803 
    804 =over 4
    805 
    806 =item name
    807 
    808 The name given to the idle watcher
    809 
    810 =item after
    811 
    812 How long the user must be idle, in seconds, before the callback is called.
    813 If the value is too small, you may have spurious or inaccurate calls.
    814 (The current lower limit is about 1 second.)
    815 
    816 =item callback
    817 
    818 The Perl subroutine that gets called when the user has been idle for C<AFTER>
    819 seconds, or comes back from being idle.  The subroutine is passed one parameter,
    820 which is true if the user is currently idle, and false otherwise.
    821 
    822 =back
    823 
    824 This method returns a unique identifier which may be passed to
    825 L<BarnOwl::unregister_idle_watcher>.
    826 
    827 =cut
    828 
    829 =head3 unregister_idle_watcher UNIQUE_ID [...]
    830 
    831 Removed and returns the idle watcher specified by C<UNIQUE_ID>.
    832 You may specify multiple unique ids.
    833 
    834 =cut
    835 
    836 my %idle_watchers;
    837 tie %idle_watchers, 'Tie::RefHash';
    838 
    839 $BarnOwl::Hooks::wakeup->add(sub {
    840         foreach my $idle_watcher (values %idle_watchers) {
    841             _wakeup_idle_watcher($idle_watcher);
    842         }
    843     });
    844 
    845 sub _wakeup_idle_watcher {
    846     my ($idle_watcher, $offset) = @_;
    847     $offset = 0 unless defined $offset;
    848     # go unidle
    849     $idle_watcher->{idle_timer}->stop if $idle_watcher->{idle_timer};
    850     undef $idle_watcher->{idle_timer};
    851     $idle_watcher->{callback}->(0) if $idle_watcher->{is_idle};
    852     $idle_watcher->{is_idle} = 0;
    853 
    854     # queue going idle
    855     $idle_watcher->{idle_timer} = BarnOwl::Timer->new({
    856         name  => $idle_watcher->{name},
    857         after => $idle_watcher->{after} - $offset,
    858         cb    => sub {
    859             $idle_watcher->{is_idle} = 1;
    860             $idle_watcher->{callback}->(1);
    861         }
    862     });
    863 }
    864 
    865 sub register_idle_watcher {
    866     my %args = (@_);
    867     $idle_watchers{\%args} = \%args;
    868     _wakeup_idle_watcher(\%args, BarnOwl::getidletime); # make sure to queue up the idle/unidle events from this idle watcher
    869     return \%args;
    870 }
    871 
    872 sub unregister_idle_watcher {
    873     my ($id) = @_;
    874     $idle_watchers{$id}->{idle_timer}->stop if $idle_watchers{$id}->{idle_timer};
    875     return delete $idle_watchers{$id};
    876 }
    877 
    878605# Stub for owl::startup / BarnOwl::startup, so it isn't bound to the
    879606# startup command. This may be redefined in a user's configfile.
  • perl/lib/BarnOwl/Complete/Client.pm

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

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

    r120dac7 rb8a3e00  
    3636Called before BarnOwl shutdown
    3737
    38 =item $wakeup
    39 
    40 Called, at most once per second, on user input
    41 
    4238=item $receiveMessage
    4339
     
    6157from every function registered with this hook will be appended and
    6258displayed in a popup window, with zephyr formatting parsed.
    63 
    64 =item $awayOn
    65 
    66 Called, for all protocol handlers, to go away, with the away message,
    67 if any.
    68 
    69 =item $awayOff
    70 
    71 Called, for all protocol handlers, to come back from away.
    72 
    73 =item $getIsAway
    74 
    75 Called to check away status for all protocol handlers.  Protocol
    76 handlers should return a true value if any account of the user is away
    77 for the given protocol, and a false value otherwise.
    7859
    7960=item $getQuickstart
     
    9273
    9374our @EXPORT_OK = qw($startup $shutdown
    94                     $wakeup
    9575                    $receiveMessage $newMessage
    9676                    $mainLoop $getBuddyList
    97                     $awayOn $awayOff $getIsAway
    9877                    $getQuickstart);
    9978
     
    10483our $startup = BarnOwl::Hook->new;
    10584our $shutdown = BarnOwl::Hook->new;
    106 our $wakeup = BarnOwl::Hook->new;
    10785our $receiveMessage = BarnOwl::Hook->new;
    10886our $newMessage = BarnOwl::Hook->new;
     
    11088our $getBuddyList = BarnOwl::Hook->new;
    11189our $getQuickstart = BarnOwl::Hook->new;
    112 our $awayOn = BarnOwl::Hook->new;
    113 our $awayOff = BarnOwl::Hook->new;
    114 our $getIsAway = BarnOwl::Hook->new;
    11590
    11691# Internal startup/shutdown routines called by the C code
     
    200175}
    201176
    202 sub _wakeup {
    203     $wakeup->run;
    204 }
    205 
    206177sub _receive_msg {
    207178    my $m = shift;
     
    228199sub _get_quickstart {
    229200    return join("\n", $getQuickstart->run);
    230 }
    231 
    232 sub _away_on {
    233     $awayOn->run(@_);
    234 }
    235 
    236 sub _away_off {
    237     $awayOff->run();
    238 }
    239 
    240 sub _get_is_away {
    241     my @is_away = grep { $_ } $getIsAway->run();
    242     return scalar @is_away;
    243201}
    244202
  • perl/lib/BarnOwl/Message.pm

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

    r0adbce1 redd0be7  
    5151    my ($m) = @_;
    5252    return undef if (!$m->is_loginout);
    53     return undef if (!defined($m->fields));
    5453    return $m->fields->[2];
    5554}
     
    5857    my ($m) = @_;
    5958    return undef if (!$m->is_loginout);
    60     return undef if (!defined($m->fields));
    6159    return $m->fields->[0];
    6260}
     
    6563
    6664sub is_ping     { return (lc(shift->opcode) eq "ping"); }
     65
     66sub is_personal {
     67    my ($m) = @_;
     68    return ((lc($m->class) eq "message")
     69            && $m->is_private);
     70}
    6771
    6872sub is_mail {
     
    167171        $class = $self->class;
    168172        $instance = $self->instance;
    169         if ($self->recipient eq '' || $self->recipient =~ /^@/) {
     173        if ($self->recipient eq '*' || $self->recipient eq '') {
     174            $to = '';
     175        } elsif ($self->recipient =~ /^@/) {
    170176            $to = $self->recipient;
    171177        } else {
  • perl/lib/BarnOwl/ModuleLoader.pm

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

    rebc6f77 r5738650  
    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         }
    118115    }
    119116
     
    129126    my $self = shift;
    130127    my $m = shift;
    131     my $sender = $self->humanize($m->long_sender, 1);
     128    my $sender = $m->long_sender;
     129    $sender =~ s/\n.*$//s;
    132130    if (BarnOwl::getvar('colorztext') eq 'on') {
    133131      return "  (" . $sender . '@color[default]' . ")";
  • perl/lib/BarnOwl/Zephyr.pm

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

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

    r926c721 rb8a3e00  
    2121
    2222use AnyEvent::IRC;
     23use Getopt::Long;
    2324use Encode;
    24 use File::Spec;
    25 use Getopt::Long;
    26 use Text::Wrap;
    2725
    2826our $VERSION = 0.02;
    29 
    30 our $IRC_SUBS_FILENAME = "ircchannels";
    3127
    3228our $irc;
     
    7167       });
    7268
    73     BarnOwl::new_variable_int('irc:max-message-length', {
    74         default     => 450,
    75         summary     => 'Split messages to at most this many characters.' .
    76                        "If non-positive, don't split messages",
    77         description => 'If set to a positive number, any paragraph in an ' .
    78                        'IRC message will be split after this many characters.'
    79        });
    80 
    8169    register_commands();
    8270    BarnOwl::filter(qw{irc type ^IRC$ or ( type ^admin$ and adminheader ^IRC$ )});
     
    141129argument listed above, and die if no channel argument can be found.
    142130
    143 =item C<CHANNEL_OR_USER>
    144 
    145 Pass the channel argument, but accept it if it's a username (e.g.
    146 has no hash).  Only relevant with C<CHANNEL_ARG>.
    147 
    148131=item C<CHANNEL_OPTIONAL>
    149132
     
    162145use constant CHANNEL_ARG        => 1;
    163146use constant CHANNEL_OPTIONAL   => 2;
    164 use constant CHANNEL_OR_USER    => 4;
    165 
    166 use constant ALLOW_DISCONNECTED => 8;
     147
     148use constant ALLOW_DISCONNECTED => 4;
    167149
    168150sub register_commands {
     
    172154            summary => 'Connect to an IRC server',
    173155            usage =>
    174 'irc-connect [-a ALIAS] [-s] [-p PASSWORD] [-n NICK] SERVER [port]',
     156'irc-connect [-a ALIAS ] [-s] [-p PASSWORD] [-n NICK] SERVER [port]',
    175157            description => <<END_DESCR
    176158Connect to an IRC server. Supported options are:
     
    206188
    207189    BarnOwl::new_command(
    208         'irc-msg' => mk_irc_command( \&cmd_msg, CHANNEL_OR_USER|CHANNEL_ARG|CHANNEL_OPTIONAL ),
     190        'irc-msg' => mk_irc_command( \&cmd_msg ),
    209191        {
    210192            summary => 'Send an IRC message',
     
    233215        {
    234216            summary => 'Join an IRC channel',
    235             usage   => 'irc-join [-a ALIAS] [-t] #channel [KEY]',
    236 
    237             description => <<END_DESCR
    238 Join an IRC channel.  If the -t option is present the subscription will only be
    239 temporary, i.e., it will not be written to the subscription file and will
    240 therefore not be present the next time BarnOwl is started, and will disappear
    241 if the connection is lost.
     217            usage   => 'irc-join [-a ALIAS] #channel [KEY]',
     218
     219            description => <<END_DESCR
     220Join an IRC channel.
    242221END_DESCR
    243222        }
     
    248227        {
    249228            summary => 'Leave an IRC channel',
    250             usage   => 'irc-part [-a ALIAS] [-t] #channel',
    251 
    252             description => <<END_DESCR
    253 Part from an IRC channel.  If the -t option is present the unsubscription will
    254 only be temporary, i.e., it will not be updated in the subscription file and
    255 will therefore not be in effect the next time BarnOwl is started, or if the
    256 connection is lost.
     229            usage   => 'irc-part [-a ALIAS] #channel',
     230
     231            description => <<END_DESCR
     232Part from an IRC channel.
    257233END_DESCR
    258234        }
     
    351327This can be used to perform some operation not yet supported by
    352328BarnOwl, or to define new IRC commands.
    353 END_DESCR
    354         }
    355     );
    356 
    357     BarnOwl::new_command(
    358         'irc-loadchannels' => \&cmd_loadchannels,
    359         {
    360             summary => 'Reload persistent channels',
    361             usage   => 'irc-loadchannels [-a ALIAS] [<file>]',
    362 
    363             description => <<END_DESCR
    364 Load persistent channels from a file.  The file defaults to
    365 \$HOME/.owl/$IRC_SUBS_FILENAME.  If the ALIAS is present, only channels
    366 on the given alias are loaded.  The ALIAS is case-sensitive.
    367 
    368 Each line of the file should describe a single channel, in the format
    369 '\$alias \$channel' (without quotes).
    370329END_DESCR
    371330        }
     
    382341######################## Owl command handlers ##################################
    383342################################################################################
    384 
    385 sub make_autoconnect_filename {
    386     # can't use ||, or else we'll treat '0' as invalid.  We could check for eq "" ...
    387     # TODO(jgross): When we move to requiring perl 5.10, combine the
    388     # following two lines using //
    389     my $filename = shift;
    390     $filename = File::Spec->catfile(BarnOwl::get_config_dir(), $IRC_SUBS_FILENAME) unless defined $filename;
    391     if (!File::Spec->file_name_is_absolute($filename)) {
    392         $filename = File::Spec->catfile($ENV{HOME}, $filename);
    393     }
    394     return $filename;
    395 }
    396 
    397 sub _get_autoconnect_lines {
    398     my $filename = shift;
    399 
    400     # TODO(jgross): Write a C-side function to do this, asynchronously;
    401     #               AIUI, perl doesn't do asynchronous I/O in any useful way
    402     if (open (my $subsfile, "<:encoding(UTF-8)", $filename)) {
    403         my @lines = <$subsfile>;
    404         close($subsfile);
    405 
    406         # strip trailing newlines
    407         local $/ = "";
    408         chomp(@lines);
    409 
    410         return @lines;
    411     }
    412 
    413     return ();
    414 }
    415 
    416 sub get_autoconnect_channels {
    417     my $filename = make_autoconnect_filename(shift);
    418     my %channel_hash = ();
    419 
    420     # Load the subs from the file
    421     my @lines = _get_autoconnect_lines($filename);
    422 
    423     foreach my $line (@lines) {
    424         my @parsed_args = split(' ', $line);
    425         if (scalar @parsed_args == 2) {
    426             push @{$channel_hash{$parsed_args[0]}}, $parsed_args[1];
    427         } else {
    428             warn "Trouble parsing irc configuration file '$filename' line '$line'; the format is '\$alias \$channel', with no spaces in either\n";
    429         }
    430     }
    431 
    432     return %channel_hash;
    433 }
    434 
    435 sub add_autoconnect_channel {
    436     my $conn = shift;
    437     my $channel = shift;
    438     my $alias = $conn->alias;
    439     my $filename = make_autoconnect_filename(shift);
    440 
    441     # we already checked for spaces in $channel in cmd_join, but we still need
    442     # to check $alias
    443     die "Alias name '$alias' contains a space; parsing will fail.  Use the -t flag.\n" unless index($alias, " ") == -1;
    444 
    445     my $line = "$alias $channel";
    446 
    447     my @lines = _get_autoconnect_lines($filename);
    448 
    449     # We don't want to be noisy about duplicated joins.  For example, some
    450     # people might have :irc-join in startup files, even though that doesn't
    451     # work correctly anymore because connect is asynchronous and so join on
    452     # startup races with connect.  Regardless, just fail silently if the line
    453     # already exists.
    454     return if grep { $_ eq $line } @lines;
    455 
    456     open (my $subsfile, ">>:encoding(UTF-8)", make_autoconnect_filename($filename))
    457         or die "Cannot open $filename for writing: $!\n";
    458     local $, = "";
    459     local $/ = "";
    460     print $subsfile "$line\n";
    461     close($subsfile);
    462 }
    463 
    464 sub remove_autoconnect_channel {
    465     my $conn = shift;
    466     my $channel = shift;
    467     my $alias = $conn->alias;
    468     my $filename = make_autoconnect_filename(shift);
    469 
    470     BarnOwl::Internal::file_deleteline($filename, "$alias $channel", 1);
    471 }
    472 
    473 sub cmd_loadchannels {
    474     my $cmd = shift;
    475     my $alias;
    476     my $getopt = Getopt::Long::Parser->new;
    477 
    478     local @ARGV = @_;
    479     $getopt->configure(qw(pass_through permute no_getopt_compat prefix_pattern=-|--));
    480     $getopt->getoptions("alias=s" => \$alias);
    481 
    482     my %channel_hash = get_autoconnect_channels(@ARGV);
    483 
    484     my $aliases = (defined $alias) ? [$alias] : [keys %channel_hash];
    485 
    486     foreach my $cur_alias (@$aliases) {
    487         # get_connection_by_alias might die, and we don't want to
    488         eval {
    489             my $conn = get_connection_by_alias($cur_alias, 1);
    490             my %existing_channels = map { $_ => 1 } @{$conn->autoconnect_channels}, @{$channel_hash{$cur_alias}};
    491             $conn->autoconnect_channels([keys %existing_channels]);
    492         };
    493         foreach my $channel (@{$channel_hash{$cur_alias}}) {
    494             if ($cur_alias eq "") {
    495                 BarnOwl::command("irc-join", "-t", $channel);
    496             } else {
    497                 BarnOwl::command("irc-join", "-t", "-a", $cur_alias, $channel);
    498             }
    499         }
    500     }
    501 }
    502343
    503344sub cmd_connect {
     
    537378    }
    538379
    539     my %channel_hash = get_autoconnect_channels;
    540 
    541380    my $conn = BarnOwl::Module::IRC::Connection->new($alias, $host, $port, {
    542         nick                 => $nick,
    543         user                 => $username,
    544         real                 => $ircname,
    545         password             => $password,
    546         SSL                  => $ssl,
    547         timeout              => sub {0},
    548         autoconnect_channels => $channel_hash{$alias}
     381        nick      => $nick,
     382        user      => $username,
     383        real      => $ircname,
     384        password  => $password,
     385        SSL       => $ssl,
     386        timeout   => sub {0}
    549387       });
    550388    $ircnets{$alias} = $conn;
     
    589427    @msgs = split "\n\n", $fullbody;
    590428    map { tr/\n/ / } @msgs;
    591     # split each body at irc:max-message-length characters, if that number
    592     # is positive.  Only split at space boundaries.  Start counting a-fresh
    593     # at the beginning of each paragraph
    594     my $max_len = BarnOwl::getvar('irc:max-message-length');
    595     if ($max_len > 0) {
    596         local($Text::Wrap::columns) = $max_len;
    597         @msgs = split "\n", wrap("", "", join "\n", @msgs);
    598     }
    599429    for my $body (@msgs) {
    600430        if ($body =~ /^\/me (.*)/) {
     
    633463sub cmd_join {
    634464    my $cmd = shift;
    635     my $is_temporary;
    636 
    637     my $getopt = Getopt::Long::Parser->new;
    638 
    639     local @ARGV = @_;
    640     $getopt->configure(qw(pass_through permute no_getopt_compat prefix_pattern=-|--));
    641     $getopt->getoptions("temporary" => \$is_temporary);
    642 
    643     my $conn = shift @ARGV;
    644     my $chan = shift @ARGV or die("Usage: $cmd channel\n");
    645 
    646     die "Channel name '$chan' contains a space.  As per RFC 2812, IRC channel names may not contain spaces.\n" unless index($chan, " ") == -1;
    647 
    648     $conn->conn->send_msg(join => $chan, @ARGV);
    649 
    650     # regardless of whether or not this is temporary, we want to persist it
    651     # across reconnects.
    652 
    653     # check if the channel is already in the list
    654     if (!grep { $_ eq $chan } @{$conn->autoconnect_channels}) {
    655         push @{$conn->autoconnect_channels}, $chan;
    656     }
    657 
    658     if (!$is_temporary) {
    659         # add the line to the subs file
    660         add_autoconnect_channel($conn, $chan);
    661     }
    662 
     465    my $conn = shift;
     466    my $chan = shift or die("Usage: $cmd channel\n");
     467    $conn->conn->send_msg(join => $chan, @_);
    663468    return;
    664469}
     
    666471sub cmd_part {
    667472    my $cmd = shift;
    668     my $is_temporary;
    669 
    670     my $getopt = Getopt::Long::Parser->new;
    671 
    672     local @ARGV = @_;
    673     $getopt->configure(qw(pass_through permute no_getopt_compat prefix_pattern=-|--));
    674     $getopt->getoptions("temporary" => \$is_temporary);
    675 
    676     my $conn = shift @ARGV;
    677     my $chan = shift @ARGV or die("Usage: $cmd channel\n");
    678 
     473    my $conn = shift;
     474    my $chan = shift;
    679475    $conn->conn->send_msg(part => $chan);
    680 
    681     # regardless of whether or not this is temporary, we want to persist it
    682     # across reconnects
    683     my %existing_channels = map { $_ => 1 } @{$conn->autoconnect_channels};
    684     delete $existing_channels{$chan};
    685     $conn->autoconnect_channels([keys %existing_channels]);
    686 
    687     if (!$is_temporary) {
    688         # remove the line from the subs file
    689         remove_autoconnect_channel($conn, $chan);
    690     }
    691 
    692476    return;
    693477}
     
    789573        my $alias;
    790574        my $channel;
    791         my $is_temporary;
    792575        my $getopt = Getopt::Long::Parser->new;
    793576        my $m = BarnOwl::getcurmsg();
     
    795578        local @ARGV = @_;
    796579        $getopt->configure(qw(pass_through permute no_getopt_compat prefix_pattern=-|--));
    797         $getopt->getoptions("alias=s" => \$alias,
    798                             "temporary" => \$is_temporary);
     580        $getopt->getoptions("alias=s" => \$alias);
    799581
    800582        if(defined($alias)) {
     
    809591                    $conn ||= $c;
    810592                }
    811             } elsif (defined($channel) && ($flags & CHANNEL_OR_USER)) {
    812                 shift @ARGV;
    813593            } elsif ($m && $m->type eq 'IRC' && !$m->is_private) {
    814594                $channel = $m->channel;
     
    818598        }
    819599
    820         if(!defined($channel) &&
     600        if(!$channel &&
    821601           ($flags & CHANNEL_ARG) &&
    822602           !($flags & CHANNEL_OPTIONAL)) {
     
    835615            die("You must specify an IRC network using -a.\n");
    836616        }
    837         push @ARGV, "-t" if $is_temporary;
    838617        if($flags & CHANNEL_ARG) {
    839618            $sub->($cmd, $conn, $channel, @ARGV);
  • perl/modules/IRC/lib/BarnOwl/Module/IRC/Completion.pm

    r76e80de rdace02a  
    5757}
    5858
    59 sub complete_irc_join_part {
    60     my $ctx = shift;
    61     return complete_flags($ctx,
    62         [qw(-t)],
    63         {
    64             "-a" => \&complete_networks,
    65         },
    66         \&complete_channels
    67        );
    68 }
    69 
    7059sub complete_irc_channel {
    7160    my $ctx = shift;
     
    10695BarnOwl::Completion::register_completer('irc-msg'        => \&complete_irc_dest);
    10796BarnOwl::Completion::register_completer('irc-mode'       => \&complete_irc_dest);
    108 BarnOwl::Completion::register_completer('irc-join'       => \&complete_irc_join_part);
    109 BarnOwl::Completion::register_completer('irc-part'       => \&complete_irc_join_part);
     97BarnOwl::Completion::register_completer('irc-join'       => \&complete_irc_channel);
     98BarnOwl::Completion::register_completer('irc-part'       => \&complete_irc_channel);
    11099BarnOwl::Completion::register_completer('irc-names'      => \&complete_irc_channel);
    111100BarnOwl::Completion::register_completer('irc-whois'      => \&complete_irc_nick);
  • perl/modules/IRC/lib/BarnOwl/Module/IRC/Connection.pm

    rbe43554 r13ee8f2  
    3939    my $self = bless({}, $class);
    4040    $self->conn($conn);
    41     # TODO(jgross): use // when we move to requiring perl 5.10
    42     $self->autoconnect_channels(defined $args->{autoconnect_channels} ? $args->{autoconnect_channels} : []);
     41    $self->autoconnect_channels([]);
    4342    $self->alias($alias);
    4443    $self->server($host);
     
    413412        $self->{reconnect_timer}->stop;
    414413    }
    415     $self->{reconnect_timer} =
     414    $self->{reconnect_timer} = 
    416415        BarnOwl::Timer->new( {
    417416            name  => 'IRC (' . $self->alias . ') reconnect_timer',
     
    446445            $self->conn->send_msg(join => $c);
    447446        }
     447        $self->autoconnect_channels([]);
    448448    }
    449449    $self->conn->enable_ping(60, sub {
     
    458458    my $backoff = $self->backoff;
    459459
     460    $self->autoconnect_channels([keys(%{$self->{channel_list}})]);
    460461    $self->conn->connect(@{$self->connect_args});
    461462}
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm

    r41064be rb8a3e00  
    320320              . "configure [<muc>]\n"
    321321              . "            Configures a MUC.\n"
    322               . "            Necessary to initialize a new MUC.\n"
     322              . "            Necessary to initalize 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"
     
    13131313    {
    13141314        my @answer = $packet->answer;
    1315         return $answer[0]->target, $answer[0]->port if @answer;
     1315        return $answer[0]{target}, $answer[0]{port};
    13161316    }
    13171317
     
    14821482}
    14831483
    1484 sub complete_jabberlogout {
    1485     my $ctx = shift;
    1486     if($ctx->word == 1) {
    1487         return ("-A", complete_account() );
    1488     } else {
    1489         return ();
    1490     }
    1491 }
    1492 
    14931484BarnOwl::Completion::register_completer(jwrite => sub { BarnOwl::Module::Jabber::complete_jwrite(@_) });
    1494 BarnOwl::Completion::register_completer(jabberlogout => sub { BarnOwl::Module::Jabber::complete_jabberlogout(@_) });
    14951485
    149614861;
  • perl/modules/Jabber/lib/Net/Jabber/Component.pm

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

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

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

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

    re4b8f93 r1fd469d4  
    1 MODULES = Jabber IRC WordWrap Twitter Facebook
     1MODULES = Jabber IRC WordWrap Twitter
    22
    3 EXTRA_DIST = $(MODULES:=/Makefile.PL) $(MODULES:=/lib)
    4 EXTRA_DIST += \
    5     Facebook/README \
    6     Twitter/README \
    7     Twitter/twitter.example
     3EXTRA_DIST = $(MODULES:=/Makefile.PL) $(MODULES:=/inc) $(MODULES:=/lib)
    84
    95all-local: $(MODULES)
     
    117        (cd $* && $(MAKE) $*.par)
    128
    13 BARNOWL_PERL := $(shell which perl) -I$(abs_srcdir)/../lib
    14 
    159MODULES_MAKEFILE = $(MODULES:=/Makefile)
    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)')
     10$(MODULES_MAKEFILE): %/Makefile: %/Makefile.PL
     11        $(AM_V_GEN)(cd $* && perl -I../../lib Makefile.PL)
    2012
    2113MODULES_CLEAN = $(MODULES:%=clean_%)
    2214clean-local: $(MODULES_CLEAN)
    2315$(MODULES_CLEAN): clean_%:
    24         (cd $* && { test ! -f Makefile || $(MAKE) realclean; })
    25         rm -f $*/$*.par
    26         rm -rf $*/inc
    27         test $(srcdir) = . || rm -f $*/Makefile.PL
     16        (cd $* && (test ! -f Makefile || $(MAKE) clean))
    2817
    2918MODULES_INSTALL = $(MODULES:%=module_install_%)
     
    3423        ${INSTALL_DATA} $*/$*.par ${DESTDIR}${pkgdatadir}/modules/$*.par
    3524
    36 uninstall-local:
    37         rm -f $(MODULES:%=${DESTDIR}${pkgdatadir}/modules/%.par)
    38 
    3925.PHONY: $(MODULES) $(MODULES_CLEAN) $(MODULES_INSTALL)
  • perl/modules/Twitter/lib/BarnOwl/Module/Twitter.pm

    r140429f rb8a3e00  
    137137        my $twitter_args = { username   => $cfg->{user},
    138138                             password   => $cfg->{password},
    139                              source     => 'barnowl',
    140                              ssl        => 1,
    141                              legacy_lists_api => 0,
     139                             source     => 'barnowl',
    142140                         };
    143141        if (defined $cfg->{service}) {
     
    276274);
    277275
    278 BarnOwl::new_command( 'twitter-favorite' => sub { cmd_twitter_favorite(@_) },
    279     {
    280     summary     => 'Favorite the current Twitter message',
    281     usage       => 'twitter-favorite [ACCOUNT]',
    282     description => <<END_DESCRIPTION
    283 Favorite the current Twitter message using ACCOUNT (defaults to the
    284 account that received the tweet).
    285 END_DESCRIPTION
    286     }
    287 );
    288 
    289276BarnOwl::new_command( 'twitter-follow' => sub { cmd_twitter_follow(@_); },
    290277    {
     
    368355    $account = $m->account unless defined($account);
    369356    find_account($account)->twitter_retweet($m);
    370     return;
    371 }
    372 
    373 sub cmd_twitter_favorite {
    374     my $cmd = shift;
    375     my $account = shift;
    376     my $m = BarnOwl::getcurmsg();
    377     if(!$m || $m->type ne 'Twitter') {
    378         die("$cmd must be used with a Twitter message selected.\n");
    379     }
    380 
    381     $account = $m->account unless defined($account);
    382     find_account($account)->twitter_favorite($m);
    383357    return;
    384358}
  • perl/modules/Twitter/lib/BarnOwl/Module/Twitter/Handle.pm

    r140429f r4ebbfbc  
    371371        $self->twitter_direct($1, $2);
    372372    } elsif(defined $self->{twitter}) {
     373        if(length($msg) > 140) {
     374            die("Twitter: Message over 140 characters long.\n");
     375        }
    373376        $self->twitter_command('update', {
    374377            status => $msg,
     
    429432}
    430433
    431 sub twitter_favorite {
    432     my $self = shift;
    433     my $msg = shift;
    434 
    435     if($msg->service ne $self->{cfg}->{service}) {
    436         die("Cannot favorite a message from a different service.\n");
    437     }
    438     $self->twitter_command(create_favorite => $msg->{status_id});
    439 }
    440 
    441 
    442434sub twitter_follow {
    443435    my $self = shift;
  • perlconfig.c

    r7dcef03 rb9517cf  
    7575  const char *type;
    7676  char *ptr, *utype, *blessas;
    77   const char *f;
    78   int i;
     77  int i, j;
    7978  const owl_pair *pair;
    8079  const owl_filter *wrap;
     
    9291                                      owl_new_sv(owl_message_get_##field(m)), 0)
    9392
    94   if (owl_message_is_type_zephyr(m) && owl_message_is_direction_in(m)) {
     93  if (owl_message_get_notice(m)) {
    9594    /* Handle zephyr-specific fields... */
    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);
     95    AV *av_zfields;
     96
     97    av_zfields = newAV();
     98    j=owl_zephyr_get_num_fields(owl_message_get_notice(m));
     99    for (i=0; i<j; i++) {
     100      ptr=owl_zephyr_get_field_as_utf8(owl_message_get_notice(m), i+1);
     101      av_push(av_zfields, owl_new_sv(ptr));
     102      g_free(ptr);
    110103    }
    111104    (void)hv_store(h, "fields", strlen("fields"), newRV_noinc((SV*)av_zfields), 0);
     105
     106    (void)hv_store(h, "auth", strlen("auth"),
     107                   owl_new_sv(owl_zephyr_get_authstr(owl_message_get_notice(m))),0);
    112108  }
    113109
     
    188184  hash = (HV*)SvRV(msg);
    189185
    190   m = g_slice_new(owl_message);
     186  m = g_new(owl_message, 1);
    191187  owl_message_init(m);
    192188
     
    228224CALLER_OWN char *owl_perlconfig_call_with_message(const char *subname, const owl_message *m)
    229225{
    230   SV *msgref, *rv;
    231   char *out = NULL;
    232 
     226  dSP ;
     227  int count;
     228  SV *msgref, *srv;
     229  char *out;
     230 
     231  ENTER ;
     232  SAVETMPS;
     233 
     234  PUSHMARK(SP) ;
    233235  msgref = owl_perlconfig_message2hashref(m);
    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                 );
     236  XPUSHs(sv_2mortal(msgref));
     237  PUTBACK ;
     238 
     239  count = call_pv(subname, G_SCALAR|G_EVAL);
     240 
     241  SPAGAIN ;
     242
     243  if (SvTRUE(ERRSV)) {
     244    owl_function_error("Perl Error: '%s'", SvPV_nolen(ERRSV));
     245    /* and clear the error */
     246    sv_setsv (ERRSV, &PL_sv_undef);
     247  }
     248
     249  if (count != 1) {
     250    fprintf(stderr, "bad perl!  no biscuit!  returned wrong count!\n");
     251    abort();
     252  }
     253
     254  srv = POPs;
     255
     256  if (srv) {
     257    out = g_strdup(SvPV_nolen(srv));
     258  } else {
     259    out = NULL;
     260  }
     261 
     262  PUTBACK ;
     263  FREETMPS ;
     264  LEAVE ;
     265
    249266  return out;
    250267}
     
    256273CALLER_OWN char *owl_perlconfig_message_call_method(const owl_message *m, const char *method, int argc, const char **argv)
    257274{
    258   SV *msgref, *rv;
    259   char *out = NULL;
    260   int i;
     275  dSP;
     276  unsigned int count, i;
     277  SV *msgref, *srv;
     278  char *out;
    261279
    262280  msgref = owl_perlconfig_message2hashref(m);
    263281
    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                 );
     282  ENTER;
     283  SAVETMPS;
     284
     285  PUSHMARK(SP);
     286  XPUSHs(sv_2mortal(msgref));
     287  for(i=0;i<argc;i++) {
     288    XPUSHs(sv_2mortal(owl_new_sv(argv[i])));
     289  }
     290  PUTBACK;
     291
     292  count = call_method(method, G_SCALAR|G_EVAL);
     293
     294  SPAGAIN;
     295
     296  if(count != 1) {
     297    fprintf(stderr, "perl returned wrong count %u\n", count);
     298    abort();
     299  }
     300
     301  if (SvTRUE(ERRSV)) {
     302    owl_function_error("Error: '%s'", SvPV_nolen(ERRSV));
     303    /* and clear the error */
     304    sv_setsv (ERRSV, &PL_sv_undef);
     305  }
     306
     307  srv = POPs;
     308
     309  if (srv) {
     310    out = g_strdup(SvPV_nolen(srv));
     311  } else {
     312    out = NULL;
     313  }
     314
     315  PUTBACK;
     316  FREETMPS;
     317  LEAVE;
     318
    279319  return out;
    280320}
     
    287327  char *err;
    288328  const char *args[4] = {"", "-e", "0;", NULL};
    289   const char *dlerr;
    290329  AV *inc;
    291330  char *path;
     
    336375  }
    337376
    338   sv_setpv(get_sv("BarnOwl::VERSION", TRUE), version);
     377  sv_setpv(get_sv("BarnOwl::VERSION", TRUE), OWL_VERSION_STRING);
    339378
    340379  /* Add the system lib path to @INC */
     
    345384  g_free(path);
    346385
    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. */
    357386  eval_pv("use BarnOwl;", FALSE);
    358387
     
    426455void owl_perlconfig_new_command(const char *name)
    427456{
    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 
    441 CALLER_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 
    463 int 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 
    485 bool 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 
    507 void 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                 );
     457  dSP;
     458
     459  ENTER;
     460  SAVETMPS;
     461
     462  PUSHMARK(SP);
     463  XPUSHs(sv_2mortal(owl_new_sv(name)));
     464  PUTBACK;
     465
     466  call_pv("BarnOwl::Hooks::_new_command", G_VOID|G_EVAL);
     467
     468  SPAGAIN;
     469
     470  if(SvTRUE(ERRSV)) {
     471    owl_function_error("%s", SvPV_nolen(ERRSV));
     472  }
     473
     474  FREETMPS;
     475  LEAVE;
    521476}
    522477
     
    524479CALLER_OWN char *owl_perlconfig_perlcmd(const owl_cmd *cmd, int argc, const char *const *argv)
    525480{
    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;
     481  int i, count;
     482  char * ret = NULL;
     483  SV *rv;
     484  dSP;
     485
     486  ENTER;
     487  SAVETMPS;
     488
     489  PUSHMARK(SP);
     490  for(i=0;i<argc;i++) {
     491    XPUSHs(sv_2mortal(owl_new_sv(argv[i])));
     492  }
     493  PUTBACK;
     494
     495  count = call_sv(cmd->cmd_perl, G_SCALAR|G_EVAL);
     496
     497  SPAGAIN;
     498
     499  if(SvTRUE(ERRSV)) {
     500    owl_function_error("%s", SvPV_nolen(ERRSV));
     501    (void)POPs;
     502  } else {
     503    if(count != 1)
     504      croak("Perl command %s returned more than one value!", cmd->name);
     505    rv = POPs;
     506    if(SvTRUE(rv)) {
     507      ret = g_strdup(SvPV_nolen(rv));
     508    }
     509  }
     510
     511  FREETMPS;
     512  LEAVE;
     513
     514  return ret;
    545515}
    546516
     
    550520}
    551521
    552 void owl_perlconfig_edit_callback(owl_editwin *e, bool success)
     522void owl_perlconfig_edit_callback(owl_editwin *e)
    553523{
    554524  SV *cb = owl_editwin_get_cbdata(e);
    555   SV *text = owl_new_sv(owl_editwin_get_text(e));
    556 
    557   if (cb == NULL) {
     525  SV *text;
     526  dSP;
     527
     528  if(cb == NULL) {
    558529    owl_function_error("Perl callback is NULL!");
    559530    return;
    560531  }
    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                 );
     532  text = owl_new_sv(owl_editwin_get_text(e));
     533
     534  ENTER;
     535  SAVETMPS;
     536
     537  PUSHMARK(SP);
     538  XPUSHs(sv_2mortal(text));
     539  PUTBACK;
     540 
     541  call_sv(cb, G_DISCARD|G_EVAL);
     542
     543  if(SvTRUE(ERRSV)) {
     544    owl_function_error("%s", SvPV_nolen(ERRSV));
     545  }
     546
     547  FREETMPS;
     548  LEAVE;
    574549}
    575550
  • perlglue.xs

    r7dcef03 rf271129  
    6767        OUTPUT:
    6868                RETVAL
    69 
    70 int
    71 getnumlines()
    72         CODE:
    73                 RETVAL = owl_global_get_lines(&g);
    74         OUTPUT:
    75                 RETVAL
    76 
     69               
    7770time_t
    7871getidletime()
     
    9588        OUTPUT:
    9689                RETVAL
     90
     91void
     92zephyr_zwrite(cmd,msg)
     93        const char *cmd
     94        const char *msg
     95        PREINIT:
     96                int i;
     97        CODE:
     98                i = owl_zwrite_create_and_send_from_line(cmd, msg);
    9799
    98100const utf8 *
     
    163165        {
    164166                owl_function_adminmsg(header, body);           
     167        }
     168
     169void
     170start_question(line, callback)
     171        const char *line
     172        SV *callback
     173        PREINIT:
     174                owl_editwin *e;
     175        CODE:
     176        {
     177                if(!SV_IS_CODEREF(callback))
     178                        croak("Callback must be a subref");
     179
     180                e = owl_function_start_question(line);
     181
     182                owl_editwin_set_cbdata(e,
     183                                       newSVsv(callback),
     184                                       owl_perlconfig_dec_refcnt);
     185                owl_editwin_set_callback(e, owl_perlconfig_edit_callback);
     186        }
     187
     188void
     189start_password(line, callback)
     190        const char *line
     191        SV *callback
     192        PREINIT:
     193                owl_editwin *e;
     194        CODE:
     195        {
     196                if(!SV_IS_CODEREF(callback))
     197                        croak("Callback must be a subref");
     198
     199                e = owl_function_start_password(line);
     200
     201                owl_editwin_set_cbdata(e,
     202                                       newSVsv(callback),
     203                                       owl_perlconfig_dec_refcnt);
     204                owl_editwin_set_callback(e, owl_perlconfig_edit_callback);
     205        }
     206
     207void
     208start_edit_win(line, callback)
     209        const char *line
     210        SV *callback
     211        CODE:
     212        {
     213                if(!SV_IS_CODEREF(callback))
     214                        croak("Callback must be a subref");
     215
     216                owl_function_start_edit_win(line,
     217                                            owl_perlconfig_edit_callback,
     218                                            newSVsv(callback),
     219                                            owl_perlconfig_dec_refcnt);
    165220        }
    166221
     
    232287     CODE:
    233288        {
    234                 s = g_slice_new(owl_style);
     289                s = g_new(owl_style, 1);
    235290                owl_style_create_perl(s, name, newSVsv(object));
    236291                owl_global_add_style(&g, s);
     
    256311        }
    257312
    258 bool
    259 message_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);
    283 
    284313const utf8 *
    285314wordwrap(in, cols)
     
    397426MODULE = BarnOwl                PACKAGE = BarnOwl::Internal
    398427
    399 
    400 int
    401 file_deleteline(filename, line, backup)
    402         const char *filename
    403         const char *line
    404         int backup
    405         CODE:
    406                 RETVAL = owl_util_file_deleteline(filename, line, backup);
    407         OUTPUT:
    408                 RETVAL
    409428
    410429void
     
    438457           }
    439458
    440 
    441 MODULE = BarnOwl                PACKAGE = BarnOwl::Internal
    442 
    443 void
    444 new_variable(name, summary, description, validsettings, takes_on_off, get_tostring_fn, set_fromstring_fn, data)
    445     const char *name
    446     const char *summary
    447     const char *description
    448     const char *validsettings
    449     int takes_on_off
    450     SV *get_tostring_fn
    451     SV *set_fromstring_fn
    452     SV *data
    453     CODE:
    454 {
    455         /* data is somewhat redundant given we can create closures, but oh
    456          * well. Might be convenient sometimes. */
    457         if(!SV_IS_CODEREF(get_tostring_fn)) {
    458                 croak("To-string function must be a coderef!");
    459         }
    460         if(!SV_IS_CODEREF(set_fromstring_fn)) {
    461                 croak("From-string function must be a coderef!");
    462         }
    463 
    464         owl_variable_dict_newvar_other(owl_global_get_vardict(&g),
    465                                        name, summary, description, validsettings, takes_on_off,
    466                                        perl_closure_new(get_tostring_fn, data, false),
    467                                        perl_closure_new(set_fromstring_fn, data, false));
    468 }
    469 
    470 void
    471 start_edit(edit_type, line, callback)
    472         const char *edit_type
    473         const char *line
    474         SV *callback
    475         PREINIT:
    476                 owl_editwin *e;
    477         CODE:
    478         {
    479                 if (!SV_IS_CODEREF(callback))
    480                         croak("Callback must be a subref");
    481 
    482                 if (!strcmp(edit_type, "question"))
    483                         e = owl_function_start_question(line);
    484                 else if (!strcmp(edit_type, "password"))
    485                         e = owl_function_start_password(line);
    486                 else if (!strcmp(edit_type, "edit_win"))
    487                         e = owl_function_start_edit_win(line);
    488                 else
    489                         croak("edit_type must be one of 'password', 'question', 'edit_win', not '%s'", edit_type);
    490 
    491                 owl_editwin_set_cbdata(e, newSVsv(callback), owl_perlconfig_dec_refcnt);
    492                 owl_editwin_set_callback(e, owl_perlconfig_edit_callback);
    493         }
    494 
    495 int
    496 zephyr_zwrite(cmd,msg)
    497         const char *cmd
    498         const char *msg
    499         CODE:
    500                 RETVAL = owl_zwrite_create_and_send_from_line(cmd, msg);
    501         OUTPUT:
    502                 RETVAL
     459void
     460new_variable_string(name, ival, summ, desc)
     461        const char * name
     462        const char * ival
     463        const char * summ
     464        const char * desc
     465        CODE:
     466        owl_variable_dict_newvar_string(owl_global_get_vardict(&g),
     467                                        name,
     468                                        summ,
     469                                        desc,
     470                                        ival);
     471
     472void
     473new_variable_int(name, ival, summ, desc)
     474        const char * name
     475        int ival
     476        const char * summ
     477        const char * desc
     478        CODE:
     479        owl_variable_dict_newvar_int(owl_global_get_vardict(&g),
     480                                     name,
     481                                     summ,
     482                                     desc,
     483                                     ival);
     484
     485void
     486new_variable_bool(name, ival, summ, desc)
     487        const char * name
     488        int ival
     489        const char * summ
     490        const char * desc
     491        CODE:
     492        owl_variable_dict_newvar_bool(owl_global_get_vardict(&g),
     493                                      name,
     494                                      summ,
     495                                      desc,
     496                                      ival);
    503497
    504498MODULE = BarnOwl                PACKAGE = BarnOwl::Editwin
  • popexec.c

    r7dcef03 re146cd7  
    2323  }
    2424
    25   pe = g_slice_new(owl_popexec);
     25  pe = g_new(owl_popexec, 1);
    2626  pe->winactive=0;
    2727  pe->pid=0;
     
    179179  if (pe->refcount<=0) {
    180180    owl_function_debugmsg("doing free of %p", pe);
    181     g_slice_free(owl_popexec, pe);
     181    g_free(pe);
    182182  }
    183183}
  • popwin.c

    r7dcef03 r6829afc  
    33CALLER_OWN owl_popwin *owl_popwin_new(void)
    44{
    5   owl_popwin *pw = g_slice_new0(owl_popwin);
     5  owl_popwin *pw = g_new0(owl_popwin, 1);
    66
    77  pw->border = owl_window_new(NULL);
     
    9292  g_object_unref(pw->content);
    9393
    94   g_slice_free(owl_popwin, pw);
     94  g_free(pw);
    9595}
    9696
  • runtests.sh

    r7dcef03 rf6ab6ee  
    11#!/bin/sh
    2 export G_SLICE=debug-blocks
    3 exec env HARNESS_PERL=./tester prove --failures "${srcdir:=$(dirname "$0")}/t/"
     2exec env HARNESS_PERL=./tester prove --failures t/
  • select.c

    r7dcef03 r84a071f  
    4141  if (t->destroy_cbdata)
    4242    t->destroy_cbdata(t->cbdata);
    43   g_slice_free(owl_task, t);
     43  g_free(t);
    4444}
    4545
     
    4747{
    4848  GSource *source = g_idle_source_new();
    49   owl_task *t = g_slice_new0(owl_task);
     49  owl_task *t = g_new0(owl_task, 1);
    5050  t->cb = cb;
    5151  t->cbdata = cbdata;
  • sepbar.c

    ra38becd r6eb3ed9  
    6767  }
    6868
    69   if (owl_function_is_away()) {
     69  if (owl_global_is_zaway(&g) || owl_global_is_aaway(&g)) {
    7070    getyx(sepwin, y, x);
    7171    wmove(sepwin, y, x+2);
    7272    wattron(sepwin, A_BOLD);
    7373    wattroff(sepwin, A_REVERSE);
    74     waddstr(sepwin, " AWAY ");
     74    if (owl_global_is_zaway(&g) && owl_global_is_aaway(&g)) {
     75      waddstr(sepwin, " AWAY ");
     76    } else if (owl_global_is_zaway(&g)) {
     77      waddstr(sepwin, " Z-AWAY ");
     78    } else if (owl_global_is_aaway(&g)) {
     79      waddstr(sepwin, " A-AWAY ");
     80    }
    7581    wattron(sepwin, A_REVERSE);
    7682    wattroff(sepwin, A_BOLD);
  • style.c

    r7dcef03 r14be3a5  
    2323{
    2424  SV *sv = NULL;
    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) {
     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) {
    3333    return SvPV_nolen(sv_2mortal(sv));
    3434  } else {
     
    5050 
    5151  /* Call the perl object */
    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                 );
     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                       );
    6059
    61   if (sv) {
     60  if(sv) {
    6261    body = SvPV_nolen(sv);
    6362  } else {
     
    103102{
    104103  owl_style_cleanup(s);
    105   g_slice_free(owl_style, s);
     104  g_free(s);
    106105}
  • t/00-core-tests.t

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

    r21dc927 ra74a044  
    33#include "owl.h"
    44#undef WINDOW
    5 #include "filterproc.h"
    65
    76#include <stdio.h>
     
    2423int owl_smartfilter_regtest(void);
    2524int owl_history_regtest(void);
    26 int call_filter_regtest(void);
    27 int owl_smartstrip_regtest(void);
    2825
    2926extern void owl_perl_xs_init(pTHX);
     
    116113  numfailures += owl_smartfilter_regtest();
    117114  numfailures += owl_history_regtest();
    118   numfailures += call_filter_regtest();
    119   numfailures += owl_smartstrip_regtest();
    120115  if (numfailures) {
    121116      fprintf(stderr, "# *** WARNING: %d failures total\n", numfailures);
     
    135130{
    136131  int numfailed=0;
    137   char *path, *home;
     132  char *s, *path, *home;
    138133
    139134  printf("# BEGIN testing owl_util\n");
     
    231226
    232227
    233   CHECK_STR_AND_FREE("baseclass barnowl",
    234                      "barnowl", owl_util_baseclass("barnowl"));
    235   CHECK_STR_AND_FREE("baseclass unbarnowl",
    236                      "barnowl", owl_util_baseclass("unbarnowl"));
    237   CHECK_STR_AND_FREE("baseclass unununbarnowl.d.d",
    238                      "barnowl", owl_util_baseclass("unununbarnowl.d.d"));
    239   CHECK_STR_AND_FREE("baseclass ununun.d.d",
    240                      "", owl_util_baseclass("ununun.d.d"));
    241   CHECK_STR_AND_FREE("baseclass d.d.d.d",
    242                      "d", owl_util_baseclass("d.d.d.d"));
    243   CHECK_STR_AND_FREE("baseclass n.d.d.d",
    244                      "n", owl_util_baseclass("n.d.d.d"));
    245   CHECK_STR_AND_FREE("baseclass ununun.",
    246                      ".", owl_util_baseclass("ununun."));
    247   CHECK_STR_AND_FREE("baseclass unununu",
    248                      "u", owl_util_baseclass("unununu"));
    249 
    250 
    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 foo/~//bar/",
    256                      "foo/~/bar/", owl_util_makepath("foo/~//bar/"));
    257   CHECK_STR_AND_FREE("makepath ~thisuserhadreallybetternotexist/foobar/",
    258                      "~thisuserhadreallybetternotexist/foobar/",
    259                      owl_util_makepath("~thisuserhadreallybetternotexist/foobar/"));
     228  s = owl_util_baseclass("barnowl");
     229  FAIL_UNLESS("baseclass barnowl", !strcmp("barnowl", s));
     230  g_free(s);
     231  s = owl_util_baseclass("unbarnowl");
     232  FAIL_UNLESS("baseclass unbarnowl", !strcmp("barnowl", s));
     233  g_free(s);
     234  s = owl_util_baseclass("unununbarnowl.d.d");
     235  FAIL_UNLESS("baseclass unununbarnowl.d.d", !strcmp("barnowl", s));
     236  g_free(s);
     237  s = owl_util_baseclass("ununun.d.d");
     238  FAIL_UNLESS("baseclass ununun.d.d", !strcmp("", s));
     239  g_free(s);
     240  s = owl_util_baseclass("d.d.d.d");
     241  FAIL_UNLESS("baseclass d.d.d.d", !strcmp("d", s));
     242  g_free(s);
     243  s = owl_util_baseclass("n.d.d.d");
     244  FAIL_UNLESS("baseclass n.d.d.d", !strcmp("n", s));
     245  g_free(s);
     246  s = owl_util_baseclass("ununun.");
     247  FAIL_UNLESS("baseclass ununun.", !strcmp(".", s));
     248  g_free(s);
     249  s = owl_util_baseclass("unununu");
     250  FAIL_UNLESS("baseclass unununu", !strcmp("u", s));
     251  g_free(s);
     252
     253
     254  s = owl_util_makepath("foo/bar");
     255  FAIL_UNLESS("makepath foo/bar", !strcmp("foo/bar", s));
     256  g_free(s);
     257  s = owl_util_makepath("//foo///bar");
     258  FAIL_UNLESS("makepath //foo///bar", !strcmp("/foo/bar", s));
     259  g_free(s);
     260  s = owl_util_makepath("foo/~//bar/");
     261  FAIL_UNLESS("makepath foo/~//bar/", !strcmp("foo/~/bar/", s));
     262  g_free(s);
     263  s = owl_util_makepath("~thisuserhadreallybetternotexist/foobar/");
     264  FAIL_UNLESS("makepath ~thisuserhadreallybetternotexist/foobar/",
     265              !strcmp("~thisuserhadreallybetternotexist/foobar/", s));
     266  g_free(s);
    260267
    261268  home = g_strdup(owl_global_get_homedir(&g));
    262   CHECK_STR_AND_FREE("makepath ~",
    263                      home, owl_util_makepath("~"));
     269  s = owl_util_makepath("~");
     270  FAIL_UNLESS("makepath ~", !strcmp(home, s));
     271  g_free(s);
    264272
    265273  path = g_build_filename(home, "foo/bar/baz", NULL);
    266   CHECK_STR_AND_FREE("makepath ~///foo/bar//baz",
    267                      path, owl_util_makepath("~///foo/bar//baz"));
     274  s = owl_util_makepath("~///foo/bar//baz");
     275  FAIL_UNLESS("makepath ~///foo/bar//baz", !strcmp(path, s));
     276  g_free(s);
    268277  g_free(path);
    269278  g_free(home);
     
    276285  }
    277286
    278   CHECK_STR_AND_FREE("makepath ~root",
    279                      home, owl_util_makepath("~root"));
     287  s = owl_util_makepath("~root");
     288  FAIL_UNLESS("makepath ~root", !strcmp(home, s));
     289  g_free(s);
    280290
    281291  path = g_build_filename(home, "foo/bar/baz", NULL);
    282   CHECK_STR_AND_FREE("makepath ~root///foo/bar//baz",
    283                      path, owl_util_makepath("~root///foo/bar//baz"));
     292  s = owl_util_makepath("~root///foo/bar//baz");
     293  FAIL_UNLESS("makepath ~root///foo/bar//baz", !strcmp(path, s));
     294  g_free(s);
    284295  g_free(path);
    285296  g_free(home);
     
    339350  int numfailed=0;
    340351  char *value;
     352  const void *v;
    341353
    342354  printf("# BEGIN testing owl_variable\n");
    343   owl_variable_dict_setup(&vd);
     355  FAIL_UNLESS("setup", 0==owl_variable_dict_setup(&vd));
    344356
    345357  FAIL_UNLESS("get bool var", NULL != (var = owl_variable_get_var(&vd, "rxping")));
     
    378390  FAIL_UNLESS("get int 7", 9 == owl_variable_get_int(var));
    379391
    380   FAIL_UNLESS("get enum var", NULL != (var = owl_variable_get_var(&vd, "scrollmode")));
    381   FAIL_UNLESS("get enum", OWL_SCROLLMODE_NORMAL == owl_variable_get_int(var));
    382   FAIL_UNLESS("get enum as string",
    383               !strcmp((value = owl_variable_get_tostring(var)), "normal"));
    384   g_free(value);
    385   FAIL_UNLESS("set enum 1", 0 == owl_variable_set_int(var, OWL_SCROLLMODE_TOP));
    386   FAIL_UNLESS("get enum 1", OWL_SCROLLMODE_TOP == owl_variable_get_int(var));
    387   FAIL_UNLESS("set enum 2a", -1 == owl_variable_set_int(var, -1));
    388   FAIL_UNLESS("set enum 2b", -1 == owl_variable_set_int(var, OWL_SCROLLMODE_PAGEDCENTER + 1));
    389   FAIL_UNLESS("get enum 2", OWL_SCROLLMODE_TOP == owl_variable_get_int(var));
    390   FAIL_UNLESS("set enum 3", 0 == owl_variable_set_fromstring(var, "center", 0));
    391   FAIL_UNLESS("get enum 4", OWL_SCROLLMODE_CENTER == owl_variable_get_int(var));
    392   FAIL_UNLESS("set enum 5", -1 == owl_variable_set_fromstring(var, "bogus", 0));
    393   FAIL_UNLESS("set enum 6", -1 == owl_variable_set_fromstring(var, "", 0));
    394   FAIL_UNLESS("get enum 7", OWL_SCROLLMODE_CENTER == owl_variable_get_int(var));
    395 
    396   owl_variable_dict_newvar_string(&vd, "stringvar", "testval", "", "");
     392  owl_variable_dict_newvar_string(&vd, "stringvar", "", "", "testval");
    397393  FAIL_UNLESS("get new string var", NULL != (var = owl_variable_get_var(&vd, "stringvar")));
     394  FAIL_UNLESS("get new string var", NULL != (v = owl_variable_get(var)));
    398395  FAIL_UNLESS("get new string val", !strcmp("testval", owl_variable_get_string(var)));
    399396  owl_variable_set_string(var, "new val");
    400397  FAIL_UNLESS("update string val", !strcmp("new val", owl_variable_get_string(var)));
    401398
    402   owl_variable_dict_newvar_int(&vd, "intvar", 47, "", "");
     399  owl_variable_dict_newvar_int(&vd, "intvar", "", "", 47);
    403400  FAIL_UNLESS("get new int var", NULL != (var = owl_variable_get_var(&vd, "intvar")));
     401  FAIL_UNLESS("get new int var", NULL != (v = owl_variable_get(var)));
    404402  FAIL_UNLESS("get new int val", 47 == owl_variable_get_int(var));
    405403  owl_variable_set_int(var, 17);
    406404  FAIL_UNLESS("update int val", 17 == owl_variable_get_int(var));
    407405
    408   owl_variable_dict_newvar_bool(&vd, "boolvar", true, "", "");
     406  owl_variable_dict_newvar_bool(&vd, "boolvar", "", "", 1);
    409407  FAIL_UNLESS("get new bool var", NULL != (var = owl_variable_get_var(&vd, "boolvar")));
     408  FAIL_UNLESS("get new bool var", NULL != (v = owl_variable_get(var)));
    410409  FAIL_UNLESS("get new bool val", owl_variable_get_bool(var));
    411410  owl_variable_set_bool_off(var);
    412411  FAIL_UNLESS("update bool val", !owl_variable_get_bool(var));
    413412
    414   owl_variable_dict_newvar_string(&vd, "nullstringvar", NULL, "", "");
     413  owl_variable_dict_newvar_string(&vd, "nullstringvar", "", "", NULL);
    415414  FAIL_UNLESS("get new string (NULL) var", NULL != (var = owl_variable_get_var(&vd, "nullstringvar")));
    416415  FAIL_UNLESS("get string (NULL)", NULL == (value = owl_variable_get_tostring(var)));
     
    419418  FAIL_UNLESS("get string (NULL) 2", NULL == (value = owl_variable_get_tostring(var)));
    420419  g_free(value);
    421 
    422   owl_variable_dict_newvar_enum(&vd, "enumvar", 0, "", "", "a,b,c,d");
    423   FAIL_UNLESS("get new enum var", NULL != (var = owl_variable_get_var(&vd, "enumvar")));
    424   FAIL_UNLESS("get new enum val", 0 == owl_variable_get_int(var));
    425   owl_variable_set_fromstring(var, "c", 0);
    426   FAIL_UNLESS("update enum val", 2 == owl_variable_get_int(var));
    427420
    428421  owl_variable_dict_cleanup(&vd);
     
    988981  return numfailed;
    989982}
    990 
    991 int call_filter_regtest(void)
    992 {
    993   int numfailed = 0;
    994   int ret;
    995   char *out = NULL;
    996   int status;
    997 
    998   printf("# BEGIN testing call_filter\n");
    999 
    1000   const char *cat_argv[] = { "cat", NULL };
    1001   ret = call_filter(cat_argv, "Mangos!", &out, &status);
    1002   FAIL_UNLESS("call_filter cat", (ret == 0 &&
    1003                                   status == 0 &&
    1004                                   strcmp(out, "Mangos!") == 0));
    1005   g_free(out); out = NULL;
    1006 
    1007   ret = call_filter(cat_argv, "", &out, &status);
    1008   FAIL_UNLESS("call_filter cat", (ret == 0 &&
    1009                                   status == 0 &&
    1010                                   strcmp(out, "") == 0));
    1011   g_free(out); out = NULL;
    1012 
    1013   ret = call_filter(cat_argv, NULL, &out, &status);
    1014   FAIL_UNLESS("call_filter cat", (ret == 0 &&
    1015                                   status == 0 &&
    1016                                   strcmp(out, "") == 0));
    1017   g_free(out); out = NULL;
    1018 
    1019   printf("# END testing call_filter (%d failures)\n", numfailed);
    1020   return numfailed;
    1021 }
    1022 
    1023 int owl_smartstrip_regtest(void)
    1024 {
    1025   int numfailed = 0;
    1026 
    1027   printf("# BEGIN testing owl_zephyr_smartstripped_user\n");
    1028 
    1029 #define CHECK_SMARTSTRIP(in, expected)                  \
    1030   do {                                                  \
    1031     char *__value = owl_zephyr_smartstripped_user(in);  \
    1032     FAIL_UNLESS("owl_zephyr_smartstripped_user " in,    \
    1033                 strcmp((expected), __value) == 0);      \
    1034     g_free(__value);                                    \
    1035   } while (0)
    1036 
    1037   CHECK_SMARTSTRIP("foo", "foo");
    1038   CHECK_SMARTSTRIP("foo.bar", "foo");
    1039   CHECK_SMARTSTRIP("foo/bar", "foo");
    1040   CHECK_SMARTSTRIP("host/bar", "host/bar");
    1041   CHECK_SMARTSTRIP("rcmd.bar", "rcmd.bar");
    1042   CHECK_SMARTSTRIP("daemon/bar", "daemon/bar");
    1043   CHECK_SMARTSTRIP("daemon.bar", "daemon.bar");
    1044 
    1045   CHECK_SMARTSTRIP("foo@ATHENA.MIT.EDU", "foo@ATHENA.MIT.EDU");
    1046   CHECK_SMARTSTRIP("foo.bar@ATHENA.MIT.EDU", "foo@ATHENA.MIT.EDU");
    1047   CHECK_SMARTSTRIP("foo/bar@ATHENA.MIT.EDU", "foo@ATHENA.MIT.EDU");
    1048   CHECK_SMARTSTRIP("host/bar@ATHENA.MIT.EDU", "host/bar@ATHENA.MIT.EDU");
    1049   CHECK_SMARTSTRIP("rcmd.bar@ATHENA.MIT.EDU", "rcmd.bar@ATHENA.MIT.EDU");
    1050   CHECK_SMARTSTRIP("daemon/bar@ATHENA.MIT.EDU", "daemon/bar@ATHENA.MIT.EDU");
    1051   CHECK_SMARTSTRIP("daemon.bar@ATHENA.MIT.EDU", "daemon.bar@ATHENA.MIT.EDU");
    1052 
    1053   printf("# END testing owl_zephyr_smartstripped_user\n");
    1054 
    1055   return numfailed;
    1056 }
  • util.c

    r7b89e8c r0071c88  
    262262CALLER_OWN char *owl_arg_quote(const char *arg)
    263263{
    264   GString *buf = g_string_new("");
     264  GString *buf = g_string_new("");;
    265265  owl_string_append_quoted_arg(buf, arg);
    266   return g_string_free(buf, false);
    267 }
    268 
    269 /* Returns a quoted version of argv. owl_parseline on the result should give
    270  * back the input. */
    271 CALLER_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   }
    280266  return g_string_free(buf, false);
    281267}
  • variable.c

    r7dcef03 rf271129  
    11#include "owl.h"
    22#include <stdio.h>
    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 
    10 typedef const char *(*get_string_t)(const owl_variable *);
    11 typedef int (*get_int_t)(const owl_variable *);
    12 typedef bool (*get_bool_t)(const owl_variable *);
    13 
    14 typedef int (*set_string_t)(owl_variable *, const char *);
    15 typedef int (*set_int_t)(owl_variable *, int);
    16 typedef int (*set_bool_t)(owl_variable *, bool);
    17 
    18 typedef int (*validate_string_t)(const owl_variable *, const char *);
    19 typedef int (*validate_int_t)(const owl_variable *, int);
    20 typedef int (*validate_bool_t)(const owl_variable *, bool);
    21 
    22 static 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 
    31 static void owl_variable_dict_newvar_string_full(owl_vardict *vd,
    32                                                  const char *name,
    33                                                  const char *default_val,
    34                                                  const char *summary,
    35                                                  const char *description,
    36                                                  const char *validsettings,
    37                                                  validate_string_t validate_fn,
    38                                                  set_string_t set_fn,
    39                                                  get_string_t get_fn);
    40 
    41 static void owl_variable_dict_newvar_int_full(owl_vardict *vd,
    42                                               const char *name,
    43                                               int default_val,
    44                                               const char *summary,
    45                                               const char *description,
    46                                               const char *validsettings,
    47                                               validate_int_t validate_fn,
    48                                               set_int_t set_fn,
    49                                               get_int_t get_fn);
    50 
    51 static void owl_variable_dict_newvar_enum_full(owl_vardict *vd,
    52                                                const char *name,
    53                                                int default_val,
    54                                                const char *summary,
    55                                                const char *description,
    56                                                const char *validsettings,
    57                                                validate_int_t validate_fn,
    58                                                set_int_t set_fn,
    59                                                get_int_t get_fn);
    60 
    61 #define OWLVAR_BOOL(name, default, summary, description) \
    62         owl_variable_dict_newvar_bool(vd, name, default, summary, description)
    63 
    64 #define OWLVAR_BOOL_FULL(name, default, summary, description, validate, set, get) \
    65         owl_variable_dict_newvar_bool_full(vd, name, default, summary, description, \
    66                                            validate, set, get)
    67 
    68 #define OWLVAR_INT(name, default, summary, description) \
    69         owl_variable_dict_newvar_int(vd, name, default, summary, description)
     3
     4#define OWLVAR_BOOL(name,default,summary,description) \
     5        { g_strdup(name), OWL_VARIABLE_BOOL, NULL, default, "on,off", g_strdup(summary), g_strdup(description), NULL, \
     6        NULL, NULL, NULL, NULL, NULL, NULL }
     7
     8#define OWLVAR_BOOL_FULL(name,default,summary,description,validate,set,get) \
     9        { g_strdup(name), OWL_VARIABLE_BOOL, NULL, default, "on,off", g_strdup(summary), g_strdup(description), NULL, \
     10        validate, set, NULL, get, NULL, NULL }
     11
     12#define OWLVAR_INT(name,default,summary,description) \
     13        { g_strdup(name), OWL_VARIABLE_INT, NULL, default, "<int>", g_strdup(summary), g_strdup(description), NULL, \
     14        NULL, NULL, NULL, NULL, NULL, NULL }
    7015
    7116#define OWLVAR_INT_FULL(name,default,summary,description,validset,validate,set,get) \
    72         owl_variable_dict_newvar_int_full(vd, name, default, summary, description, \
    73                                           validset, validate, set, get)
    74 
    75 #define OWLVAR_PATH(name, default, summary, description) \
    76         owl_variable_dict_newvar_path(vd, name, default, summary, description)
    77 
    78 #define OWLVAR_STRING(name, default, summary, description) \
    79         owl_variable_dict_newvar_string(vd, name, default, summary, description)
    80 
    81 #define OWLVAR_STRING_FULL(name, default, validset, summary, description, validate, set, get) \
    82         owl_variable_dict_newvar_string_full(vd, name, default, summary, description, \
    83                                              validset, validate, set, get)
     17        { g_strdup(name), OWL_VARIABLE_INT, NULL, default, validset, g_strdup(summary), g_strdup(description), NULL, \
     18        validate, set, NULL, get, NULL, NULL }
     19
     20#define OWLVAR_PATH(name,default,summary,description) \
     21        { g_strdup(name), OWL_VARIABLE_STRING, g_strdup(default), 0, "<path>", g_strdup(summary), g_strdup(description),  NULL, \
     22        NULL, NULL, NULL, NULL, NULL, NULL }
     23
     24#define OWLVAR_STRING(name,default,summary,description) \
     25        { g_strdup(name), OWL_VARIABLE_STRING, g_strdup(default), 0, "<string>", g_strdup(summary), g_strdup(description), NULL, \
     26        NULL, NULL, NULL, NULL, NULL, NULL }
     27
     28#define OWLVAR_STRING_FULL(name,default,validset,summary,description,validate,set,get) \
     29        { g_strdup(name), OWL_VARIABLE_STRING, g_strdup(default), 0, validset, g_strdup(summary), g_strdup(description), NULL, \
     30        validate, set, NULL, get, NULL, NULL }
    8431
    8532/* enums are really integers, but where validset is a comma-separated
    8633 * list of strings which can be specified.  The tokens, starting at 0,
    8734 * correspond to the values that may be specified. */
    88 #define OWLVAR_ENUM(name, default, summary, description, validset) \
    89         owl_variable_dict_newvar_enum(vd, name, default, summary, description, validset)
     35#define OWLVAR_ENUM(name,default,summary,description,validset) \
     36        { g_strdup(name), OWL_VARIABLE_INT, NULL, default, validset, g_strdup(summary), g_strdup(description), NULL, \
     37        owl_variable_enum_validate, \
     38        NULL, owl_variable_enum_set_fromstring, \
     39        NULL, owl_variable_enum_get_tostring, \
     40        NULL }
    9041
    9142#define OWLVAR_ENUM_FULL(name,default,summary,description,validset,validate, set, get) \
    92         owl_variable_dict_newvar_enum_full(vd, name, default, summary, description, \
    93                                            validset, validate, set, get)
    94 
    95 void owl_variable_add_defaults(owl_vardict *vd)
    96 {
     43        { g_strdup(name), OWL_VARIABLE_INT, NULL, default, validset, g_strdup(summary), g_strdup(description), NULL, \
     44        validate, \
     45        set, owl_variable_enum_set_fromstring, \
     46        get, owl_variable_enum_get_tostring, \
     47        NULL }
     48
     49int owl_variable_add_defaults(owl_vardict *vd)
     50{
     51  owl_variable variables_to_init[] = {
     52
    9753  OWLVAR_STRING( "personalbell" /* %OwlVarStub */, "off",
    9854                 "ring the terminal bell when personal messages are received",
    9955                 "Can be set to 'on', 'off', or the name of a filter which\n"
    100                  "messages need to match in order to ring the bell");
     56                 "messages need to match in order to ring the bell"),
    10157
    10258  OWLVAR_BOOL( "bell" /* %OwlVarStub */, 1,
    103                "enable / disable the terminal bell", "" );
     59               "enable / disable the terminal bell", "" ),
    10460
    10561  OWLVAR_BOOL_FULL( "debug" /* %OwlVarStub */, OWL_DEBUG,
     
    10763                    "If set to 'on', debugging messages are logged to the\n"
    10864                    "file specified by the debugfile variable.\n",
    109                     NULL, owl_variable_debug_set, NULL);
     65                    NULL, owl_variable_debug_set, NULL),
    11066
    11167  OWLVAR_BOOL( "startuplogin" /* %OwlVarStub */, 1,
    112                "send a login message when BarnOwl starts", "" );
     68               "send a login message when BarnOwl starts", "" ),
    11369
    11470  OWLVAR_BOOL( "shutdownlogout" /* %OwlVarStub */, 1,
    115                "send a logout message when BarnOwl exits", "" );
     71               "send a logout message when BarnOwl exits", "" ),
    11672
    11773  OWLVAR_BOOL( "rxping" /* %OwlVarStub */, 0,
    118                "display received pings", "" );
     74               "display received pings", "" ),
    11975
    12076  OWLVAR_BOOL( "txping" /* %OwlVarStub */, 1,
    121                "send pings", "" );
     77               "send pings", "" ),
    12278
    12379  OWLVAR_BOOL( "sepbar_disable" /* %OwlVarStub */, 0,
    124                "disable printing information in the separator bar", "" );
     80               "disable printing information in the separator bar", "" ),
    12581
    12682  OWLVAR_BOOL( "smartstrip" /* %OwlVarStub */, 1,
    127                "strip kerberos instance for reply", "");
     83               "strip kerberos instance for reply", ""),
    12884
    12985  OWLVAR_BOOL( "newlinestrip" /* %OwlVarStub */, 1,
    130                "strip leading and trailing newlines", "");
     86               "strip leading and trailing newlines", ""),
    13187
    13288  OWLVAR_BOOL( "displayoutgoing" /* %OwlVarStub */, 1,
    133                "display outgoing messages", "" );
     89               "display outgoing messages", "" ),
    13490
    13591  OWLVAR_BOOL( "loginsubs" /* %OwlVarStub */, 1,
    136                "load logins from .anyone on startup", "" );
     92               "load logins from .anyone on startup", "" ),
    13793
    13894  OWLVAR_BOOL( "logging" /* %OwlVarStub */, 0,
     
    14197               "logged in the directory specified\n"
    14298               "by the 'logpath' variable.  The filename in that\n"
    143                "directory is derived from the sender of the message.\n" );
     99               "directory is derived from the sender of the message.\n" ),
    144100
    145101  OWLVAR_BOOL( "classlogging" /* %OwlVarStub */, 0,
     
    149105               "by the 'classlogpath' variable.\n"
    150106               "The filename in that directory is derived from\n"
    151                "the name of the class to which the message was sent.\n" );
     107               "the name of the class to which the message was sent.\n" ),
    152108
    153109  OWLVAR_ENUM( "loggingdirection" /* %OwlVarStub */, OWL_LOGGING_DIRECTION_BOTH,
     
    158114               "is selected both incoming and outgoing messages are\n"
    159115               "logged.",
    160                "both,in,out");
    161 
    162   OWLVAR_BOOL_FULL( "colorztext" /* %OwlVarStub */, 1,
    163                     "allow @color() in zephyrs to change color",
    164                     NULL, NULL, owl_variable_colorztext_set, NULL);
     116               "both,in,out"),
     117
     118  OWLVAR_BOOL( "colorztext" /* %OwlVarStub */, 1,
     119               "allow @color() in zephyrs to change color",
     120               "Note that only messages received after this variable\n"
     121               "is set will be affected." ),
    165122
    166123  OWLVAR_BOOL( "fancylines" /* %OwlVarStub */, 1,
     
    168125               "If turned off, dashes, pipes and pluses will be used\n"
    169126               "to draw lines on the screen.  Useful when the terminal\n"
    170                "is causing problems" );
     127               "is causing problems" ),
    171128
    172129  OWLVAR_BOOL( "zcrypt" /* %OwlVarStub */, 1,
    173130               "Do automatic zcrypt processing",
    174                "" );
     131               "" ),
    175132
    176133  OWLVAR_BOOL_FULL( "pseudologins" /* %OwlVarStub */, 0,
     
    180137                    "but sent no login message, or a user is not present that sent no\n"
    181138                    "logout message, a pseudo login or logout message will be created\n",
    182                     NULL, owl_variable_pseudologins_set, NULL);
     139                    NULL, owl_variable_pseudologins_set, NULL),
    183140
    184141  OWLVAR_BOOL( "ignorelogins" /* %OwlVarStub */, 0,
     
    186143               "When this is enabled, BarnOwl will print login and logout notifications\n"
    187144               "for AIM, zephyr, or other protocols.  If disabled BarnOwl will not print\n"
    188                "login or logout notifications.\n");
     145               "login or logout notifications.\n"),
    189146
    190147  OWLVAR_STRING( "logfilter" /* %OwlVarStub */, "",
     
    195152                 "variables like logging, classlogging, loglogins, loggingdirection,\n"
    196153                 "etc.  If you want this variable to control all logging, make sure\n"
    197                  "all other logging variables are in their default state.\n");
     154                 "all other logging variables are in their default state.\n"),
    198155
    199156  OWLVAR_BOOL( "loglogins" /* %OwlVarStub */, 0,
     
    201158               "When this is enabled, BarnOwl will log login and logout notifications\n"
    202159               "for AIM, zephyr, or other protocols.  If disabled BarnOwl will not print\n"
    203                "login or logout notifications.\n");
     160               "login or logout notifications.\n"),
    204161
    205162  OWLVAR_ENUM_FULL( "disable-ctrl-d" /* %OwlVarStub:lockout_ctrld */, 1,
     
    213170                    "in the editmulti keymap.\n",
    214171                    "off,middle,on",
    215                     NULL, owl_variable_disable_ctrl_d_set, NULL);
     172                    NULL, owl_variable_disable_ctrl_d_set, NULL),
    216173
    217174  OWLVAR_PATH( "logpath" /* %OwlVarStub */, "~/zlog/people",
    218175               "path for logging personal zephyrs",
    219176               "Specifies a directory which must exist.\n"
    220                "Files will be created in the directory for each sender.\n");
     177               "Files will be created in the directory for each sender.\n"),
    221178
    222179  OWLVAR_PATH( "classlogpath" /* %OwlVarStub:classlogpath */, "~/zlog/class",
    223180               "path for logging class zephyrs",
    224181               "Specifies a directory which must exist.\n"
    225                "Files will be created in the directory for each class.\n");
     182               "Files will be created in the directory for each class.\n"),
    226183
    227184  OWLVAR_PATH( "debug_file" /* %OwlVarStub */, OWL_DEBUG_FILE,
    228185               "path for logging debug messages when debugging is enabled",
    229186               "This file will be logged to if 'debug' is set to 'on'.\n"
    230                "BarnOwl will append a dot and the current process's pid to the filename.");
     187               "BarnOwl will append a dot and the current process's pid to the filename."),
    231188 
    232189  OWLVAR_PATH( "zsigproc" /* %OwlVarStub:zsigproc */, NULL,
     
    236193               "See the documentation for 'zsig' for more information about\n"
    237194               "how the outgoing zsig is chosen."
    238                );
     195               ),
    239196
    240197  OWLVAR_PATH( "newmsgproc" /* %OwlVarStub:newmsgproc */, NULL,
     
    242199               "The named program will be run when BarnOwl receives new\n"
    243200               "messages.  It will not be run again until the first\n"
    244                "instance exits");
     201               "instance exits"),
    245202
    246203  OWLVAR_STRING( "zsender" /* %OwlVarStub */, "",
     
    249206         "zephyrs.  If this is unset, it will use your Kerberos\n"
    250207         "principal. Note that customizing the sender name will\n"
    251          "cause your zephyrs to be sent unauthenticated.");
     208         "cause your zephyrs to be sent unauthenticated."),
    252209
    253210  OWLVAR_STRING( "zsigfunc" /* %OwlVarStub */, "BarnOwl::default_zephyr_signature()",
     
    256213                 "explicit zsig.  The default setting implements the policy\n"
    257214                 "described in the documentation for the 'zsig' variable.\n"
    258                  "See also BarnOwl::random_zephyr_signature().\n");
     215                 "See also BarnOwl::random_zephyr_signature().\n"),
    259216
    260217  OWLVAR_STRING( "zsig" /* %OwlVarStub */, "",
     
    263220                 "unset, 'zsigproc' will be run to generate a zsig. If that is\n"
    264221                 "also unset, the 'zwrite-signature' zephyr variable will be\n"
    265                  "used instead.\n");
     222                 "used instead.\n"),
    266223
    267224  OWLVAR_STRING( "appendtosepbar" /* %OwlVarStub */, "",
     
    269226                 "The sepbar is the bar separating the top and bottom\n"
    270227                 "of the BarnOwl screen.  Any string specified here will\n"
    271                  "be displayed on the right of the sepbar\n");
     228                 "be displayed on the right of the sepbar\n"),
    272229
    273230  OWLVAR_BOOL( "zaway" /* %OwlVarStub */, 0,
    274                "turn zaway on or off", "" );
     231               "turn zaway on or off", "" ),
    275232
    276233  OWLVAR_STRING( "zaway_msg" /* %OwlVarStub */,
    277234                 OWL_DEFAULT_ZAWAYMSG,
    278                  "zaway msg for responding to zephyrs when away", "" );
     235                 "zaway msg for responding to zephyrs when away", "" ),
    279236
    280237  OWLVAR_STRING( "zaway_msg_default" /* %OwlVarStub */,
    281238                 OWL_DEFAULT_ZAWAYMSG,
    282                  "default zaway message", "" );
     239                 "default zaway message", "" ),
    283240
    284241  OWLVAR_BOOL_FULL( "aaway" /* %OwlVarStub */, 0,
    285242                    "Set AIM away status",
    286243                    "",
    287                     NULL, owl_variable_aaway_set, NULL);
     244                    NULL, owl_variable_aaway_set, NULL),
    288245
    289246  OWLVAR_STRING( "aaway_msg" /* %OwlVarStub */,
    290247                 OWL_DEFAULT_AAWAYMSG,
    291                  "AIM away msg for responding when away", "" );
     248                 "AIM away msg for responding when away", "" ),
    292249
    293250  OWLVAR_STRING( "aaway_msg_default" /* %OwlVarStub */,
    294251                 OWL_DEFAULT_AAWAYMSG,
    295                  "default AIM away message", "" );
     252                 "default AIM away message", "" ),
    296253
    297254  OWLVAR_STRING( "view_home" /* %OwlVarStub */, "all",
    298255                 "home view to switch to after 'X' and 'V'",
    299                  "SEE ALSO: view, filter\n" );
     256                 "SEE ALSO: view, filter\n" ),
    300257
    301258  OWLVAR_STRING( "alert_filter" /* %OwlVarStub */, "none",
    302259                 "filter on which to trigger alert actions",
    303                  "" );
     260                 "" ),
    304261
    305262  OWLVAR_STRING( "alert_action" /* %OwlVarStub */, "nop",
    306263                 "BarnOwl command to execute for alert actions",
    307                  "" );
     264                 "" ),
    308265
    309266  OWLVAR_STRING_FULL( "tty" /* %OwlVarStub */, "", "<string>", "tty name for zephyr location", "",
    310                       NULL, owl_variable_tty_set, NULL);
     267                      NULL, owl_variable_tty_set, NULL),
    311268
    312269  OWLVAR_STRING( "default_style" /* %OwlVarStub */, "default",
     
    319276                 "   perl     - legacy perl interface\n"
    320277                 "\nSEE ALSO: style, show styles, view -s <style>\n"
    321                  );
     278                 ),
    322279
    323280
     
    326283                 "This specifies the maximum number of columns for M-q to fill text\n"
    327284                 "to.  If set to 0, M-q will wrap to the width of the window, and\n"
    328                  "values less than 0 disable M-q entirely.\n");
     285                 "values less than 0 disable M-q entirely.\n"),
    329286
    330287  OWLVAR_INT(    "edit:maxwrapcols" /* %OwlVarStub:edit_maxwrapcols */, 70,
     
    335292                 "\n"
    336293                 "As a courtesy to recipients, it is recommended that outgoing\n"
    337                  "Zephyr messages be no wider than 70 columns.\n");
     294                 "Zephyr messages be no wider than 70 columns.\n"),
    338295
    339296  OWLVAR_INT( "aim_ignorelogin_timer" /* %OwlVarStub */, 15,
     
    342299              "AIM login before allowing the receipt of AIM login notifications.\n"
    343300              "By default this is set to 15.  If you would like to view login\n"
    344               "notifications of buddies as soon as you login, set it to 0 instead.");
     301              "notifications of buddies as soon as you login, set it to 0 instead."),
    345302
    346303             
     
    355312                   owl_variable_typewinsize_set,
    356313                   NULL /* use default for get */
    357                    );
     314                   ),
    358315
    359316  OWLVAR_INT( "typewindelta" /* %OwlVarStub */, 0,
     
    365322           "typewinsize to 1.\n\n"
    366323           "This works a lot better with a non-default scrollmode;\n"
    367            "try :set scrollmode pagedcenter.\n");
     324           "try :set scrollmode pagedcenter.\n"),
    368325
    369326  OWLVAR_ENUM( "scrollmode" /* %OwlVarStub */, OWL_SCROLLMODE_NORMAL,
     
    394351               "                 the screen will be paged up or down and\n"
    395352               "                 the cursor will be near the center.\n",
    396                "normal,top,neartop,center,paged,pagedcenter" );
     353               "normal,top,neartop,center,paged,pagedcenter" ),
    397354
    398355  OWLVAR_BOOL( "narrow-related" /* %OwlVarStub:narrow_related */, 1,
    399356               "Make smartnarrow use broader filters",
    400                "Causes smartfilter to narrow to messages \"related\" to \n"
     357               "Causes smartfiler to narrow to messages \"related\" to \n"
    401358               "the current message, as well as ones to the same place.\n\n"
    402359               "for Zephyr, this controls whether to narrow to e.g. class-help or\n"
    403360               "class-help.d alone, or to related-class-help, which includes\n"
    404                "help, unhelp, help.d, etc.\n\nDefault is true (include unclasses, etc.).\n" );
     361               "help, unhelp, help.d, etc.\n\nDefault is true (include unclasses, etc.).\n" ),
    405362
    406363  OWLVAR_BOOL( "_followlast" /* %OwlVarStub */, 0,
     
    409366               "continue to follow the last message if this is set.\n"
    410367               "Note that this is currently risky as you might accidentally\n"
    411                "delete a message right as it came in.\n" );
     368               "delete a message right as it came in.\n" ),
    412369
    413370  OWLVAR_STRING_FULL( "default_exposure" /* %OwlVarStub */, "",
     
    418375                      "~/.zephyr.vars.\n"
    419376                      "See the description of exposure for the values this can be.",
    420                       NULL, owl_variable_default_exposure_set, owl_variable_default_exposure_get );
     377                      NULL, owl_variable_default_exposure_set, owl_variable_default_exposure_get ),
    421378
    422379  OWLVAR_STRING_FULL( "exposure" /* %OwlVarStub */, "",
     
    474431                      "                     personal subscriptions will be entered for the\n"
    475432                      "                     user.\n",
    476                       NULL, owl_variable_exposure_set, NULL /* use default for get */ );
     433                      NULL, owl_variable_exposure_set, NULL /* use default for get */ ),
     434
     435  /* This MUST be last... */
     436  { NULL, 0, NULL, 0, NULL, NULL, NULL, NULL,
     437    NULL, NULL, NULL, NULL, NULL, NULL }
     438
     439  };
     440
     441  int ret = owl_variable_dict_add_from_list(vd, variables_to_init);
     442  owl_variable *var;
     443  for (var = variables_to_init; var->name != NULL; var++)
     444    owl_variable_cleanup(var);
     445  return ret;
    477446}
    478447
     
    484453/* commonly useful */
    485454
    486 int owl_variable_int_validate_gt0(const owl_variable *v, int newval)
    487 {
    488   return !(newval < 1);
    489 }
    490 
    491 int owl_variable_int_validate_positive(const owl_variable *v, int newval)
    492 {
    493   return !(newval < 0);
     455int owl_variable_int_validate_gt0(const owl_variable *v, const void *newval)
     456{
     457  if (newval == NULL) return(0);
     458  else if (*(const int*)newval < 1) return(0);
     459  else return (1);
     460}
     461
     462int owl_variable_int_validate_positive(const owl_variable *v, const void *newval)
     463{
     464  if (newval == NULL) return(0);
     465  else if (*(const int*)newval < 0) return(0);
     466  else return (1);
    494467}
    495468
    496469/* typewinsize */
    497 int owl_variable_typewinsize_set(owl_variable *v, int newval)
     470int owl_variable_typewinsize_set(owl_variable *v, const void *newval)
    498471{
    499472  int rv;
     
    504477
    505478/* debug (cache value in g->debug) */
    506 int owl_variable_debug_set(owl_variable *v, bool newval)
    507 {
    508   g.debug = newval;
     479int owl_variable_debug_set(owl_variable *v, const void *newval)
     480{
     481  if (newval && (*(const int*)newval == 1 || *(const int*)newval == 0)) {
     482    g.debug = *(const int*)newval;
     483  }
    509484  return owl_variable_bool_set_default(v, newval);
    510485}
    511486
    512487/* When 'aaway' is changed, need to notify the AIM server */
    513 int owl_variable_aaway_set(owl_variable *v, bool newval)
     488int owl_variable_aaway_set(owl_variable *v, const void *newval)
    514489{
    515490  if (newval) {
    516     owl_aim_set_awaymsg(owl_global_get_aaway_msg(&g));
    517   } else {
    518     owl_aim_set_awaymsg("");
     491    if (*(const int*)newval == 1) {
     492      owl_aim_set_awaymsg(owl_global_get_aaway_msg(&g));
     493    } else if (*(const int*)newval == 0) {
     494      owl_aim_set_awaymsg("");
     495    }
    519496  }
    520497  return owl_variable_bool_set_default(v, newval);
    521498}
    522499
    523 int owl_variable_colorztext_set(owl_variable *v, bool newval)
    524 {
    525   int ret = owl_variable_bool_set_default(v, newval);
    526   /* flush the format cache so that we see the update, but only if we're done initializing BarnOwl */
    527   if (owl_global_get_msglist(&g) != NULL)
    528     owl_messagelist_invalidate_formats(owl_global_get_msglist(&g));
    529   if (owl_global_get_mainwin(&g) != NULL) {
    530     owl_function_calculate_topmsg(OWL_DIRECTION_DOWNWARDS);
    531     owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    532   }
    533   return ret;
    534 }
    535 
    536 int owl_variable_pseudologins_set(owl_variable *v, bool newval)
     500int owl_variable_pseudologins_set(owl_variable *v, const void *newval)
    537501{
    538502  static guint timer = 0;
    539503  if (newval) {
    540     owl_function_zephyr_buddy_check(0);
    541     if (timer == 0) {
    542       timer = g_timeout_add_seconds(180, owl_zephyr_buddycheck_timer, NULL);
    543     }
    544   } else {
    545     if (timer != 0) {
    546       g_source_remove(timer);
    547       timer = 0;
     504    if (*(const int*)newval == 1) {
     505      owl_function_zephyr_buddy_check(0);
     506      if (timer == 0) {
     507        timer = g_timeout_add_seconds(180, owl_zephyr_buddycheck_timer, NULL);
     508      }
     509    } else {
     510      if (timer != 0) {
     511        g_source_remove(timer);
     512        timer = 0;
     513      }
    548514    }
    549515  }
     
    553519/* note that changing the value of this will clobber
    554520 * any user setting of this */
    555 int owl_variable_disable_ctrl_d_set(owl_variable *v, int newval)
    556 {
    557   if (!owl_context_is_startup(owl_global_get_context(&g))) {
    558     if (newval == 2) {
     521int owl_variable_disable_ctrl_d_set(owl_variable *v, const void *newval)
     522{
     523  if (newval && !owl_context_is_startup(owl_global_get_context(&g))) {
     524    if (*(const int*)newval == 2) {
    559525      owl_function_command_norv("bindkey editmulti C-d command edit:delete-next-char");
    560     } else if (newval == 1) {
     526    } else if (*(const int*)newval == 1) {
    561527      owl_function_command_norv("bindkey editmulti C-d command edit:done-or-delete");
    562528    } else {
     
    564530    }
    565531  } 
    566   return owl_variable_int_set_default(v, newval);
    567 }
    568 
    569 int owl_variable_tty_set(owl_variable *v, const char *newval)
     532  return owl_variable_int_set_default(v, newval); 
     533}
     534
     535int owl_variable_tty_set(owl_variable *v, const void *newval)
    570536{
    571537  owl_zephyr_set_locationinfo(g_get_host_name(), newval);
    572   return owl_variable_string_set_default(v, newval);
    573 }
    574 
    575 int owl_variable_default_exposure_set(owl_variable *v, const char *newval)
     538  return(owl_variable_string_set_default(v, newval));
     539}
     540
     541int owl_variable_default_exposure_set(owl_variable *v, const void *newval)
    576542{
    577543  return owl_zephyr_set_default_exposure(newval);
    578544}
    579545
    580 const char *owl_variable_default_exposure_get(const owl_variable *v)
     546const void *owl_variable_default_exposure_get(const owl_variable *v)
    581547{
    582548  return owl_zephyr_get_default_exposure();
    583549}
    584550
    585 int owl_variable_exposure_set(owl_variable *v, const char *newval)
     551int owl_variable_exposure_set(owl_variable *v, const void *newval)
    586552{
    587553  int ret = owl_zephyr_set_exposure(newval);
     
    595561/**************************************************************************/
    596562
    597 void owl_variable_dict_setup(owl_vardict *vd) {
     563int owl_variable_dict_setup(owl_vardict *vd) {
    598564  owl_dict_create(vd);
    599   owl_variable_add_defaults(vd);
    600 }
    601 
    602 CALLER_OWN GClosure *owl_variable_make_closure(owl_variable *v,
    603                                                GCallback fn,
    604                                                GClosureMarshal marshal) {
    605   GClosure *closure = g_cclosure_new_swap(fn, v, NULL);
    606   g_closure_set_marshal(closure,marshal);
    607   g_closure_ref(closure);
    608   g_closure_sink(closure);
    609   return closure;
     565  return owl_variable_add_defaults(vd);
     566}
     567
     568int owl_variable_dict_add_from_list(owl_vardict *vd, owl_variable *variables_to_init)
     569{
     570  owl_variable *var, *cur;
     571  for (var = variables_to_init; var->name != NULL; var++) {
     572    cur = g_new(owl_variable, 1);
     573    *cur = *var;
     574    /* strdup all the strings so we can delete them consistently. */
     575    cur->name = g_strdup(var->name);
     576    cur->summary = g_strdup(var->summary);
     577    cur->description = g_strdup(var->description);
     578    switch (cur->type) {
     579    case OWL_VARIABLE_OTHER:
     580      cur->set_fn(cur, cur->pval_default);
     581      break;
     582    case OWL_VARIABLE_STRING:
     583      if (!cur->validate_fn)
     584        cur->validate_fn = owl_variable_string_validate_default;
     585      if (!cur->set_fn)
     586        cur->set_fn = owl_variable_string_set_default;
     587      if (!cur->set_fromstring_fn)
     588        cur->set_fromstring_fn = owl_variable_string_set_fromstring_default;
     589      if (!cur->get_fn)
     590        cur->get_fn = owl_variable_get_default;
     591      if (!cur->get_tostring_fn)
     592        cur->get_tostring_fn = owl_variable_string_get_tostring_default;     
     593      if (!cur->delete_fn)
     594        cur->delete_fn = owl_variable_delete_default;
     595      cur->pval_default = g_strdup(var->pval_default);
     596      cur->set_fn(cur, cur->pval_default);
     597      break;
     598    case OWL_VARIABLE_BOOL:
     599      if (!cur->validate_fn)
     600        cur->validate_fn = owl_variable_bool_validate_default;
     601      if (!cur->set_fn)
     602        cur->set_fn = owl_variable_bool_set_default;
     603      if (!cur->set_fromstring_fn)
     604        cur->set_fromstring_fn = owl_variable_bool_set_fromstring_default;
     605      if (!cur->get_fn)
     606        cur->get_fn = owl_variable_get_default;
     607      if (!cur->get_tostring_fn)
     608        cur->get_tostring_fn = owl_variable_bool_get_tostring_default;     
     609      if (!cur->delete_fn)
     610        cur->delete_fn = owl_variable_delete_default;
     611      cur->val = g_new(int, 1);
     612      cur->set_fn(cur, &cur->ival_default);
     613      break;
     614    case OWL_VARIABLE_INT:
     615      if (!cur->validate_fn)
     616        cur->validate_fn = owl_variable_int_validate_default;
     617      if (!cur->set_fn)
     618        cur->set_fn = owl_variable_int_set_default;
     619      if (!cur->set_fromstring_fn)
     620        cur->set_fromstring_fn = owl_variable_int_set_fromstring_default;
     621      if (!cur->get_fn)
     622        cur->get_fn = owl_variable_get_default;
     623      if (!cur->get_tostring_fn)
     624        cur->get_tostring_fn = owl_variable_int_get_tostring_default;     
     625      if (!cur->delete_fn)
     626        cur->delete_fn = owl_variable_delete_default;
     627      cur->val = g_new(int, 1);
     628      cur->set_fn(cur, &cur->ival_default);
     629      break;
     630    default:
     631      fprintf(stderr, "owl_variable_setup: invalid variable type\n");
     632      return(-2);
     633    }
     634    owl_dict_insert_element(vd, cur->name, cur, NULL);
     635  }
     636  return 0;
    610637}
    611638
    612639void owl_variable_dict_add_variable(owl_vardict * vardict,
    613640                                    owl_variable * var) {
    614   char *oldvalue = NULL;
    615   owl_variable *oldvar = owl_variable_get_var(vardict, var->name);
    616   /* Save the old value as a string. */
    617   if (oldvar) {
    618     oldvalue = owl_variable_get_tostring(oldvar);
    619   }
    620641  owl_dict_insert_element(vardict, var->name, var, (void (*)(void *))owl_variable_delete);
    621   /* Restore the old value. */
    622   if (oldvalue) {
    623     owl_variable_set_fromstring(var, oldvalue, 0);
    624     g_free(oldvalue);
    625   }
    626 }
    627 
    628 static owl_variable *owl_variable_newvar(int type, const char *name, const char *summary, const char *description, const char *validsettings) {
    629   owl_variable *var = g_slice_new0(owl_variable);
    630   var->type = type;
     642}
     643
     644CALLER_OWN owl_variable *owl_variable_newvar(const char *name, const char *summary, const char *description)
     645{
     646  owl_variable * var = g_new0(owl_variable, 1);
    631647  var->name = g_strdup(name);
    632648  var->summary = g_strdup(summary);
    633649  var->description = g_strdup(description);
    634   var->validsettings = g_strdup(validsettings);
    635650  return var;
    636651}
    637652
    638 static void owl_variable_dict_newvar_int_full(owl_vardict *vd, const char *name, int default_val, const char *summary, const char *description, const char *validsettings, validate_int_t validate_fn, set_int_t set_fn, get_int_t get_fn)
    639 {
    640   owl_variable *var = owl_variable_newvar(OWL_VARIABLE_INT, name, summary,
    641                                           description, validsettings);
    642   var->takes_on_off = false;
    643   var->get_fn = G_CALLBACK(get_fn ? get_fn : owl_variable_int_get_default);
    644   var->set_fn = G_CALLBACK(set_fn ? set_fn : owl_variable_int_set_default);
    645   var->validate_fn = G_CALLBACK(validate_fn ? validate_fn : owl_variable_int_validate_default);
    646 
    647   var->get_tostring_fn = owl_variable_make_closure(
    648       var, G_CALLBACK(owl_variable_int_get_tostring_default),
    649       g_cclosure_user_marshal_STRING__VOID);
    650   var->set_fromstring_fn = owl_variable_make_closure(
    651       var, G_CALLBACK(owl_variable_int_set_fromstring_default),
    652       g_cclosure_user_marshal_INT__STRING);
    653 
    654   g_value_init(&var->val, G_TYPE_INT);
    655   owl_variable_set_int(var, default_val);
    656 
    657   var->default_str = owl_variable_get_tostring(var);
    658   owl_variable_dict_add_variable(vd, var);
    659 }
    660 
    661 void owl_variable_dict_newvar_int(owl_vardict *vd, const char *name, int default_val, const char *summary, const char *description) {
    662   owl_variable_dict_newvar_int_full(vd, name, default_val, summary, description,
    663                                     "<int>", NULL, NULL, NULL);
    664 }
    665 
    666 static void owl_variable_dict_newvar_bool_full(owl_vardict *vd, const char *name, bool default_val, const char *summary, const char *description, validate_bool_t validate_fn, set_bool_t set_fn, get_bool_t get_fn)
    667 {
    668   owl_variable *var = owl_variable_newvar(OWL_VARIABLE_BOOL, name, summary,
    669                                           description, "on,off");
    670   var->takes_on_off = true;
    671   var->get_fn = G_CALLBACK(get_fn ? get_fn : owl_variable_bool_get_default);
    672   var->set_fn = G_CALLBACK(set_fn ? set_fn : owl_variable_bool_set_default);
    673   var->validate_fn = G_CALLBACK(validate_fn ? validate_fn : owl_variable_bool_validate_default);
    674 
    675   var->get_tostring_fn = owl_variable_make_closure(
    676       var, G_CALLBACK(owl_variable_bool_get_tostring_default),
    677       g_cclosure_user_marshal_STRING__VOID);
    678   var->set_fromstring_fn = owl_variable_make_closure(
    679       var, G_CALLBACK(owl_variable_bool_set_fromstring_default),
    680       g_cclosure_user_marshal_INT__STRING);
    681 
    682   g_value_init(&var->val, G_TYPE_BOOLEAN);
    683   owl_variable_set_bool(var, default_val);
    684 
    685   var->default_str = owl_variable_get_tostring(var);
    686   owl_variable_dict_add_variable(vd, var);
    687 }
    688 
    689 void owl_variable_dict_newvar_bool(owl_vardict *vd, const char *name, bool default_val, const char *summary, const char *description) {
    690   owl_variable_dict_newvar_bool_full(vd, name, default_val, summary, description,
    691                                      NULL, NULL, NULL);
    692 }
    693 
    694 static void owl_variable_dict_newvar_string_full(owl_vardict *vd, const char *name, const char *default_val, const char *summary, const char *description, const char *validsettings, validate_string_t validate_fn, set_string_t set_fn, get_string_t get_fn)
    695 {
    696   owl_variable *var = owl_variable_newvar(OWL_VARIABLE_STRING, name, summary,
    697                                           description, validsettings);
    698   var->takes_on_off = false;
    699   var->get_fn = G_CALLBACK(get_fn ? get_fn : owl_variable_string_get_default);
    700   var->set_fn = G_CALLBACK(set_fn ? set_fn : owl_variable_string_set_default);
    701   var->validate_fn = G_CALLBACK(validate_fn ? validate_fn : owl_variable_string_validate_default);
    702 
    703   var->get_tostring_fn = owl_variable_make_closure(
    704       var, G_CALLBACK(owl_variable_string_get_tostring_default),
    705       g_cclosure_user_marshal_STRING__VOID);
    706   var->set_fromstring_fn = owl_variable_make_closure(
    707       var, G_CALLBACK(owl_variable_string_set_fromstring_default),
    708       g_cclosure_user_marshal_INT__STRING);
    709 
    710   g_value_init(&var->val, G_TYPE_STRING);
    711   owl_variable_set_string(var, default_val);
    712 
    713   var->default_str = owl_variable_get_tostring(var);
    714   owl_variable_dict_add_variable(vd, var);
    715 }
    716 
    717 void owl_variable_dict_newvar_string(owl_vardict *vd, const char *name, const char *default_val, const char *summary, const char *description) {
    718   owl_variable_dict_newvar_string_full(vd, name, default_val, summary, description,
    719                                        "<string>", NULL, NULL, NULL);
    720 }
    721 
    722 void owl_variable_dict_newvar_path(owl_vardict *vd, const char *name, const char *default_val, const char *summary, const char *description) {
    723   owl_variable_dict_newvar_string_full(vd, name, default_val, summary, description,
    724                                        "<path>", NULL, NULL, NULL);
    725 }
    726 
    727 static void owl_variable_dict_newvar_enum_full(owl_vardict *vd, const char *name, int default_val, const char *summary, const char *description, const char *validsettings, validate_int_t validate_fn, set_int_t set_fn, get_int_t get_fn)
    728 {
    729   owl_variable *var = owl_variable_newvar(OWL_VARIABLE_INT, name, summary,
    730                                           description, validsettings);
    731   var->takes_on_off = false;
    732   var->get_fn = G_CALLBACK(get_fn ? get_fn : owl_variable_int_get_default);
    733   var->set_fn = G_CALLBACK(set_fn ? set_fn : owl_variable_int_set_default);
    734   var->validate_fn = G_CALLBACK(validate_fn ? validate_fn : owl_variable_enum_validate);
    735 
    736   var->get_tostring_fn = owl_variable_make_closure(
    737       var, G_CALLBACK(owl_variable_enum_get_tostring),
    738       g_cclosure_user_marshal_STRING__VOID);
    739   var->set_fromstring_fn = owl_variable_make_closure(
    740       var, G_CALLBACK(owl_variable_enum_set_fromstring),
    741       g_cclosure_user_marshal_INT__STRING);
    742 
    743   g_value_init(&var->val, G_TYPE_INT);
    744   owl_variable_set_int(var, default_val);
    745 
    746   var->default_str = owl_variable_get_tostring(var);
    747   owl_variable_dict_add_variable(vd, var);
    748 }
    749 
    750 void owl_variable_dict_newvar_enum(owl_vardict *vd, const char *name, int default_val, const char *summary, const char *description, const char *validset) {
    751   owl_variable_dict_newvar_enum_full(vd, name, default_val, summary, description,
    752                                      validset, NULL, NULL, NULL);
    753 }
    754 
    755 void owl_variable_dict_newvar_other(owl_vardict *vd, const char *name, const char *summary, const char *description, const char *validsettings, bool takes_on_off, GClosure *get_tostring_fn, GClosure *set_fromstring_fn)
    756 {
    757   owl_variable *var = owl_variable_newvar(OWL_VARIABLE_OTHER, name, summary,
    758                                           description, validsettings);
    759   var->takes_on_off = takes_on_off;
    760 
    761   var->get_tostring_fn = g_closure_ref(get_tostring_fn);
    762   g_closure_sink(get_tostring_fn);
    763 
    764   var->set_fromstring_fn = g_closure_ref(set_fromstring_fn);
    765   g_closure_sink(set_fromstring_fn);
    766 
    767   var->default_str = owl_variable_get_tostring(var);
    768 
    769   /* Note: this'll overwrite any existing variable of that name, even a C one,
    770      but it's consistent with previous behavior and commands. */
    771   owl_variable_dict_add_variable(vd, var);
     653void owl_variable_update(owl_variable *var, const char *summary, const char *desc) {
     654  g_free(var->summary);
     655  var->summary = g_strdup(summary);
     656  g_free(var->description);
     657  var->description = g_strdup(desc);
     658}
     659
     660void owl_variable_dict_newvar_string(owl_vardict *vd, const char *name, const char *summ, const char *desc, const char *initval)
     661{
     662  owl_variable *old = owl_variable_get_var(vd, name);
     663  if (old && owl_variable_get_type(old) == OWL_VARIABLE_STRING) {
     664    owl_variable_update(old, summ, desc);
     665    g_free(old->pval_default);
     666    old->pval_default = g_strdup(initval);
     667  } else {
     668    owl_variable * var = owl_variable_newvar(name, summ, desc);
     669    var->type = OWL_VARIABLE_STRING;
     670    var->validsettings = "<string>";
     671    var->pval_default = g_strdup(initval);
     672    var->set_fn = owl_variable_string_set_default;
     673    var->set_fromstring_fn = owl_variable_string_set_fromstring_default;
     674    var->get_fn = owl_variable_get_default;
     675    var->get_tostring_fn = owl_variable_string_get_tostring_default;
     676    var->delete_fn = owl_variable_delete_default;
     677    var->set_fn(var, initval);
     678    owl_variable_dict_add_variable(vd, var);
     679  }
     680}
     681
     682void owl_variable_dict_newvar_int(owl_vardict *vd, const char *name, const char *summ, const char *desc, int initval)
     683{
     684  owl_variable *old = owl_variable_get_var(vd, name);
     685  if (old && owl_variable_get_type(old) == OWL_VARIABLE_INT) {
     686    owl_variable_update(old, summ, desc);
     687    old->ival_default = initval;
     688  } else {
     689    owl_variable * var = owl_variable_newvar(name, summ, desc);
     690    var->type = OWL_VARIABLE_INT;
     691    var->validsettings = "<int>";
     692    var->ival_default = initval;
     693    var->validate_fn = owl_variable_int_validate_default;
     694    var->set_fn = owl_variable_int_set_default;
     695    var->set_fromstring_fn = owl_variable_int_set_fromstring_default;
     696    var->get_fn = owl_variable_get_default;
     697    var->get_tostring_fn = owl_variable_int_get_tostring_default;
     698    var->delete_fn = owl_variable_delete_default;
     699    var->val = g_new(int, 1);
     700    var->set_fn(var, &initval);
     701    owl_variable_dict_add_variable(vd, var);
     702  }
     703}
     704
     705void owl_variable_dict_newvar_bool(owl_vardict *vd, const char *name, const char *summ, const char *desc, int initval)
     706{
     707  owl_variable *old = owl_variable_get_var(vd, name);
     708  if (old && owl_variable_get_type(old) == OWL_VARIABLE_BOOL) {
     709    owl_variable_update(old, summ, desc);
     710    old->ival_default = initval;
     711  } else {
     712    owl_variable * var = owl_variable_newvar(name, summ, desc);
     713    var->type = OWL_VARIABLE_BOOL;
     714    var->validsettings = "on,off";
     715    var->ival_default = initval;
     716    var->validate_fn = owl_variable_bool_validate_default;
     717    var->set_fn = owl_variable_bool_set_default;
     718    var->set_fromstring_fn = owl_variable_bool_set_fromstring_default;
     719    var->get_fn = owl_variable_get_default;
     720    var->get_tostring_fn = owl_variable_bool_get_tostring_default;
     721    var->delete_fn = owl_variable_delete_default;
     722    var->val = g_new(int, 1);
     723    var->set_fn(var, &initval);
     724    owl_variable_dict_add_variable(vd, var);
     725  }
    772726}
    773727
     
    781735}
    782736
    783 void owl_variable_delete(owl_variable *v)
    784 {
     737void owl_variable_cleanup(owl_variable *v)
     738{
     739  if (v->delete_fn) v->delete_fn(v);
    785740  g_free(v->name);
    786741  g_free(v->summary);
    787742  g_free(v->description);
    788   g_free(v->default_str);
    789   g_free(v->validsettings);
    790   if (v->type != OWL_VARIABLE_OTHER)
    791     g_value_unset(&(v->val));
    792   g_closure_unref(v->get_tostring_fn);
    793   g_closure_unref(v->set_fromstring_fn);
    794 
    795   g_slice_free(owl_variable, v);
     743  if (v->type == OWL_VARIABLE_STRING)
     744    g_free(v->pval_default);
     745}
     746
     747void owl_variable_delete(owl_variable *v)
     748{
     749  owl_variable_cleanup(v);
     750  g_free(v);
    796751}
    797752
     
    818773  return v->type;
    819774}
     775
     776/* functions for getting and setting variable values */
    820777
    821778/* returns 0 on success, prints a status msg if msg is true */
    822779int owl_variable_set_fromstring(owl_variable *v, const char *value, int msg) {
    823780  char *tostring;
    824   GValue values[] = {G_VALUE_INIT, G_VALUE_INIT};
    825   GValue return_box = G_VALUE_INIT;
    826   int set_successfully;
    827 
    828   g_value_init(&values[0], G_TYPE_POINTER);
    829   g_value_set_pointer(&values[0], NULL);
    830   g_value_init(&values[1], G_TYPE_STRING);
    831   g_value_set_static_string(&values[1], value);
    832   g_value_init(&return_box, G_TYPE_INT);
    833   g_closure_invoke(v->set_fromstring_fn, &return_box, 2, values, NULL);
    834 
    835   set_successfully = g_value_get_int(&return_box);
    836   if (0 != set_successfully) {
     781  if (!v->set_fromstring_fn) {
     782    if (msg) owl_function_error("Variable %s is read-only", owl_variable_get_name(v));
     783    return -1;   
     784  }
     785  if (0 != v->set_fromstring_fn(v, value)) {
    837786    if (msg) owl_function_error("Unable to set %s (must be %s)", owl_variable_get_name(v),
    838787                                owl_variable_get_validsettings(v));
    839   } else if (msg) {
    840     tostring = owl_variable_get_tostring(v);
    841     if (tostring) {
     788    return -1;
     789  }
     790  if (msg) {
     791    tostring = v->get_tostring_fn(v, v->get_fn(v));
     792    if (tostring)
    842793      owl_function_makemsg("%s = '%s'", owl_variable_get_name(v), tostring);
    843     } else {
     794    else
    844795      owl_function_makemsg("%s = <null>", owl_variable_get_name(v));
    845     }
    846796    g_free(tostring);
    847   }
    848 
    849   g_value_unset(&return_box);
    850   g_value_unset(&values[1]);
    851   g_value_unset(&values[0]);
    852   return set_successfully;
     797  }   
     798  return 0;
    853799}
    854800 
    855801int owl_variable_set_string(owl_variable *v, const char *newval)
    856802{
    857   g_return_val_if_fail(v->type == OWL_VARIABLE_STRING, -1);
    858 
    859   set_string_t cb = (set_string_t) v->set_fn;
    860   return cb(v, newval);
    861 }
    862 
     803  if (v->type != OWL_VARIABLE_STRING) return -1;
     804  return v->set_fn(v, newval);
     805}
     806 
    863807int owl_variable_set_int(owl_variable *v, int newval)
    864808{
    865   g_return_val_if_fail(v->type == OWL_VARIABLE_INT, -1);
    866 
    867   set_int_t cb = (set_int_t) v->set_fn;
    868   return cb(v, newval);
    869 }
    870 
    871 int owl_variable_set_bool(owl_variable *v, bool newval) {
    872   g_return_val_if_fail(v->type == OWL_VARIABLE_BOOL, -1);
    873 
    874   set_bool_t cb = (set_bool_t) v->set_fn;
    875   return cb(v, newval);
    876 }
    877 
     809  if (v->type != OWL_VARIABLE_INT && v->type != OWL_VARIABLE_BOOL) return -1;
     810  return v->set_fn(v, &newval);
     811}
     812 
    878813int owl_variable_set_bool_on(owl_variable *v)
    879814{
    880815  if (v->type != OWL_VARIABLE_BOOL) return -1;
    881   return owl_variable_set_bool(v, true);
     816  return owl_variable_set_int(v, true);
    882817}
    883818
     
    885820{
    886821  if (v->type != OWL_VARIABLE_BOOL) return -1;
    887   return owl_variable_set_bool(v, false);
     822  return owl_variable_set_int(v, false);
    888823}
    889824
    890825CALLER_OWN char *owl_variable_get_tostring(const owl_variable *v)
    891826{
    892   GValue instance = G_VALUE_INIT;
    893   GValue tostring_box = G_VALUE_INIT;
    894   char *ret = NULL;
    895 
    896   g_value_init(&instance, G_TYPE_POINTER);
    897   g_value_set_pointer(&instance, NULL);
    898   g_value_init(&tostring_box, G_TYPE_STRING);
    899   g_closure_invoke(v->get_tostring_fn, &tostring_box, 1, &instance, NULL);
    900 
    901   ret = g_value_dup_string(&tostring_box);
    902 
    903   g_value_unset(&tostring_box);
    904   g_value_unset(&instance);
    905   return ret;
    906 }
    907 
    908 const char *owl_variable_get_default_tostring(const owl_variable *v)
    909 {
    910   return v->default_str;
     827  return v->get_tostring_fn(v, v->get_fn(v));
     828}
     829
     830CALLER_OWN char *owl_variable_get_default_tostring(const owl_variable *v)
     831{
     832  if (v->type == OWL_VARIABLE_INT || v->type == OWL_VARIABLE_BOOL) {
     833    return v->get_tostring_fn(v, &(v->ival_default));
     834  } else {
     835    return v->get_tostring_fn(v, v->pval_default);
     836  }
    911837}
    912838
     
    916842}
    917843
     844/* returns a reference */
     845const void *owl_variable_get(const owl_variable *v)
     846{
     847  return v->get_fn(v);
     848}
     849
    918850const char *owl_variable_get_string(const owl_variable *v)
    919851{
    920   g_return_val_if_fail(v->type == OWL_VARIABLE_STRING, NULL);
    921 
    922   get_string_t cb = (get_string_t) v->get_fn;
    923   return cb(v);
     852  if (owl_variable_get_type(v) != OWL_VARIABLE_STRING) {
     853    owl_function_error("Variable '%s' is not a string.", owl_variable_get_name(v));
     854    return NULL;
     855  }
     856  return owl_variable_get(v);
     857}
     858
     859/* returns a reference */
     860const void *owl_variable_get_other(const owl_variable *v)
     861{
     862  if (owl_variable_get_type(v) != OWL_VARIABLE_OTHER) {
     863    owl_function_error("Variable '%s' is not type other.", owl_variable_get_name(v));
     864    return NULL;
     865  }
     866  return owl_variable_get(v);
    924867}
    925868
    926869int owl_variable_get_int(const owl_variable *v)
    927870{
    928   g_return_val_if_fail(v->type == OWL_VARIABLE_INT, 0);
    929 
    930   get_int_t cb = (get_int_t) v->get_fn;
    931   return cb(v);
    932 }
    933 
    934 bool owl_variable_get_bool(const owl_variable *v)
    935 {
    936   g_return_val_if_fail(v->type == OWL_VARIABLE_BOOL, FALSE);
    937 
    938   get_bool_t cb = (get_bool_t) v->get_fn;
    939   return cb(v);
     871  if (owl_variable_get_type(v) != OWL_VARIABLE_INT) {
     872    owl_function_error("Variable '%s' is an int.", owl_variable_get_name(v));
     873    return -1;
     874  }
     875  const int *pi = owl_variable_get(v);
     876  if (!pi) return -1;
     877  return *pi;
     878}
     879
     880int owl_variable_get_bool(const owl_variable *v)
     881{
     882  if (owl_variable_get_type(v) != OWL_VARIABLE_BOOL) {
     883    owl_function_error("Variable '%s' is a boolean.", owl_variable_get_name(v));
     884    return -1;
     885  }
     886  const int *pi = owl_variable_get(v);
     887  if (!pi) return -1;
     888  return *pi;
    940889}
    941890
    942891void owl_variable_describe(const owl_variable *v, owl_fmtext *fm)
    943892{
    944   const char *default_str = owl_variable_get_default_tostring(v);
     893  char *tostring = owl_variable_get_default_tostring(v);
    945894  char *default_buf;
    946895
    947   if (default_str)
    948     default_buf = g_strdup_printf("'%s'", default_str);
     896  if (tostring)
     897    default_buf = g_strdup_printf("'%s'", tostring);
    949898  else
    950899    default_buf = g_strdup("<null>");
     
    953902                            owl_variable_get_summary(v), default_buf);
    954903  g_free(default_buf);
     904  g_free(tostring);
    955905}
    956906
    957907void owl_variable_get_help(const owl_variable *v, owl_fmtext *fm) {
    958908  char *tostring;
    959   const char *default_str;
    960909
    961910  owl_fmtext_append_bold(fm, "OWL VARIABLE\n\n");
     
    972921  owl_fmtext_append_normal(fm, "\n\n");
    973922
    974   default_str = owl_variable_get_default_tostring(v);
     923
     924  tostring = owl_variable_get_default_tostring(v);
    975925  owl_fmtext_append_normal(fm, "Default:        ");
    976   owl_fmtext_append_normal(fm, (default_str ? default_str : "<null>"));
     926  owl_fmtext_append_normal(fm, (tostring ? tostring : "<null>"));
    977927  owl_fmtext_append_normal(fm, "\n\n");
    978928
     
    986936    owl_fmtext_append_normal(fm, "\n\n");
    987937  }
     938  g_free(tostring);
    988939}
    989940
     
    997948/* default common functions */
    998949
    999 const char *owl_variable_string_get_default(const owl_variable *v) {
    1000   return g_value_get_string(&(v->val));
    1001 }
    1002 
    1003 int owl_variable_int_get_default(const owl_variable *v) {
    1004   return g_value_get_int(&(v->val));
    1005 }
    1006 
    1007 bool owl_variable_bool_get_default(const owl_variable *v) {
    1008   return g_value_get_boolean(&(v->val));
     950const void *owl_variable_get_default(const owl_variable *v) {
     951  return v->val;
     952}
     953
     954void owl_variable_delete_default(owl_variable *v)
     955{
     956  g_free(v->val);
    1009957}
    1010958
    1011959/* default functions for booleans */
    1012960
    1013 int owl_variable_bool_validate_default(const owl_variable *v, bool newval) {
    1014   return (newval == 1) || (newval == 0);
    1015 }
    1016 
    1017 int owl_variable_bool_set_default(owl_variable *v, bool newval) {
    1018   if (!((validate_bool_t)v->validate_fn)(v, newval))
    1019     return -1;
    1020 
    1021   g_value_set_boolean(&(v->val), newval);
     961int owl_variable_bool_validate_default(const owl_variable *v, const void *newval) {
     962  if (newval == NULL) return(0);
     963  else if (*(const int*)newval==1 || *(const int*)newval==0) return(1);
     964  else return (0);
     965}
     966
     967int owl_variable_bool_set_default(owl_variable *v, const void *newval) {
     968  if (v->validate_fn) {
     969    if (!v->validate_fn(v, newval)) return(-1);
     970  }
     971  *(int*)v->val = *(const int*)newval;
    1022972  return(0);
    1023973}
    1024974
    1025 int owl_variable_bool_set_fromstring_default(owl_variable *v, const char *newval, void *dummy) {
    1026   bool i;
    1027   if (!strcmp(newval, "on")) {
    1028     i = true;
    1029   } else if (!strcmp(newval, "off")) {
    1030     i = false;
    1031   } else {
    1032     return(-1);
    1033   }
    1034 
    1035   return owl_variable_set_bool(v, i);
    1036 }
    1037 
    1038 CALLER_OWN char *owl_variable_bool_get_tostring_default(const owl_variable *v, void *dummy)
    1039 {
    1040   bool val = owl_variable_get_bool(v);
    1041   if (val == 0) {
     975int owl_variable_bool_set_fromstring_default(owl_variable *v, const char *newval) {
     976  int i;
     977  if (!strcmp(newval, "on")) i=1;
     978  else if (!strcmp(newval, "off")) i=0;
     979  else return(-1);
     980  return (v->set_fn(v, &i));
     981}
     982
     983CALLER_OWN char *owl_variable_bool_get_tostring_default(const owl_variable *v, const void *val)
     984{
     985  if (val == NULL) {
     986    return NULL;
     987  } else if (*(const int*)val == 0) {
    1042988    return g_strdup("off");
    1043   } else if (val == 1) {
     989  } else if (*(const int*)val == 1) {
    1044990    return g_strdup("on");
    1045991  } else {
     
    1050996/* default functions for integers */
    1051997
    1052 int owl_variable_int_validate_default(const owl_variable *v, int newval)
    1053 {
    1054   return (1);
    1055 }
    1056 
    1057 int owl_variable_int_set_default(owl_variable *v, int newval) {
    1058   if (!((validate_int_t)v->validate_fn)(v, newval))
    1059     return -1;
    1060 
    1061   g_value_set_int(&(v->val), newval);
     998int owl_variable_int_validate_default(const owl_variable *v, const void *newval) {
     999  if (newval == NULL) return(0);
     1000  else return (1);
     1001}
     1002
     1003int owl_variable_int_set_default(owl_variable *v, const void *newval) {
     1004  if (v->validate_fn) {
     1005    if (!v->validate_fn(v, newval)) return(-1);
     1006  }
     1007  *(int*)v->val = *(const int*)newval;
    10621008  return(0);
    10631009}
    10641010
    1065 int owl_variable_int_set_fromstring_default(owl_variable *v, const char *newval, void *dummy) {
     1011int owl_variable_int_set_fromstring_default(owl_variable *v, const char *newval) {
    10661012  int i;
    10671013  char *ep;
    10681014  i = strtol(newval, &ep, 10);
    10691015  if (*ep || ep==newval) return(-1);
    1070   return owl_variable_set_int(v, i);
    1071 }
    1072 
    1073 CALLER_OWN char *owl_variable_int_get_tostring_default(const owl_variable *v, void *dummy)
    1074 {
    1075   return g_strdup_printf("%d", owl_variable_get_int(v));
     1016  return (v->set_fn(v, &i));
     1017}
     1018
     1019CALLER_OWN char *owl_variable_int_get_tostring_default(const owl_variable *v, const void *val)
     1020{
     1021  if (val == NULL) {
     1022    return NULL;
     1023  } else {
     1024    return g_strdup_printf("%d", *(const int*)val);
     1025  }
    10761026}
    10771027
    10781028/* default functions for enums (a variant of integers) */
    10791029
    1080 int owl_variable_enum_validate(const owl_variable *v, int newval) {
     1030int owl_variable_enum_validate(const owl_variable *v, const void *newval) { 
    10811031  char **enums;
    10821032  int nenums, val;
     1033  if (newval == NULL) return(0);
    10831034  enums = g_strsplit_set(v->validsettings, ",", 0);
    10841035  nenums = g_strv_length(enums);
    10851036  g_strfreev(enums);
    1086   val = newval;
     1037  val = *(const int*)newval;
    10871038  if (val < 0 || val >= nenums) {
    10881039    return(0);
     
    10911042}
    10921043
    1093 int owl_variable_enum_set_fromstring(owl_variable *v, const char *newval, void *dummy) {
     1044int owl_variable_enum_set_fromstring(owl_variable *v, const char *newval) {
    10941045  char **enums;
    10951046  int i, val=-1;
     
    11031054  g_strfreev(enums);
    11041055  if (val == -1) return(-1);
    1105   return owl_variable_set_int(v, val);
    1106 }
    1107 
    1108 CALLER_OWN char *owl_variable_enum_get_tostring(const owl_variable *v, void *dummy)
     1056  return (v->set_fn(v, &val));
     1057}
     1058
     1059CALLER_OWN char *owl_variable_enum_get_tostring(const owl_variable *v, const void *val)
    11091060{
    11101061  char **enums;
     
    11121063  char *tostring;
    11131064
     1065  if (val == NULL) {
     1066    return NULL;
     1067  }
    11141068  enums = g_strsplit_set(v->validsettings, ",", 0);
    11151069  nenums = g_strv_length(enums);
    1116   i = owl_variable_get_int(v);
     1070  i = *(const int*)val;
    11171071  if (i<0 || i>=nenums) {
    11181072    g_strfreev(enums);
     
    11261080/* default functions for stringeans */
    11271081
    1128 int owl_variable_string_validate_default(const owl_variable *v, const char *newval) {
     1082int owl_variable_string_validate_default(const struct _owl_variable *v, const void *newval) {
    11291083  if (newval == NULL) return(0);
    11301084  else return (1);
    11311085}
    11321086
    1133 int owl_variable_string_set_default(owl_variable *v, const char *newval) {
    1134   if (!((validate_string_t)v->validate_fn)(v, newval))
    1135     return -1;
    1136 
    1137   g_value_set_string(&(v->val), newval);
     1087int owl_variable_string_set_default(owl_variable *v, const void *newval) {
     1088  if (v->validate_fn) {
     1089    if (!v->validate_fn(v, newval)) return(-1);
     1090  }
     1091  g_free(v->val);
     1092  v->val = g_strdup(newval);
    11381093  return(0);
    11391094}
    11401095
    1141 int owl_variable_string_set_fromstring_default(owl_variable *v, const char *newval, void *dummy)
    1142 {
    1143   return owl_variable_set_string(v, newval);
    1144 }
    1145 
    1146 CALLER_OWN char *owl_variable_string_get_tostring_default(const owl_variable *v, void *dummy)
    1147 {
    1148   return g_strdup(owl_variable_get_string(v));
    1149 }
    1150 
     1096int owl_variable_string_set_fromstring_default(owl_variable *v, const char *newval) {
     1097  return (v->set_fn(v, newval));
     1098}
     1099
     1100CALLER_OWN char *owl_variable_string_get_tostring_default(const owl_variable *v, const void *val)
     1101{
     1102  return g_strdup((const char*)val);
     1103}
     1104
  • view.c

    r219f52c rf271129  
    66  v->filter=f;
    77  v->style=s;
    8   v->ml = owl_messagelist_new();
     8  owl_messagelist_create(&(v->ml));
    99  owl_view_recalculate(v);
    1010}
     
    1919{
    2020  if (owl_filter_message_match(v->filter, m)) {
    21     owl_messagelist_append_element(v->ml, m);
     21    owl_messagelist_append_element(&(v->ml), m);
    2222  }
    2323}
     
    3030  int i, j;
    3131  const owl_messagelist *gml;
     32  owl_messagelist *ml;
    3233  owl_message *m;
    3334
    3435  gml=owl_global_get_msglist(&g);
     36  ml=&(v->ml);
    3537
    3638  /* nuke the old list, don't free the messages */
    37   owl_messagelist_delete(v->ml, false);
    38   v->ml = owl_messagelist_new();
     39  owl_messagelist_cleanup(ml, false);
     40  owl_messagelist_create(&(v->ml));
    3941
    4042  /* find all the messages we want */
     
    4345    m=owl_messagelist_get_element(gml, i);
    4446    if (owl_filter_message_match(v->filter, m)) {
    45       owl_messagelist_append_element(v->ml, m);
     47      owl_messagelist_append_element(ml, m);
    4648    }
    4749  }
     
    7072owl_message *owl_view_get_element(const owl_view *v, int index)
    7173{
    72   return owl_messagelist_get_element(v->ml, index);
     74  return(owl_messagelist_get_element(&(v->ml), index));
    7375}
    7476
    7577void owl_view_delete_element(owl_view *v, int index)
    7678{
    77   owl_messagelist_delete_element(v->ml, index);
     79  owl_messagelist_delete_element(&(v->ml), index);
    7880}
    7981
    8082void owl_view_undelete_element(owl_view *v, int index)
    8183{
    82   owl_messagelist_undelete_element(v->ml, index);
     84  owl_messagelist_undelete_element(&(v->ml), index);
    8385}
    8486
    8587int owl_view_get_size(const owl_view *v)
    8688{
    87   return owl_messagelist_get_size(v->ml);
     89  return(owl_messagelist_get_size(&(v->ml)));
    8890}
    8991
     
    156158void owl_view_cleanup(owl_view *v)
    157159{
    158   owl_messagelist_delete(v->ml, false);
     160  owl_messagelist_cleanup(&v->ml, false);
    159161  g_free(v->name);
    160162}
  • viewwin.c

    r7dcef03 rf271129  
    1313CALLER_OWN owl_viewwin *owl_viewwin_new_text(owl_window *win, const char *text)
    1414{
    15   owl_viewwin *v = g_slice_new0(owl_viewwin);
     15  owl_viewwin *v = g_new0(owl_viewwin, 1);
    1616  owl_fmtext_init_null(&(v->fmtext));
    1717  if (text) {
     
    3636{
    3737  char *text;
    38   owl_viewwin *v = g_slice_new0(owl_viewwin);
     38  owl_viewwin *v = g_new0(owl_viewwin, 1);
    3939
    4040  owl_fmtext_copy(&(v->fmtext), fmtext);
     
    158158} owl_viewwin_search_data;
    159159
    160 static void owl_viewwin_callback_search(owl_editwin *e, bool success)
    161 {
    162   if (!success) return;
     160static void owl_viewwin_callback_search(owl_editwin *e)
     161{
    163162  int consider_current = false;
    164163  const char *line = owl_editwin_get_text(e);
     
    424423  g_object_unref(v->status);
    425424  owl_fmtext_cleanup(&(v->fmtext));
    426   g_slice_free(owl_viewwin, v);
    427 }
     425  g_free(v);
     426}
  • window.c

    r3442788 rf271129  
    397397}
    398398
    399 static owl_window *_get_cursor(bool *is_default)
    400 {
    401   *is_default = false;
     399static owl_window *_get_cursor(void)
     400{
    402401  if (cursor_owner && owl_window_is_realized(cursor_owner))
    403402    return cursor_owner;
    404   *is_default = true;
    405403  if (default_cursor && owl_window_is_realized(default_cursor))
    406404    return default_cursor;
     
    443441}
    444442
    445 static bool _owl_window_is_subtree_dirty(owl_window *w)
    446 {
    447   owl_window *child;
    448 
    449   if (w->dirty)
    450     return true;
    451   for (child = w->child;
    452        child != NULL;
    453        child = child->next) {
    454     if (child->dirty_subtree)
    455       return true;
    456   }
    457   return false;
    458 }
    459 
    460443static void _owl_window_redraw_subtree(owl_window *w)
    461444{
    462445  FuncOneArg ptr = (FuncOneArg)_owl_window_redraw_subtree;
    463 
    464446  if (!w->dirty_subtree)
    465447    return;
    466 
    467448  _owl_window_redraw(w);
    468449  owl_window_children_foreach(w, first_arg_only, &ptr);
    469 
    470   /* Clear the dirty_subtree bit, unless a child doesn't have it
    471    * cleared because we dirtied a window in redraw. Dirtying a
    472    * non-descendant window during a redraw handler is
    473    * discouraged. Redraw will not break, but it is undefined whether
    474    * the dirty is delayed to the next event loop iteration. */
    475   if (_owl_window_is_subtree_dirty(w)) {
    476     owl_function_debugmsg("subtree still dirty after one iteration!");
    477   } else {
    478     w->dirty_subtree = 0;
    479   }
     450  w->dirty_subtree = 0;
    480451}
    481452
     
    488459  owl_window *cursor;
    489460  owl_window *screen = owl_window_get_screen();
    490   bool default_cursor;
    491461
    492462  if (!screen->dirty_subtree)
     
    494464  _owl_window_redraw_subtree(screen);
    495465  update_panels();
    496   cursor = _get_cursor(&default_cursor);
     466  cursor = _get_cursor();
    497467  if (cursor && cursor->win) {
    498     /* If supported, hide the default cursor. */
    499     curs_set(default_cursor ? 0 : 1);
    500468    /* untouch it to avoid drawing; window should be clean now, but we must
    501469     * clean up in case there was junk left over on a subwin (cleaning up after
  • zcrypt.c

    rca1fb26a rc6332f5  
    1616#include <sys/wait.h>
    1717#include <ctype.h>
    18 #include <limits.h>
    19 #include <getopt.h>
    20 
    21 #include <config.h>
     18
     19#include "config.h"
    2220
    2321#ifdef HAVE_KERBEROS_IV
     
    2826
    2927#include "filterproc.h"
    30 
    31 extern const char *version;
    3228
    3329/* Annotate functions in which the caller owns the return value and is
     
    110106}
    111107
    112 void usage(FILE *file, const char *progname)
    113 {
    114   fprintf(file, "Usage: %s [-Z|-D|-E|-R|-S] [-F Keyfile] [-c class] [-i instance]\n", progname);
    115   fprintf(file, "       [-advqtluon] [-s signature] [-f arg] [-m message]\n");
    116   fprintf(file, "  One or more of class, instance, and keyfile must be specified.\n");
    117 }
    118 
    119108int main(int argc, char *argv[])
    120109{
     
    127116  int mode = M_NONE;
    128117
    129   int c;
     118  char c;
    130119
    131120  int messageflag = FALSE;
     
    133122  zoptions.flags = 0;
    134123
    135   enum {
    136     OPT_VERSION = CHAR_MAX + 1,
    137     OPT_HELP,
    138   };
    139   static const struct option options[] = {
    140     {"version", no_argument, NULL, OPT_VERSION},
    141     {"help", no_argument, NULL, OPT_HELP},
    142     {NULL, 0, NULL, 0}
    143   };
    144 
    145   while ((c = getopt_long(argc, argv, "ZDERSF:c:i:advqtluons:f:m", options, NULL)) != -1)
     124  while ((c = getopt(argc, argv, "ZDERSF:c:i:advqtluons:f:m")) != (char)EOF)
    146125  {
    147126    switch(c)
    148127    {
    149       case OPT_VERSION:
    150         /* Version */
    151         printf("This is zcrypt version %s\n", version);
    152         exit(0);
    153       case OPT_HELP:
    154         /* Help */
    155         usage(stdout, argv[0]);
    156         exit(0);
    157128      case 'Z':
    158129        /* Zephyr encrypt */
     
    286257  if (error || !cryptspec)
    287258  {
    288     usage(stderr, argv[0]);
     259    fprintf(stderr, "Usage: %s [-Z|-D|-E|-R|-S] [-F Keyfile] [-c class] [-i instance]\n", argv[0]);
     260    fprintf(stderr, "       [-advqtluon] [-s signature] [-f arg] [-m message]\n");
     261    fprintf(stderr, "  One or more of class, instance, and keyfile must be specified.\n");
    289262    exit(1);
    290263  }
     
    793766    "gpg",
    794767    "--symmetric",
    795     "--no-options",
    796     "--no-default-keyring",
    797     "--keyring", "/dev/null",
    798     "--secret-keyring", "/dev/null",
    799768    "--batch",
    800769    "--quiet",
     
    805774    NULL
    806775  };
    807   err = call_filter(argv, in, &out, &status);
     776  err = call_filter("gpg", argv, in, &out, &status);
    808777  if(err || status) {
    809778    g_free(out);
     
    877846    "gpg",
    878847    "--decrypt",
    879     "--no-options",
    880     "--no-default-keyring",
    881     "--keyring", "/dev/null",
    882     "--secret-keyring", "/dev/null",
    883848    "--batch",
    884849    "--no-use-agent",
     
    892857  if(!in) return FALSE;
    893858
    894   err = call_filter(argv, in, &out, &status);
    895   free(in);
     859  err = call_filter("gpg", argv, in, &out, &status);
    896860  if(err || status) {
    897861    g_free(out);
  • zephyr.c

    r7dcef03 rf271129  
    2929#define HM_SVC_FALLBACK         htons((unsigned short) 2104)
    3030
    31 static CALLER_OWN char *owl_zephyr_dotfile(const char *name, const char *input)
     31static char *owl_zephyr_dotfile(const char *name, const char *input)
    3232{
    3333  if (input != NULL)
     
    125125    owl_zephyr_loadsubs_helper(subs->subs, subs->nsubs);
    126126    deferred_subs = g_list_delete_link(deferred_subs, deferred_subs);
    127     g_slice_free(owl_sub_list, subs);
     127    g_free(subs);
    128128  }
    129129
     
    152152  ret_sd = owl_zephyr_loaddefaultsubs();
    153153
    154   /* load BarnOwl default subscriptions */
     154  /* load Barnowl default subscriptions */
    155155  ret_bd = owl_zephyr_loadbarnowldefaultsubs();
    156156
     
    261261    g_free(subs);
    262262  } else {
    263     owl_sub_list *s = g_slice_new(owl_sub_list);
     263    owl_sub_list *s = g_new(owl_sub_list, 1);
    264264    s->subs = subs;
    265265    s->nsubs = count;
     
    291291  struct stat statbuff;
    292292
     293  subs = g_new(ZSubscription_t, subSize);
    293294  subsfile = owl_zephyr_dotfile(".zephyr.subs", filename);
    294295
     
    306307  if (!file)
    307308    return -1;
    308 
    309   subs = g_new(ZSubscription_t, subSize);
    310309  while (owl_getline(&buffer, file)) {
    311310    if (buffer[0] == '#' || buffer[0] == '\n')
     
    354353}
    355354
    356 /* Load default BarnOwl subscriptions
     355/* Load default Barnowl subscriptions
    357356 *
    358357 * Returns 0 on success.
     
    363362#ifdef HAVE_LIBZEPHYR
    364363  ZSubscription_t *subs;
    365   int subSize = 10; /* Max BarnOwl default subs we allow */
     364  int subSize = 10; /* Max Barnowl default subs we allow */
    366365  int count, ret;
    367366
     
    455454}
    456455
    457 bool unsuball(void)
     456void unsuball(void)
    458457{
    459458#if HAVE_LIBZEPHYR
     
    465464    owl_function_error("Zephyr: Cancelling subscriptions: %s",
    466465                       error_message(ret));
    467   return (ret == ZERR_NONE);
    468 #endif
    469   return true;
     466#endif
    470467}
    471468
     
    519516}
    520517
    521 #ifdef HAVE_LIBZEPHYR
    522 const char *owl_zephyr_first_raw_field(const ZNotice_t *n)
    523 {
     518/* return a pointer to the data in the Jth field, (NULL terminated by
     519 * definition).  Caller must free the return.
     520 */
     521#ifdef HAVE_LIBZEPHYR
     522CALLER_OWN char *owl_zephyr_get_field(const ZNotice_t *n, int j)
     523{
     524  int i, count, save;
     525
     526  /* If there's no message here, just run along now */
    524527  if (n->z_message_len == 0)
    525     return NULL;
    526   return n->z_message;
    527 }
    528 
    529 const char *owl_zephyr_next_raw_field(const ZNotice_t *n, const char *f)
    530 {
    531   const char *end = n->z_message + n->z_message_len;
    532   f = memchr(f, '\0', end - f);
    533   if (f == NULL)
    534     return NULL;
    535   return f + 1;
    536 }
    537 
    538 const char *owl_zephyr_get_raw_field(const ZNotice_t *n, int j)
    539 {
    540   int i;
    541   const char *f;
    542   for (i = 1, f = owl_zephyr_first_raw_field(n); i < j && f != NULL;
    543        i++, f = owl_zephyr_next_raw_field(n, f))
    544     ;
    545   return f;
    546 }
    547 
    548 CALLER_OWN char *owl_zephyr_field(const ZNotice_t *n, const char *f)
    549 {
    550   if (f == NULL)
    551     return g_strdup("");
    552   return g_strndup(f, n->z_message + n->z_message_len - f);
    553 }
    554 
    555 CALLER_OWN char *owl_zephyr_field_as_utf8(const ZNotice_t *n, const char *f)
    556 {
    557   char *tmp = owl_zephyr_field(n, f);
    558   char *out = owl_validate_or_convert(tmp);
    559   g_free(tmp);
    560   return out;
    561 }
    562 
    563 CALLER_OWN char *owl_zephyr_get_field(const ZNotice_t *n, int j)
    564 {
    565   return owl_zephyr_field(n, owl_zephyr_get_raw_field(n, j));
     528    return(g_strdup(""));
     529
     530  count=save=0;
     531  for (i=0; i<n->z_message_len; i++) {
     532    if (n->z_message[i]=='\0') {
     533      count++;
     534      if (count==j) {
     535        /* just found the end of the field we're looking for */
     536        return(g_strdup(n->z_message+save));
     537      } else {
     538        save=i+1;
     539      }
     540    }
     541  }
     542  /* catch the last field, which might not be null terminated */
     543  if (count==j-1) {
     544    return g_strndup(n->z_message + save, n->z_message_len - save);
     545  }
     546
     547  return(g_strdup(""));
    566548}
    567549
    568550CALLER_OWN char *owl_zephyr_get_field_as_utf8(const ZNotice_t *n, int j)
    569551{
    570   return owl_zephyr_field_as_utf8(n, owl_zephyr_get_raw_field(n, j));
    571 }
    572 #else
    573 const char *owl_zephyr_first_raw_field(const void *n)
    574 {
    575   return NULL;
    576 }
    577 
    578 const char *owl_zephyr_next_raw_field(const void *n, const char *f)
    579 {
    580   return NULL;
    581 }
    582 
    583 const char *owl_zephyr_get_raw_field(const void *n, int j)
    584 {
    585   return NULL;
    586 }
    587 
    588 CALLER_OWN char *owl_zephyr_field(const void *n, const char *f)
    589 {
    590   return g_strdup("");
    591 }
    592 
    593 CALLER_OWN char *owl_zephyr_field_as_utf8(const void *n, const char *f)
    594 {
    595   return g_strdup("");
    596 }
    597 
    598 CALLER_OWN char *owl_zephyr_get_field(const void *n, int j)
    599 {
    600   return g_strdup("");
    601 }
    602 
    603 CALLER_OWN char *owl_zephyr_get_field_as_utf8(const void *n, int j)
    604 {
    605   return owl_zephyr_field(n, owl_zephyr_get_raw_field(n, j));
     552  int i, count, save;
     553
     554  /* If there's no message here, just run along now */
     555  if (n->z_message_len == 0)
     556    return(g_strdup(""));
     557
     558  count=save=0;
     559  for (i = 0; i < n->z_message_len; i++) {
     560    if (n->z_message[i]=='\0') {
     561      count++;
     562      if (count == j) {
     563        /* just found the end of the field we're looking for */
     564        return(owl_validate_or_convert(n->z_message + save));
     565      } else {
     566        save = i + 1;
     567      }
     568    }
     569  }
     570  /* catch the last field, which might not be null terminated */
     571  if (count == j - 1) {
     572    char *tmp, *out;
     573    tmp = g_strndup(n->z_message + save, n->z_message_len - save);
     574    out = owl_validate_or_convert(tmp);
     575    g_free(tmp);
     576    return out;
     577  }
     578
     579  return(g_strdup(""));
     580}
     581#else
     582CALLER_OWN char *owl_zephyr_get_field(void *n, int j)
     583{
     584  return(g_strdup(""));
     585}
     586CALLER_OWN char *owl_zephyr_get_field_as_utf8(void *n, int j)
     587{
     588  return owl_zephyr_get_field(n, j);
    606589}
    607590#endif
     
    611594int owl_zephyr_get_num_fields(const ZNotice_t *n)
    612595{
    613   int i;
    614   const char *f;
    615   for (i = 0, f = owl_zephyr_first_raw_field(n); f != NULL;
    616        i++, f = owl_zephyr_next_raw_field(n, f))
    617     ;
    618   return i;
     596  int i, fields;
     597
     598  if(n->z_message_len == 0)
     599    return 0;
     600
     601  fields=1;
     602  for (i=0; i<n->z_message_len; i++) {
     603    if (n->z_message[i]=='\0') fields++;
     604  }
     605 
     606  return(fields);
    619607}
    620608#else
     
    709697  Code_t ret;
    710698  ZNotice_t notice;
    711   char *zsender = NULL;
    712699   
    713700  memset(&notice, 0, sizeof(notice));
     
    719706  notice.z_kind=ACKED;
    720707  notice.z_port=0;
    721 #ifdef ZCHARSET_UTF_8
    722   notice.z_charset = ZCHARSET_UTF_8;
    723 #endif
    724708  notice.z_class=zstr(class);
    725709  notice.z_class_inst=zstr(instance);
    726   if (!strcmp(recipient, "@")) {
     710  notice.z_sender=NULL;
     711  if (!strcmp(recipient, "*") || !strcmp(recipient, "@")) {
    727712    notice.z_recipient=zstr("");
     713    if (*owl_global_get_zsender(&g))
     714        notice.z_sender=zstr(owl_global_get_zsender(&g));
    728715  } else {
    729716    notice.z_recipient=zstr(recipient);
    730717  }
    731   if (!owl_zwrite_recip_is_personal(recipient) && *owl_global_get_zsender(&g))
    732     notice.z_sender = zsender = long_zuser(owl_global_get_zsender(&g));
    733   notice.z_default_format=zstr(ZEPHYR_DEFAULT_FORMAT);
     718  notice.z_default_format=zstr("Class $class, Instance $instance:\nTo: @bold($recipient) at $time $date\nFrom: @bold{$1 <$sender>}\n\n$2");
    734719  if (opcode) notice.z_opcode=zstr(opcode);
    735720
     
    744729  /* free then check the return */
    745730  g_free(notice.z_message);
    746   g_free(zsender);
     731  ZFreeNotice(&notice);
    747732  if (ret != ZERR_NONE) {
    748733    owl_function_error("Error sending zephyr: %s", error_message(ret));
     
    804789  } else if (!strcmp(retnotice->z_message, ZSRVACK_NOTSENT)) {
    805790    if (retnotice->z_recipient == NULL
    806         || !owl_zwrite_recip_is_personal(retnotice->z_recipient)) {
     791        || *retnotice->z_recipient == 0
     792        || *retnotice->z_recipient == '@') {
    807793      char *buff;
    808794      owl_function_error("No one subscribed to class %s", retnotice->z_class);
     
    923909  g_free(to);
    924910
    925   z = owl_zwrite_new_from_line(tmpbuff);
     911  z = owl_zwrite_new(tmpbuff);
    926912  g_free(tmpbuff);
    927913  if (z == NULL) {
     
    10251011  }
    10261012
    1027   g_free(subsfile);
    10281013  g_free(line);
    10291014#endif
     
    11051090  g_free(filename);
    11061091}
    1107 
    1108 #ifdef HAVE_LIBZEPHYR
    1109 const char *owl_zephyr_get_charsetstr(const ZNotice_t *n)
    1110 {
    1111 #ifdef ZCHARSET_UTF_8
    1112   return ZCharsetToString(n->z_charset);
    1113 #else
    1114   return "";
    1115 #endif
    1116 }
    1117 #else
    1118 const char *owl_zephyr_get_charsetstr(const void *n)
    1119 {
    1120   return "";
    1121 }
    1122 #endif
    11231092
    11241093/* return auth string */
     
    13191288CALLER_OWN char *owl_zephyr_smartstripped_user(const char *in)
    13201289{
    1321   int n = strcspn(in, "./");
    1322   char *realm = strchrnul(in, '@');
    1323 
    1324   if (in + n >= realm ||
    1325       g_str_has_prefix(in, OWL_ZEPHYR_NOSTRIP_HOST) ||
    1326       g_str_has_prefix(in, OWL_ZEPHYR_NOSTRIP_RCMD) ||
    1327       g_str_has_prefix(in, OWL_ZEPHYR_NOSTRIP_DAEMON5) ||
    1328       g_str_has_prefix(in, OWL_ZEPHYR_NOSTRIP_DAEMON4))
    1329     return g_strdup(in);
    1330   else
    1331     return g_strdup_printf("%.*s%s", n, in, realm);
     1290  char *slash, *dot, *realm, *out;
     1291
     1292  out = g_strdup(in);
     1293
     1294  /* bail immeaditly if we don't have to do any work */
     1295  slash = strchr(out, '/');
     1296  dot = strchr(out, '.');
     1297  if (!slash && !dot) {
     1298    return(out);
     1299  }
     1300
     1301  if (!strncasecmp(out, OWL_ZEPHYR_NOSTRIP_HOST, strlen(OWL_ZEPHYR_NOSTRIP_HOST)) ||
     1302      !strncasecmp(out, OWL_ZEPHYR_NOSTRIP_RCMD, strlen(OWL_ZEPHYR_NOSTRIP_RCMD)) ||
     1303      !strncasecmp(out, OWL_ZEPHYR_NOSTRIP_DAEMON5, strlen(OWL_ZEPHYR_NOSTRIP_DAEMON5)) ||
     1304      !strncasecmp(out, OWL_ZEPHYR_NOSTRIP_DAEMON4, strlen(OWL_ZEPHYR_NOSTRIP_DAEMON4))) {
     1305    return(out);
     1306  }
     1307
     1308  realm = strchr(out, '@');
     1309  if (!slash && dot && realm && (dot > realm)) {
     1310    /* There's no '/', and the first '.' is in the realm */
     1311    return(out);
     1312  }
     1313
     1314  /* remove the realm from out, but hold on to it */
     1315  if (realm) realm[0]='\0';
     1316
     1317  /* strip */
     1318  if (slash) slash[0] = '\0';  /* krb5 style user/instance */
     1319  else if (dot) dot[0] = '\0'; /* krb4 style user.instance */
     1320
     1321  /* reattach the realm if we had one */
     1322  if (realm) {
     1323    strcat(out, "@");
     1324    strcat(out, realm+1);
     1325  }
     1326
     1327  return(out);
    13321328}
    13331329
     
    14131409          if (ret == ZERR_NONE) {
    14141410            /* Send a PSEUDO LOGIN! */
    1415             m = g_slice_new(owl_message);
     1411            m = g_new(owl_message, 1);
    14161412            owl_message_create_pseudo_zlogin(m, 0, zald->user,
    14171413                                             location.host,
     
    14261422        /* Send a PSEUDO LOGOUT! */
    14271423        if (notify) {
    1428           m = g_slice_new(owl_message);
     1424          m = g_new(owl_message, 1);
    14291425          owl_message_create_pseudo_zlogin(m, 1, zald->user, "", "", "");
    14301426          owl_global_messagequeue_addmsg(&g, m);
     
    14351431    }
    14361432    ZFreeALD(zald);
    1437     g_slice_free(ZAsyncLocateData_t, zald);
     1433    g_free(zald);
    14381434  }
    14391435}
     
    15021498
    15031499      /* create the new message */
    1504       m=g_slice_new(owl_message);
     1500      m=g_new(owl_message, 1);
    15051501      owl_message_create_from_znotice(m, &notice);
    15061502
  • zwrite.c

    r7dcef03 rf271129  
    11#include "owl.h"
    22
    3 CALLER_OWN owl_zwrite *owl_zwrite_new_from_line(const char *line)
    4 {
    5   owl_zwrite *z = g_slice_new(owl_zwrite);
    6   if (owl_zwrite_create_from_line(z, line) != 0) {
    7     g_slice_free(owl_zwrite, z);
     3CALLER_OWN owl_zwrite *owl_zwrite_new(const char *line)
     4{
     5  owl_zwrite *z = g_new(owl_zwrite, 1);
     6  if (owl_zwrite_create_from_line(z, line) < 0) {
     7    owl_zwrite_delete(z);
    88    return NULL;
    99  }
     
    1111}
    1212
    13 CALLER_OWN owl_zwrite *owl_zwrite_new(int argc, const char *const *argv)
    14 {
    15   owl_zwrite *z = g_slice_new(owl_zwrite);
    16   if (owl_zwrite_create(z, argc, argv) != 0) {
    17     g_slice_free(owl_zwrite, z);
    18     return NULL;
    19   }
    20   return z;
    21 }
    22 
    2313G_GNUC_WARN_UNUSED_RESULT int owl_zwrite_create_from_line(owl_zwrite *z, const char *line)
    2414{
    25   int argc;
     15  int argc, badargs, myargc;
    2616  char **argv;
    27   int ret;
    28 
    29   /* parse the command line for options */
    30   argv = owl_parseline(line, &argc);
    31   if (argc < 0) {
    32     owl_function_error("Unbalanced quotes in zwrite");
    33     return -1;
    34   }
    35   ret = owl_zwrite_create(z, argc, strs(argv));
    36   g_strfreev(argv);
    37   return ret;
    38 }
    39 
    40 G_GNUC_WARN_UNUSED_RESULT int owl_zwrite_create(owl_zwrite *z, int argc, const char *const *argv)
    41 {
    42   int badargs = 0;
     17  const char *const *myargv;
    4318  char *msg = NULL;
     19
     20  badargs=0;
    4421 
    4522  /* start with null entries */
     
    5431  z->noping=0;
    5532  z->recips = g_ptr_array_new();
    56   z->zwriteline = owl_argv_quote(argc, argv);
    57 
    58   if (argc && *(argv[0])!='-') {
    59     z->cmd=g_strdup(argv[0]);
    60     argc--;
    61     argv++;
    62   }
    63   while (argc) {
    64     if (!strcmp(argv[0], "-c")) {
    65       if (argc<2) {
    66         badargs=1;
    67         break;
    68       }
    69       z->class=owl_validate_utf8(argv[1]);
    70       argv+=2;
    71       argc-=2;
    72     } else if (!strcmp(argv[0], "-i")) {
    73       if (argc<2) {
    74         badargs=1;
    75         break;
    76       }
    77       z->inst=owl_validate_utf8(argv[1]);
    78       argv+=2;
    79       argc-=2;
    80     } else if (!strcmp(argv[0], "-r")) {
    81       if (argc<2) {
    82         badargs=1;
    83         break;
    84       }
    85       z->realm=owl_validate_utf8(argv[1]);
    86       argv+=2;
    87       argc-=2;
    88     } else if (!strcmp(argv[0], "-s")) {
    89       if (argc<2) {
    90         badargs=1;
    91         break;
    92       }
    93       z->zsig=owl_validate_utf8(argv[1]);
    94       argv+=2;
    95       argc-=2;
    96     } else if (!strcmp(argv[0], "-O")) {
    97       if (argc<2) {
    98         badargs=1;
    99         break;
    100       }
    101       z->opcode=owl_validate_utf8(argv[1]);
    102       argv+=2;
    103       argc-=2;
    104     } else if (!strcmp(argv[0], "-m")) {
    105       if (argc<2) {
     33  z->zwriteline = g_strdup(line);
     34
     35  /* parse the command line for options */
     36  argv=owl_parseline(line, &argc);
     37  myargv=strs(argv);
     38  if (argc<0) {
     39    owl_function_error("Unbalanced quotes in zwrite");
     40    return(-1);
     41  }
     42  myargc=argc;
     43  if (myargc && *(myargv[0])!='-') {
     44    z->cmd=g_strdup(myargv[0]);
     45    myargc--;
     46    myargv++;
     47  }
     48  while (myargc) {
     49    if (!strcmp(myargv[0], "-c")) {
     50      if (myargc<2) {
     51        badargs=1;
     52        break;
     53      }
     54      z->class=owl_validate_utf8(myargv[1]);
     55      myargv+=2;
     56      myargc-=2;
     57    } else if (!strcmp(myargv[0], "-i")) {
     58      if (myargc<2) {
     59        badargs=1;
     60        break;
     61      }
     62      z->inst=owl_validate_utf8(myargv[1]);
     63      myargv+=2;
     64      myargc-=2;
     65    } else if (!strcmp(myargv[0], "-r")) {
     66      if (myargc<2) {
     67        badargs=1;
     68        break;
     69      }
     70      z->realm=owl_validate_utf8(myargv[1]);
     71      myargv+=2;
     72      myargc-=2;
     73    } else if (!strcmp(myargv[0], "-s")) {
     74      if (myargc<2) {
     75        badargs=1;
     76        break;
     77      }
     78      z->zsig=owl_validate_utf8(myargv[1]);
     79      myargv+=2;
     80      myargc-=2;
     81    } else if (!strcmp(myargv[0], "-O")) {
     82      if (myargc<2) {
     83        badargs=1;
     84        break;
     85      }
     86      z->opcode=owl_validate_utf8(myargv[1]);
     87      myargv+=2;
     88      myargc-=2;
     89    } else if (!strcmp(myargv[0], "-m")) {
     90      if (myargc<2) {
    10691        badargs=1;
    10792        break;
     
    11499
    115100      /* Once we have -m, gobble up everything else on the line */
    116       argv++;
    117       argc--;
    118       msg = g_strjoinv(" ", (char**)argv);
     101      myargv++;
     102      myargc--;
     103      msg = g_strjoinv(" ", (char**)myargv);
    119104      break;
    120     } else if (!strcmp(argv[0], "-C")) {
     105    } else if (!strcmp(myargv[0], "-C")) {
    121106      z->cc=1;
    122       argv++;
    123       argc--;
    124     } else if (!strcmp(argv[0], "-n")) {
     107      myargv++;
     108      myargc--;
     109    } else if (!strcmp(myargv[0], "-n")) {
    125110      z->noping=1;
    126       argv++;
    127       argc--;
     111      myargv++;
     112      myargc--;
    128113    } else {
    129114      /* anything unattached is a recipient */
    130       g_ptr_array_add(z->recips, owl_validate_utf8(argv[0]));
    131       argv++;
    132       argc--;
     115      g_ptr_array_add(z->recips, owl_validate_utf8(myargv[0]));
     116      myargv++;
     117      myargc--;
    133118    }
    134119  }
    135120
     121  g_strfreev(argv);
     122
    136123  if (badargs) {
    137     owl_zwrite_cleanup(z);
    138124    return(-1);
    139125  }
     
    143129      z->recips->len == 0) {
    144130    owl_function_error("You must specify a recipient for zwrite");
    145     owl_zwrite_cleanup(z);
    146131    return(-1);
    147132  }
     
    182167  }
    183168
     169  /* if there are no recipients we won't send a ping, which
     170     is what we want */
    184171  for (i = 0; i < z->recips->len; i++) {
    185172    to = owl_zwrite_get_recip_n_with_realm(z, i);
    186     if (owl_zwrite_recip_is_personal(to))
    187       send_ping(to, z->class, z->inst);
     173    send_ping(to, z->class, z->inst);
    188174    g_free(to);
    189175  }
     
    206192  g_free(z->message);
    207193
    208   if (z->cc && owl_zwrite_is_personal(z)) {
     194  if (z->recips->len > 0 && z->cc) {
    209195    message = g_string_new("CC: ");
    210196    for (i = 0; i < z->recips->len; i++) {
     
    268254  owl_zwrite z;
    269255  int rv;
    270   rv = owl_zwrite_create_from_line(&z, cmd);
    271   if (rv != 0) return rv;
     256  rv=owl_zwrite_create_from_line(&z, cmd);
     257  if (rv) return(rv);
    272258  if (!owl_zwrite_is_message_set(&z)) {
    273259    owl_zwrite_set_message(&z, msg);
     
    337323}
    338324
    339 bool owl_zwrite_recip_is_personal(const char *recipient)
    340 {
    341   return recipient[0] && recipient[0] != '@';
    342 }
    343 
    344 bool owl_zwrite_is_personal(const owl_zwrite *z)
     325int owl_zwrite_is_personal(const owl_zwrite *z)
    345326{
    346327  /* return true if at least one of the recipients is personal */
    347328  int i;
    348 
    349   for (i = 0; i < z->recips->len; i++)
    350     if (owl_zwrite_recip_is_personal(z->recips->pdata[i]))
    351       return true;
    352   return false;
     329  char *recip;
     330
     331  for (i = 0; i < z->recips->len; i++) {
     332    recip = z->recips->pdata[i];
     333    if (recip[0] != '@') return 1;
     334  }
     335  return(0);
    353336}
    354337
     
    356339{
    357340  owl_zwrite_cleanup(z);
    358   g_slice_free(owl_zwrite, z);
     341  g_free(z);
    359342}
    360343
Note: See TracChangeset for help on using the changeset viewer.