Changes in / [2e42098:0071c88]
- 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 8 META.yml 9 Makefile 2 10 Makefile.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 11 Makefile.old 47 12 TAGS 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 \#*# 14 aclocal.m4 15 autom4te.cache 16 barnowl.bin 17 tester.bin 18 zcrypt 19 blib 20 config.cache 21 config.h 22 config.h.in 23 config.log 24 config.status 25 configure 26 core 27 depcomp 28 install-sh 29 jabber.log 30 missing 31 owl_prototypes.h 32 owl_prototypes.h.new 33 perlglue.c 34 perlwrap.c 35 pm_to_blib 36 stamp-h1 37 varstubs.c -
AUTHORS
r80c0fc7 r1d2c4c3 3 3 4 4 The following people have provided patches or other contributions: 5 Sam Hartman 5 6 Alex Vandiver 6 Kevin Chen 7 Arun Tharuvai 8 Sam Hartman 7 Geoffrey Thomas 9 8 Derrick Brashear 10 9 David Glasser 10 Matthew Goldstein 11 Arun Tharuvai 12 Kevin Chen 11 13 Eric Price 12 Matthew Goldstein13 Geoffrey Thomas14 Anders Kaseorg15 Greg Price16 Chris Lesniewski-Laas17 Alex Dehnert18 Edward Z. Yang19 Karl Ramm20 Evan Broder21 David Benjamin22 Cathy Zhang23 Joshua Oreman24 Leonid Grinberg25 Kevin Riggle26 Brian Sniffen27 William Throwe28 Jason Gross29 Adam Glasgall30 Tim Hill31 DD Liu32 Betsy Riley33 Robert Jacobs34 14 35 BarnOwl is based on code from Owl, which was originally primar ily15 BarnOwl is based on code from Owl, which was originally primarly 36 16 written by James Kretchmar. Erik Nygren also made substantial 37 contributions and improvem ents to the program.17 contributions and improvemnts to the program. 38 18 39 The following people provided patches and other tech nical support for19 The following people provided patches and other techincal support for 40 20 Owl: 41 21 … … 50 30 Mark Eichin 51 31 52 Mark Eichin is also maintaining the Debian package of Owl.32 Mark Eichin is also maintaining the debian package of Owl. 53 33 54 34 The following people helped with beta testing the earliest versions of -
COPYING
rccc182c rb03c714 549 549 550 550 That's all there is to it! 551 552 ======================================================================553 554 Files under perl/modules/Facebook/lib/Facebook are copyright (c) 2010 Plain555 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 under560 the same terms as the Perl 5 programming language system itself.561 562 Terms of the Perl programming language system itself563 564 a) the GNU General Public License as published by the Free565 Software Foundation; either version 1, or (at your option) any566 later version, or567 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 1989576 577 GNU GENERAL PUBLIC LICENSE578 Version 1, February 1989579 580 Copyright (C) 1989 Free Software Foundation, Inc.581 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA582 583 Everyone is permitted to copy and distribute verbatim copies584 of this license document, but changing it is not allowed.585 586 Preamble587 588 The license agreements of most software companies try to keep users589 at the mercy of those companies. By contrast, our General Public590 License is intended to guarantee your freedom to share and change free591 software--to make sure the software is free for all its users. The592 General Public License applies to the Free Software Foundation's593 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, not597 price. Specifically, the General Public License is designed to make598 sure that you have the freedom to give away or sell copies of free599 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 free601 programs; and that you know you can do these things.602 603 To protect your rights, we need to make restrictions that forbid604 anyone to deny you these rights or to ask you to surrender the rights.605 These restrictions translate to certain responsibilities for you if you606 distribute copies of the software, or if you modify it.607 608 For example, if you distribute copies of a such a program, whether609 gratis or for a fee, you must give the recipients all the rights that610 you have. You must make sure that they, too, receive or can get the611 source code. And you must tell them their rights.612 613 We protect your rights with two steps: (1) copyright the software, and614 (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 certain618 that everyone understands that there is no warranty for this free619 software. If the software is modified by someone else and passed on, we620 want its recipients to know that what they have is not the original, so621 that any problems introduced by others will not reflect on the original622 authors' reputations.623 624 The precise terms and conditions for copying, distribution and625 modification follow.626 627 GNU GENERAL PUBLIC LICENSE628 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION629 630 0. This License Agreement applies to any program or other work which631 contains a notice placed by the copyright holder saying it may be632 distributed under the terms of this General Public License. The633 "Program", below, refers to any such program or work, and a "work based634 on the Program" means either the Program or any work containing the635 Program or a portion of it, either verbatim or with modifications. Each636 licensee is addressed as "you".637 638 1. You may copy and distribute verbatim copies of the Program's source639 code as you receive it, in any medium, provided that you conspicuously and640 appropriately publish on each copy an appropriate copyright notice and641 disclaimer of warranty; keep intact all the notices that refer to this642 General Public License and to the absence of any warranty; and give any643 other recipients of the Program a copy of this General Public License644 along with the Program. You may charge a fee for the physical act of645 transferring a copy.646 647 2. You may modify your copy or copies of the Program or any portion of648 it, and copy and distribute such modifications under the terms of Paragraph649 1 above, provided that you also do the following:650 651 a) cause the modified files to carry prominent notices stating that652 you changed the files and the date of any change; and653 654 b) cause the whole of any work that you distribute or publish, that655 in whole or in part contains the Program or any part thereof, either656 with or without modifications, to be licensed at no charge to all657 third parties under the terms of this General Public License (except658 that you may choose to grant warranty protection to some or all659 third parties, at your option).660 661 c) If the modified program normally reads commands interactively when662 run, you must cause it, when started running for such interactive use663 in the simplest and most usual way, to print or display an664 announcement including an appropriate copyright notice and a notice665 that there is no warranty (or else, saying that you provide a666 warranty) and that users may redistribute the program under these667 conditions, and telling the user how to view a copy of this General668 Public License.669 670 d) You may charge a fee for the physical act of transferring a671 copy, and you may at your option offer warranty protection in672 exchange for a fee.673 674 Mere aggregation of another independent work with the Program (or its675 derivative) on a volume of a storage or distribution medium does not bring676 the other work under the scope of these terms.677 678 3. You may copy and distribute the Program (or a portion or derivative of679 it, under Paragraph 2) in object code or executable form under the terms of680 Paragraphs 1 and 2 above provided that you also do one of the following:681 682 a) accompany it with the complete corresponding machine-readable683 source code, which must be distributed under the terms of684 Paragraphs 1 and 2 above; or,685 686 b) accompany it with a written offer, valid for at least three687 years, to give any third party free (except for a nominal charge688 for the cost of distribution) a complete machine-readable copy of the689 corresponding source code, to be distributed under the terms of690 Paragraphs 1 and 2 above; or,691 692 c) accompany it with the information you received as to where the693 corresponding source code may be obtained. (This alternative is694 allowed only for noncommercial distribution and only if you695 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 making698 modifications to it. For an executable file, complete source code means699 all the source code for all modules it contains; but, as a special700 exception, it need not include source code for modules which are standard701 libraries that accompany the operating system on which the executable702 file runs, or for standard header files or definitions files that703 accompany that operating system.704 705 4. You may not copy, modify, sublicense, distribute or transfer the706 Program except as expressly provided under this General Public License.707 Any attempt otherwise to copy, modify, sublicense, distribute or transfer708 the Program is void, and will automatically terminate your rights to use709 the Program under this License. However, parties who have received710 copies, or rights to use copies, from you under this General Public711 License will not have their licenses terminated so long as such parties712 remain in full compliance.713 714 5. By copying, distributing or modifying the Program (or any work based715 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 the719 Program), the recipient automatically receives a license from the original720 licensor to copy, distribute or modify the Program subject to these721 terms and conditions. You may not impose any further restrictions on the722 recipients' exercise of the rights granted herein.723 724 7. The Free Software Foundation may publish revised and/or new versions725 of the General Public License from time to time. Such new versions will726 be similar in spirit to the present version, but may differ in detail to727 address new problems or concerns.728 729 Each version is given a distinguishing version number. If the Program730 specifies a version number of the license which applies to it and "any731 later version", you have the option of following the terms and conditions732 either of that version or of any later version published by the Free733 Software Foundation. If the Program does not specify a version number of734 the license, you may choose any version ever published by the Free Software735 Foundation.736 737 8. If you wish to incorporate parts of the Program into other free738 programs whose distribution conditions are different, write to the author739 to ask for permission. For software which is copyrighted by the Free740 Software Foundation, write to the Free Software Foundation; we sometimes741 make exceptions for this. Our decision will be guided by the two goals742 of preserving the free status of all derivatives of our free software and743 of promoting the sharing and reuse of software generally.744 745 NO WARRANTY746 747 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY748 FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN749 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES750 PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED751 OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF752 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS753 TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE754 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 WRITING758 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR759 REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,760 INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING761 OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED762 TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY763 YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER764 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE765 POSSIBILITY OF SUCH DAMAGES.766 767 END OF TERMS AND CONDITIONS768 769 Appendix: How to Apply These Terms to Your New Programs770 771 If you develop a new program, and you want it to be of the greatest772 possible use to humanity, the best way to achieve this is to make it773 free software which everyone can redistribute and change under these774 terms.775 776 To do so, attach the following notices to the program. It is safest to777 attach them to the start of each source file to most effectively convey778 the exclusion of warranty; and each file should have at least the779 "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 modify785 it under the terms of the GNU General Public License as published by786 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 of791 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the792 GNU General Public License for more details.793 794 You should have received a copy of the GNU General Public License795 along with this program; if not, write to the Free Software796 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA797 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 this802 when it starts in an interactive mode:803 804 Gnomovision version 69, Copyright (C) 19xx name of author805 Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.806 This is free software, and you are welcome to redistribute it807 under certain conditions; type `show c' for details.808 809 The hypothetical commands `show w' and `show c' should show the810 appropriate parts of the General Public License. Of course, the811 commands you use may be called something other than `show w' and `show812 c'; they could even be mouse-clicks or menu items--whatever suits your813 program.814 815 You should also get your employer (if you work as a programmer) or your816 school, if any, to sign a "copyright disclaimer" for the program, if817 necessary. Here a sample; alter the names:818 819 Yoyodyne, Inc., hereby disclaims all copyright interest in the820 program `Gnomovision' (a program to direct compilers to make passes821 at assemblers) written by James Hacker.822 823 <signature of Ty Coon>, 1 April 1989824 Ty Coon, President of Vice825 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.0836 837 The Artistic License838 839 Preamble840 841 The intent of this document is to state the conditions under which a Package842 may be copied, such that the Copyright Holder maintains some semblance of843 artistic control over the development of the package, while giving the users of844 the package the right to use and distribute the Package in a more-or-less845 customary fashion, plus the right to make reasonable modifications.846 847 Definitions:848 849 - "Package" refers to the collection of files distributed by the Copyright850 Holder, and derivatives of that collection of files created through851 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 Copyright854 Holder.855 - "Copyright Holder" is whoever is named in the copyright or copyrights for856 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 media859 cost, duplication charges, time of people involved, and so on. (You will860 not be required to justify it to the Copyright Holder, but only to the861 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, though863 there may be fees involved in handling the item. It also means that864 recipients of the item may redistribute it under the same conditions they865 received it.866 867 1. You may make and give away verbatim copies of the source form of the868 Standard Version of this Package without restriction, provided that you869 duplicate all of the original copyright notices and associated disclaimers.870 871 2. You may apply bug fixes, portability fixes and other modifications derived872 from the Public Domain or from the Copyright Holder. A Package modified in such873 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 that876 you insert a prominent notice in each changed file stating how and when you877 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 them880 Freely Available, such as by posting said modifications to Usenet or an881 equivalent medium, or placing the modifications on a major archive site882 such as ftp.uu.net, or by allowing the Copyright Holder to include your883 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 with888 standard executables, which must also be provided, and provide a separate889 manual page for each non-standard executable that clearly documents how it890 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 executable895 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 to899 get the Standard Version.900 901 b) accompany the distribution with the machine-readable source of the Package902 with your modifications.903 904 c) accompany any non-standard executables with their corresponding Standard905 Version executables, giving the non-standard executables non-standard906 names, and clearly documenting the differences in manual pages (or907 equivalent), together with instructions on where to get the Standard908 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 this913 Package. You may charge any fee you choose for support of this Package. You914 may not charge a fee for this Package itself. However, you may distribute this915 Package in aggregate with other (possibly commercial) programs as part of a916 larger (possibly commercial) software distribution provided that you do not917 advertise this Package as a product of your own.918 919 6. The scripts and library files supplied as input to or produced as output920 from the programs of this Package do not automatically fall under the copyright921 of this Package, but belong to whomever generated them, and may be sold922 commercially, and may be aggregated with this Package.923 924 7. C or perl subroutines supplied by you and linked into this Package shall not925 be considered part of this Package.926 927 8. The name of the Copyright Holder may not be used to endorse or promote928 products derived from this software without specific prior written permission.929 930 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED931 WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF932 MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.933 934 The End -
ChangeLog
r6f87658 r65ff3f4 1 1.92 * Update Jabber module for Net::DNS changes -james2vegas@aim.com3 * Update and make configurable the Zephyr default format -adehnert@mit.edu4 * Fix a crash when zcrypt fails -andersk@mit.edu5 * Fix building with OpenSSL before 0.9.8 -andersk@mit.edu6 * Make :loadsubs reload instanced personals too -davidben@mit.edu7 * Make Perl zephyr_zwrite call die() when it fails -jgross@mit.edu8 * Tell gpg calls from zcrypt to ignore ~/.gnupg -andersk@mit.edu9 * Replace outgoing zephyr default format with a small URL -geofft@mit.edu10 * Add getnumlines() to perl interface -asedeno@mit.edu11 * Include names of invalid filters on filter errors -adehnert@mit.edu12 * Don't incorrectly mark decryption failures as decrypted -davidben@mit.edu13 * Hide the default cursor when possible -davidben@mit.edu14 * Complete viewperson and vp as viewuser and vu -davidben@mit.edu15 * Set z_charset = ZCHARSET_UTF_8 -andersk@mit.edu16 * Allow zsender spoofing on cross-realm classes -andersk@mit.edu17 * Append the realm to the zsender if missing -andersk@mit.edu18 * Redisplay on setting colorztext -jgross@mit.edu19 * Rename default config file to .owl/init.pl -kevinr@free-dissociation.com20 * Add completion for jabberlogout -adehnert@mit.edu21 * Switch to interactive context before sourcing the startup file -davidben@mit.edu22 * Add completion for reload-module -adehnert@mit.edu23 * editwin callback for canceling the editwin -jgross@mit.edu24 * Fix dirtying windows inside a redraw handler -davidben@mit.edu25 * Facebook module -ezyang@mit.edu26 * Complete unstartup command just like startup command -jgross@mit.edu27 * Fix the description of disable-ctrl-d -jgross@mit.edu28 * Use wbkgrndset instead of wbkgdset in _owl_fmtext_wcolor_set -davidben@mit.edu29 * Show the time zone in :info -jgross@mit.edu30 * Treat [!.?]" as end of sentence in edit:fill-paragraph -jgross@mit.edu31 * Correctly display multiline fields in :info -jgross@mit.edu32 33 1.8.134 * Only add outgoing messages for personal part of half-personal messages -andersk@mit.edu35 * Don’t write CC: line on zwrite -C '' -andersk@mit.edu36 * Don’t send public pings on zwrite '' or zwrite @REALM -andersk@mit.edu37 * Don’t treat zwrite '' as personal -andersk@mit.edu38 * Stop pretending to support zwrite * -andersk@mit.edu39 * Show foreign realms on non-personal zephyrs like Owl did -andersk@mit.edu40 * Fix memory leak in zcrypt -davidben@mit.edu41 * Don't attempt to switch filters in :view -d if invalid -davidben@mit.edu42 * Fixed typo in unbindkey usage error -rileyb@mit.edu43 * Fix bug generating filter text in 256-color mode -asedeno@mit.edu44 * Remove ^noc from reply-lockout -geofft@mit.edu45 * Avoid quadratic loops when receiving zephyrs -andersk@mit.edu46 * Fix hang on empty zcrypt messages -adehnert@MIT.EDU47 48 1 1.8 49 2 * Compute the home directory in zcrypt consistently with BarnOwl -davidben@mit.edu … … 329 282 * Support --program-{prefix,suffix,transform}. -nelhage 330 283 * Send instanced pings and give useful error messages -adehnert 331 * Add <message,*,%me%> to default Barn Owl subs. -adehnert284 * Add <message,*,%me%> to default Barnowl subs. -adehnert 332 285 * Maintain instance when using shift-R on personals -adehnert 333 286 * Improve handling of outgoing instanced personals -adehnert -
Makefile.am
rca1fb26a rc266281 1 1 ACLOCAL_AMFLAGS = -I m4 2 2 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 3 GIT_DESCRIPTION := $(if $(wildcard .git),$(shell git describe --match='barnowl-*' HEAD 2>/dev/null)) 4 GIT_FLAGS := $(if $(GIT_DESCRIPTION),-DGIT_VERSION=$(GIT_DESCRIPTION:barnowl-%=%)) 6 5 7 FORCE: 8 BUILD_VERSION.mk: $(if $(filter-out $(BUILD_VERSION),$(VERSION)),FORCE) 9 echo 'BUILD_VERSION = $(VERSION)' > $@ 10 11 bin_PROGRAMS = bin/barnowl 6 bin_PROGRAMS = barnowl.bin 12 7 if ENABLE_ZCRYPT 13 8 bin_PROGRAMS += zcrypt 14 9 endif 15 10 16 zcrypt_SOURCES = zcrypt.c filterproc.c version.c11 zcrypt_SOURCES = zcrypt.c filterproc.c 17 12 18 check_PROGRAMS = bin/tester 19 dist_check_DATA = t 20 dist_check_SCRIPTS = runtests.sh 13 check_PROGRAMS = tester.bin 21 14 22 noinst_SCRIPTS = barnowl 23 check_SCRIPTS = tester 15 barnowl_bin_SOURCES = $(BASE_SRCS) \ 16 owl.h owl_perl.h config.h \ 17 owl.c \ 18 $(GEN_C) $(GEN_H) 24 19 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 $@ 20 man_MANS = doc/barnowl.1 21 doc_DATA = doc/intro.txt doc/advanced.txt 31 22 32 bin_barnowl_SOURCES = $(BASE_SRCS) \ 33 owl.h owl_perl.h \ 34 owl.c 35 nodist_bin_barnowl_SOURCES = $(GEN_C) $(GEN_H) 23 barnowl_bin_LDADD = compat/libcompat.a libfaim/libfaim.a 36 24 37 dist_man_MANS = doc/barnowl.1 38 dist_doc_DATA = doc/intro.txt doc/advanced.txt 25 tester_bin_SOURCES = $(BASE_SRCS) \ 26 owl.h owl_perl.h config.h \ 27 $(GEN_C) $(GEN_H) \ 28 tester.c 39 29 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 30 tester_bin_LDADD = compat/libcompat.a libfaim/libfaim.a 48 31 49 32 TESTS=runtests.sh 50 33 51 AM_CPPFLAGS = \34 AM_CPPFLAGS = -I$(top_srcdir)/ \ 52 35 -I$(top_srcdir)/libfaim/ \ 53 36 -DDATADIR='"$(pkgdatadir)"' \ 54 -DBINDIR='"$(bindir)"' 37 -DBINDIR='"$(bindir)"' \ 38 $(GIT_FLAGS) 55 39 56 40 CODELIST_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 \ 59 42 perlconfig.c keys.c functions.c zwrite.c viewwin.c help.c filter.c \ 60 43 regex.c history.c view.c dict.c variable.c filterelement.c pair.c \ … … 62 45 aim.c buddy.c buddylist.c style.c errqueue.c \ 63 46 zbuddylist.c popexec.c select.c wcwidth.c \ 64 mainpanel.c msgwin.c sepbar.c editcontext.c signal.c closures.c47 mainpanel.c msgwin.c sepbar.c editcontext.c signal.c 65 48 66 NORMAL_SRCS = filterproc.c filterproc.h window.c window.hwindowcb.c49 NORMAL_SRCS = filterproc.c window.c windowcb.c 67 50 68 51 BASE_SRCS = $(CODELIST_SRCS) $(NORMAL_SRCS) 69 52 70 GEN_C = varstubs.c perlglue.c gmarshal_funcs.c version.c version.c.new71 GEN_H = owl_prototypes.h owl_prototypes.h.new gmarshal_funcs.h53 GEN_C = varstubs.c perlglue.c 54 GEN_H = owl_prototypes.h 72 55 73 BUILT_SOURCES = $(GEN_ H)56 BUILT_SOURCES = $(GEN_C) $(GEN_H) 74 57 75 58 # Only copy file into place if file.new is different 76 owl_prototypes.h version.c:%: %.new59 %: %.new 77 60 @diff -U0 $@ $< || { \ 78 61 test -f $@ && echo '$@ changed!'; \ … … 82 65 proto: owl_prototypes.h 83 66 84 perlglue.c: perlglue.xs typemap85 $(AM_V_GEN)perl $(XSUBPPDIR)/xsubpp $(XSUBPPFLAGS) -prototypes $< > $@67 perlglue.c: perlglue.xs $(TYPEMAP) 68 $(AM_V_GEN)perl $(XSUBPPDIR)/xsubpp $(XSUBPPFLAGS) -prototypes perlglue.xs > perlglue.c 86 69 87 70 varstubs.c: stubgen.pl variable.c … … 91 74 $(AM_V_GEN)perl $< $(sort $(filter-out $<,$+)) > $@ 92 75 93 version.c.new: Makefile BUILD_VERSION.mk94 $(AM_V_GEN)echo 'const char *version = "$(VERSION)";' > $@95 96 gmarshal_funcs.h: marshal_types97 glib-genmarshal --header $< > $@98 gmarshal_funcs.c: marshal_types99 glib-genmarshal --body $< > $@100 101 76 # For emacs flymake-mode 102 77 check-syntax: proto 103 78 $(COMPILE) -Wall -Wextra -pedantic -fsyntax-only $(CHK_SOURCES) 104 79 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 80 install-data-local: 81 $(mkinstalldirs) ${DESTDIR}${pkgdatadir}/lib 82 (cd perl/lib && tar -cf - . ) | (cd ${DESTDIR}${pkgdatadir}/lib && tar -xf - ) 83 84 do_transform = $(shell echo '$(1)' | sed '$(transform)') 85 install-exec-hook: 86 mv -f $(DESTDIR)$(bindir)/$(call do_transform,barnowl.bin) \ 87 $(DESTDIR)$(bindir)/$(call do_transform,barnowl) 119 88 120 89 SUBDIRS = compat libfaim perl -
README
r1c22155 rb711711 10 10 following CPAN modules: 11 11 12 Facebook::Graph13 12 Net::Jabber 14 13 Net::XMPP 15 14 XML::Stream 16 15 17 Somehave been modified slightly for the needs of this project.16 They have been modified slightly for the needs of this project. 18 17 19 18 BarnOwl currently requires the following perl modules off of CPAN: … … 21 20 AnyEvent 22 21 Class::Accessor 23 ExtUtils::Depends24 22 Glib 25 Module::Install26 23 PAR 27 24 … … 29 26 We plan to soon add targets to the Makefile to check for and install 30 27 these for you. 31 32 The Facebook module requires:33 34 Any::Moose35 AnyEvent::HTTP36 DateTime37 DateTime::Format::Strptime38 JSON39 MIME::Base64::URLSafe40 Ouch41 URI42 URI::Encode43 28 44 29 The IRC module requires: … … 51 36 Authen::SASL::Perl 52 37 IO::Socket::SSL 53 Digest::SHA 38 Digest::SHA1 54 39 55 40 The Twitter module requires: -
aim.c
r7dcef03 rf271129 707 707 { 708 708 aim_clientready(sess, fr->conn); 709 owl_function_debugmsg("conninitdone_admin: initializ ation done for admin connection");709 owl_function_debugmsg("conninitdone_admin: initializtion done for admin connection"); 710 710 return(1); 711 711 } … … 836 836 params = va_arg(ap, struct aim_icbmparameters *); 837 837 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 rec eiver 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", 840 840 params->maxchan, params->flags, params->maxmsglen, ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, params->minmsginterval); 841 841 … … 1049 1049 wrapmsg=owl_text_wordwrap(stripmsg, 70); 1050 1050 nz_screenname=owl_aim_normalize_screenname(userinfo->sn); 1051 m=g_ slice_new(owl_message);1051 m=g_new(owl_message, 1); 1052 1052 owl_message_create_aim(m, 1053 1053 nz_screenname, -
buddy.c
r7dcef03 rd4927a7 72 72 { 73 73 owl_buddy_cleanup(b); 74 g_ slice_free(owl_buddy,b);74 g_free(b); 75 75 } -
buddylist.c
r7dcef03 r3cdd6d2 11 11 { 12 12 owl_buddy *b; 13 b=g_ slice_new(owl_buddy);13 b=g_new(owl_buddy, 1); 14 14 15 15 owl_buddy_create(b, OWL_PROTOCOL_AIM, screenname); … … 50 50 51 51 /* if not, create the login message */ 52 m=g_ slice_new(owl_message);52 m=g_new(owl_message, 1); 53 53 owl_message_create_aim(m, 54 54 screenname, … … 69 69 70 70 if (owl_buddylist_is_aim_buddy_loggedin(bl, screenname)) { 71 m=g_ slice_new(owl_message);71 m=g_new(owl_message, 1); 72 72 owl_message_create_aim(m, 73 73 screenname, -
cmd.c
r7dcef03 rf271129 35 35 void owl_cmddict_add_alias(owl_cmddict *cd, const char *alias_from, const char *alias_to) { 36 36 owl_cmd *cmd; 37 cmd = g_ slice_new(owl_cmd);37 cmd = g_new(owl_cmd, 1); 38 38 owl_cmd_create_alias(cmd, alias_from, alias_to); 39 39 owl_perlconfig_new_command(cmd->name); … … 42 42 43 43 int 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); 45 45 if(owl_cmd_create_from_template(newcmd, cmd) < 0) { 46 g_ slice_free(owl_cmd,newcmd);46 g_free(newcmd); 47 47 return -1; 48 48 } … … 141 141 { 142 142 owl_cmd_cleanup(cmd); 143 g_ slice_free(owl_cmd,cmd);143 g_free(cmd); 144 144 } 145 145 -
commands.c
rca1fb26a rf271129 96 96 OWLCMD_ARGS("unbindkey", owl_command_unbindkey, OWL_CTX_ANY, 97 97 "removes a binding in a keymap", 98 " unbindkey <keymap> <keyseq>",98 "bindkey <keymap> <keyseq>", 99 99 "Removes a binding of a key sequence within a keymap.\n" 100 100 "Use 'show keymaps' to see the existing keymaps.\n" … … 479 479 480 480 OWLCMD_ARGS("away", owl_command_away, OWL_CTX_INTERACTIVE, 481 "Set, enable or disable allaway messages",481 "Set, enable or disable both AIM and zephyr away messages", 482 482 "away [ on | off | toggle ]\n" 483 483 "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" 485 485 "'message' is specified turn them on with that message,\n" 486 486 "otherwise use the default.\n" 487 "\n" 488 "This command really just runs the 'aaway' and 'zaway'\n" 489 "commands together\n" 487 490 "\n" 488 491 "SEE ALSO: aaway, zaway"), … … 1030 1033 OWLCMD_ARGS_CTX("popless:start-search", owl_viewwin_command_start_search, OWL_CTX_POPLESS, 1031 1034 "starts a command line to search for particular string", 1032 "popless:start-search [-r] [init ial-value]",1035 "popless:start-search [-r] [inital-value]", 1033 1036 "Initializes the command-line to search for initial-value. If\n" 1034 1037 "-r is used, the search will be performed backwards.\n\n" … … 1114 1117 void owl_command_version(void) 1115 1118 { 1116 owl_function_makemsg("BarnOwl version %s", version);1119 owl_function_makemsg("BarnOwl version %s", OWL_VERSION_STRING); 1117 1120 } 1118 1121 … … 1528 1531 char *owl_command_away(int argc, const char *const *argv, const char *buff) 1529 1532 { 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"))) { 1536 1535 owl_global_set_aaway_msg(&g, owl_global_get_aaway_msg_default(&g)); 1537 1536 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")) { 1548 1544 owl_function_aaway_off(); 1549 1545 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."); 1566 1571 return NULL; 1567 1572 } … … 1599 1604 if (v == NULL) { 1600 1605 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) { 1602 1607 if (!silent) owl_function_error("Variable '%s' is not a boolean", var); 1603 1608 } else { … … 1628 1633 if (v == NULL) { 1629 1634 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) { 1631 1636 if (!silent) owl_function_error("Variable '%s' is not a boolean", var); 1632 1637 } else { … … 1773 1778 1774 1779 if (argc < 3) { 1775 owl_function_makemsg("Usage: unbindkey <keymap> <binding>");1780 owl_function_makemsg("Usage: bindkey <keymap> <binding>"); 1776 1781 return NULL; 1777 1782 } … … 1980 1985 } 1981 1986 /* check for a zwrite -m */ 1982 z = owl_zwrite_new( argc, argv);1987 z = owl_zwrite_new(buff); 1983 1988 if (!z) { 1984 1989 owl_function_error("Error in zwrite arguments"); … … 2185 2190 if (!strcmp(argv[0], "-f")) { 2186 2191 if (argc<2) { 2187 owl_function_makemsg("Too few arg uments to the view command");2192 owl_function_makemsg("Too few argments to the view command"); 2188 2193 return(NULL); 2189 2194 } … … 2197 2202 } else if (!strcmp(argv[0], "-s")) { 2198 2203 if (argc<2) { 2199 owl_function_makemsg("Too few arg uments to the view command");2204 owl_function_makemsg("Too few argments to the view command"); 2200 2205 return(NULL); 2201 2206 } … … 2204 2209 argv+=2; 2205 2210 } else { 2206 owl_function_makemsg("Too few arg uments to the view command");2211 owl_function_makemsg("Too few argments to the view command"); 2207 2212 return(NULL); 2208 2213 } … … 2791 2796 owl_history_store(hist, owl_editwin_get_text(e), false); 2792 2797 2793 /* Take a reference to the editwin, so that it survives the pop2794 * context. TODO: We should perhaps refcount or otherwise protect2795 * the context so that, even if a command pops a context, the2796 * context itself will last until the command returns. */2797 owl_editwin_ref(e);2798 2798 owl_global_pop_context(&g); 2799 2800 owl_editwin_do_callback(e, false);2801 owl_editwin_unref(e);2802 2799 } 2803 2800 … … 2859 2856 owl_global_pop_context(&g); 2860 2857 2861 owl_editwin_do_callback(e , true);2858 owl_editwin_do_callback(e); 2862 2859 owl_editwin_unref(e); 2863 2860 } -
compat/Makefile.am
rb80bae0 r12a6616 1 1 noinst_LIBRARIES = libcompat.a 2 2 3 libcompat_a_SOURCES = compat.h3 libcompat_a_SOURCES = 4 4 libcompat_a_LIBADD = $(LIBOBJS) -
compat/compat.h
r6249a88f r4dde585 2 2 #define INC_BARNOWL_COMPAT_COMPAT_H 3 3 4 #include <config.h>4 #include "../config.h" 5 5 6 6 #include <stddef.h> -
configure.ac
r77dfeb1 r883502d 1 1 dnl 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]) 2 AC_INIT([BarnOwl],[1.9dev],[bug-barnowl@mit.edu]) 3 AM_INIT_AUTOMAKE([1.7.0 -Wall -Wno-portability foreign]) 5 4 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) 6 5 … … 10 9 AC_PROG_CC 11 10 AC_PROG_CC_C99 12 AC_PROG_LN_S13 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 in19 yes) withval='Config error: see http://mit.edu/df';;20 no) withval='';;21 esac22 zephyr_default_format=$withval23 ],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 )29 11 30 12 AC_ARG_WITH([stack-protector], … … 59 41 60 42 AS_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"], 64 44 [AC_MSG_CHECKING([for Kerberos IV]) 65 45 AS_IF([krb5-config krb4 --libs >/dev/null 2>&1], 66 46 [AC_MSG_RESULT([yes]) 67 have_krb4=yes68 47 AC_DEFINE([HAVE_KERBEROS_IV], [1], [Define if you have kerberos IV]) 69 48 AM_CFLAGS="${AM_CFLAGS} `krb5-config krb4 --cflags`" … … 72 51 [AC_MSG_RESULT([no]) 73 52 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 ])]) 86 58 AC_CHECK_LIB([zephyr], [ZGetSender], 87 59 [LIBS="$LIBS -lzephyr" … … 118 90 dnl Find the location of perl XSUBPP 119 91 AC_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;'`"92 XSUBPPDIR="`(perl -MExtUtils::MakeMaker -e 'print ExtUtils::MakeMaker->new({NAME => qw(owl)})->tool_xsubpp;') | grep \^XSUBPPDIR | sed -e 's/XSUBPPDIR = //g;'`" 121 93 if test -n "${XSUBPPDIR}"; then 122 94 AC_MSG_RESULT(${XSUBPPDIR}) … … 141 113 AX_PROG_PERL_MODULES([Class::Accessor::Fast],, 142 114 [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])])145 115 AX_PROG_PERL_MODULES([Glib],, 146 116 [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])])149 117 AX_PROG_PERL_MODULES([PAR],, 150 118 [AC_MSG_WARN([PAR.pm not found. Loadable modules will be disabled.])]) … … 161 129 prefix="${ac_default_prefix}" 162 130 fi 163 164 dnl Add CFLAGS for glib-perl165 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}"168 131 169 132 dnl Checks for typedefs, structures, and compiler characteristics. … … 187 150 dnl Define __EXTENSIONS__ for strcasecmp on Solaris. 188 151 AM_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 with191 dnl _XOPEN_SOURCE=600, but some versions of ncurses192 dnl apparently still need it.193 AM_CFLAGS="$AM_CFLAGS -D_XOPEN_SOURCE_EXTENDED"194 152 195 153 AC_SUBST([AM_CFLAGS]) … … 210 168 AC_REPLACE_FUNCS([memrchr]) 211 169 212 AC_SUBST([abs_builddir])213 AC_SUBST([abs_srcdir])214 215 170 AC_CONFIG_FILES([Makefile compat/Makefile libfaim/Makefile perl/Makefile perl/modules/Makefile]) 216 171 AC_OUTPUT -
context.c
r7dcef03 rf271129 10 10 if (!(mode & OWL_CTX_MODE_BITS)) 11 11 mode |= OWL_CTX_INTERACTIVE; 12 c = g_ slice_new0(owl_context);12 c = g_new0(owl_context, 1); 13 13 c->mode = mode; 14 14 c->data = data; … … 71 71 if (ctx->delete_cb) 72 72 ctx->delete_cb(ctx); 73 g_ slice_free(owl_context,ctx);73 g_free(ctx); 74 74 } -
doc/barnowl.1
r8135737 rbad4496 35 35 .TP 36 36 \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. 37 Specify an alternate config file for \fBBarnOwl\fP to use. By default, 38 \fBBarnOwl\fP uses \fI~/.barnowlconf\fP if it exists, and \fI~/.owlconf\fP otherwise. 45 39 46 40 .TP -
doc/releasing-barnowl.txt
rd995ff3 r5f08dbe 16 16 - [ ] Do a locker build (See DOING A LOCKER BUILD) 17 17 - [ ] Update configure.ac on master to bump the version to 1.(N+1)dev 18 - [ ] Add the barnowl-1.(N+1)dev git tag19 18 - [ ] Push git git: 20 19 - [ ] The RC commit 21 20 - [ ] The configure.ac change on master 22 21 - [ ] A release-1.N branch pointing at the RC commit 23 - [ ] the new git tags24 - [ ] 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" or27 "Placeholder version number for daily builds."; fix your name and email28 if necessary29 - [ ] bzr commit && bzr push30 22 - [ ] Copy tarball into /mit/barnowl/web_scripts/dist 31 23 - [ ] Send mail announcing the RC to barnowl-dev@mit.edu … … 39 31 * DOING THE ACTUAL RELEASE 40 32 - [ ] Update the changelog and configure.ac for barnowl 1.N 41 - [ ] Copy the changelog changes to the master branch42 33 - [ ] run ./scripts/do-release 43 34 - [ ] Do the locker build -
editwin.c
r7dcef03 rf271129 33 33 oe_excursion *excursions; 34 34 35 void (*callback)(struct _owl_editwin *e, bool success);35 void (*callback)(struct _owl_editwin*); 36 36 void (*destroy_cbdata)(void *); 37 37 void *cbdata; … … 68 68 static CALLER_OWN owl_editwin *owl_editwin_allocate(void) 69 69 { 70 owl_editwin *e = g_ slice_new0(owl_editwin);70 owl_editwin *e = g_new0(owl_editwin, 1); 71 71 e->refcount = 1; 72 72 return e; … … 87 87 oe_destroy_cbdata(e); 88 88 89 g_ slice_free(owl_editwin,e);89 g_free(e); 90 90 } 91 91 … … 220 220 } 221 221 222 void owl_editwin_set_callback(owl_editwin *e, void (*cb)(owl_editwin *, bool))222 void owl_editwin_set_callback(owl_editwin *e, void (*cb)(owl_editwin*)) 223 223 { 224 224 e->callback = cb; 225 225 } 226 226 227 void (*owl_editwin_get_callback(owl_editwin *e))(owl_editwin *, bool)227 void (*owl_editwin_get_callback(owl_editwin *e))(owl_editwin*) 228 228 { 229 229 return e->callback; … … 248 248 } 249 249 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) { 250 void owl_editwin_do_callback(owl_editwin *e) { 251 void (*cb)(owl_editwin*); 252 cb=owl_editwin_get_callback(e); 253 if(!cb) { 255 254 owl_function_error("Internal error: No editwin callback!"); 256 255 } else { 257 cb(e, success); 256 /* owl_function_error("text: |%s|", owl_editwin_get_text(e)); */ 257 cb(e); 258 258 } 259 259 } … … 373 373 owl_editwin_excursion *owl_editwin_begin_excursion(owl_editwin *e) 374 374 { 375 owl_editwin_excursion *x = g_ slice_new(owl_editwin_excursion);375 owl_editwin_excursion *x = g_new(owl_editwin_excursion, 1); 376 376 oe_save_excursion(e, x); 377 377 return x; … … 381 381 { 382 382 oe_restore_excursion(e, x); 383 g_ slice_free(owl_editwin_excursion,x);383 g_free(x); 384 384 } 385 385 … … 619 619 620 620 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."); 622 622 return 0; 623 623 } -
filter.c
r7dcef03 rf271129 18 18 owl_filter *f; 19 19 20 f = g_ slice_new(owl_filter);20 f = g_new(owl_filter, 1); 21 21 22 22 f->name=g_strdup(name); … … 69 69 if(!argc) return NULL; 70 70 71 fe = g_ slice_new(owl_filterelement);71 fe = g_new(owl_filterelement, 1); 72 72 owl_filterelement_create(fe); 73 73 … … 114 114 err: 115 115 owl_filterelement_cleanup(fe); 116 g_ slice_free(owl_filterelement,fe);116 g_free(fe); 117 117 return NULL; 118 118 } … … 124 124 125 125 op1 = owl_filter_parse_primitive_expression(argc-i, argv+i, &skip); 126 i += skip; 126 127 if(!op1) goto err; 127 i += skip;128 128 129 129 while(i < argc) { … … 132 132 op2 = owl_filter_parse_primitive_expression(argc-i-1, argv+i+1, &skip); 133 133 if(!op2) goto err; 134 tmp = g_ slice_new(owl_filterelement);134 tmp = g_new(owl_filterelement, 1); 135 135 if(!strcasecmp(argv[i], "and")) { 136 136 owl_filterelement_create_and(tmp, op1, op2); … … 152 152 if(op1) { 153 153 owl_filterelement_cleanup(op1); 154 g_ slice_free(owl_filterelement,op1);154 g_free(op1); 155 155 } 156 156 return NULL; … … 219 219 } 220 220 else { 221 g_string_append_printf(out, "%i",f-> bgcolor);221 g_string_append_printf(out, "%i",f->fgcolor); 222 222 } 223 223 g_string_append(out, " "); … … 262 262 if (f->root) { 263 263 owl_filterelement_cleanup(f->root); 264 g_ slice_free(owl_filterelement,f->root);264 g_free(f->root); 265 265 } 266 266 if (f->name) 267 267 g_free(f->name); 268 g_ slice_free(owl_filter,f);269 } 268 g_free(f); 269 } -
filterelement.c
r7dcef03 r7756dde 328 328 if (fe->left) { 329 329 owl_filterelement_cleanup(fe->left); 330 g_ slice_free(owl_filterelement,fe->left);330 g_free(fe->left); 331 331 } 332 332 if (fe->right) { 333 333 owl_filterelement_cleanup(fe->right); 334 g_ slice_free(owl_filterelement,fe->right);334 g_free(fe->right); 335 335 } 336 336 owl_regex_cleanup(&(fe->re)); -
filterproc.c
r7155955 rf271129 1 #include " filterproc.h"1 #include "owl.h" 2 2 #include <sys/wait.h> 3 #include <fcntl.h>4 #include <glib.h>5 3 #include <poll.h> 6 #include <string.h>7 #include <unistd.h>8 4 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) 5 int send_receive(int rfd, int wfd, const char *out, char **in) 12 6 { 13 7 GString *str = g_string_new(""); … … 24 18 fds[1].fd = wfd; 25 19 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 }32 20 33 21 while(1) { … … 52 40 } 53 41 if(!out || !*out || fds[1].revents & (POLLERR | POLLHUP)) { 54 close(wfd); wfd = -1;42 close(wfd); 55 43 out = NULL; 56 44 } … … 68 56 } 69 57 70 if (wfd >= 0) close(wfd);71 close(rfd);72 58 *in = g_string_free(str, err < 0); 73 59 return err; 74 60 } 75 61 76 int call_filter(const char * const *argv, const char *in, char **out, int *status)62 int call_filter(const char *prog, const char *const *argv, const char *in, char **out, int *status) 77 63 { 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]; 81 68 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 } 89 97 } 90 98 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: 95 106 return err; 96 107 } -
filterproc.h
r97cdbaf5 r06adc25 2 2 #define INC_BARNOWL_FILTER_PROC_H 3 3 4 int call_filter(const char *const *argv, 4 int call_filter(const char *prog, 5 const char *const *argv, 5 6 const char *in, 6 7 char **out, int *status); -
functions.c
r7dcef03 r0071c88 115 115 void owl_function_show_license(void) 116 116 { 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" 119 121 "Copyright (c) 2006-2011 The BarnOwl Developers. All rights reserved.\n" 120 122 "Copyright (c) 2004 James Kretchmar. All rights reserved.\n" … … 153 155 "WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n" 154 156 "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"; 157 158 owl_function_popless_text(text); 158 g_free(text);159 159 } 160 160 … … 196 196 owl_message *m; 197 197 198 m=g_ slice_new(owl_message);198 m=g_new(owl_message, 1); 199 199 owl_message_create_admin(m, header, body); 200 200 … … 204 204 205 205 /* 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(); 207 207 208 208 /* redisplay etc. */ … … 216 216 void owl_function_add_outgoing_zephyrs(const owl_zwrite *z) 217 217 { 218 if (z->cc && owl_zwrite_is_personal(z)) {218 if (z->cc || owl_zwrite_get_numrecips(z) == 0) { 219 219 /* create the message */ 220 owl_message *m = g_ slice_new(owl_message);220 owl_message *m = g_new(owl_message, 1); 221 221 owl_message_create_from_zwrite(m, z, owl_zwrite_get_message(z), 0); 222 222 … … 225 225 int i; 226 226 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 232 227 /* create the message */ 233 m = g_slice_new(owl_message);228 owl_message *m = g_new(owl_message, 1); 234 229 owl_message_create_from_zwrite(m, z, owl_zwrite_get_message(z), i); 235 230 … … 251 246 if (!owl_global_is_aimloggedin(&g)) return(NULL); 252 247 253 m=g_ slice_new(owl_message);248 m=g_new(owl_message, 1); 254 249 owl_message_create_aim(m, 255 250 owl_global_get_aim_screenname(&g), … … 270 265 271 266 /* create the message */ 272 m=g_ slice_new(owl_message);267 m=g_new(owl_message, 1); 273 268 owl_message_create_loopback(m, body); 274 269 owl_message_set_direction_out(m); … … 277 272 } 278 273 279 owl_editwin *owl_function_start_edit_win(const char *line)274 void owl_function_start_edit_win(const char *line, void (*callback)(owl_editwin *), void *data, void (*cleanup)(void *)) 280 275 { 281 276 owl_editwin *e; … … 291 286 g_free(s); 292 287 288 owl_editwin_set_cbdata(e, data, cleanup); 289 owl_editwin_set_callback(e, callback); 293 290 ctx = owl_editcontext_new(OWL_CTX_EDITMULTI, e, "editmulti", 294 291 owl_global_deactivate_editcontext, &g); 295 292 owl_global_push_context_obj(&g, ctx); 296 return e; 293 297 294 } 298 295 … … 312 309 void owl_function_zwrite_setup(owl_zwrite *z) 313 310 { 314 owl_editwin *e;315 311 /* send a ping if necessary */ 316 312 if (owl_global_is_txping(&g)) { … … 320 316 321 317 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); 325 321 } 326 322 327 323 void owl_function_aimwrite_setup(const char *to) 328 324 { 329 owl_editwin *e;330 325 /* TODO: We probably actually want an owl_aimwrite object like 331 326 * owl_zwrite. */ 332 327 char *line = g_strdup_printf("aimwrite %s", to); 333 328 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); 337 333 g_free(line); 338 334 } … … 340 336 void owl_function_loopwrite_setup(void) 341 337 { 342 owl_editwin *e;343 338 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 344 void owl_callback_zwrite(owl_editwin *e) { 351 345 owl_zwrite *z = owl_editwin_get_cbdata(e); 352 346 owl_function_zwrite(z, owl_editwin_get_text(e)); … … 378 372 owl_function_makemsg("Waiting for ack..."); 379 373 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 } 382 379 } 383 380 #else … … 405 402 406 403 zcrypt = g_build_filename(owl_get_bindir(), "zcrypt", NULL); 407 argv[0] = zcrypt;404 argv[0] = "zcrypt"; 408 405 argv[1] = "-E"; 409 406 argv[2] = "-c"; argv[3] = owl_zwrite_get_class(z); … … 411 408 argv[6] = NULL; 412 409 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); 414 411 415 412 g_free(zcrypt); … … 429 426 owl_function_makemsg("Waiting for ack..."); 430 427 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 */ 436 436 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 439 void owl_callback_aimwrite(owl_editwin *e) { 443 440 char *to = owl_editwin_get_cbdata(e); 444 441 owl_function_aimwrite(to, owl_editwin_get_text(e), true); … … 504 501 } 505 502 506 void owl_callback_loopwrite(owl_editwin *e, bool success) 507 { 508 if (!success) return; 503 void owl_callback_loopwrite(owl_editwin *e) { 509 504 owl_function_loopwrite(owl_editwin_get_text(e)); 510 505 } … … 516 511 /* create a message and put it on the message queue. This simulates 517 512 * an incoming message */ 518 min=g_ slice_new(owl_message);513 min=g_new(owl_message, 1); 519 514 mout=owl_function_make_outgoing_loopback(msg); 520 515 … … 813 808 } 814 809 815 void owl_function_lastmsg (void)810 void owl_function_lastmsg_noredisplay(void) 816 811 { 817 812 int oldcurmsg, curmsg; … … 831 826 owl_global_set_curmsg(&g, curmsg+1); 832 827 } 833 owl_mainwin_redisplay(owl_global_get_mainwin(&g));828 /* owl_mainwin_redisplay(owl_global_get_mainwin(&g)); */ 834 829 owl_global_set_direction_downwards(&g); 830 } 831 832 void owl_function_lastmsg(void) 833 { 834 owl_function_lastmsg_noredisplay(); 835 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 835 836 } 836 837 … … 855 856 void owl_function_unsuball(void) 856 857 { 857 if (unsuball())858 858 unsuball(); 859 owl_function_makemsg("Unsubscribed from all messages."); 859 860 } 860 861 … … 871 872 void owl_function_loadsubs(const char *file) 872 873 { 873 int ret, ret2, ret3; 874 int ret, ret2; 875 const char *foo; 874 876 char *path; 875 877 … … 883 885 884 886 /* for backwards compatibility for now */ 885 ret2 = owl_zephyr_loaddefaultsubs(); 886 ret3 = owl_zephyr_loadbarnowldefaultsubs(); 887 ret2=owl_zephyr_loaddefaultsubs(); 887 888 888 889 if (!owl_context_is_interactive(owl_global_get_context(&g))) return; 889 890 890 if (ret == 0 && ret2 == 0 && ret3 == 0) { 891 foo=file?file:"file"; 892 if (ret==0 && ret2==0) { 891 893 if (!file) { 892 894 owl_function_makemsg("Subscribed to messages."); … … 894 896 owl_function_makemsg("Subscribed to messages from %s", file); 895 897 } 896 } else if (ret ==-1) {897 owl_function_error("Could not read %s", f ile ? file : "file");898 } else if (ret2 == -1){898 } else if (ret==-1) { 899 owl_function_error("Could not read %s", foo); 900 } else { 899 901 owl_function_error("Error subscribing to messages"); 900 } else {901 owl_function_error("Error subscribing to instanced personals");902 902 } 903 903 } … … 918 918 } 919 919 920 void owl_callback_aimlogin(owl_editwin *e, bool success) 921 { 922 if (!success) return; 920 void owl_callback_aimlogin(owl_editwin *e) { 923 921 char *user = owl_editwin_get_cbdata(e); 924 922 owl_function_aimlogin(user, … … 991 989 /* owl_aim_set_awaymsg(""); */ 992 990 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);1000 991 } 1001 992 … … 1359 1350 void owl_function_about(void) 1360 1351 { 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" 1363 1354 "BarnOwl is a fork of the Owl zephyr client, written and\n" 1364 1355 "maintained by Alejandro Sedeno and Nelson Elhage at the\n" … … 1379 1370 "This program is free software. You can redistribute it and/or\n" 1380 1371 "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 ); 1385 1374 } 1386 1375 … … 1441 1430 char *tmpbuff, *tmpbuff2; 1442 1431 int i, fields; 1443 const char *f;1444 1432 1445 1433 if (!owl_message_is_pseudo(m)) { … … 1472 1460 owl_fmtext_append_normal(&fm, "\n"); 1473 1461 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));1475 1462 owl_fmtext_appendf_normal(&fm, " Auth : %s\n", owl_zephyr_get_authstr(n)); 1476 1463 … … 1484 1471 owl_fmtext_appendf_normal(&fm, " Fields : %i\n", fields); 1485 1472 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); 1489 1475 tmpbuff2 = owl_text_indent(tmpbuff, 14, false); 1490 1476 owl_fmtext_appendf_normal(&fm, " Field %i : %s\n", i + 1, tmpbuff2); … … 1784 1770 1785 1771 owl_fmtext_append_normal(&fm, " Version: "); 1786 owl_fmtext_append_normal(&fm, version);1772 owl_fmtext_append_normal(&fm, OWL_VERSION_STRING); 1787 1773 owl_fmtext_append_normal(&fm, "\n"); 1788 1774 … … 1954 1940 } 1955 1941 1956 void owl_callback_command(owl_editwin *e, bool success) 1957 { 1958 if (!success) return; 1942 void owl_callback_command(owl_editwin *e) 1943 { 1959 1944 char *rv; 1960 1945 const char *line = owl_editwin_get_text(e); … … 1967 1952 } 1968 1953 1969 owl_editwin *owl_function_start_command(const char *line)1954 void owl_function_start_command(const char *line) 1970 1955 { 1971 1956 owl_editwin *tw; … … 1982 1967 owl_global_push_context_obj(&g, ctx); 1983 1968 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 1971 CALLER_OWN owl_editwin *owl_function_start_question(const char *line) 1988 1972 { 1989 1973 owl_editwin *tw; … … 2000 1984 } 2001 1985 2002 owl_editwin *owl_function_start_password(const char *line)1986 CALLER_OWN owl_editwin *owl_function_start_password(const char *line) 2003 1987 { 2004 1988 owl_editwin *tw; … … 2197 2181 f = owl_filter_new(argv[1], argc-2, argv+2); 2198 2182 if (f == NULL) { 2199 owl_function_error("Invalid filter : %s", argv[1]);2183 owl_function_error("Invalid filter"); 2200 2184 return false; 2201 2185 } … … 3482 3466 while (zaldptr) { 3483 3467 ZFreeALD(zaldptr->data); 3484 g_ slice_free(ZAsyncLocateData_t,zaldptr->data);3468 g_free(zaldptr->data); 3485 3469 zaldptr = g_list_next(zaldptr); 3486 3470 } … … 3492 3476 for (i = 0; i < anyone->len; i++) { 3493 3477 user = anyone->pdata[i]; 3494 zald = g_ slice_new(ZAsyncLocateData_t);3478 zald = g_new(ZAsyncLocateData_t, 1); 3495 3479 if (ZRequestLocations(zstr(user), zald, UNACKED, ZAUTH) == ZERR_NONE) { 3496 3480 *zaldlist = g_list_append(*zaldlist, zald); 3497 3481 } else { 3498 g_ slice_free(ZAsyncLocateData_t,zald);3482 g_free(zald); 3499 3483 } 3500 3484 } -
global.c
r7dcef03 r9078f69 9 9 const char *homedir; 10 10 11 #if !GLIB_CHECK_VERSION(2, 35, 0)12 11 g_type_init(); 13 #endif14 #if !GLIB_CHECK_VERSION(2, 31, 0)15 12 g_thread_init(NULL); 16 #endif17 13 18 14 owl_select_init(); … … 56 52 g->starttime=time(NULL); /* assumes we call init only a start time */ 57 53 g->lastinputtime=g->starttime; 58 g->last_wakeup_time = g->starttime;59 54 g->newmsgproc_pid=0; 60 55 … … 80 75 g_free(cd); 81 76 82 g->msglist = owl_messagelist_new();77 owl_messagelist_create(&(g->msglist)); 83 78 84 79 _owl_global_init_windows(g); … … 105 100 106 101 g->interrupt_count = 0; 107 #if GLIB_CHECK_VERSION(2, 31, 0)108 g_mutex_init(&g->interrupt_lock);109 #else110 102 g->interrupt_lock = g_mutex_new(); 111 #endif112 103 } 113 104 … … 118 109 119 110 /* Create the widgets */ 120 g->mw = owl_mainwin_new(g->mainpanel.recwin);111 owl_mainwin_init(&(g->mw), g->mainpanel.recwin); 121 112 owl_msgwin_init(&(g->msgwin), g->mainpanel.msgwin); 122 113 owl_sepbar_init(g->mainpanel.sepwin); … … 250 241 /* windows */ 251 242 252 owl_mainwin *owl_global_get_mainwin(owl_global *g) 253 { 254 return g->mw; 243 owl_mainwin *owl_global_get_mainwin(owl_global *g) { 244 return(&(g->mw)); 255 245 } 256 246 … … 266 256 267 257 owl_messagelist *owl_global_get_msglist(owl_global *g) { 268 return g->msglist;258 return(&(g->msglist)); 269 259 } 270 260 … … 485 475 } 486 476 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 495 477 /* viewwin */ 496 478 … … 553 535 e->g->filterlist = g_list_remove(e->g->filterlist, e->f); 554 536 owl_filter_delete(e->f); 555 g_ slice_free(owl_global_filter_ent,e);537 g_free(e); 556 538 } 557 539 558 540 void 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); 560 542 e->g = g; 561 543 e->f = f; … … 858 840 } filters[] = { 859 841 { "personal", 860 "isprivate ^true$ and ( not type ^zephyr$ or ( class ^message $) )" },842 "isprivate ^true$ and ( not type ^zephyr$ or ( class ^message ) )" }, 861 843 { "trash", 862 844 "class ^mail$ or opcode ^ping$ or type ^admin$ or ( not login ^none$ )" }, … … 865 847 { "auto", "opcode ^auto$" }, 866 848 { "login", "not login ^none$" }, 867 { "reply-lockout", "class ^mail$ or class ^filsrv$" },849 { "reply-lockout", "class ^mail$" }, 868 850 { "out", "direction ^out$" }, 869 851 { "aim", "type ^aim$" }, … … 916 898 } 917 899 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 #else923 return g->interrupt_lock;924 #endif925 }926 927 900 void owl_global_add_interrupt(owl_global *g) { 928 901 /* TODO: This can almost certainly be done with atomic 929 902 * operations. Whatever. */ 930 g_mutex_lock( owl_global_get_interrupt_lock(g));903 g_mutex_lock(g->interrupt_lock); 931 904 g->interrupt_count++; 932 g_mutex_unlock( owl_global_get_interrupt_lock(g));905 g_mutex_unlock(g->interrupt_lock); 933 906 } 934 907 935 908 bool owl_global_take_interrupt(owl_global *g) { 936 909 bool ans = false; 937 g_mutex_lock( owl_global_get_interrupt_lock(g));910 g_mutex_lock(g->interrupt_lock); 938 911 if (g->interrupt_count > 0) { 939 912 ans = true; 940 913 g->interrupt_count--; 941 914 } 942 g_mutex_unlock( owl_global_get_interrupt_lock(g));915 g_mutex_unlock(g->interrupt_lock); 943 916 return ans; 944 917 } -
help.c
r8258ea5 rf271129 73 73 " : , M-x Enter command mode\n" 74 74 "\n" 75 " / Fo rward search\n"75 " / Foward search\n" 76 76 " ? Reverse search\n" 77 77 "\n\n" … … 107 107 " unsuball Unsubscribe from all zephyr classes\n" 108 108 " load-subs Load zephyr subscriptions from a file\n" 109 " zpunt Sup press messages from a zephyr triplet\n"109 " zpunt Supress messages from a zephyr triplet\n" 110 110 " zlog Send a login or logout notification\n" 111 111 " zlist Print a list of zephyr buddies logged in\n" -
keybinding.c
r7dcef03 rf271129 14 14 CALLER_OWN owl_keybinding *owl_keybinding_new(const char *keyseq, const char *command, void (*function_fn)(void), const char *desc) 15 15 { 16 owl_keybinding *kb = g_ slice_new(owl_keybinding);16 owl_keybinding *kb = g_new(owl_keybinding, 1); 17 17 18 18 owl_function_debugmsg("owl_keybinding_init: creating binding for <%s> with desc: <%s>", keyseq, desc); 19 19 if (command && function_fn) { 20 g_ slice_free(owl_keybinding,kb);20 g_free(kb); 21 21 return NULL; 22 22 } else if (command && !function_fn) { … … 29 29 30 30 if (owl_keybinding_make_keys(kb, keyseq) != 0) { 31 g_ slice_free(owl_keybinding,kb);31 g_free(kb); 32 32 return NULL; 33 33 } … … 70 70 g_free(kb->desc); 71 71 g_free(kb->command); 72 g_ slice_free(owl_keybinding,kb);72 g_free(kb); 73 73 } 74 74 -
keymap.c
r7dcef03 rf271129 189 189 { 190 190 owl_keymap *km; 191 km = g_ slice_new(owl_keymap);191 km = g_new(owl_keymap, 1); 192 192 owl_keymap_init(km, name, desc, default_fn, prealways_fn, postalways_fn); 193 193 owl_keyhandler_add_keymap(kh, km); -
libfaim/Makefile.am
rb80bae0 r215c119 13 13 libfaim_a_CPPFLAGS = -DAIM_BUILDDATE=\"x\" -DAIM_BUILDTIME=\"x\" \ 14 14 -I${top_srcdir}/libfaim 15 16 EXTRA_DIST = oscar.c -
logging.c
r7dcef03 rf271129 177 177 g_free(msg->message); 178 178 g_free(msg->filename); 179 g_ slice_free(owl_log_entry,msg);179 g_free(msg); 180 180 } 181 181 } … … 184 184 { 185 185 owl_log_entry *log_msg = NULL; 186 log_msg = g_ slice_new(owl_log_entry);186 log_msg = g_new(owl_log_entry,1); 187 187 log_msg->message = g_strdup(buffer); 188 188 log_msg->filename = g_strdup(filename); … … 266 266 * owl_log_shouldlog_message(void) 267 267 */ 268 m = g_ slice_new(owl_message);268 m = g_new(owl_message, 1); 269 269 /* recip_index = 0 because there can only be one recipient anyway */ 270 270 owl_message_create_from_zwrite(m, zw, text, 0); … … 429 429 static gpointer owl_log_thread_func(gpointer data) 430 430 { 431 log_context = g_main_context_new(); 431 432 log_loop = g_main_loop_new(log_context, FALSE); 432 433 g_main_loop_run(log_loop); … … 436 437 void owl_log_init(void) 437 438 { 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 #else444 439 GError *error = NULL; 445 440 logging_thread = g_thread_create(owl_log_thread_func, … … 453 448 exit(1); 454 449 } 455 #endif456 450 457 451 } -
m4/ax_cflags_warn_all.m4
re9b4a2c r378ede7 25 25 # - $3 action-if-found : add value to shellvariable 26 26 # - $4 action-if-not-found : nothing 27 #28 # NOTE: These macros depend on AX_APPEND_FLAG.29 27 # 30 28 # LICENSE … … 59 57 # exception to the GPL to apply to your modified version as well. 60 58 61 #serial 1 459 #serial 10 62 60 63 AC_DEFUN([AX_ FLAGS_WARN_ALL],[dnl64 AS_VAR_PUSHDEF([FLAGS],[ _AC_LANG_PREFIX[]FLAGS])dnl65 AS_VAR_PUSHDEF([VAR],[ac_cv_ []_AC_LANG_ABBREV[]flags_warn_all])dnl61 AC_DEFUN([AX_CFLAGS_WARN_ALL],[dnl 62 AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl 63 AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_warn_all])dnl 66 64 AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings], 67 65 VAR,[VAR="no, unknown" 68 ac_save_[]FLAGS="$[]FLAGS" 66 AC_LANG_PUSH([C]) 67 ac_save_[]FLAGS="$[]FLAGS" 68 for ac_arg dnl 69 in "-pedantic % -Wall" dnl GCC 70 "-xstrconst % -v" dnl Solaris C 71 "-std1 % -verbose -w0 -warnprotos" dnl Digital Unix 72 "-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX 73 "-ansi -ansiE % -fullwarn" dnl IRIX 74 "+ESlit % +w1" dnl HP-UX C 75 "-Xc % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10) 76 "-h conform % -h msglevel 2" dnl Cray C (Unicos) 77 # 78 do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` 79 AC_COMPILE_IFELSE([AC_LANG_PROGRAM], 80 [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) 81 done 82 FLAGS="$ac_save_[]FLAGS" 83 AC_LANG_POP([C]) 84 ]) 85 case ".$VAR" in 86 .ok|.ok,*) m4_ifvaln($3,$3) ;; 87 .|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[ 88 AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"]) 89 m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])]) ;; 90 *) m4_ifvaln($3,$3,[ 91 if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null 92 then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR]) 93 else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"]) 94 m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR" 95 fi ]) ;; 96 esac 97 AS_VAR_POPDEF([VAR])dnl 98 AS_VAR_POPDEF([FLAGS])dnl 99 ]) 100 101 dnl the only difference - the LANG selection... and the default FLAGS 102 103 AC_DEFUN([AX_CXXFLAGS_WARN_ALL],[dnl 104 AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl 105 AS_VAR_PUSHDEF([VAR],[ax_cv_cxxflags_warn_all])dnl 106 AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings], 107 VAR,[VAR="no, unknown" 108 AC_LANG_PUSH([C++]) 109 ac_save_[]FLAGS="$[]FLAGS" 110 for ac_arg dnl 111 in "-pedantic % -Wall" dnl GCC 112 "-xstrconst % -v" dnl Solaris C 113 "-std1 % -verbose -w0 -warnprotos" dnl Digital Unix 114 "-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX 115 "-ansi -ansiE % -fullwarn" dnl IRIX 116 "+ESlit % +w1" dnl HP-UX C 117 "-Xc % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10) 118 "-h conform % -h msglevel 2" dnl Cray C (Unicos) 119 # 120 do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` 121 AC_COMPILE_IFELSE([AC_LANG_PROGRAM], 122 [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) 123 done 124 FLAGS="$ac_save_[]FLAGS" 125 AC_LANG_POP([C++]) 126 ]) 127 case ".$VAR" in 128 .ok|.ok,*) m4_ifvaln($3,$3) ;; 129 .|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[ 130 AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"]) 131 m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])]) ;; 132 *) m4_ifvaln($3,$3,[ 133 if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null 134 then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR]) 135 else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"]) 136 m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR" 137 fi ]) ;; 138 esac 139 AS_VAR_POPDEF([VAR])dnl 140 AS_VAR_POPDEF([FLAGS])dnl 141 ]) 142 143 dnl the only difference - the LANG selection... and the default FLAGS 144 145 AC_DEFUN([AX_FCFLAGS_WARN_ALL],[dnl 146 AS_VAR_PUSHDEF([FLAGS],[FCFLAGS])dnl 147 AS_VAR_PUSHDEF([VAR],[ax_cv_fcflags_warn_all])dnl 148 AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings], 149 VAR,[VAR="no, unknown" 150 AC_LANG_PUSH([Fortran]) 151 ac_save_[]FLAGS="$[]FLAGS" 69 152 for ac_arg dnl 70 153 in "-warn all % -warn all" dnl Intel … … 82 165 [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) 83 166 done 84 FLAGS="$ac_save_[]FLAGS" 167 FLAGS="$ac_save_[]FLAGS" 168 AC_LANG_POP([Fortran]) 85 169 ]) 86 AS_VAR_POPDEF([FLAGS])dnl87 AC_REQUIRE([AX_APPEND_FLAG])88 170 case ".$VAR" in 89 171 .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 ]) ;; 92 181 esac 93 182 AS_VAR_POPDEF([VAR])dnl 94 ])dnl AX_FLAGS_WARN_ALL 183 AS_VAR_POPDEF([FLAGS])dnl 184 ]) 185 95 186 dnl implementation tactics: 96 187 dnl the for-argument contains a list of options. The first part of … … 103 194 dnl delimiter. A non-option comment can be given after "%%" marks 104 195 dnl which will be shown but not added to the respective C/CXXFLAGS. 105 106 AC_DEFUN([AX_CFLAGS_WARN_ALL],[dnl107 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],[dnl113 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],[dnl119 AC_LANG_PUSH([Fortran])120 AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4])121 AC_LANG_POP([Fortran])122 ]) -
m4/pkg.m4
r13a39ae8 r650fb2c 158 158 fi[]dnl 159 159 ])# PKG_CHECK_MODULES 160 161 162 # PKG_INSTALLDIR(DIRECTORY)163 # -------------------------164 # Substitutes the variable pkgconfigdir as the location where a module165 # should install pkg-config .pc files. By default the directory is166 # $libdir/pkgconfig, but the default can be changed by passing167 # DIRECTORY. The user can override through the --with-pkgconfigdir168 # 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_INSTALLDIR180 181 182 # PKG_NOARCH_INSTALLDIR(DIRECTORY)183 # -------------------------184 # Substitutes the variable noarch_pkgconfigdir as the location where a185 # module should install arch-independent pkg-config .pc files. By186 # default the directory is $datadir/pkgconfig, but the default can be187 # changed by passing DIRECTORY. The user can override through the188 # --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_INSTALLDIR200 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])dnl208 AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl209 210 _PKG_CONFIG([$1], [variable="][$3]["], [$2])211 AS_VAR_COPY([$1], [pkg_cv_][$1])212 213 AS_VAR_IF([$1], [""], [$5], [$4])dnl214 ])# PKG_CHECK_VAR -
mainwin.c
r7dcef03 r099597c 4 4 static void owl_mainwin_resized(owl_window *w, void *user_data); 5 5 6 CALLER_OWN owl_mainwin *owl_mainwin_new(owl_window *window)6 void owl_mainwin_init(owl_mainwin *mw, owl_window *window) 7 7 { 8 owl_mainwin *mw = g_slice_new(owl_mainwin);9 8 mw->curtruncated=0; 10 9 mw->lastdisplayed=-1; … … 17 16 /* For now, we do not bother with connecting up dependencies; that'll be a 18 17 * future refactor of the mainwin */ 19 20 return mw;21 18 } 22 19 -
message.c
r7dcef03 r0071c88 70 70 71 71 if(pair == NULL) { 72 pair = g_ slice_new(owl_pair);72 pair = g_new(owl_pair, 1); 73 73 owl_pair_create(pair, attrname, NULL); 74 74 g_ptr_array_add(m->attributes, pair); … … 836 836 837 837 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 != '@') { 840 842 owl_message_set_isprivate(m); 841 843 } … … 875 877 if (owl_global_is_zcrypt(&g) && !strcasecmp(n->z_opcode, "crypt")) { 876 878 const char *argv[] = { 877 NULL,879 "zcrypt", 878 880 "-D", 879 881 "-c", owl_message_get_class(m), … … 881 883 NULL 882 884 }; 883 char *out = NULL;885 char *out; 884 886 int rv; 885 887 int status; … … 887 889 888 890 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); 892 893 g_free(zcrypt); 893 894 … … 898 899 } 899 900 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 } 906 905 } 907 906 … … 1019 1018 p = m->attributes->pdata[i]; 1020 1019 g_free(owl_pair_get_value(p)); 1021 g_ slice_free(owl_pair,p);1020 g_free(p); 1022 1021 } 1023 1022 … … 1030 1029 { 1031 1030 owl_message_cleanup(m); 1032 g_ slice_free(owl_message,m);1033 } 1031 g_free(m); 1032 } -
messagelist.c
r7dcef03 rf271129 1 1 #include "owl.h" 2 2 3 CALLER_OWN owl_messagelist *owl_messagelist_new(void)3 void owl_messagelist_create(owl_messagelist *ml) 4 4 { 5 owl_messagelist *ml = g_slice_new(owl_messagelist);6 5 ml->list = g_ptr_array_new(); 7 return ml;8 6 } 9 7 10 void owl_messagelist_ delete(owl_messagelist *ml, bool free_messages)8 void owl_messagelist_cleanup(owl_messagelist *ml, bool free_messages) 11 9 { 12 10 if (free_messages) 13 11 g_ptr_array_foreach(ml->list, (GFunc)owl_message_delete, NULL); 14 12 g_ptr_array_free(ml->list, true); 15 g_slice_free(owl_messagelist, ml);16 13 } 17 14 -
owl.c
r441fd42 rf271129 12 12 #include <sys/stat.h> 13 13 #include <locale.h> 14 #include <unistd.h>15 14 16 15 #if OWL_STDERR_REDIR … … 34 33 } owl_options; 35 34 36 void usage( FILE *file)35 void usage(void) 37 36 { 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"); 47 46 } 48 47 … … 80 79 break; 81 80 case 'v': 82 printf("This is BarnOwl version %s\n", version);81 printf("This is BarnOwl version %s\n", OWL_VERSION_STRING); 83 82 exit(0); 84 83 case 'h': 85 usage(stdout);86 exit(0);87 84 default: 88 usage( stderr);85 usage(); 89 86 exit(1); 90 87 } … … 265 262 /* follow the last message if we're supposed to */ 266 263 if (followlast) 267 owl_function_lastmsg ();264 owl_function_lastmsg_noredisplay(); 268 265 269 266 /* do the newmsgproc thing */ … … 289 286 290 287 owl_global_set_lastinputtime(&g, time(NULL)); 291 owl_global_wakeup(&g);292 288 ret = owl_keyhandler_process(owl_global_get_keyhandler(&g), j); 293 289 if (ret!=0 && ret!=1) { … … 431 427 if (0 != pipe(pipefds)) { 432 428 perror("pipe"); 433 owl_function_debugmsg("stderr_replace: pipe FAILED ");429 owl_function_debugmsg("stderr_replace: pipe FAILED\n"); 434 430 return -1; 435 431 } 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)); 439 435 perror("dup2"); 440 436 return -1; … … 518 514 #if OWL_STDERR_REDIR 519 515 /* 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); 526 520 #endif 527 521 … … 578 572 /* welcome message */ 579 573 owl_function_debugmsg("startup: creating splash message"); 580 char *welcome = g_strdup_printf(574 owl_function_adminmsg("", 581 575 "-----------------------------------------------------------------------\n" 582 "Welcome to BarnOwl version %s.\n"576 "Welcome to BarnOwl version " OWL_VERSION_STRING ".\n" 583 577 "To see a quick introduction, type ':show quickstart'. \n" 584 578 "Press 'h' for on-line help. \n" … … 588 582 " OvO \n" 589 583 "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 ); 599 586 600 587 /* process the startup file */ … … 609 596 owl_function_error("No such style: %s", owl_global_get_default_style(&g)); 610 597 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 611 603 source = owl_window_redraw_source_new(); 612 604 g_source_attach(source, NULL); -
owl.h
rca1fb26a rb9517cf 10 10 #define INC_BARNOWL_OWL_H 11 11 12 #include <config.h>12 #include "config.h" 13 13 14 14 #include "compat/compat.h" … … 47 47 /* Perl and curses don't play nice. */ 48 48 #ifdef OWL_PERL 49 typedef struct _owl_fake_WINDOWWINDOW;50 typedef struct _owl_fake_PANELPANEL;49 typedef void WINDOW; 50 typedef void PANEL; 51 51 /* logout is defined in FreeBSD. */ 52 52 #define logout logout_ … … 57 57 #include "XSUB.h" 58 58 #else 59 typedef struct _owl_fake_SVSV;60 typedef struct _owl_fake_AVAV;61 typedef struct _owl_fake_HVHV;59 typedef void SV; 60 typedef void AV; 61 typedef void HV; 62 62 #endif 63 63 64 64 #include "window.h" 65 65 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 */ 67 75 68 76 /* Feature that is being tested to redirect stderr through a pipe. … … 227 235 char *name; 228 236 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 */ 231 240 char *summary; /* summary of usage */ 232 241 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); 235 246 /* 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); 241 262 /* 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 */ 259 266 } owl_variable; 260 261 267 262 268 typedef struct _owl_input { … … 446 452 char *name; 447 453 owl_filter *filter; 448 owl_messagelist *ml;454 owl_messagelist ml; 449 455 const owl_style *style; 450 456 int cachedmsgid; … … 527 533 528 534 typedef struct _owl_global { 529 owl_mainwin *mw;535 owl_mainwin mw; 530 536 owl_popwin *pw; 531 537 owl_msgwin msgwin; … … 545 551 int curmsg_vert_offset; 546 552 owl_view current_view; 547 owl_messagelist *msglist;553 owl_messagelist msglist; 548 554 WINDOW *input_pad; 549 555 owl_mainpanel mainpanel; … … 563 569 time_t starttime; 564 570 time_t lastinputtime; 565 time_t last_wakeup_time;566 571 char *startupargs; 567 572 int nextmsgid; … … 591 596 char *kill_buffer; 592 597 int interrupt_count; 593 #if GLIB_CHECK_VERSION(2, 31, 0)594 GMutex interrupt_lock;595 #else596 598 GMutex *interrupt_lock; 597 #endif598 599 } owl_global; 599 600 … … 601 602 extern owl_global g; 602 603 603 #include <owl_prototypes.h>604 #include "owl_prototypes.h" 604 605 605 606 /* These were missing from the Zephyr includes before Zephyr 3. */ … … 609 610 #endif 610 611 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 617 612 #endif /* INC_BARNOWL_OWL_H */ -
owl_perl.h
r92ffd89 rf271129 4 4 #include <stdio.h> 5 5 6 /* 7 * This macro defines a convenience wrapper around the boilerplate 8 * of pushing char * arguments on to the stack for perl calling. 9 * 10 * Arguments are 11 * * i - the counter variable to use, which must be declared prior 12 * to calling this macro 13 * * argc - the number of arguments 14 * * argv - an array of char*s, of length at least argc; the arguments 15 * to push on to the stack 16 */ 17 #define OWL_PERL_PUSH_ARGS(i, argc, argv) { \ 18 for (i = 0; i < argc; i++) { \ 19 XPUSHs(sv_2mortal(owl_new_sv(argv[i]))); \ 20 } \ 21 } 6 #define OWL_PERL_VOID_CALL (void)POPs; 22 7 23 8 /* 24 9 * 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. 26 11 * 27 12 * 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 35 19 * 36 20 * See also: `perldoc perlcall', `perldoc perlapi' 37 21 */ 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 } \ 61 49 } else { \ 62 owl_function_error(err, SvPV_nolen(ERRSV)); \ 63 if (!discardret) (void)POPs; \ 64 sv_setsv(ERRSV, &PL_sv_undef); \ 50 ret; \ 65 51 } \ 66 } else if (!discardret) { \ 67 ret; \ 68 } \ 69 PUTBACK; \ 70 FREETMPS; \ 71 LEAVE; \ 52 PUTBACK; \ 53 FREETMPS; \ 54 LEAVE; \ 72 55 } 73 56 -
perl/Makefile.am
ra870319 r10557e6 1 1 SUBDIRS = 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 5 5 6 6 use base qw(Exporter); 7 our @EXPORT_OK = qw(command getcurmsg getnumcols getnumlines getidletime 8 register_idle_watcher unregister_idle_watcher 7 our @EXPORT_OK = qw(command getcurmsg getnumcols getidletime 9 8 zephyr_getsender zephyr_getrealm zephyr_zwrite 10 9 zephyr_stylestrip zephyr_smartstrip_user zephyr_getsubs 11 10 queue_message admin_message 12 start_edit13 11 start_question start_password start_edit_win 14 12 get_data_dir get_config_dir popless_text popless_ztext 15 13 error debug 16 14 create_style getnumcolors wordwrap 17 message_matches_filter18 15 add_dispatch remove_dispatch 19 16 add_io_dispatch remove_io_dispatch 20 17 new_command 21 18 new_variable_int new_variable_bool new_variable_string 22 new_variable_enum23 19 quote redisplay); 24 20 our %EXPORT_TAGS = (all => \@EXPORT_OK); … … 47 43 48 44 use List::Util qw(max); 49 use Tie::RefHash;50 45 51 46 =head1 NAME … … 97 92 command line, and C<MESSAGE> is the zephyr body to send. 98 93 99 =cut100 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 107 94 =head2 ztext_stylestrip STRING 108 95 … … 118 105 Enqueue a message in the BarnOwl message list, logging it and 119 106 processing it appropriately. C<MESSAGE> should be an instance of 120 BarnOwl::Message or a subclass. 107 BarnOwl::Message or a subclass. Returns the queued message. This 108 is useful for, e.g., deleting a message from the message list. 121 109 122 110 =head2 admin_message HEADER BODY … … 124 112 Display a BarnOwl B<Admin> message, with the given header and body. 125 113 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 116 Displays C<PROMPT> on the screen and lets the user enter a line of 117 text, and calls C<CALLBACK>, which must be a perl subroutine 118 reference, with the text the user entered 119 120 =head2 start_password PROMPT CALLBACK 121 122 Like C<start_question>, but echoes the user's input as C<*>s when they 157 123 input. 158 124 159 =back160 161 =item callback162 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 canceled166 the edit_win and true otherwise.167 168 =back169 170 =head2 start_question PROMPT CALLBACK171 172 =head2 start_password PROMPT CALLBACK173 174 125 =head2 start_edit_win PROMPT CALLBACK 175 126 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 } 127 Like C<start_question>, but displays C<PROMPT> on a line of its own 128 and opens the editwin. If the user cancels the edit win, C<CALLBACK> 129 is not invoked. 212 130 213 131 =head2 get_data_dir … … 242 160 243 161 Returns 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, and248 C<MESSAGE> matches that filter. Returns 0 otherwise. If249 C<QUIET> is false, this method displays an error message if250 if C<FILTER_NAME> does not name a valid filter.251 162 252 163 =head2 add_dispatch FD CALLBACK … … 348 259 our @all_commands; 349 260 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 } 261 if(!$configfile && -f $ENV{HOME} . "/.barnowlconf") { 262 $configfile = $ENV{HOME} . "/.barnowlconf"; 263 } 264 $configfile ||= $ENV{HOME}."/.owlconf"; 359 265 360 266 # populate global variable space for legacy owlconf files … … 413 319 =head2 new_variable_string NAME [{ARGS}] 414 320 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 321 Add a new owl variable, either an int, a bool, or a string, with the 418 322 specified name. 419 323 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: 324 ARGS can optionally contain the following keys: 423 325 424 326 =over 4 … … 438 340 =back 439 341 440 In addition, new_variable_string optionally accepts a string validsettings441 parameter, in case people want to set it to "<path>".442 443 342 =cut 444 343 445 344 sub 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; 458 347 } 459 348 460 349 sub 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; 473 352 } 474 353 475 354 sub 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 359 sub _new_variable { 360 my $func = shift; 361 my $default_default = shift; 535 362 my $name = shift; 536 363 my $args = shift || {}; 537 364 my %args = ( 538 summary => "",365 summary => "", 539 366 description => "", 540 takes_on_off => 0, 541 validsettings => "<string>", 367 default => $default_default, 542 368 %{$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}); 562 370 } 563 371 … … 795 603 } 796 604 797 =head3 register_idle_watcher %ARGS798 799 Call a callback whenever the amount of time the user becomes idle or comes800 back from being idle.801 802 You must include the following parameters:803 804 =over 4805 806 =item name807 808 The name given to the idle watcher809 810 =item after811 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 callback817 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 =back823 824 This method returns a unique identifier which may be passed to825 L<BarnOwl::unregister_idle_watcher>.826 827 =cut828 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 =cut835 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 unidle849 $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 idle855 $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 watcher869 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 878 605 # Stub for owl::startup / BarnOwl::startup, so it isn't bound to the 879 606 # startup command. This may be redefined in a user's configfile. -
perl/lib/BarnOwl/Complete/Client.pm
r4626016 r58f4fb2 20 20 21 21 my %show = ( 22 information => undef, 22 23 colors => undef, 23 24 commands => undef, … … 204 205 BarnOwl::Completion::register_completer(set => \&complete_set); 205 206 BarnOwl::Completion::register_completer(unset => \&complete_set); 206 BarnOwl::Completion::register_completer(startup => \&complete_startup); 207 BarnOwl::Completion::register_completer(unstartup => \&complete_startup); 207 BarnOwl::Completion::register_completer(startup => \&complete_startup); 208 208 BarnOwl::Completion::register_completer(bindkey => \&complete_bindkey); 209 209 BarnOwl::Completion::register_completer(print => \&complete_print); -
perl/lib/BarnOwl/Complete/Zephyr.pm
re6e7842 r3e8625f 64 64 BarnOwl::Completion::register_completer(viewuser => \&complete_viewuser); 65 65 BarnOwl::Completion::register_completer(vu => \&complete_viewuser); 66 BarnOwl::Completion::register_completer(viewperson => \&complete_viewuser);67 BarnOwl::Completion::register_completer(vp => \&complete_viewuser);68 66 69 67 BarnOwl::Completion::register_completer(unsub => \&complete_unsub); -
perl/lib/BarnOwl/Hooks.pm
r120dac7 rb8a3e00 36 36 Called before BarnOwl shutdown 37 37 38 =item $wakeup39 40 Called, at most once per second, on user input41 42 38 =item $receiveMessage 43 39 … … 61 57 from every function registered with this hook will be appended and 62 58 displayed in a popup window, with zephyr formatting parsed. 63 64 =item $awayOn65 66 Called, for all protocol handlers, to go away, with the away message,67 if any.68 69 =item $awayOff70 71 Called, for all protocol handlers, to come back from away.72 73 =item $getIsAway74 75 Called to check away status for all protocol handlers. Protocol76 handlers should return a true value if any account of the user is away77 for the given protocol, and a false value otherwise.78 59 79 60 =item $getQuickstart … … 92 73 93 74 our @EXPORT_OK = qw($startup $shutdown 94 $wakeup95 75 $receiveMessage $newMessage 96 76 $mainLoop $getBuddyList 97 $awayOn $awayOff $getIsAway98 77 $getQuickstart); 99 78 … … 104 83 our $startup = BarnOwl::Hook->new; 105 84 our $shutdown = BarnOwl::Hook->new; 106 our $wakeup = BarnOwl::Hook->new;107 85 our $receiveMessage = BarnOwl::Hook->new; 108 86 our $newMessage = BarnOwl::Hook->new; … … 110 88 our $getBuddyList = BarnOwl::Hook->new; 111 89 our $getQuickstart = BarnOwl::Hook->new; 112 our $awayOn = BarnOwl::Hook->new;113 our $awayOff = BarnOwl::Hook->new;114 our $getIsAway = BarnOwl::Hook->new;115 90 116 91 # Internal startup/shutdown routines called by the C code … … 200 175 } 201 176 202 sub _wakeup {203 $wakeup->run;204 }205 206 177 sub _receive_msg { 207 178 my $m = shift; … … 228 199 sub _get_quickstart { 229 200 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;243 201 } 244 202 -
perl/lib/BarnOwl/Message.pm
r0adbce1 ra130fc5 51 51 sub is_ping { return 0; } 52 52 sub is_mail { return 0; } 53 sub is_personal { return BarnOwl::message_matches_filter(shift, "personal"); }53 sub is_personal { return shift->is_private; } 54 54 sub class { return undef; } 55 55 sub instance { return undef; } -
perl/lib/BarnOwl/Message/Zephyr.pm
r0adbce1 redd0be7 51 51 my ($m) = @_; 52 52 return undef if (!$m->is_loginout); 53 return undef if (!defined($m->fields));54 53 return $m->fields->[2]; 55 54 } … … 58 57 my ($m) = @_; 59 58 return undef if (!$m->is_loginout); 60 return undef if (!defined($m->fields));61 59 return $m->fields->[0]; 62 60 } … … 65 63 66 64 sub is_ping { return (lc(shift->opcode) eq "ping"); } 65 66 sub is_personal { 67 my ($m) = @_; 68 return ((lc($m->class) eq "message") 69 && $m->is_private); 70 } 67 71 68 72 sub is_mail { … … 167 171 $class = $self->class; 168 172 $instance = $self->instance; 169 if ($self->recipient eq '' || $self->recipient =~ /^@/) { 173 if ($self->recipient eq '*' || $self->recipient eq '') { 174 $to = ''; 175 } elsif ($self->recipient =~ /^@/) { 170 176 $to = $self->recipient; 171 177 } else { -
perl/lib/BarnOwl/ModuleLoader.pm
rf34728b rf544216 127 127 } 128 128 129 sub complete_module_name {130 return sort(keys %modules);131 }132 133 129 sub register_keybindings { 134 130 BarnOwl::new_command('reload-modules', sub {BarnOwl::ModuleLoader->reload}, { … … 142 138 description => q{Reloads a single module located in ~/.owl/modules or the system modules directory} 143 139 }); 144 145 BarnOwl::Completion::register_completer('reload-module', \&complete_module_name);146 140 } 147 141 -
perl/lib/BarnOwl/Style/Default.pm
rebc6f77 r5738650 113 113 } 114 114 $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 }118 115 } 119 116 … … 129 126 my $self = shift; 130 127 my $m = shift; 131 my $sender = $self->humanize($m->long_sender, 1); 128 my $sender = $m->long_sender; 129 $sender =~ s/\n.*$//s; 132 130 if (BarnOwl::getvar('colorztext') eq 'on') { 133 131 return " (" . $sender . '@color[default]' . ")"; -
perl/lib/BarnOwl/Zephyr.pm
r53151d4 rdf569c5 12 12 use BarnOwl::Hook; 13 13 14 our$zephyrStartup = BarnOwl::Hook->new;14 my $zephyrStartup = BarnOwl::Hook->new; 15 15 16 16 sub _zephyr_startup { -
perl/lib/Module/Install/BarnOwl.pm
re4b8f93 rb8a3e00 41 41 my $class = ref $self; 42 42 43 my $srcdir = $ENV{BARNOWL_SRCDIR} || '.';44 45 43 $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"); 49 45 50 46 $self->postamble(<<"END_MAKEFILE"); 51 47 52 48 # --- $class section: 53 54 BARNOWL_SRCDIR = $srcdir55 export BARNOWL_SRCDIR56 49 57 50 $name.par: pm_to_blib -
perl/modules/IRC/lib/BarnOwl/Module/IRC.pm
r926c721 rb8a3e00 21 21 22 22 use AnyEvent::IRC; 23 use Getopt::Long; 23 24 use Encode; 24 use File::Spec;25 use Getopt::Long;26 use Text::Wrap;27 25 28 26 our $VERSION = 0.02; 29 30 our $IRC_SUBS_FILENAME = "ircchannels";31 27 32 28 our $irc; … … 71 67 }); 72 68 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 81 69 register_commands(); 82 70 BarnOwl::filter(qw{irc type ^IRC$ or ( type ^admin$ and adminheader ^IRC$ )}); … … 141 129 argument listed above, and die if no channel argument can be found. 142 130 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 148 131 =item C<CHANNEL_OPTIONAL> 149 132 … … 162 145 use constant CHANNEL_ARG => 1; 163 146 use constant CHANNEL_OPTIONAL => 2; 164 use constant CHANNEL_OR_USER => 4; 165 166 use constant ALLOW_DISCONNECTED => 8; 147 148 use constant ALLOW_DISCONNECTED => 4; 167 149 168 150 sub register_commands { … … 172 154 summary => 'Connect to an IRC server', 173 155 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]', 175 157 description => <<END_DESCR 176 158 Connect to an IRC server. Supported options are: … … 206 188 207 189 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 ), 209 191 { 210 192 summary => 'Send an IRC message', … … 233 215 { 234 216 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 220 Join an IRC channel. 242 221 END_DESCR 243 222 } … … 248 227 { 249 228 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 232 Part from an IRC channel. 257 233 END_DESCR 258 234 } … … 351 327 This can be used to perform some operation not yet supported by 352 328 BarnOwl, or to define new IRC commands. 353 END_DESCR354 }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_DESCR364 Load persistent channels from a file. The file defaults to365 \$HOME/.owl/$IRC_SUBS_FILENAME. If the ALIAS is present, only channels366 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 format369 '\$alias \$channel' (without quotes).370 329 END_DESCR 371 330 } … … 382 341 ######################## Owl command handlers ################################## 383 342 ################################################################################ 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 the388 # 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 way402 if (open (my $subsfile, "<:encoding(UTF-8)", $filename)) {403 my @lines = <$subsfile>;404 close($subsfile);405 406 # strip trailing newlines407 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 file421 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 need442 # to check $alias443 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, some450 # people might have :irc-join in startup files, even though that doesn't451 # work correctly anymore because connect is asynchronous and so join on452 # startup races with connect. Regardless, just fail silently if the line453 # 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 to488 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 }502 343 503 344 sub cmd_connect { … … 537 378 } 538 379 539 my %channel_hash = get_autoconnect_channels;540 541 380 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} 549 387 }); 550 388 $ircnets{$alias} = $conn; … … 589 427 @msgs = split "\n\n", $fullbody; 590 428 map { tr/\n/ / } @msgs; 591 # split each body at irc:max-message-length characters, if that number592 # is positive. Only split at space boundaries. Start counting a-fresh593 # at the beginning of each paragraph594 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 }599 429 for my $body (@msgs) { 600 430 if ($body =~ /^\/me (.*)/) { … … 633 463 sub cmd_join { 634 464 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, @_); 663 468 return; 664 469 } … … 666 471 sub cmd_part { 667 472 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; 679 475 $conn->conn->send_msg(part => $chan); 680 681 # regardless of whether or not this is temporary, we want to persist it682 # across reconnects683 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 file689 remove_autoconnect_channel($conn, $chan);690 }691 692 476 return; 693 477 } … … 789 573 my $alias; 790 574 my $channel; 791 my $is_temporary;792 575 my $getopt = Getopt::Long::Parser->new; 793 576 my $m = BarnOwl::getcurmsg(); … … 795 578 local @ARGV = @_; 796 579 $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); 799 581 800 582 if(defined($alias)) { … … 809 591 $conn ||= $c; 810 592 } 811 } elsif (defined($channel) && ($flags & CHANNEL_OR_USER)) {812 shift @ARGV;813 593 } elsif ($m && $m->type eq 'IRC' && !$m->is_private) { 814 594 $channel = $m->channel; … … 818 598 } 819 599 820 if(! defined($channel)&&600 if(!$channel && 821 601 ($flags & CHANNEL_ARG) && 822 602 !($flags & CHANNEL_OPTIONAL)) { … … 835 615 die("You must specify an IRC network using -a.\n"); 836 616 } 837 push @ARGV, "-t" if $is_temporary;838 617 if($flags & CHANNEL_ARG) { 839 618 $sub->($cmd, $conn, $channel, @ARGV); -
perl/modules/IRC/lib/BarnOwl/Module/IRC/Completion.pm
r76e80de rdace02a 57 57 } 58 58 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_channels67 );68 }69 70 59 sub complete_irc_channel { 71 60 my $ctx = shift; … … 106 95 BarnOwl::Completion::register_completer('irc-msg' => \&complete_irc_dest); 107 96 BarnOwl::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);97 BarnOwl::Completion::register_completer('irc-join' => \&complete_irc_channel); 98 BarnOwl::Completion::register_completer('irc-part' => \&complete_irc_channel); 110 99 BarnOwl::Completion::register_completer('irc-names' => \&complete_irc_channel); 111 100 BarnOwl::Completion::register_completer('irc-whois' => \&complete_irc_nick); -
perl/modules/IRC/lib/BarnOwl/Module/IRC/Connection.pm
rbe43554 r13ee8f2 39 39 my $self = bless({}, $class); 40 40 $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([]); 43 42 $self->alias($alias); 44 43 $self->server($host); … … 413 412 $self->{reconnect_timer}->stop; 414 413 } 415 $self->{reconnect_timer} = 414 $self->{reconnect_timer} = 416 415 BarnOwl::Timer->new( { 417 416 name => 'IRC (' . $self->alias . ') reconnect_timer', … … 446 445 $self->conn->send_msg(join => $c); 447 446 } 447 $self->autoconnect_channels([]); 448 448 } 449 449 $self->conn->enable_ping(60, sub { … … 458 458 my $backoff = $self->backoff; 459 459 460 $self->autoconnect_channels([keys(%{$self->{channel_list}})]); 460 461 $self->conn->connect(@{$self->connect_args}); 461 462 } -
perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm
r41064be rb8a3e00 320 320 . "configure [<muc>]\n" 321 321 . " Configures a MUC.\n" 322 . " Necessary to init ialize a new MUC.\n"322 . " Necessary to initalize a new MUC.\n" 323 323 . " At present, only the default configuration is supported.\n" 324 324 . " The MUC is taken from the current message if not supplied.\n\n" … … 1313 1313 { 1314 1314 my @answer = $packet->answer; 1315 return $answer[0] ->target, $answer[0]->port if @answer;1315 return $answer[0]{target}, $answer[0]{port}; 1316 1316 } 1317 1317 … … 1482 1482 } 1483 1483 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 1493 1484 BarnOwl::Completion::register_completer(jwrite => sub { BarnOwl::Module::Jabber::complete_jwrite(@_) }); 1494 BarnOwl::Completion::register_completer(jabberlogout => sub { BarnOwl::Module::Jabber::complete_jabberlogout(@_) });1495 1485 1496 1486 1; -
perl/modules/Jabber/lib/Net/Jabber/Component.pm
ra8c55b5 rc2bed55 220 220 $self->{STREAM}->SetCallBacks(node=>undef); 221 221 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>"); 223 223 my $handshake = $self->Process(); 224 224 -
perl/modules/Jabber/lib/Net/Jabber/Key.pm
ra8c55b5 rc2bed55 104 104 $self->{CACHE} = {}; 105 105 106 if (eval "require Digest::SHA ")106 if (eval "require Digest::SHA1") 107 107 { 108 108 $self->{DIGEST} = 1; 109 Digest::SHA ->import(qw(sha1 sha1_hex sha1_base64));109 Digest::SHA1->import(qw(sha1 sha1_hex sha1_base64)); 110 110 } 111 111 else 112 112 { 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"; 114 114 exit(0); 115 115 } … … 132 132 133 133 my $string = $$.time.rand(1000000); 134 $string = Digest::SHA ::sha1_hex($string);134 $string = Digest::SHA1::sha1_hex($string); 135 135 $self->{DEBUG}->Log1("Generate: key($string)"); 136 136 return $string; -
perl/modules/Jabber/lib/Net/XMPP.pm
ra8c55b5 rc2bed55 213 213 use Time::Local; 214 214 use Carp; 215 use Digest::SHA ;215 use Digest::SHA1; 216 216 use Authen::SASL; 217 217 use MIME::Base64; -
perl/modules/Jabber/lib/Net/XMPP/Protocol.pm
ra8c55b5 r7f33c18 1849 1849 if ($authType eq "zerok") 1850 1850 { 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); 1853 1853 1854 1854 for (1..$sequence) 1855 1855 { 1856 $args{hash} = Digest::SHA ::sha1_hex($args{hash});1856 $args{hash} = Digest::SHA1::sha1_hex($args{hash}); 1857 1857 } 1858 1858 } … … 1868 1868 if ($authType eq "digest") 1869 1869 { 1870 $args{digest} = Digest::SHA ::sha1_hex($self->GetStreamID().$password);1870 $args{digest} = Digest::SHA1::sha1_hex($self->GetStreamID().$password); 1871 1871 } 1872 1872 -
perl/modules/Makefile.am
re4b8f93 r1fd469d4 1 MODULES = Jabber IRC WordWrap Twitter Facebook1 MODULES = Jabber IRC WordWrap Twitter 2 2 3 EXTRA_DIST = $(MODULES:=/Makefile.PL) $(MODULES:=/lib) 4 EXTRA_DIST += \ 5 Facebook/README \ 6 Twitter/README \ 7 Twitter/twitter.example 3 EXTRA_DIST = $(MODULES:=/Makefile.PL) $(MODULES:=/inc) $(MODULES:=/lib) 8 4 9 5 all-local: $(MODULES) … … 11 7 (cd $* && $(MAKE) $*.par) 12 8 13 BARNOWL_PERL := $(shell which perl) -I$(abs_srcdir)/../lib14 15 9 MODULES_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) 20 12 21 13 MODULES_CLEAN = $(MODULES:%=clean_%) 22 14 clean-local: $(MODULES_CLEAN) 23 15 $(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)) 28 17 29 18 MODULES_INSTALL = $(MODULES:%=module_install_%) … … 34 23 ${INSTALL_DATA} $*/$*.par ${DESTDIR}${pkgdatadir}/modules/$*.par 35 24 36 uninstall-local:37 rm -f $(MODULES:%=${DESTDIR}${pkgdatadir}/modules/%.par)38 39 25 .PHONY: $(MODULES) $(MODULES_CLEAN) $(MODULES_INSTALL) -
perl/modules/Twitter/lib/BarnOwl/Module/Twitter.pm
r140429f rb8a3e00 137 137 my $twitter_args = { username => $cfg->{user}, 138 138 password => $cfg->{password}, 139 source => 'barnowl', 140 ssl => 1, 141 legacy_lists_api => 0, 139 source => 'barnowl', 142 140 }; 143 141 if (defined $cfg->{service}) { … … 276 274 ); 277 275 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_DESCRIPTION283 Favorite the current Twitter message using ACCOUNT (defaults to the284 account that received the tweet).285 END_DESCRIPTION286 }287 );288 289 276 BarnOwl::new_command( 'twitter-follow' => sub { cmd_twitter_follow(@_); }, 290 277 { … … 368 355 $account = $m->account unless defined($account); 369 356 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);383 357 return; 384 358 } -
perl/modules/Twitter/lib/BarnOwl/Module/Twitter/Handle.pm
r140429f r4ebbfbc 371 371 $self->twitter_direct($1, $2); 372 372 } elsif(defined $self->{twitter}) { 373 if(length($msg) > 140) { 374 die("Twitter: Message over 140 characters long.\n"); 375 } 373 376 $self->twitter_command('update', { 374 377 status => $msg, … … 429 432 } 430 433 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 442 434 sub twitter_follow { 443 435 my $self = shift; -
perlconfig.c
r7dcef03 rb9517cf 75 75 const char *type; 76 76 char *ptr, *utype, *blessas; 77 const char *f; 78 int i; 77 int i, j; 79 78 const owl_pair *pair; 80 79 const owl_filter *wrap; … … 92 91 owl_new_sv(owl_message_get_##field(m)), 0) 93 92 94 if (owl_message_ is_type_zephyr(m) && owl_message_is_direction_in(m)) {93 if (owl_message_get_notice(m)) { 95 94 /* 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); 110 103 } 111 104 (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); 112 108 } 113 109 … … 188 184 hash = (HV*)SvRV(msg); 189 185 190 m = g_ slice_new(owl_message);186 m = g_new(owl_message, 1); 191 187 owl_message_init(m); 192 188 … … 228 224 CALLER_OWN char *owl_perlconfig_call_with_message(const char *subname, const owl_message *m) 229 225 { 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) ; 233 235 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 249 266 return out; 250 267 } … … 256 273 CALLER_OWN char *owl_perlconfig_message_call_method(const owl_message *m, const char *method, int argc, const char **argv) 257 274 { 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; 261 279 262 280 msgref = owl_perlconfig_message2hashref(m); 263 281 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 279 319 return out; 280 320 } … … 287 327 char *err; 288 328 const char *args[4] = {"", "-e", "0;", NULL}; 289 const char *dlerr;290 329 AV *inc; 291 330 char *path; … … 336 375 } 337 376 338 sv_setpv(get_sv("BarnOwl::VERSION", TRUE), version);377 sv_setpv(get_sv("BarnOwl::VERSION", TRUE), OWL_VERSION_STRING); 339 378 340 379 /* Add the system lib path to @INC */ … … 345 384 g_free(path); 346 385 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. */357 386 eval_pv("use BarnOwl;", FALSE); 358 387 … … 426 455 void owl_perlconfig_new_command(const char *name) 427 456 { 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; 521 476 } 522 477 … … 524 479 CALLER_OWN char *owl_perlconfig_perlcmd(const owl_cmd *cmd, int argc, const char *const *argv) 525 480 { 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; 545 515 } 546 516 … … 550 520 } 551 521 552 void owl_perlconfig_edit_callback(owl_editwin *e , bool success)522 void owl_perlconfig_edit_callback(owl_editwin *e) 553 523 { 554 524 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) { 558 529 owl_function_error("Perl callback is NULL!"); 559 530 return; 560 531 } 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; 574 549 } 575 550 -
perlglue.xs
r7dcef03 rf271129 67 67 OUTPUT: 68 68 RETVAL 69 70 int 71 getnumlines() 72 CODE: 73 RETVAL = owl_global_get_lines(&g); 74 OUTPUT: 75 RETVAL 76 69 77 70 time_t 78 71 getidletime() … … 95 88 OUTPUT: 96 89 RETVAL 90 91 void 92 zephyr_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); 97 99 98 100 const utf8 * … … 163 165 { 164 166 owl_function_adminmsg(header, body); 167 } 168 169 void 170 start_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 188 void 189 start_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 207 void 208 start_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); 165 220 } 166 221 … … 232 287 CODE: 233 288 { 234 s = g_ slice_new(owl_style);289 s = g_new(owl_style, 1); 235 290 owl_style_create_perl(s, name, newSVsv(object)); 236 291 owl_global_add_style(&g, s); … … 256 311 } 257 312 258 bool259 message_matches_filter(message, filter_name, quiet = false)260 SV *message261 const char *filter_name262 bool quiet263 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 RETVAL281 CLEANUP:282 owl_message_delete(m);283 284 313 const utf8 * 285 314 wordwrap(in, cols) … … 397 426 MODULE = BarnOwl PACKAGE = BarnOwl::Internal 398 427 399 400 int401 file_deleteline(filename, line, backup)402 const char *filename403 const char *line404 int backup405 CODE:406 RETVAL = owl_util_file_deleteline(filename, line, backup);407 OUTPUT:408 RETVAL409 428 410 429 void … … 438 457 } 439 458 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 459 void 460 new_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 472 void 473 new_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 485 void 486 new_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); 503 497 504 498 MODULE = BarnOwl PACKAGE = BarnOwl::Editwin -
popexec.c
r7dcef03 re146cd7 23 23 } 24 24 25 pe = g_ slice_new(owl_popexec);25 pe = g_new(owl_popexec, 1); 26 26 pe->winactive=0; 27 27 pe->pid=0; … … 179 179 if (pe->refcount<=0) { 180 180 owl_function_debugmsg("doing free of %p", pe); 181 g_ slice_free(owl_popexec,pe);181 g_free(pe); 182 182 } 183 183 } -
popwin.c
r7dcef03 r6829afc 3 3 CALLER_OWN owl_popwin *owl_popwin_new(void) 4 4 { 5 owl_popwin *pw = g_ slice_new0(owl_popwin);5 owl_popwin *pw = g_new0(owl_popwin, 1); 6 6 7 7 pw->border = owl_window_new(NULL); … … 92 92 g_object_unref(pw->content); 93 93 94 g_ slice_free(owl_popwin,pw);94 g_free(pw); 95 95 } 96 96 -
runtests.sh
r7dcef03 rf6ab6ee 1 1 #!/bin/sh 2 export G_SLICE=debug-blocks 3 exec env HARNESS_PERL=./tester prove --failures "${srcdir:=$(dirname "$0")}/t/" 2 exec env HARNESS_PERL=./tester prove --failures t/ -
select.c
r7dcef03 r84a071f 41 41 if (t->destroy_cbdata) 42 42 t->destroy_cbdata(t->cbdata); 43 g_ slice_free(owl_task,t);43 g_free(t); 44 44 } 45 45 … … 47 47 { 48 48 GSource *source = g_idle_source_new(); 49 owl_task *t = g_ slice_new0(owl_task);49 owl_task *t = g_new0(owl_task, 1); 50 50 t->cb = cb; 51 51 t->cbdata = cbdata; -
sepbar.c
ra38becd r6eb3ed9 67 67 } 68 68 69 if (owl_ function_is_away()) {69 if (owl_global_is_zaway(&g) || owl_global_is_aaway(&g)) { 70 70 getyx(sepwin, y, x); 71 71 wmove(sepwin, y, x+2); 72 72 wattron(sepwin, A_BOLD); 73 73 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 } 75 81 wattron(sepwin, A_REVERSE); 76 82 wattroff(sepwin, A_BOLD); -
style.c
r7dcef03 r14be3a5 23 23 { 24 24 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 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) { 33 33 return SvPV_nolen(sv_2mortal(sv)); 34 34 } else { … … 50 50 51 51 /* 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 ); 60 59 61 if 60 if(sv) { 62 61 body = SvPV_nolen(sv); 63 62 } else { … … 103 102 { 104 103 owl_style_cleanup(s); 105 g_ slice_free(owl_style,s);104 g_free(s); 106 105 } -
t/00-core-tests.t
r5db8835 r95414bf 1 1 #!/usr/bin/env perl 2 system("./tester", "--builtin"); 2 use File::Basename; 3 system(dirname($0) . "/../tester", "--builtin"); -
tester.c
r21dc927 ra74a044 3 3 #include "owl.h" 4 4 #undef WINDOW 5 #include "filterproc.h"6 5 7 6 #include <stdio.h> … … 24 23 int owl_smartfilter_regtest(void); 25 24 int owl_history_regtest(void); 26 int call_filter_regtest(void);27 int owl_smartstrip_regtest(void);28 25 29 26 extern void owl_perl_xs_init(pTHX); … … 116 113 numfailures += owl_smartfilter_regtest(); 117 114 numfailures += owl_history_regtest(); 118 numfailures += call_filter_regtest();119 numfailures += owl_smartstrip_regtest();120 115 if (numfailures) { 121 116 fprintf(stderr, "# *** WARNING: %d failures total\n", numfailures); … … 135 130 { 136 131 int numfailed=0; 137 char * path, *home;132 char *s, *path, *home; 138 133 139 134 printf("# BEGIN testing owl_util\n"); … … 231 226 232 227 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); 260 267 261 268 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); 264 272 265 273 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); 268 277 g_free(path); 269 278 g_free(home); … … 276 285 } 277 286 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); 280 290 281 291 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); 284 295 g_free(path); 285 296 g_free(home); … … 339 350 int numfailed=0; 340 351 char *value; 352 const void *v; 341 353 342 354 printf("# BEGIN testing owl_variable\n"); 343 owl_variable_dict_setup(&vd);355 FAIL_UNLESS("setup", 0==owl_variable_dict_setup(&vd)); 344 356 345 357 FAIL_UNLESS("get bool var", NULL != (var = owl_variable_get_var(&vd, "rxping"))); … … 378 390 FAIL_UNLESS("get int 7", 9 == owl_variable_get_int(var)); 379 391 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"); 397 393 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))); 398 395 FAIL_UNLESS("get new string val", !strcmp("testval", owl_variable_get_string(var))); 399 396 owl_variable_set_string(var, "new val"); 400 397 FAIL_UNLESS("update string val", !strcmp("new val", owl_variable_get_string(var))); 401 398 402 owl_variable_dict_newvar_int(&vd, "intvar", 47, "", "");399 owl_variable_dict_newvar_int(&vd, "intvar", "", "", 47); 403 400 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))); 404 402 FAIL_UNLESS("get new int val", 47 == owl_variable_get_int(var)); 405 403 owl_variable_set_int(var, 17); 406 404 FAIL_UNLESS("update int val", 17 == owl_variable_get_int(var)); 407 405 408 owl_variable_dict_newvar_bool(&vd, "boolvar", true, "", "");406 owl_variable_dict_newvar_bool(&vd, "boolvar", "", "", 1); 409 407 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))); 410 409 FAIL_UNLESS("get new bool val", owl_variable_get_bool(var)); 411 410 owl_variable_set_bool_off(var); 412 411 FAIL_UNLESS("update bool val", !owl_variable_get_bool(var)); 413 412 414 owl_variable_dict_newvar_string(&vd, "nullstringvar", NULL, "", "");413 owl_variable_dict_newvar_string(&vd, "nullstringvar", "", "", NULL); 415 414 FAIL_UNLESS("get new string (NULL) var", NULL != (var = owl_variable_get_var(&vd, "nullstringvar"))); 416 415 FAIL_UNLESS("get string (NULL)", NULL == (value = owl_variable_get_tostring(var))); … … 419 418 FAIL_UNLESS("get string (NULL) 2", NULL == (value = owl_variable_get_tostring(var))); 420 419 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));427 420 428 421 owl_variable_dict_cleanup(&vd); … … 988 981 return numfailed; 989 982 } 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 262 262 CALLER_OWN char *owl_arg_quote(const char *arg) 263 263 { 264 GString *buf = g_string_new(""); 264 GString *buf = g_string_new("");; 265 265 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 give270 * 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 }280 266 return g_string_free(buf, false); 281 267 } -
variable.c
r7dcef03 rf271129 1 1 #include "owl.h" 2 2 #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 } 70 15 71 16 #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 } 84 31 85 32 /* enums are really integers, but where validset is a comma-separated 86 33 * list of strings which can be specified. The tokens, starting at 0, 87 34 * 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 } 90 41 91 42 #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 49 int owl_variable_add_defaults(owl_vardict *vd) 50 { 51 owl_variable variables_to_init[] = { 52 97 53 OWLVAR_STRING( "personalbell" /* %OwlVarStub */, "off", 98 54 "ring the terminal bell when personal messages are received", 99 55 "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"), 101 57 102 58 OWLVAR_BOOL( "bell" /* %OwlVarStub */, 1, 103 "enable / disable the terminal bell", "" ) ;59 "enable / disable the terminal bell", "" ), 104 60 105 61 OWLVAR_BOOL_FULL( "debug" /* %OwlVarStub */, OWL_DEBUG, … … 107 63 "If set to 'on', debugging messages are logged to the\n" 108 64 "file specified by the debugfile variable.\n", 109 NULL, owl_variable_debug_set, NULL) ;65 NULL, owl_variable_debug_set, NULL), 110 66 111 67 OWLVAR_BOOL( "startuplogin" /* %OwlVarStub */, 1, 112 "send a login message when BarnOwl starts", "" ) ;68 "send a login message when BarnOwl starts", "" ), 113 69 114 70 OWLVAR_BOOL( "shutdownlogout" /* %OwlVarStub */, 1, 115 "send a logout message when BarnOwl exits", "" ) ;71 "send a logout message when BarnOwl exits", "" ), 116 72 117 73 OWLVAR_BOOL( "rxping" /* %OwlVarStub */, 0, 118 "display received pings", "" ) ;74 "display received pings", "" ), 119 75 120 76 OWLVAR_BOOL( "txping" /* %OwlVarStub */, 1, 121 "send pings", "" ) ;77 "send pings", "" ), 122 78 123 79 OWLVAR_BOOL( "sepbar_disable" /* %OwlVarStub */, 0, 124 "disable printing information in the separator bar", "" ) ;80 "disable printing information in the separator bar", "" ), 125 81 126 82 OWLVAR_BOOL( "smartstrip" /* %OwlVarStub */, 1, 127 "strip kerberos instance for reply", "") ;83 "strip kerberos instance for reply", ""), 128 84 129 85 OWLVAR_BOOL( "newlinestrip" /* %OwlVarStub */, 1, 130 "strip leading and trailing newlines", "") ;86 "strip leading and trailing newlines", ""), 131 87 132 88 OWLVAR_BOOL( "displayoutgoing" /* %OwlVarStub */, 1, 133 "display outgoing messages", "" ) ;89 "display outgoing messages", "" ), 134 90 135 91 OWLVAR_BOOL( "loginsubs" /* %OwlVarStub */, 1, 136 "load logins from .anyone on startup", "" ) ;92 "load logins from .anyone on startup", "" ), 137 93 138 94 OWLVAR_BOOL( "logging" /* %OwlVarStub */, 0, … … 141 97 "logged in the directory specified\n" 142 98 "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" ), 144 100 145 101 OWLVAR_BOOL( "classlogging" /* %OwlVarStub */, 0, … … 149 105 "by the 'classlogpath' variable.\n" 150 106 "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" ), 152 108 153 109 OWLVAR_ENUM( "loggingdirection" /* %OwlVarStub */, OWL_LOGGING_DIRECTION_BOTH, … … 158 114 "is selected both incoming and outgoing messages are\n" 159 115 "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." ), 165 122 166 123 OWLVAR_BOOL( "fancylines" /* %OwlVarStub */, 1, … … 168 125 "If turned off, dashes, pipes and pluses will be used\n" 169 126 "to draw lines on the screen. Useful when the terminal\n" 170 "is causing problems" ) ;127 "is causing problems" ), 171 128 172 129 OWLVAR_BOOL( "zcrypt" /* %OwlVarStub */, 1, 173 130 "Do automatic zcrypt processing", 174 "" ) ;131 "" ), 175 132 176 133 OWLVAR_BOOL_FULL( "pseudologins" /* %OwlVarStub */, 0, … … 180 137 "but sent no login message, or a user is not present that sent no\n" 181 138 "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), 183 140 184 141 OWLVAR_BOOL( "ignorelogins" /* %OwlVarStub */, 0, … … 186 143 "When this is enabled, BarnOwl will print login and logout notifications\n" 187 144 "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"), 189 146 190 147 OWLVAR_STRING( "logfilter" /* %OwlVarStub */, "", … … 195 152 "variables like logging, classlogging, loglogins, loggingdirection,\n" 196 153 "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"), 198 155 199 156 OWLVAR_BOOL( "loglogins" /* %OwlVarStub */, 0, … … 201 158 "When this is enabled, BarnOwl will log login and logout notifications\n" 202 159 "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"), 204 161 205 162 OWLVAR_ENUM_FULL( "disable-ctrl-d" /* %OwlVarStub:lockout_ctrld */, 1, … … 213 170 "in the editmulti keymap.\n", 214 171 "off,middle,on", 215 NULL, owl_variable_disable_ctrl_d_set, NULL) ;172 NULL, owl_variable_disable_ctrl_d_set, NULL), 216 173 217 174 OWLVAR_PATH( "logpath" /* %OwlVarStub */, "~/zlog/people", 218 175 "path for logging personal zephyrs", 219 176 "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"), 221 178 222 179 OWLVAR_PATH( "classlogpath" /* %OwlVarStub:classlogpath */, "~/zlog/class", 223 180 "path for logging class zephyrs", 224 181 "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"), 226 183 227 184 OWLVAR_PATH( "debug_file" /* %OwlVarStub */, OWL_DEBUG_FILE, 228 185 "path for logging debug messages when debugging is enabled", 229 186 "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."), 231 188 232 189 OWLVAR_PATH( "zsigproc" /* %OwlVarStub:zsigproc */, NULL, … … 236 193 "See the documentation for 'zsig' for more information about\n" 237 194 "how the outgoing zsig is chosen." 238 ) ;195 ), 239 196 240 197 OWLVAR_PATH( "newmsgproc" /* %OwlVarStub:newmsgproc */, NULL, … … 242 199 "The named program will be run when BarnOwl receives new\n" 243 200 "messages. It will not be run again until the first\n" 244 "instance exits") ;201 "instance exits"), 245 202 246 203 OWLVAR_STRING( "zsender" /* %OwlVarStub */, "", … … 249 206 "zephyrs. If this is unset, it will use your Kerberos\n" 250 207 "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."), 252 209 253 210 OWLVAR_STRING( "zsigfunc" /* %OwlVarStub */, "BarnOwl::default_zephyr_signature()", … … 256 213 "explicit zsig. The default setting implements the policy\n" 257 214 "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"), 259 216 260 217 OWLVAR_STRING( "zsig" /* %OwlVarStub */, "", … … 263 220 "unset, 'zsigproc' will be run to generate a zsig. If that is\n" 264 221 "also unset, the 'zwrite-signature' zephyr variable will be\n" 265 "used instead.\n") ;222 "used instead.\n"), 266 223 267 224 OWLVAR_STRING( "appendtosepbar" /* %OwlVarStub */, "", … … 269 226 "The sepbar is the bar separating the top and bottom\n" 270 227 "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"), 272 229 273 230 OWLVAR_BOOL( "zaway" /* %OwlVarStub */, 0, 274 "turn zaway on or off", "" ) ;231 "turn zaway on or off", "" ), 275 232 276 233 OWLVAR_STRING( "zaway_msg" /* %OwlVarStub */, 277 234 OWL_DEFAULT_ZAWAYMSG, 278 "zaway msg for responding to zephyrs when away", "" ) ;235 "zaway msg for responding to zephyrs when away", "" ), 279 236 280 237 OWLVAR_STRING( "zaway_msg_default" /* %OwlVarStub */, 281 238 OWL_DEFAULT_ZAWAYMSG, 282 "default zaway message", "" ) ;239 "default zaway message", "" ), 283 240 284 241 OWLVAR_BOOL_FULL( "aaway" /* %OwlVarStub */, 0, 285 242 "Set AIM away status", 286 243 "", 287 NULL, owl_variable_aaway_set, NULL) ;244 NULL, owl_variable_aaway_set, NULL), 288 245 289 246 OWLVAR_STRING( "aaway_msg" /* %OwlVarStub */, 290 247 OWL_DEFAULT_AAWAYMSG, 291 "AIM away msg for responding when away", "" ) ;248 "AIM away msg for responding when away", "" ), 292 249 293 250 OWLVAR_STRING( "aaway_msg_default" /* %OwlVarStub */, 294 251 OWL_DEFAULT_AAWAYMSG, 295 "default AIM away message", "" ) ;252 "default AIM away message", "" ), 296 253 297 254 OWLVAR_STRING( "view_home" /* %OwlVarStub */, "all", 298 255 "home view to switch to after 'X' and 'V'", 299 "SEE ALSO: view, filter\n" ) ;256 "SEE ALSO: view, filter\n" ), 300 257 301 258 OWLVAR_STRING( "alert_filter" /* %OwlVarStub */, "none", 302 259 "filter on which to trigger alert actions", 303 "" ) ;260 "" ), 304 261 305 262 OWLVAR_STRING( "alert_action" /* %OwlVarStub */, "nop", 306 263 "BarnOwl command to execute for alert actions", 307 "" ) ;264 "" ), 308 265 309 266 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), 311 268 312 269 OWLVAR_STRING( "default_style" /* %OwlVarStub */, "default", … … 319 276 " perl - legacy perl interface\n" 320 277 "\nSEE ALSO: style, show styles, view -s <style>\n" 321 ) ;278 ), 322 279 323 280 … … 326 283 "This specifies the maximum number of columns for M-q to fill text\n" 327 284 "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"), 329 286 330 287 OWLVAR_INT( "edit:maxwrapcols" /* %OwlVarStub:edit_maxwrapcols */, 70, … … 335 292 "\n" 336 293 "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"), 338 295 339 296 OWLVAR_INT( "aim_ignorelogin_timer" /* %OwlVarStub */, 15, … … 342 299 "AIM login before allowing the receipt of AIM login notifications.\n" 343 300 "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."), 345 302 346 303 … … 355 312 owl_variable_typewinsize_set, 356 313 NULL /* use default for get */ 357 ) ;314 ), 358 315 359 316 OWLVAR_INT( "typewindelta" /* %OwlVarStub */, 0, … … 365 322 "typewinsize to 1.\n\n" 366 323 "This works a lot better with a non-default scrollmode;\n" 367 "try :set scrollmode pagedcenter.\n") ;324 "try :set scrollmode pagedcenter.\n"), 368 325 369 326 OWLVAR_ENUM( "scrollmode" /* %OwlVarStub */, OWL_SCROLLMODE_NORMAL, … … 394 351 " the screen will be paged up or down and\n" 395 352 " the cursor will be near the center.\n", 396 "normal,top,neartop,center,paged,pagedcenter" ) ;353 "normal,top,neartop,center,paged,pagedcenter" ), 397 354 398 355 OWLVAR_BOOL( "narrow-related" /* %OwlVarStub:narrow_related */, 1, 399 356 "Make smartnarrow use broader filters", 400 "Causes smartfil ter to narrow to messages \"related\" to \n"357 "Causes smartfiler to narrow to messages \"related\" to \n" 401 358 "the current message, as well as ones to the same place.\n\n" 402 359 "for Zephyr, this controls whether to narrow to e.g. class-help or\n" 403 360 "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" ), 405 362 406 363 OWLVAR_BOOL( "_followlast" /* %OwlVarStub */, 0, … … 409 366 "continue to follow the last message if this is set.\n" 410 367 "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" ), 412 369 413 370 OWLVAR_STRING_FULL( "default_exposure" /* %OwlVarStub */, "", … … 418 375 "~/.zephyr.vars.\n" 419 376 "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 ), 421 378 422 379 OWLVAR_STRING_FULL( "exposure" /* %OwlVarStub */, "", … … 474 431 " personal subscriptions will be entered for the\n" 475 432 " 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; 477 446 } 478 447 … … 484 453 /* commonly useful */ 485 454 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); 455 int 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 462 int 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); 494 467 } 495 468 496 469 /* typewinsize */ 497 int owl_variable_typewinsize_set(owl_variable *v, intnewval)470 int owl_variable_typewinsize_set(owl_variable *v, const void *newval) 498 471 { 499 472 int rv; … … 504 477 505 478 /* debug (cache value in g->debug) */ 506 int owl_variable_debug_set(owl_variable *v, bool newval) 507 { 508 g.debug = newval; 479 int 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 } 509 484 return owl_variable_bool_set_default(v, newval); 510 485 } 511 486 512 487 /* When 'aaway' is changed, need to notify the AIM server */ 513 int owl_variable_aaway_set(owl_variable *v, boolnewval)488 int owl_variable_aaway_set(owl_variable *v, const void *newval) 514 489 { 515 490 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 } 519 496 } 520 497 return owl_variable_bool_set_default(v, newval); 521 498 } 522 499 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) 500 int owl_variable_pseudologins_set(owl_variable *v, const void *newval) 537 501 { 538 502 static guint timer = 0; 539 503 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 } 548 514 } 549 515 } … … 553 519 /* note that changing the value of this will clobber 554 520 * any user setting of this */ 555 int owl_variable_disable_ctrl_d_set(owl_variable *v, intnewval)556 { 557 if ( !owl_context_is_startup(owl_global_get_context(&g))) {558 if ( newval == 2) {521 int 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) { 559 525 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) { 561 527 owl_function_command_norv("bindkey editmulti C-d command edit:done-or-delete"); 562 528 } else { … … 564 530 } 565 531 } 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 535 int owl_variable_tty_set(owl_variable *v, const void *newval) 570 536 { 571 537 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 541 int owl_variable_default_exposure_set(owl_variable *v, const void *newval) 576 542 { 577 543 return owl_zephyr_set_default_exposure(newval); 578 544 } 579 545 580 const char*owl_variable_default_exposure_get(const owl_variable *v)546 const void *owl_variable_default_exposure_get(const owl_variable *v) 581 547 { 582 548 return owl_zephyr_get_default_exposure(); 583 549 } 584 550 585 int owl_variable_exposure_set(owl_variable *v, const char*newval)551 int owl_variable_exposure_set(owl_variable *v, const void *newval) 586 552 { 587 553 int ret = owl_zephyr_set_exposure(newval); … … 595 561 /**************************************************************************/ 596 562 597 voidowl_variable_dict_setup(owl_vardict *vd) {563 int owl_variable_dict_setup(owl_vardict *vd) { 598 564 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 568 int 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; 610 637 } 611 638 612 639 void owl_variable_dict_add_variable(owl_vardict * vardict, 613 640 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 }620 641 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 644 CALLER_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); 631 647 var->name = g_strdup(name); 632 648 var->summary = g_strdup(summary); 633 649 var->description = g_strdup(description); 634 var->validsettings = g_strdup(validsettings);635 650 return var; 636 651 } 637 652 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); 653 void 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 660 void 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 682 void 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 705 void 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 } 772 726 } 773 727 … … 781 735 } 782 736 783 void owl_variable_delete(owl_variable *v) 784 { 737 void owl_variable_cleanup(owl_variable *v) 738 { 739 if (v->delete_fn) v->delete_fn(v); 785 740 g_free(v->name); 786 741 g_free(v->summary); 787 742 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 747 void owl_variable_delete(owl_variable *v) 748 { 749 owl_variable_cleanup(v); 750 g_free(v); 796 751 } 797 752 … … 818 773 return v->type; 819 774 } 775 776 /* functions for getting and setting variable values */ 820 777 821 778 /* returns 0 on success, prints a status msg if msg is true */ 822 779 int owl_variable_set_fromstring(owl_variable *v, const char *value, int msg) { 823 780 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)) { 837 786 if (msg) owl_function_error("Unable to set %s (must be %s)", owl_variable_get_name(v), 838 787 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) 842 793 owl_function_makemsg("%s = '%s'", owl_variable_get_name(v), tostring); 843 } else {794 else 844 795 owl_function_makemsg("%s = <null>", owl_variable_get_name(v)); 845 }846 796 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; 853 799 } 854 800 855 801 int owl_variable_set_string(owl_variable *v, const char *newval) 856 802 { 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 863 807 int owl_variable_set_int(owl_variable *v, int newval) 864 808 { 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 878 813 int owl_variable_set_bool_on(owl_variable *v) 879 814 { 880 815 if (v->type != OWL_VARIABLE_BOOL) return -1; 881 return owl_variable_set_ bool(v, true);816 return owl_variable_set_int(v, true); 882 817 } 883 818 … … 885 820 { 886 821 if (v->type != OWL_VARIABLE_BOOL) return -1; 887 return owl_variable_set_ bool(v, false);822 return owl_variable_set_int(v, false); 888 823 } 889 824 890 825 CALLER_OWN char *owl_variable_get_tostring(const owl_variable *v) 891 826 { 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 830 CALLER_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 } 911 837 } 912 838 … … 916 842 } 917 843 844 /* returns a reference */ 845 const void *owl_variable_get(const owl_variable *v) 846 { 847 return v->get_fn(v); 848 } 849 918 850 const char *owl_variable_get_string(const owl_variable *v) 919 851 { 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 */ 860 const 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); 924 867 } 925 868 926 869 int owl_variable_get_int(const owl_variable *v) 927 870 { 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 880 int 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; 940 889 } 941 890 942 891 void owl_variable_describe(const owl_variable *v, owl_fmtext *fm) 943 892 { 944 c onst char *default_str= owl_variable_get_default_tostring(v);893 char *tostring = owl_variable_get_default_tostring(v); 945 894 char *default_buf; 946 895 947 if ( default_str)948 default_buf = g_strdup_printf("'%s'", default_str);896 if (tostring) 897 default_buf = g_strdup_printf("'%s'", tostring); 949 898 else 950 899 default_buf = g_strdup("<null>"); … … 953 902 owl_variable_get_summary(v), default_buf); 954 903 g_free(default_buf); 904 g_free(tostring); 955 905 } 956 906 957 907 void owl_variable_get_help(const owl_variable *v, owl_fmtext *fm) { 958 908 char *tostring; 959 const char *default_str;960 909 961 910 owl_fmtext_append_bold(fm, "OWL VARIABLE\n\n"); … … 972 921 owl_fmtext_append_normal(fm, "\n\n"); 973 922 974 default_str = owl_variable_get_default_tostring(v); 923 924 tostring = owl_variable_get_default_tostring(v); 975 925 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>")); 977 927 owl_fmtext_append_normal(fm, "\n\n"); 978 928 … … 986 936 owl_fmtext_append_normal(fm, "\n\n"); 987 937 } 938 g_free(tostring); 988 939 } 989 940 … … 997 948 /* default common functions */ 998 949 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)); 950 const void *owl_variable_get_default(const owl_variable *v) { 951 return v->val; 952 } 953 954 void owl_variable_delete_default(owl_variable *v) 955 { 956 g_free(v->val); 1009 957 } 1010 958 1011 959 /* default functions for booleans */ 1012 960 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); 961 int 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 967 int 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; 1022 972 return(0); 1023 973 } 1024 974 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) { 975 int 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 983 CALLER_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) { 1042 988 return g_strdup("off"); 1043 } else if ( val == 1) {989 } else if (*(const int*)val == 1) { 1044 990 return g_strdup("on"); 1045 991 } else { … … 1050 996 /* default functions for integers */ 1051 997 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, intnewval) {1058 if ( !((validate_int_t)v->validate_fn)(v, newval))1059 return -1;1060 1061 g_value_set_int(&(v->val), newval);998 int owl_variable_int_validate_default(const owl_variable *v, const void *newval) { 999 if (newval == NULL) return(0); 1000 else return (1); 1001 } 1002 1003 int 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; 1062 1008 return(0); 1063 1009 } 1064 1010 1065 int owl_variable_int_set_fromstring_default(owl_variable *v, const char *newval , void *dummy) {1011 int owl_variable_int_set_fromstring_default(owl_variable *v, const char *newval) { 1066 1012 int i; 1067 1013 char *ep; 1068 1014 i = strtol(newval, &ep, 10); 1069 1015 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 1019 CALLER_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 } 1076 1026 } 1077 1027 1078 1028 /* default functions for enums (a variant of integers) */ 1079 1029 1080 int owl_variable_enum_validate(const owl_variable *v, int newval) {1030 int owl_variable_enum_validate(const owl_variable *v, const void *newval) { 1081 1031 char **enums; 1082 1032 int nenums, val; 1033 if (newval == NULL) return(0); 1083 1034 enums = g_strsplit_set(v->validsettings, ",", 0); 1084 1035 nenums = g_strv_length(enums); 1085 1036 g_strfreev(enums); 1086 val = newval;1037 val = *(const int*)newval; 1087 1038 if (val < 0 || val >= nenums) { 1088 1039 return(0); … … 1091 1042 } 1092 1043 1093 int owl_variable_enum_set_fromstring(owl_variable *v, const char *newval , void *dummy) {1044 int owl_variable_enum_set_fromstring(owl_variable *v, const char *newval) { 1094 1045 char **enums; 1095 1046 int i, val=-1; … … 1103 1054 g_strfreev(enums); 1104 1055 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 1059 CALLER_OWN char *owl_variable_enum_get_tostring(const owl_variable *v, const void *val) 1109 1060 { 1110 1061 char **enums; … … 1112 1063 char *tostring; 1113 1064 1065 if (val == NULL) { 1066 return NULL; 1067 } 1114 1068 enums = g_strsplit_set(v->validsettings, ",", 0); 1115 1069 nenums = g_strv_length(enums); 1116 i = owl_variable_get_int(v);1070 i = *(const int*)val; 1117 1071 if (i<0 || i>=nenums) { 1118 1072 g_strfreev(enums); … … 1126 1080 /* default functions for stringeans */ 1127 1081 1128 int owl_variable_string_validate_default(const owl_variable *v, const char*newval) {1082 int owl_variable_string_validate_default(const struct _owl_variable *v, const void *newval) { 1129 1083 if (newval == NULL) return(0); 1130 1084 else return (1); 1131 1085 } 1132 1086 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); 1087 int 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); 1138 1093 return(0); 1139 1094 } 1140 1095 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 1096 int owl_variable_string_set_fromstring_default(owl_variable *v, const char *newval) { 1097 return (v->set_fn(v, newval)); 1098 } 1099 1100 CALLER_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 6 6 v->filter=f; 7 7 v->style=s; 8 v->ml = owl_messagelist_new();8 owl_messagelist_create(&(v->ml)); 9 9 owl_view_recalculate(v); 10 10 } … … 19 19 { 20 20 if (owl_filter_message_match(v->filter, m)) { 21 owl_messagelist_append_element( v->ml, m);21 owl_messagelist_append_element(&(v->ml), m); 22 22 } 23 23 } … … 30 30 int i, j; 31 31 const owl_messagelist *gml; 32 owl_messagelist *ml; 32 33 owl_message *m; 33 34 34 35 gml=owl_global_get_msglist(&g); 36 ml=&(v->ml); 35 37 36 38 /* 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)); 39 41 40 42 /* find all the messages we want */ … … 43 45 m=owl_messagelist_get_element(gml, i); 44 46 if (owl_filter_message_match(v->filter, m)) { 45 owl_messagelist_append_element( v->ml, m);47 owl_messagelist_append_element(ml, m); 46 48 } 47 49 } … … 70 72 owl_message *owl_view_get_element(const owl_view *v, int index) 71 73 { 72 return owl_messagelist_get_element(v->ml, index);74 return(owl_messagelist_get_element(&(v->ml), index)); 73 75 } 74 76 75 77 void owl_view_delete_element(owl_view *v, int index) 76 78 { 77 owl_messagelist_delete_element( v->ml, index);79 owl_messagelist_delete_element(&(v->ml), index); 78 80 } 79 81 80 82 void owl_view_undelete_element(owl_view *v, int index) 81 83 { 82 owl_messagelist_undelete_element( v->ml, index);84 owl_messagelist_undelete_element(&(v->ml), index); 83 85 } 84 86 85 87 int owl_view_get_size(const owl_view *v) 86 88 { 87 return owl_messagelist_get_size(v->ml);89 return(owl_messagelist_get_size(&(v->ml))); 88 90 } 89 91 … … 156 158 void owl_view_cleanup(owl_view *v) 157 159 { 158 owl_messagelist_ delete(v->ml, false);160 owl_messagelist_cleanup(&v->ml, false); 159 161 g_free(v->name); 160 162 } -
viewwin.c
r7dcef03 rf271129 13 13 CALLER_OWN owl_viewwin *owl_viewwin_new_text(owl_window *win, const char *text) 14 14 { 15 owl_viewwin *v = g_ slice_new0(owl_viewwin);15 owl_viewwin *v = g_new0(owl_viewwin, 1); 16 16 owl_fmtext_init_null(&(v->fmtext)); 17 17 if (text) { … … 36 36 { 37 37 char *text; 38 owl_viewwin *v = g_ slice_new0(owl_viewwin);38 owl_viewwin *v = g_new0(owl_viewwin, 1); 39 39 40 40 owl_fmtext_copy(&(v->fmtext), fmtext); … … 158 158 } owl_viewwin_search_data; 159 159 160 static void owl_viewwin_callback_search(owl_editwin *e, bool success) 161 { 162 if (!success) return; 160 static void owl_viewwin_callback_search(owl_editwin *e) 161 { 163 162 int consider_current = false; 164 163 const char *line = owl_editwin_get_text(e); … … 424 423 g_object_unref(v->status); 425 424 owl_fmtext_cleanup(&(v->fmtext)); 426 g_ slice_free(owl_viewwin,v);427 } 425 g_free(v); 426 } -
window.c
r3442788 rf271129 397 397 } 398 398 399 static owl_window *_get_cursor(bool *is_default) 400 { 401 *is_default = false; 399 static owl_window *_get_cursor(void) 400 { 402 401 if (cursor_owner && owl_window_is_realized(cursor_owner)) 403 402 return cursor_owner; 404 *is_default = true;405 403 if (default_cursor && owl_window_is_realized(default_cursor)) 406 404 return default_cursor; … … 443 441 } 444 442 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 460 443 static void _owl_window_redraw_subtree(owl_window *w) 461 444 { 462 445 FuncOneArg ptr = (FuncOneArg)_owl_window_redraw_subtree; 463 464 446 if (!w->dirty_subtree) 465 447 return; 466 467 448 _owl_window_redraw(w); 468 449 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; 480 451 } 481 452 … … 488 459 owl_window *cursor; 489 460 owl_window *screen = owl_window_get_screen(); 490 bool default_cursor;491 461 492 462 if (!screen->dirty_subtree) … … 494 464 _owl_window_redraw_subtree(screen); 495 465 update_panels(); 496 cursor = _get_cursor( &default_cursor);466 cursor = _get_cursor(); 497 467 if (cursor && cursor->win) { 498 /* If supported, hide the default cursor. */499 curs_set(default_cursor ? 0 : 1);500 468 /* untouch it to avoid drawing; window should be clean now, but we must 501 469 * clean up in case there was junk left over on a subwin (cleaning up after -
zcrypt.c
rca1fb26a rc6332f5 16 16 #include <sys/wait.h> 17 17 #include <ctype.h> 18 #include <limits.h> 19 #include <getopt.h> 20 21 #include <config.h> 18 19 #include "config.h" 22 20 23 21 #ifdef HAVE_KERBEROS_IV … … 28 26 29 27 #include "filterproc.h" 30 31 extern const char *version;32 28 33 29 /* Annotate functions in which the caller owns the return value and is … … 110 106 } 111 107 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 119 108 int main(int argc, char *argv[]) 120 109 { … … 127 116 int mode = M_NONE; 128 117 129 intc;118 char c; 130 119 131 120 int messageflag = FALSE; … … 133 122 zoptions.flags = 0; 134 123 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) 146 125 { 147 126 switch(c) 148 127 { 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);157 128 case 'Z': 158 129 /* Zephyr encrypt */ … … 286 257 if (error || !cryptspec) 287 258 { 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"); 289 262 exit(1); 290 263 } … … 793 766 "gpg", 794 767 "--symmetric", 795 "--no-options",796 "--no-default-keyring",797 "--keyring", "/dev/null",798 "--secret-keyring", "/dev/null",799 768 "--batch", 800 769 "--quiet", … … 805 774 NULL 806 775 }; 807 err = call_filter( argv, in, &out, &status);776 err = call_filter("gpg", argv, in, &out, &status); 808 777 if(err || status) { 809 778 g_free(out); … … 877 846 "gpg", 878 847 "--decrypt", 879 "--no-options",880 "--no-default-keyring",881 "--keyring", "/dev/null",882 "--secret-keyring", "/dev/null",883 848 "--batch", 884 849 "--no-use-agent", … … 892 857 if(!in) return FALSE; 893 858 894 err = call_filter(argv, in, &out, &status); 895 free(in); 859 err = call_filter("gpg", argv, in, &out, &status); 896 860 if(err || status) { 897 861 g_free(out); -
zephyr.c
r7dcef03 rf271129 29 29 #define HM_SVC_FALLBACK htons((unsigned short) 2104) 30 30 31 static CALLER_OWNchar *owl_zephyr_dotfile(const char *name, const char *input)31 static char *owl_zephyr_dotfile(const char *name, const char *input) 32 32 { 33 33 if (input != NULL) … … 125 125 owl_zephyr_loadsubs_helper(subs->subs, subs->nsubs); 126 126 deferred_subs = g_list_delete_link(deferred_subs, deferred_subs); 127 g_ slice_free(owl_sub_list,subs);127 g_free(subs); 128 128 } 129 129 … … 152 152 ret_sd = owl_zephyr_loaddefaultsubs(); 153 153 154 /* load Barn Owl default subscriptions */154 /* load Barnowl default subscriptions */ 155 155 ret_bd = owl_zephyr_loadbarnowldefaultsubs(); 156 156 … … 261 261 g_free(subs); 262 262 } else { 263 owl_sub_list *s = g_ slice_new(owl_sub_list);263 owl_sub_list *s = g_new(owl_sub_list, 1); 264 264 s->subs = subs; 265 265 s->nsubs = count; … … 291 291 struct stat statbuff; 292 292 293 subs = g_new(ZSubscription_t, subSize); 293 294 subsfile = owl_zephyr_dotfile(".zephyr.subs", filename); 294 295 … … 306 307 if (!file) 307 308 return -1; 308 309 subs = g_new(ZSubscription_t, subSize);310 309 while (owl_getline(&buffer, file)) { 311 310 if (buffer[0] == '#' || buffer[0] == '\n') … … 354 353 } 355 354 356 /* Load default Barn Owl subscriptions355 /* Load default Barnowl subscriptions 357 356 * 358 357 * Returns 0 on success. … … 363 362 #ifdef HAVE_LIBZEPHYR 364 363 ZSubscription_t *subs; 365 int subSize = 10; /* Max Barn Owl default subs we allow */364 int subSize = 10; /* Max Barnowl default subs we allow */ 366 365 int count, ret; 367 366 … … 455 454 } 456 455 457 boolunsuball(void)456 void unsuball(void) 458 457 { 459 458 #if HAVE_LIBZEPHYR … … 465 464 owl_function_error("Zephyr: Cancelling subscriptions: %s", 466 465 error_message(ret)); 467 return (ret == ZERR_NONE); 468 #endif 469 return true; 466 #endif 470 467 } 471 468 … … 519 516 } 520 517 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 522 CALLER_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 */ 524 527 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("")); 566 548 } 567 549 568 550 CALLER_OWN char *owl_zephyr_get_field_as_utf8(const ZNotice_t *n, int j) 569 551 { 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 582 CALLER_OWN char *owl_zephyr_get_field(void *n, int j) 583 { 584 return(g_strdup("")); 585 } 586 CALLER_OWN char *owl_zephyr_get_field_as_utf8(void *n, int j) 587 { 588 return owl_zephyr_get_field(n, j); 606 589 } 607 590 #endif … … 611 594 int owl_zephyr_get_num_fields(const ZNotice_t *n) 612 595 { 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); 619 607 } 620 608 #else … … 709 697 Code_t ret; 710 698 ZNotice_t notice; 711 char *zsender = NULL;712 699 713 700 memset(¬ice, 0, sizeof(notice)); … … 719 706 notice.z_kind=ACKED; 720 707 notice.z_port=0; 721 #ifdef ZCHARSET_UTF_8722 notice.z_charset = ZCHARSET_UTF_8;723 #endif724 708 notice.z_class=zstr(class); 725 709 notice.z_class_inst=zstr(instance); 726 if (!strcmp(recipient, "@")) { 710 notice.z_sender=NULL; 711 if (!strcmp(recipient, "*") || !strcmp(recipient, "@")) { 727 712 notice.z_recipient=zstr(""); 713 if (*owl_global_get_zsender(&g)) 714 notice.z_sender=zstr(owl_global_get_zsender(&g)); 728 715 } else { 729 716 notice.z_recipient=zstr(recipient); 730 717 } 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"); 734 719 if (opcode) notice.z_opcode=zstr(opcode); 735 720 … … 744 729 /* free then check the return */ 745 730 g_free(notice.z_message); 746 g_free(zsender);731 ZFreeNotice(¬ice); 747 732 if (ret != ZERR_NONE) { 748 733 owl_function_error("Error sending zephyr: %s", error_message(ret)); … … 804 789 } else if (!strcmp(retnotice->z_message, ZSRVACK_NOTSENT)) { 805 790 if (retnotice->z_recipient == NULL 806 || !owl_zwrite_recip_is_personal(retnotice->z_recipient)) { 791 || *retnotice->z_recipient == 0 792 || *retnotice->z_recipient == '@') { 807 793 char *buff; 808 794 owl_function_error("No one subscribed to class %s", retnotice->z_class); … … 923 909 g_free(to); 924 910 925 z = owl_zwrite_new _from_line(tmpbuff);911 z = owl_zwrite_new(tmpbuff); 926 912 g_free(tmpbuff); 927 913 if (z == NULL) { … … 1025 1011 } 1026 1012 1027 g_free(subsfile);1028 1013 g_free(line); 1029 1014 #endif … … 1105 1090 g_free(filename); 1106 1091 } 1107 1108 #ifdef HAVE_LIBZEPHYR1109 const char *owl_zephyr_get_charsetstr(const ZNotice_t *n)1110 {1111 #ifdef ZCHARSET_UTF_81112 return ZCharsetToString(n->z_charset);1113 #else1114 return "";1115 #endif1116 }1117 #else1118 const char *owl_zephyr_get_charsetstr(const void *n)1119 {1120 return "";1121 }1122 #endif1123 1092 1124 1093 /* return auth string */ … … 1319 1288 CALLER_OWN char *owl_zephyr_smartstripped_user(const char *in) 1320 1289 { 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); 1332 1328 } 1333 1329 … … 1413 1409 if (ret == ZERR_NONE) { 1414 1410 /* Send a PSEUDO LOGIN! */ 1415 m = g_ slice_new(owl_message);1411 m = g_new(owl_message, 1); 1416 1412 owl_message_create_pseudo_zlogin(m, 0, zald->user, 1417 1413 location.host, … … 1426 1422 /* Send a PSEUDO LOGOUT! */ 1427 1423 if (notify) { 1428 m = g_ slice_new(owl_message);1424 m = g_new(owl_message, 1); 1429 1425 owl_message_create_pseudo_zlogin(m, 1, zald->user, "", "", ""); 1430 1426 owl_global_messagequeue_addmsg(&g, m); … … 1435 1431 } 1436 1432 ZFreeALD(zald); 1437 g_ slice_free(ZAsyncLocateData_t,zald);1433 g_free(zald); 1438 1434 } 1439 1435 } … … 1502 1498 1503 1499 /* create the new message */ 1504 m=g_ slice_new(owl_message);1500 m=g_new(owl_message, 1); 1505 1501 owl_message_create_from_znotice(m, ¬ice); 1506 1502 -
zwrite.c
r7dcef03 rf271129 1 1 #include "owl.h" 2 2 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);3 CALLER_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); 8 8 return NULL; 9 9 } … … 11 11 } 12 12 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 23 13 G_GNUC_WARN_UNUSED_RESULT int owl_zwrite_create_from_line(owl_zwrite *z, const char *line) 24 14 { 25 int argc ;15 int argc, badargs, myargc; 26 16 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; 43 18 char *msg = NULL; 19 20 badargs=0; 44 21 45 22 /* start with null entries */ … … 54 31 z->noping=0; 55 32 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) { 106 91 badargs=1; 107 92 break; … … 114 99 115 100 /* 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); 119 104 break; 120 } else if (!strcmp( argv[0], "-C")) {105 } else if (!strcmp(myargv[0], "-C")) { 121 106 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")) { 125 110 z->noping=1; 126 argv++;127 argc--;111 myargv++; 112 myargc--; 128 113 } else { 129 114 /* 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--; 133 118 } 134 119 } 135 120 121 g_strfreev(argv); 122 136 123 if (badargs) { 137 owl_zwrite_cleanup(z);138 124 return(-1); 139 125 } … … 143 129 z->recips->len == 0) { 144 130 owl_function_error("You must specify a recipient for zwrite"); 145 owl_zwrite_cleanup(z);146 131 return(-1); 147 132 } … … 182 167 } 183 168 169 /* if there are no recipients we won't send a ping, which 170 is what we want */ 184 171 for (i = 0; i < z->recips->len; i++) { 185 172 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); 188 174 g_free(to); 189 175 } … … 206 192 g_free(z->message); 207 193 208 if (z-> cc && owl_zwrite_is_personal(z)) {194 if (z->recips->len > 0 && z->cc) { 209 195 message = g_string_new("CC: "); 210 196 for (i = 0; i < z->recips->len; i++) { … … 268 254 owl_zwrite z; 269 255 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); 272 258 if (!owl_zwrite_is_message_set(&z)) { 273 259 owl_zwrite_set_message(&z, msg); … … 337 323 } 338 324 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) 325 int owl_zwrite_is_personal(const owl_zwrite *z) 345 326 { 346 327 /* return true if at least one of the recipients is personal */ 347 328 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); 353 336 } 354 337 … … 356 339 { 357 340 owl_zwrite_cleanup(z); 358 g_ slice_free(owl_zwrite,z);341 g_free(z); 359 342 } 360 343
Note: See TracChangeset
for help on using the changeset viewer.