Changeset 2323e49
- Timestamp:
- Jun 22, 2013, 9:49:34 PM (11 years ago)
- Parents:
- 96d80e9 (diff), 15a7aee (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Files:
-
- 36 added
- 38 deleted
- 70 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
.gitignore
rf93cc34 r1c22155 2 2 *.o 3 3 *.par 4 *~5 .#*6 .*.swp7 4 .deps 5 /bin/ 8 6 META.yml 7 MYMETA.yml 9 8 Makefile 10 9 Makefile.in 11 10 Makefile.old 12 11 TAGS 13 \#*#14 12 aclocal.m4 15 13 autom4te.cache 16 barnowl.bin 17 tester.bin 18 zcrypt 14 barnowl 19 15 blib 20 16 config.cache 21 17 config.h 22 18 config.h.in 19 config.h.in~ 23 20 config.log 24 21 config.status … … 26 23 core 27 24 depcomp 25 gmarshal_funcs.c 26 gmarshal_funcs.h 27 inc/ 28 28 install-sh 29 29 jabber.log … … 32 32 owl_prototypes.h.new 33 33 perlglue.c 34 perlwrap.c35 34 pm_to_blib 35 runtests.sh.log 36 runtests.sh.trs 36 37 stamp-h1 38 test-driver 39 test-suite.log 40 tester 37 41 varstubs.c 42 zcrypt -
AUTHORS
r1d2c4c3 r80c0fc7 3 3 4 4 The following people have provided patches or other contributions: 5 Alex Vandiver 6 Kevin Chen 7 Arun Tharuvai 5 8 Sam Hartman 6 Alex Vandiver7 Geoffrey Thomas8 9 Derrick Brashear 9 10 David Glasser 11 Eric Price 10 12 Matthew Goldstein 11 Arun Tharuvai 12 Kevin Chen 13 Eric Price 13 Geoffrey Thomas 14 Anders Kaseorg 15 Greg Price 16 Chris Lesniewski-Laas 17 Alex Dehnert 18 Edward Z. Yang 19 Karl Ramm 20 Evan Broder 21 David Benjamin 22 Cathy Zhang 23 Joshua Oreman 24 Leonid Grinberg 25 Kevin Riggle 26 Brian Sniffen 27 William Throwe 28 Jason Gross 29 Adam Glasgall 30 Tim Hill 31 DD Liu 32 Betsy Riley 33 Robert Jacobs 14 34 15 BarnOwl is based on code from Owl, which was originally primar ly35 BarnOwl is based on code from Owl, which was originally primarily 16 36 written by James Kretchmar. Erik Nygren also made substantial 17 contributions and improvem nts to the program.37 contributions and improvements to the program. 18 38 19 The following people provided patches and other tech incal support for39 The following people provided patches and other technical support for 20 40 Owl: 21 41 … … 30 50 Mark Eichin 31 51 32 Mark Eichin is also maintaining the debian package of Owl.52 Mark Eichin is also maintaining the Debian package of Owl. 33 53 34 54 The following people helped with beta testing the earliest versions of -
COPYING
rb03c714 rccc182c 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 Plain 555 Black Corporation. 556 557 This software is copyright (c) 2010 by Plain Black Corporation. 558 559 This is free software; you can redistribute it and/or modify it under 560 the same terms as the Perl 5 programming language system itself. 561 562 Terms of the Perl programming language system itself 563 564 a) the GNU General Public License as published by the Free 565 Software Foundation; either version 1, or (at your option) any 566 later version, or 567 b) the "Artistic License" 568 569 --- The GNU General Public License, Version 1, February 1989 --- 570 571 This software is Copyright (c) 2010 by Plain Black Corporation. 572 573 This is free software, licensed under: 574 575 The GNU General Public License, Version 1, February 1989 576 577 GNU GENERAL PUBLIC LICENSE 578 Version 1, February 1989 579 580 Copyright (C) 1989 Free Software Foundation, Inc. 581 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 582 583 Everyone is permitted to copy and distribute verbatim copies 584 of this license document, but changing it is not allowed. 585 586 Preamble 587 588 The license agreements of most software companies try to keep users 589 at the mercy of those companies. By contrast, our General Public 590 License is intended to guarantee your freedom to share and change free 591 software--to make sure the software is free for all its users. The 592 General Public License applies to the Free Software Foundation's 593 software and to any other program whose authors commit to using it. 594 You can use it for your programs, too. 595 596 When we speak of free software, we are referring to freedom, not 597 price. Specifically, the General Public License is designed to make 598 sure that you have the freedom to give away or sell copies of free 599 software, that you receive source code or can get it if you want it, 600 that you can change the software or use pieces of it in new free 601 programs; and that you know you can do these things. 602 603 To protect your rights, we need to make restrictions that forbid 604 anyone to deny you these rights or to ask you to surrender the rights. 605 These restrictions translate to certain responsibilities for you if you 606 distribute copies of the software, or if you modify it. 607 608 For example, if you distribute copies of a such a program, whether 609 gratis or for a fee, you must give the recipients all the rights that 610 you have. You must make sure that they, too, receive or can get the 611 source code. And you must tell them their rights. 612 613 We protect your rights with two steps: (1) copyright the software, and 614 (2) offer you this license which gives you legal permission to copy, 615 distribute and/or modify the software. 616 617 Also, for each author's protection and ours, we want to make certain 618 that everyone understands that there is no warranty for this free 619 software. If the software is modified by someone else and passed on, we 620 want its recipients to know that what they have is not the original, so 621 that any problems introduced by others will not reflect on the original 622 authors' reputations. 623 624 The precise terms and conditions for copying, distribution and 625 modification follow. 626 627 GNU GENERAL PUBLIC LICENSE 628 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 629 630 0. This License Agreement applies to any program or other work which 631 contains a notice placed by the copyright holder saying it may be 632 distributed under the terms of this General Public License. The 633 "Program", below, refers to any such program or work, and a "work based 634 on the Program" means either the Program or any work containing the 635 Program or a portion of it, either verbatim or with modifications. Each 636 licensee is addressed as "you". 637 638 1. You may copy and distribute verbatim copies of the Program's source 639 code as you receive it, in any medium, provided that you conspicuously and 640 appropriately publish on each copy an appropriate copyright notice and 641 disclaimer of warranty; keep intact all the notices that refer to this 642 General Public License and to the absence of any warranty; and give any 643 other recipients of the Program a copy of this General Public License 644 along with the Program. You may charge a fee for the physical act of 645 transferring a copy. 646 647 2. You may modify your copy or copies of the Program or any portion of 648 it, and copy and distribute such modifications under the terms of Paragraph 649 1 above, provided that you also do the following: 650 651 a) cause the modified files to carry prominent notices stating that 652 you changed the files and the date of any change; and 653 654 b) cause the whole of any work that you distribute or publish, that 655 in whole or in part contains the Program or any part thereof, either 656 with or without modifications, to be licensed at no charge to all 657 third parties under the terms of this General Public License (except 658 that you may choose to grant warranty protection to some or all 659 third parties, at your option). 660 661 c) If the modified program normally reads commands interactively when 662 run, you must cause it, when started running for such interactive use 663 in the simplest and most usual way, to print or display an 664 announcement including an appropriate copyright notice and a notice 665 that there is no warranty (or else, saying that you provide a 666 warranty) and that users may redistribute the program under these 667 conditions, and telling the user how to view a copy of this General 668 Public License. 669 670 d) You may charge a fee for the physical act of transferring a 671 copy, and you may at your option offer warranty protection in 672 exchange for a fee. 673 674 Mere aggregation of another independent work with the Program (or its 675 derivative) on a volume of a storage or distribution medium does not bring 676 the other work under the scope of these terms. 677 678 3. You may copy and distribute the Program (or a portion or derivative of 679 it, under Paragraph 2) in object code or executable form under the terms of 680 Paragraphs 1 and 2 above provided that you also do one of the following: 681 682 a) accompany it with the complete corresponding machine-readable 683 source code, which must be distributed under the terms of 684 Paragraphs 1 and 2 above; or, 685 686 b) accompany it with a written offer, valid for at least three 687 years, to give any third party free (except for a nominal charge 688 for the cost of distribution) a complete machine-readable copy of the 689 corresponding source code, to be distributed under the terms of 690 Paragraphs 1 and 2 above; or, 691 692 c) accompany it with the information you received as to where the 693 corresponding source code may be obtained. (This alternative is 694 allowed only for noncommercial distribution and only if you 695 received the program in object code or executable form alone.) 696 697 Source code for a work means the preferred form of the work for making 698 modifications to it. For an executable file, complete source code means 699 all the source code for all modules it contains; but, as a special 700 exception, it need not include source code for modules which are standard 701 libraries that accompany the operating system on which the executable 702 file runs, or for standard header files or definitions files that 703 accompany that operating system. 704 705 4. You may not copy, modify, sublicense, distribute or transfer the 706 Program except as expressly provided under this General Public License. 707 Any attempt otherwise to copy, modify, sublicense, distribute or transfer 708 the Program is void, and will automatically terminate your rights to use 709 the Program under this License. However, parties who have received 710 copies, or rights to use copies, from you under this General Public 711 License will not have their licenses terminated so long as such parties 712 remain in full compliance. 713 714 5. By copying, distributing or modifying the Program (or any work based 715 on the Program) you indicate your acceptance of this license to do so, 716 and all its terms and conditions. 717 718 6. Each time you redistribute the Program (or any work based on the 719 Program), the recipient automatically receives a license from the original 720 licensor to copy, distribute or modify the Program subject to these 721 terms and conditions. You may not impose any further restrictions on the 722 recipients' exercise of the rights granted herein. 723 724 7. The Free Software Foundation may publish revised and/or new versions 725 of the General Public License from time to time. Such new versions will 726 be similar in spirit to the present version, but may differ in detail to 727 address new problems or concerns. 728 729 Each version is given a distinguishing version number. If the Program 730 specifies a version number of the license which applies to it and "any 731 later version", you have the option of following the terms and conditions 732 either of that version or of any later version published by the Free 733 Software Foundation. If the Program does not specify a version number of 734 the license, you may choose any version ever published by the Free Software 735 Foundation. 736 737 8. If you wish to incorporate parts of the Program into other free 738 programs whose distribution conditions are different, write to the author 739 to ask for permission. For software which is copyrighted by the Free 740 Software Foundation, write to the Free Software Foundation; we sometimes 741 make exceptions for this. Our decision will be guided by the two goals 742 of preserving the free status of all derivatives of our free software and 743 of promoting the sharing and reuse of software generally. 744 745 NO WARRANTY 746 747 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 748 FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 749 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 750 PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 751 OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 752 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 753 TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 754 PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 755 REPAIR OR CORRECTION. 756 757 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 758 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 759 REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 760 INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 761 OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 762 TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 763 YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 764 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 765 POSSIBILITY OF SUCH DAMAGES. 766 767 END OF TERMS AND CONDITIONS 768 769 Appendix: How to Apply These Terms to Your New Programs 770 771 If you develop a new program, and you want it to be of the greatest 772 possible use to humanity, the best way to achieve this is to make it 773 free software which everyone can redistribute and change under these 774 terms. 775 776 To do so, attach the following notices to the program. It is safest to 777 attach them to the start of each source file to most effectively convey 778 the exclusion of warranty; and each file should have at least the 779 "copyright" line and a pointer to where the full notice is found. 780 781 <one line to give the program's name and a brief idea of what it does.> 782 Copyright (C) 19yy <name of author> 783 784 This program is free software; you can redistribute it and/or modify 785 it under the terms of the GNU General Public License as published by 786 the Free Software Foundation; either version 1, or (at your option) 787 any later version. 788 789 This program is distributed in the hope that it will be useful, 790 but WITHOUT ANY WARRANTY; without even the implied warranty of 791 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 792 GNU General Public License for more details. 793 794 You should have received a copy of the GNU General Public License 795 along with this program; if not, write to the Free Software 796 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA 797 798 799 Also add information on how to contact you by electronic and paper mail. 800 801 If the program is interactive, make it output a short notice like this 802 when it starts in an interactive mode: 803 804 Gnomovision version 69, Copyright (C) 19xx name of author 805 Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 806 This is free software, and you are welcome to redistribute it 807 under certain conditions; type `show c' for details. 808 809 The hypothetical commands `show w' and `show c' should show the 810 appropriate parts of the General Public License. Of course, the 811 commands you use may be called something other than `show w' and `show 812 c'; they could even be mouse-clicks or menu items--whatever suits your 813 program. 814 815 You should also get your employer (if you work as a programmer) or your 816 school, if any, to sign a "copyright disclaimer" for the program, if 817 necessary. Here a sample; alter the names: 818 819 Yoyodyne, Inc., hereby disclaims all copyright interest in the 820 program `Gnomovision' (a program to direct compilers to make passes 821 at assemblers) written by James Hacker. 822 823 <signature of Ty Coon>, 1 April 1989 824 Ty Coon, President of Vice 825 826 That's all there is to it! 827 828 829 --- The Artistic License 1.0 --- 830 831 This software is Copyright (c) 2010 by Plain Black Corporation. 832 833 This is free software, licensed under: 834 835 The Artistic License 1.0 836 837 The Artistic License 838 839 Preamble 840 841 The intent of this document is to state the conditions under which a Package 842 may be copied, such that the Copyright Holder maintains some semblance of 843 artistic control over the development of the package, while giving the users of 844 the package the right to use and distribute the Package in a more-or-less 845 customary fashion, plus the right to make reasonable modifications. 846 847 Definitions: 848 849 - "Package" refers to the collection of files distributed by the Copyright 850 Holder, and derivatives of that collection of files created through 851 textual modification. 852 - "Standard Version" refers to such a Package if it has not been modified, 853 or has been modified in accordance with the wishes of the Copyright 854 Holder. 855 - "Copyright Holder" is whoever is named in the copyright or copyrights for 856 the package. 857 - "You" is you, if you're thinking about copying or distributing this Package. 858 - "Reasonable copying fee" is whatever you can justify on the basis of media 859 cost, duplication charges, time of people involved, and so on. (You will 860 not be required to justify it to the Copyright Holder, but only to the 861 computing community at large as a market that must bear the fee.) 862 - "Freely Available" means that no fee is charged for the item itself, though 863 there may be fees involved in handling the item. It also means that 864 recipients of the item may redistribute it under the same conditions they 865 received it. 866 867 1. You may make and give away verbatim copies of the source form of the 868 Standard Version of this Package without restriction, provided that you 869 duplicate all of the original copyright notices and associated disclaimers. 870 871 2. You may apply bug fixes, portability fixes and other modifications derived 872 from the Public Domain or from the Copyright Holder. A Package modified in such 873 a way shall still be considered the Standard Version. 874 875 3. You may otherwise modify your copy of this Package in any way, provided that 876 you insert a prominent notice in each changed file stating how and when you 877 changed that file, and provided that you do at least ONE of the following: 878 879 a) place your modifications in the Public Domain or otherwise make them 880 Freely Available, such as by posting said modifications to Usenet or an 881 equivalent medium, or placing the modifications on a major archive site 882 such as ftp.uu.net, or by allowing the Copyright Holder to include your 883 modifications in the Standard Version of the Package. 884 885 b) use the modified Package only within your corporation or organization. 886 887 c) rename any non-standard executables so the names do not conflict with 888 standard executables, which must also be provided, and provide a separate 889 manual page for each non-standard executable that clearly documents how it 890 differs from the Standard Version. 891 892 d) make other distribution arrangements with the Copyright Holder. 893 894 4. You may distribute the programs of this Package in object code or executable 895 form, provided that you do at least ONE of the following: 896 897 a) distribute a Standard Version of the executables and library files, 898 together with instructions (in the manual page or equivalent) on where to 899 get the Standard Version. 900 901 b) accompany the distribution with the machine-readable source of the Package 902 with your modifications. 903 904 c) accompany any non-standard executables with their corresponding Standard 905 Version executables, giving the non-standard executables non-standard 906 names, and clearly documenting the differences in manual pages (or 907 equivalent), together with instructions on where to get the Standard 908 Version. 909 910 d) make other distribution arrangements with the Copyright Holder. 911 912 5. You may charge a reasonable copying fee for any distribution of this 913 Package. You may charge any fee you choose for support of this Package. You 914 may not charge a fee for this Package itself. However, you may distribute this 915 Package in aggregate with other (possibly commercial) programs as part of a 916 larger (possibly commercial) software distribution provided that you do not 917 advertise this Package as a product of your own. 918 919 6. The scripts and library files supplied as input to or produced as output 920 from the programs of this Package do not automatically fall under the copyright 921 of this Package, but belong to whomever generated them, and may be sold 922 commercially, and may be aggregated with this Package. 923 924 7. C or perl subroutines supplied by you and linked into this Package shall not 925 be considered part of this Package. 926 927 8. The name of the Copyright Holder may not be used to endorse or promote 928 products derived from this software without specific prior written permission. 929 930 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED 931 WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 932 MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 933 934 The End -
ChangeLog
r65ff3f4 r1b17f50 1 1.9 2 * Add getnumlines() to perl interface -asedeno@mit.edu 3 * Include names of invalid filters on filter errors -adehnert@mit.edu 4 * Don't incorrectly mark decryption failures as decrypted -davidben@mit.edu 5 * Hide the default cursor when possible -davidben@mit.edu 6 * Complete viewperson and vp as viewuser and vu -davidben@mit.edu 7 * Set z_charset = ZCHARSET_UTF_8 -andersk@mit.edu 8 * Allow zsender spoofing on cross-realm classes -andersk@mit.edu 9 * Append the realm to the zsender if missing -andersk@mit.edu 10 * Redisplay on setting colorztext -jgross@mit.edu 11 * Rename default config file to .owl/init.pl -kevinr@free-dissociation.com 12 * Add completion for jabberlogout -adehnert@mit.edu 13 * Switch to interactive context before sourcing the startup file -davidben@mit.edu 14 * Add completion for reload-module -adehnert@mit.edu 15 * editwin callback for canceling the editwin -jgross@mit.edu 16 * Fix dirtying windows inside a redraw handler -davidben@mit.edu 17 * Facebook module -ezyang@mit.edu 18 * Complete unstartup command just like startup command -jgross@mit.edu 19 * Fix the description of disable-ctrl-d -jgross@mit.edu 20 * Use wbkgrndset instead of wbkgdset in _owl_fmtext_wcolor_set -davidben@mit.edu 21 * Show the time zone in :info -jgross@mit.edu 22 * Treat [!.?]" as end of sentence in edit:fill-paragraph -jgross@mit.edu 23 * Correctly display multiline fields in :info -jgross@mit.edu 24 25 1.8.1 26 * Only add outgoing messages for personal part of half-personal messages -andersk@mit.edu 27 * Don’t write CC: line on zwrite -C '' -andersk@mit.edu 28 * Don’t send public pings on zwrite '' or zwrite @REALM -andersk@mit.edu 29 * Don’t treat zwrite '' as personal -andersk@mit.edu 30 * Stop pretending to support zwrite * -andersk@mit.edu 31 * Show foreign realms on non-personal zephyrs like Owl did -andersk@mit.edu 32 * Fix memory leak in zcrypt -davidben@mit.edu 33 * Don't attempt to switch filters in :view -d if invalid -davidben@mit.edu 34 * Fixed typo in unbindkey usage error -rileyb@mit.edu 35 * Fix bug generating filter text in 256-color mode -asedeno@mit.edu 36 * Remove ^noc from reply-lockout -geofft@mit.edu 37 * Avoid quadratic loops when receiving zephyrs -andersk@mit.edu 38 * Fix hang on empty zcrypt messages -adehnert@MIT.EDU 39 1 40 1.8 2 41 * Compute the home directory in zcrypt consistently with BarnOwl -davidben@mit.edu -
Makefile.am
rc266281 ra223b6b 4 4 GIT_FLAGS := $(if $(GIT_DESCRIPTION),-DGIT_VERSION=$(GIT_DESCRIPTION:barnowl-%=%)) 5 5 6 bin_PROGRAMS = b arnowl.bin6 bin_PROGRAMS = bin/barnowl 7 7 if ENABLE_ZCRYPT 8 8 bin_PROGRAMS += zcrypt … … 11 11 zcrypt_SOURCES = zcrypt.c filterproc.c 12 12 13 check_PROGRAMS = tester.bin 13 check_PROGRAMS = bin/tester 14 dist_check_DATA = t 15 dist_check_SCRIPTS = runtests.sh 14 16 15 barnowl_bin_SOURCES = $(BASE_SRCS) \ 16 owl.h owl_perl.h config.h \ 17 owl.c \ 18 $(GEN_C) $(GEN_H) 17 noinst_SCRIPTS = barnowl 18 check_SCRIPTS = tester 19 19 20 man_MANS = doc/barnowl.1 21 doc_DATA = doc/intro.txt doc/advanced.txt 20 barnowl tester: %: barnowl-wrapper.in bin/% Makefile 21 sed \ 22 -e 's,[@]abs_srcdir[@],$(abs_srcdir),g' \ 23 -e 's,[@]abs_builddir[@],$(abs_builddir),g' \ 24 $< > $@ 25 chmod +x $@ 22 26 23 barnowl_bin_LDADD = compat/libcompat.a libfaim/libfaim.a 27 bin_barnowl_SOURCES = $(BASE_SRCS) \ 28 owl.h owl_perl.h \ 29 owl.c 30 nodist_bin_barnowl_SOURCES = $(GEN_C) $(GEN_H) 24 31 25 tester_bin_SOURCES = $(BASE_SRCS) \ 26 owl.h owl_perl.h config.h \ 27 $(GEN_C) $(GEN_H) \ 32 dist_man_MANS = doc/barnowl.1 33 dist_doc_DATA = doc/intro.txt doc/advanced.txt 34 35 bin_barnowl_LDADD = compat/libcompat.a libfaim/libfaim.a 36 37 bin_tester_SOURCES = $(BASE_SRCS) \ 38 owl.h owl_perl.h \ 28 39 tester.c 40 nodist_bin_tester_SOURCES = $(GEN_C) $(GEN_H) 29 41 30 tester_bin_LDADD = compat/libcompat.a libfaim/libfaim.a42 bin_tester_LDADD = compat/libcompat.a libfaim/libfaim.a 31 43 32 44 TESTS=runtests.sh 33 45 34 AM_CPPFLAGS = -I$(top_srcdir)/\46 AM_CPPFLAGS = \ 35 47 -I$(top_srcdir)/libfaim/ \ 36 48 -DDATADIR='"$(pkgdatadir)"' \ … … 39 51 40 52 CODELIST_SRCS=message.c mainwin.c popwin.c zephyr.c messagelist.c \ 41 commands.c global.c text.c fmtext.c editwin.c util.c logging.c \ 53 commands.c global.c text.c fmtext.c editwin.c \ 54 util.c logging.c \ 42 55 perlconfig.c keys.c functions.c zwrite.c viewwin.c help.c filter.c \ 43 56 regex.c history.c view.c dict.c variable.c filterelement.c pair.c \ … … 45 58 aim.c buddy.c buddylist.c style.c errqueue.c \ 46 59 zbuddylist.c popexec.c select.c wcwidth.c \ 47 mainpanel.c msgwin.c sepbar.c editcontext.c signal.c 60 mainpanel.c msgwin.c sepbar.c editcontext.c signal.c closures.c 48 61 49 NORMAL_SRCS = filterproc.c window.cwindowcb.c62 NORMAL_SRCS = filterproc.c filterproc.h window.c window.h windowcb.c 50 63 51 64 BASE_SRCS = $(CODELIST_SRCS) $(NORMAL_SRCS) 52 65 53 GEN_C = varstubs.c perlglue.c 54 GEN_H = owl_prototypes.h 66 GEN_C = varstubs.c perlglue.c gmarshal_funcs.c 67 GEN_H = owl_prototypes.h owl_prototypes.h.new gmarshal_funcs.h 55 68 56 69 BUILT_SOURCES = $(GEN_C) $(GEN_H) … … 65 78 proto: owl_prototypes.h 66 79 67 perlglue.c: perlglue.xs $(TYPEMAP)68 $(AM_V_GEN)perl $(XSUBPPDIR)/xsubpp $(XSUBPPFLAGS) -prototypes perlglue.xs > perlglue.c80 perlglue.c: perlglue.xs typemap 81 $(AM_V_GEN)perl $(XSUBPPDIR)/xsubpp $(XSUBPPFLAGS) -prototypes $< > $@ 69 82 70 83 varstubs.c: stubgen.pl variable.c … … 74 87 $(AM_V_GEN)perl $< $(sort $(filter-out $<,$+)) > $@ 75 88 89 gmarshal_funcs.h: marshal_types 90 glib-genmarshal --header $< > $@ 91 gmarshal_funcs.c: marshal_types 92 glib-genmarshal --body $< > $@ 93 76 94 # For emacs flymake-mode 77 95 check-syntax: proto 78 96 $(COMPILE) -Wall -Wextra -pedantic -fsyntax-only $(CHK_SOURCES) 79 97 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) 98 CLEANFILES = $(BUILT_SOURCES) $(noinst_SCRIPTS) $(check_SCRIPTS) 99 EXTRA_DIST = \ 100 autogen.sh \ 101 barnowl-wrapper.in \ 102 codelist.pl \ 103 doc/code.txt \ 104 doc/owl-window.txt \ 105 doc/releasing-barnowl.txt \ 106 examples \ 107 marshal_types \ 108 perlglue.xs \ 109 scripts \ 110 stubgen.pl \ 111 typemap 88 112 89 113 SUBDIRS = compat libfaim perl -
README
rb711711 r1c22155 10 10 following CPAN modules: 11 11 12 Facebook::Graph 12 13 Net::Jabber 13 14 Net::XMPP 14 15 XML::Stream 15 16 16 Theyhave been modified slightly for the needs of this project.17 Some have been modified slightly for the needs of this project. 17 18 18 19 BarnOwl currently requires the following perl modules off of CPAN: … … 20 21 AnyEvent 21 22 Class::Accessor 23 ExtUtils::Depends 22 24 Glib 25 Module::Install 23 26 PAR 24 27 … … 26 29 We plan to soon add targets to the Makefile to check for and install 27 30 these for you. 31 32 The Facebook module requires: 33 34 Any::Moose 35 AnyEvent::HTTP 36 DateTime 37 DateTime::Format::Strptime 38 JSON 39 MIME::Base64::URLSafe 40 Ouch 41 URI 42 URI::Encode 28 43 29 44 The IRC module requires: … … 36 51 Authen::SASL::Perl 37 52 IO::Socket::SSL 38 Digest::SHA 153 Digest::SHA 39 54 40 55 The Twitter module requires: -
aim.c
r3234121 r8258ea5 1 #include <stdio.h>2 #include <stdio.h>3 #include <sys/stat.h>4 1 #include "owl.h" 5 2 … … 710 707 { 711 708 aim_clientready(sess, fr->conn); 712 owl_function_debugmsg("conninitdone_admin: initializ tion done for admin connection");709 owl_function_debugmsg("conninitdone_admin: initialization done for admin connection"); 713 710 return(1); 714 711 } … … 839 836 params = va_arg(ap, struct aim_icbmparameters *); 840 837 va_end(ap); 841 842 owl_function_debugmsg("faimtest_icbmparaminfo: ICBM Parameters: maxchannel = %d, default flags = 0x%08x, max msg len = %d, max sender evil = %f, max rec iever evil = %f, min msg interval = %u",838 839 owl_function_debugmsg("faimtest_icbmparaminfo: ICBM Parameters: maxchannel = %d, default flags = 0x%08x, max msg len = %d, max sender evil = %f, max receiver evil = %f, min msg interval = %u", 843 840 params->maxchan, params->flags, params->maxmsglen, ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, params->minmsginterval); 844 841 -
barnowl-wrapper.in
- Property mode changed from 100755 to 100644
rf5f6ec0 ra223b6b 1 1 #!/bin/sh 2 2 # This is a wrapper script to point BARNOWL_DATA_DIR at the source dir 3 # if we're running from a build tree. b arnowl.binis the actual built3 # if we're running from a build tree. bin/barnowl is the actual built 4 4 # binary. 5 5 6 SRCDIR=`dirname "${0}"` 7 EXE="$0.bin" 6 EXE="@abs_builddir@/bin/$(basename "$0")" 8 7 9 8 if test ! -x "$EXE"; then … … 12 11 fi 13 12 14 BARNOWL_DATA_DIR=" $SRCDIR/perl/"15 BARNOWL_BIN_DIR=" $SRCDIR/"13 BARNOWL_DATA_DIR="@abs_srcdir@/perl" 14 BARNOWL_BIN_DIR="@abs_builddir@" 16 15 export BARNOWL_DATA_DIR 17 16 export BARNOWL_BIN_DIR -
cmd.c
r14be3a5 rf271129 1 #include <stdio.h>2 #include <stdlib.h>3 #include <string.h>4 #include <unistd.h>5 1 #include "owl.h" 6 2 -
commands.c
r287c634 r3b9ca71 1 #include "owl.h" 1 2 #include <getopt.h> 2 #include <stdio.h>3 #include <stdlib.h>4 #include <string.h>5 #include <unistd.h>6 #include "owl.h"7 3 8 4 /* fn is "char *foo(int argc, const char *const *argv, const char *buff)" */ … … 100 96 OWLCMD_ARGS("unbindkey", owl_command_unbindkey, OWL_CTX_ANY, 101 97 "removes a binding in a keymap", 102 " bindkey <keymap> <keyseq>",98 "unbindkey <keymap> <keyseq>", 103 99 "Removes a binding of a key sequence within a keymap.\n" 104 100 "Use 'show keymaps' to see the existing keymaps.\n" … … 1037 1033 OWLCMD_ARGS_CTX("popless:start-search", owl_viewwin_command_start_search, OWL_CTX_POPLESS, 1038 1034 "starts a command line to search for particular string", 1039 "popless:start-search [-r] [init al-value]",1035 "popless:start-search [-r] [initial-value]", 1040 1036 "Initializes the command-line to search for initial-value. If\n" 1041 1037 "-r is used, the search will be performed backwards.\n\n" … … 1608 1604 if (v == NULL) { 1609 1605 if (!silent) owl_function_error("Unknown variable '%s'", var); 1610 } else if (requirebool && owl_variable_get_type(v) != OWL_VARIABLE_BOOL) {1606 } else if (requirebool && !v->takes_on_off) { 1611 1607 if (!silent) owl_function_error("Variable '%s' is not a boolean", var); 1612 1608 } else { … … 1637 1633 if (v == NULL) { 1638 1634 if (!silent) owl_function_error("Unknown variable '%s'", var); 1639 } else if ( owl_variable_get_type(v) != OWL_VARIABLE_BOOL) {1635 } else if (!v->takes_on_off) { 1640 1636 if (!silent) owl_function_error("Variable '%s' is not a boolean", var); 1641 1637 } else { … … 1782 1778 1783 1779 if (argc < 3) { 1784 owl_function_makemsg("Usage: bindkey <keymap> <binding>");1780 owl_function_makemsg("Usage: unbindkey <keymap> <binding>"); 1785 1781 return NULL; 1786 1782 } … … 1989 1985 } 1990 1986 /* check for a zwrite -m */ 1991 z = owl_zwrite_new( buff);1987 z = owl_zwrite_new(argc, argv); 1992 1988 if (!z) { 1993 1989 owl_function_error("Error in zwrite arguments"); … … 2194 2190 if (!strcmp(argv[0], "-f")) { 2195 2191 if (argc<2) { 2196 owl_function_makemsg("Too few arg ments to the view command");2192 owl_function_makemsg("Too few arguments to the view command"); 2197 2193 return(NULL); 2198 2194 } … … 2206 2202 } else if (!strcmp(argv[0], "-s")) { 2207 2203 if (argc<2) { 2208 owl_function_makemsg("Too few arg ments to the view command");2204 owl_function_makemsg("Too few arguments to the view command"); 2209 2205 return(NULL); 2210 2206 } … … 2213 2209 argv+=2; 2214 2210 } else { 2215 owl_function_makemsg("Too few arg ments to the view command");2211 owl_function_makemsg("Too few arguments to the view command"); 2216 2212 return(NULL); 2217 2213 } … … 2800 2796 owl_history_store(hist, owl_editwin_get_text(e), false); 2801 2797 2798 /* Take a reference to the editwin, so that it survives the pop 2799 * context. TODO: We should perhaps refcount or otherwise protect 2800 * the context so that, even if a command pops a context, the 2801 * context itself will last until the command returns. */ 2802 owl_editwin_ref(e); 2802 2803 owl_global_pop_context(&g); 2804 2805 owl_editwin_do_callback(e, false); 2806 owl_editwin_unref(e); 2803 2807 } 2804 2808 … … 2860 2864 owl_global_pop_context(&g); 2861 2865 2862 owl_editwin_do_callback(e );2866 owl_editwin_do_callback(e, true); 2863 2867 owl_editwin_unref(e); 2864 2868 } -
compat/Makefile.am
r12a6616 rb80bae0 1 1 noinst_LIBRARIES = libcompat.a 2 2 3 libcompat_a_SOURCES = 3 libcompat_a_SOURCES = compat.h 4 4 libcompat_a_LIBADD = $(LIBOBJS) -
compat/compat.h
r4dde585 r6249a88f 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
r883502d re4b8f93 1 1 dnl Process this file with autoconf to produce a configure script. 2 AC_INIT([BarnOwl],[1.9dev],[bug-barnowl@mit.edu]) 3 AM_INIT_AUTOMAKE([1.7.0 -Wall -Wno-portability foreign]) 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]) 4 5 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) 5 6 … … 9 10 AC_PROG_CC 10 11 AC_PROG_CC_C99 12 AC_PROG_LN_S 13 14 AC_ARG_WITH([zephyr-default-format], 15 [AS_HELP_STRING([--with-zephyr-default-format], 16 [value for the default format zephyrgram field])], 17 [ 18 case $withval in 19 yes) withval='Config error: see http://mit.edu/df';; 20 no) withval='';; 21 esac 22 zephyr_default_format=$withval 23 ], 24 [zephyr_default_format='Config error: see http://mit.edu/df']) 25 AC_DEFINE_UNQUOTED( 26 [ZEPHYR_DEFAULT_FORMAT], ["$zephyr_default_format"], 27 [Value for the default format zephyrgram field] 28 ) 11 29 12 30 AC_ARG_WITH([stack-protector], … … 41 59 42 60 AS_IF([test "x$with_zephyr" != xno], 43 [AS_IF([test "x$with_krb4" != "xno"], 61 [have_krb4=no 62 63 AS_IF([test "x$with_krb4" != "xno"], 44 64 [AC_MSG_CHECKING([for Kerberos IV]) 45 65 AS_IF([krb5-config krb4 --libs >/dev/null 2>&1], 46 66 [AC_MSG_RESULT([yes]) 67 have_krb4=yes 47 68 AC_DEFINE([HAVE_KERBEROS_IV], [1], [Define if you have kerberos IV]) 48 69 AM_CFLAGS="${AM_CFLAGS} `krb5-config krb4 --cflags`" … … 51 72 [AC_MSG_RESULT([no]) 52 73 AS_IF([test "x$with_krb4" = "xyes"], 53 [AC_MSG_ERROR([Kerberos IV requested but not found])]) 54 PKG_CHECK_MODULES([LIBCRYPTO], [libcrypto]) 55 AM_CFLAGS="${AM_CFLAGS} ${LIBCRYPTO_CFLAGS}" 56 LIBS="${LIBS} ${LIBCRYPTO_LIBS}" 57 ])]) 74 [AC_MSG_ERROR([Kerberos IV requested but not found])])])]) 75 76 AS_IF([test "x$have_krb4" != xyes], 77 [PKG_CHECK_MODULES([LIBCRYPTO], [libcrypto], 78 [AM_CFLAGS="${AM_CFLAGS} ${LIBCRYPTO_CFLAGS}" 79 LIBS="${LIBS} ${LIBCRYPTO_LIBS}" 80 ], 81 [PKG_CHECK_MODULES([OPENSSL], [openssl], 82 [AM_CFLAGS="${AM_CFLAGS} ${OPENSSL_CFLAGS}" 83 LIBS="${LIBS} ${OPENSSL_LIBS}" 84 ])])]) 85 58 86 AC_CHECK_LIB([zephyr], [ZGetSender], 59 87 [LIBS="$LIBS -lzephyr" … … 90 118 dnl Find the location of perl XSUBPP 91 119 AC_MSG_CHECKING(for the perl xsubpp precompiler) 92 XSUBPPDIR="` (perl -MExtUtils::MakeMaker -e 'print ExtUtils::MakeMaker->new({NAME => qw(owl)})->tool_xsubpp;')| grep \^XSUBPPDIR | sed -e 's/XSUBPPDIR = //g;'`"120 XSUBPPDIR="`cd "$srcdir" && perl -MExtUtils::MakeMaker -e 'print ExtUtils::MakeMaker->new({NAME => qw(owl)})->tool_xsubpp;' | grep \^XSUBPPDIR | sed -e 's/XSUBPPDIR = //g;'`" 93 121 if test -n "${XSUBPPDIR}"; then 94 122 AC_MSG_RESULT(${XSUBPPDIR}) … … 113 141 AX_PROG_PERL_MODULES([Class::Accessor::Fast],, 114 142 [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])]) 115 145 AX_PROG_PERL_MODULES([Glib],, 116 146 [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])]) 117 149 AX_PROG_PERL_MODULES([PAR],, 118 150 [AC_MSG_WARN([PAR.pm not found. Loadable modules will be disabled.])]) … … 129 161 prefix="${ac_default_prefix}" 130 162 fi 163 164 dnl Add CFLAGS for glib-perl 165 GLIB_PERL_CFLAGS=`perl -MExtUtils::Depends -e 'my $e = ExtUtils::Depends->new("BarnOwl","Glib"); my %h = $e->get_makefile_vars; print $h{"INC"}'` 166 AC_MSG_NOTICE([Adding glib-perl CFLAGS ${GLIB_PERL_CFLAGS}]) 167 AM_CFLAGS="${GLIB_PERL_CFLAGS} ${AM_CFLAGS}" 131 168 132 169 dnl Checks for typedefs, structures, and compiler characteristics. … … 168 205 AC_REPLACE_FUNCS([memrchr]) 169 206 207 AC_SUBST([abs_builddir]) 208 AC_SUBST([abs_srcdir]) 209 170 210 AC_CONFIG_FILES([Makefile compat/Makefile libfaim/Makefile perl/Makefile perl/modules/Makefile]) 171 211 AC_OUTPUT -
context.c
r6829afc rf271129 1 #include <string.h>2 1 #include "owl.h" 3 2 -
dict.c
rce68f23 rf271129 6 6 */ 7 7 8 #include <stdlib.h>9 #include <string.h>10 #include <unistd.h>11 8 #include "owl.h" 12 13 9 14 10 #define INITSIZE 30 -
doc/barnowl.1
rbad4496 r8135737 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. By default, 38 \fBBarnOwl\fP uses \fI~/.barnowlconf\fP if it exists, and \fI~/.owlconf\fP otherwise. 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. 39 45 40 46 .TP -
editcontext.c
r6829afc rf271129 1 1 #include "owl.h" 2 3 2 #include <assert.h> 4 3 -
editwin.c
rf661cee r8258ea5 1 1 #include "owl.h" 2 #include <stdlib.h>3 #include <unistd.h>4 #include <string.h>5 #include <ctype.h>6 2 7 3 #define VALID_EXCURSION (0x9a2b4729) … … 37 33 oe_excursion *excursions; 38 34 39 void (*callback)(struct _owl_editwin *);35 void (*callback)(struct _owl_editwin *e, bool success); 40 36 void (*destroy_cbdata)(void *); 41 37 void *cbdata; … … 224 220 } 225 221 226 void owl_editwin_set_callback(owl_editwin *e, void (*cb)(owl_editwin *))222 void owl_editwin_set_callback(owl_editwin *e, void (*cb)(owl_editwin *, bool)) 227 223 { 228 224 e->callback = cb; 229 225 } 230 226 231 void (*owl_editwin_get_callback(owl_editwin *e))(owl_editwin *)227 void (*owl_editwin_get_callback(owl_editwin *e))(owl_editwin *, bool) 232 228 { 233 229 return e->callback; … … 252 248 } 253 249 254 void owl_editwin_do_callback(owl_editwin *e) { 255 void (*cb)(owl_editwin*); 256 cb=owl_editwin_get_callback(e); 257 if(!cb) { 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) { 258 255 owl_function_error("Internal error: No editwin callback!"); 259 256 } else { 260 /* owl_function_error("text: |%s|", owl_editwin_get_text(e)); */ 261 cb(e); 257 cb(e, success); 262 258 } 263 259 } … … 623 619 624 620 if (!g_utf8_validate(s, -1, NULL)) { 625 owl_function_debugmsg("owl_editwin_insert_string: received non- utf-8 string.");621 owl_function_debugmsg("owl_editwin_insert_string: received non-UTF-8 string."); 626 622 return 0; 627 623 } -
filter.c
r2560529 rc068c03 1 #include <string.h>2 1 #include "owl.h" 3 2 … … 125 124 126 125 op1 = owl_filter_parse_primitive_expression(argc-i, argv+i, &skip); 126 if(!op1) goto err; 127 127 i += skip; 128 if(!op1) goto err;129 128 130 129 while(i < argc) { … … 220 219 } 221 220 else { 222 g_string_append_printf(out, "%i",f-> fgcolor);221 g_string_append_printf(out, "%i",f->bgcolor); 223 222 } 224 223 g_string_append(out, " "); -
filterproc.c
re2cc848 r7155955 1 #include <signal.h> 1 #include "filterproc.h" 2 #include <sys/wait.h> 3 #include <fcntl.h> 4 #include <glib.h> 5 #include <poll.h> 6 #include <string.h> 2 7 #include <unistd.h> 3 #include <sys/select.h>4 #include <sys/types.h>5 #include <sys/wait.h>6 #include <poll.h>7 #include <fcntl.h>8 #include <string.h>9 8 10 #include <glib.h> 11 12 int send_receive(int rfd, int wfd, const char *out, char **in)9 /* Even in case of error, send_receive is responsible for closing wfd 10 * (to EOF the child) and rfd (for consistency). */ 11 static int send_receive(int rfd, int wfd, const char *out, char **in) 13 12 { 14 13 GString *str = g_string_new(""); … … 25 24 fds[1].fd = wfd; 26 25 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 } 27 32 28 33 while(1) { … … 47 52 } 48 53 if(!out || !*out || fds[1].revents & (POLLERR | POLLHUP)) { 49 close(wfd); 54 close(wfd); wfd = -1; 50 55 out = NULL; 51 56 } … … 63 68 } 64 69 70 if (wfd >= 0) close(wfd); 71 close(rfd); 65 72 *in = g_string_free(str, err < 0); 66 73 return err; 67 74 } 68 75 69 int call_filter(const char * prog, const char *const *argv, const char *in, char **out, int *status)76 int call_filter(const char *const *argv, const char *in, char **out, int *status) 70 77 { 71 int err = 0; 72 pid_t pid; 73 int rfd[2]; 74 int wfd[2]; 78 int err; 79 GPid child_pid; 80 int child_stdin, child_stdout; 75 81 76 if((err = pipe(rfd))) goto out; 77 if((err = pipe(wfd))) goto out_close_rfd; 78 79 pid = fork(); 80 if(pid < 0) { 81 err = pid; 82 goto out_close_all; 83 } 84 if(pid) { 85 /* parent */ 86 close(rfd[1]); 87 close(wfd[0]); 88 err = send_receive(rfd[0], wfd[1], in, out); 89 if(err == 0) { 90 waitpid(pid, status, 0); 91 } 92 } else { 93 /* child */ 94 close(rfd[0]); 95 close(wfd[1]); 96 dup2(rfd[1], 1); 97 dup2(wfd[0], 0); 98 close(rfd[1]); 99 close(wfd[0]); 100 101 if(execvp(prog, (char *const *)argv)) { 102 _exit(-1); 103 } 82 if (!g_spawn_async_with_pipes(NULL, (char**)argv, NULL, 83 G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, 84 NULL, NULL, 85 &child_pid, &child_stdin, &child_stdout, NULL, 86 NULL)) { 87 *out = NULL; 88 return 1; 104 89 } 105 90 106 out_close_all: 107 close(wfd[0]); 108 close(wfd[1]); 109 out_close_rfd: 110 close(rfd[0]); 111 close(rfd[1]); 112 out: 91 err = send_receive(child_stdout, child_stdin, in, out); 92 if (err == 0) { 93 waitpid(child_pid, status, 0); 94 } 113 95 return err; 114 96 } -
filterproc.h
r06adc25 r97cdbaf5 2 2 #define INC_BARNOWL_FILTER_PROC_H 3 3 4 int call_filter(const char *prog, 5 const char *const *argv, 4 int call_filter(const char *const *argv, 6 5 const char *in, 7 6 char **out, int *status); -
fmtext.c
r7abfcf2 rf271129 1 1 #include "owl.h" 2 #include <stdlib.h>3 #include <string.h>4 2 5 3 /* initialize an fmtext with no data */ -
functions.c
r15a7aee r60e8617 1 #include "owl.h" 2 #include "filterproc.h" 1 3 #include <stdio.h> 2 #include <stdlib.h>3 #include <unistd.h>4 #include <signal.h>5 #include <netinet/in.h>6 #include <string.h>7 #include <time.h>8 #include <sys/types.h>9 4 #include <sys/stat.h> 10 5 #include <sys/wait.h> 11 #include <errno.h>12 #include <signal.h>13 #include "owl.h"14 #include "filterproc.h"15 6 16 7 CALLER_OWN char *owl_function_command(const char *cmdbuff) … … 213 204 214 205 /* do followlast if necessary */ 215 if (owl_global_should_followlast(&g)) owl_function_lastmsg _noredisplay();206 if (owl_global_should_followlast(&g)) owl_function_lastmsg(); 216 207 217 208 /* redisplay etc. */ … … 225 216 void owl_function_add_outgoing_zephyrs(const owl_zwrite *z) 226 217 { 227 if (z->cc || owl_zwrite_get_numrecips(z) == 0) {218 if (z->cc && owl_zwrite_is_personal(z)) { 228 219 /* create the message */ 229 220 owl_message *m = g_new(owl_message, 1); … … 234 225 int i; 235 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 236 232 /* create the message */ 237 owl_message *m = g_new(owl_message, 1);233 m = g_new(owl_message, 1); 238 234 owl_message_create_from_zwrite(m, z, owl_zwrite_get_message(z), i); 239 235 … … 281 277 } 282 278 283 void owl_function_start_edit_win(const char *line, void (*callback)(owl_editwin *), void *data, void (*cleanup)(void *))279 owl_editwin *owl_function_start_edit_win(const char *line) 284 280 { 285 281 owl_editwin *e; … … 295 291 g_free(s); 296 292 297 owl_editwin_set_cbdata(e, data, cleanup);298 owl_editwin_set_callback(e, callback);299 293 ctx = owl_editcontext_new(OWL_CTX_EDITMULTI, e, "editmulti", 300 294 owl_global_deactivate_editcontext, &g); 301 295 owl_global_push_context_obj(&g, ctx); 302 296 return e; 303 297 } 304 298 … … 318 312 void owl_function_zwrite_setup(owl_zwrite *z) 319 313 { 314 owl_editwin *e; 320 315 /* send a ping if necessary */ 321 316 if (owl_global_is_txping(&g)) { … … 325 320 326 321 owl_function_write_setup("zephyr"); 327 owl_function_start_edit_win(z->zwriteline,328 &owl_callback_zwrite,329 z, (void(*)(void*))owl_zwrite_delete);322 e = owl_function_start_edit_win(z->zwriteline); 323 owl_editwin_set_cbdata(e, z, (void (*)(void *))owl_zwrite_delete); 324 owl_editwin_set_callback(e, &owl_callback_zwrite); 330 325 } 331 326 332 327 void owl_function_aimwrite_setup(const char *to) 333 328 { 329 owl_editwin *e; 334 330 /* TODO: We probably actually want an owl_aimwrite object like 335 331 * owl_zwrite. */ 336 332 char *line = g_strdup_printf("aimwrite %s", to); 337 333 owl_function_write_setup("message"); 338 owl_function_start_edit_win(line, 339 &owl_callback_aimwrite, 340 g_strdup(to), 341 g_free); 334 e = owl_function_start_edit_win(line); 335 owl_editwin_set_cbdata(e, g_strdup(to), g_free); 336 owl_editwin_set_callback(e, &owl_callback_aimwrite); 342 337 g_free(line); 343 338 } … … 345 340 void owl_function_loopwrite_setup(void) 346 341 { 342 owl_editwin *e; 347 343 owl_function_write_setup("message"); 348 owl_function_start_edit_win("loopwrite", 349 &owl_callback_loopwrite, 350 NULL, NULL); 351 } 352 353 void owl_callback_zwrite(owl_editwin *e) { 344 e = owl_function_start_edit_win("loopwrite"); 345 owl_editwin_set_callback(e, &owl_callback_loopwrite); 346 } 347 348 void owl_callback_zwrite(owl_editwin *e, bool success) 349 { 350 if (!success) return; 354 351 owl_zwrite *z = owl_editwin_get_cbdata(e); 355 352 owl_function_zwrite(z, owl_editwin_get_text(e)); … … 381 378 owl_function_makemsg("Waiting for ack..."); 382 379 383 /* If it's personal */ 384 if (owl_zwrite_is_personal(z)) { 385 /* create the outgoing message */ 386 owl_function_add_outgoing_zephyrs(z); 387 } 380 /* create the outgoing message */ 381 owl_function_add_outgoing_zephyrs(z); 388 382 } 389 383 #else … … 411 405 412 406 zcrypt = g_build_filename(owl_get_bindir(), "zcrypt", NULL); 413 argv[0] = "zcrypt";407 argv[0] = zcrypt; 414 408 argv[1] = "-E"; 415 409 argv[2] = "-c"; argv[3] = owl_zwrite_get_class(z); … … 417 411 argv[6] = NULL; 418 412 419 rv = call_filter( zcrypt,argv, owl_zwrite_get_message(z), &cryptmsg, &status);413 rv = call_filter(argv, owl_zwrite_get_message(z), &cryptmsg, &status); 420 414 421 415 g_free(zcrypt); … … 435 429 owl_function_makemsg("Waiting for ack..."); 436 430 437 /* If it's personal */ 438 if (owl_zwrite_is_personal(z)) { 439 /* Create the outgoing message. Restore the un-crypted message for display. */ 440 owl_zwrite_set_message_raw(z, old_msg); 441 owl_function_add_outgoing_zephyrs(z); 442 } 443 444 /* free the zwrite */ 431 /* Create the outgoing message. Restore the un-crypted message for display. */ 432 owl_zwrite_set_message_raw(z, old_msg); 433 owl_function_add_outgoing_zephyrs(z); 434 435 /* Clean up. */ 445 436 g_free(cryptmsg); 446 } 447 448 void owl_callback_aimwrite(owl_editwin *e) { 437 g_free(old_msg); 438 } 439 440 void owl_callback_aimwrite(owl_editwin *e, bool success) 441 { 442 if (!success) return; 449 443 char *to = owl_editwin_get_cbdata(e); 450 444 owl_function_aimwrite(to, owl_editwin_get_text(e), true); … … 510 504 } 511 505 512 void owl_callback_loopwrite(owl_editwin *e) { 506 void owl_callback_loopwrite(owl_editwin *e, bool success) 507 { 508 if (!success) return; 513 509 owl_function_loopwrite(owl_editwin_get_text(e)); 514 510 } … … 817 813 } 818 814 819 void owl_function_lastmsg _noredisplay(void)815 void owl_function_lastmsg(void) 820 816 { 821 817 int oldcurmsg, curmsg; … … 835 831 owl_global_set_curmsg(&g, curmsg+1); 836 832 } 837 /* owl_mainwin_redisplay(owl_global_get_mainwin(&g)); */833 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 838 834 owl_global_set_direction_downwards(&g); 839 }840 841 void owl_function_lastmsg(void)842 {843 owl_function_lastmsg_noredisplay();844 owl_mainwin_redisplay(owl_global_get_mainwin(&g));845 835 } 846 836 … … 865 855 void owl_function_unsuball(void) 866 856 { 867 unsuball();868 owl_function_makemsg("Unsubscribed from all messages.");857 if (unsuball()) 858 owl_function_makemsg("Unsubscribed from all messages."); 869 859 } 870 860 … … 881 871 void owl_function_loadsubs(const char *file) 882 872 { 883 int ret, ret2; 884 const char *foo; 873 int ret, ret2, ret3; 885 874 char *path; 886 875 … … 894 883 895 884 /* for backwards compatibility for now */ 896 ret2=owl_zephyr_loaddefaultsubs(); 885 ret2 = owl_zephyr_loaddefaultsubs(); 886 ret3 = owl_zephyr_loadbarnowldefaultsubs(); 897 887 898 888 if (!owl_context_is_interactive(owl_global_get_context(&g))) return; 899 889 900 foo=file?file:"file"; 901 if (ret==0 && ret2==0) { 890 if (ret == 0 && ret2 == 0 && ret3 == 0) { 902 891 if (!file) { 903 892 owl_function_makemsg("Subscribed to messages."); … … 905 894 owl_function_makemsg("Subscribed to messages from %s", file); 906 895 } 907 } else if (ret ==-1) {908 owl_function_error("Could not read %s", f oo);909 } else {896 } else if (ret == -1) { 897 owl_function_error("Could not read %s", file ? file : "file"); 898 } else if (ret2 == -1) { 910 899 owl_function_error("Error subscribing to messages"); 900 } else { 901 owl_function_error("Error subscribing to instanced personals"); 911 902 } 912 903 } … … 927 918 } 928 919 929 void owl_callback_aimlogin(owl_editwin *e) { 920 void owl_callback_aimlogin(owl_editwin *e, bool success) 921 { 922 if (!success) return; 930 923 char *user = owl_editwin_get_cbdata(e); 931 924 owl_function_aimlogin(user, … … 1238 1231 now = time(NULL); 1239 1232 1240 tmpbuff = owl_util_ time_to_timestr(localtime(&now));1233 tmpbuff = owl_util_format_time(localtime(&now)); 1241 1234 fprintf(file, "[%d - %s - %lds]: ", 1242 1235 (int) getpid(), tmpbuff, now - owl_global_get_starttime(&g)); … … 1388 1381 owl_fmtext fm, attrfm; 1389 1382 const owl_view *v; 1383 char *time; 1390 1384 #ifdef HAVE_LIBZEPHYR 1391 1385 const ZNotice_t *n; … … 1418 1412 } 1419 1413 1420 owl_fmtext_appendf_normal(&fm, " Time : %s\n", owl_message_get_timestr(m)); 1414 time = owl_message_format_time(m); 1415 owl_fmtext_appendf_normal(&fm, " Time : %s\n", time); 1416 g_free(time); 1421 1417 1422 1418 if (!owl_message_is_type_admin(m)) { … … 1432 1428 owl_fmtext_appendf_normal(&fm, " Opcode : %s\n", owl_message_get_opcode(m)); 1433 1429 #ifdef HAVE_LIBZEPHYR 1434 if (owl_message_is_direction_in(m)) { 1430 n = owl_message_get_notice(m); 1431 if (n != NULL) { 1435 1432 char *tmpbuff, *tmpbuff2; 1436 1433 int i, fields; 1437 1438 n=owl_message_get_notice(m); 1434 const char *f; 1439 1435 1440 1436 if (!owl_message_is_pseudo(m)) { … … 1478 1474 owl_fmtext_appendf_normal(&fm, " Fields : %i\n", fields); 1479 1475 1480 for (i = 0; i < fields; i++) { 1481 tmpbuff = owl_zephyr_get_field_as_utf8(n, i + 1); 1476 for (i = 0, f = owl_zephyr_first_raw_field(n); f != NULL; 1477 i++, f = owl_zephyr_next_raw_field(n, f)) { 1478 tmpbuff = owl_zephyr_field_as_utf8(n, f); 1482 1479 tmpbuff2 = owl_text_indent(tmpbuff, 14, false); 1483 1480 owl_fmtext_appendf_normal(&fm, " Field %i : %s\n", i + 1, tmpbuff2); … … 1792 1789 owl_fmtext_append_normal(&fm, "\n"); 1793 1790 1794 tmpbuff = owl_util_ time_to_timestr(localtime(&start));1791 tmpbuff = owl_util_format_time(localtime(&start)); 1795 1792 owl_fmtext_appendf_normal(&fm, " Startup Time: %s\n", tmpbuff); 1796 1793 g_free(tmpbuff); … … 1947 1944 } 1948 1945 1949 void owl_callback_command(owl_editwin *e) 1950 { 1946 void owl_callback_command(owl_editwin *e, bool success) 1947 { 1948 if (!success) return; 1951 1949 char *rv; 1952 1950 const char *line = owl_editwin_get_text(e); … … 1959 1957 } 1960 1958 1961 voidowl_function_start_command(const char *line)1959 owl_editwin *owl_function_start_command(const char *line) 1962 1960 { 1963 1961 owl_editwin *tw; … … 1974 1972 owl_global_push_context_obj(&g, ctx); 1975 1973 owl_editwin_set_callback(tw, owl_callback_command); 1976 } 1977 1978 CALLER_OWN owl_editwin *owl_function_start_question(const char *line) 1974 return tw; 1975 } 1976 1977 owl_editwin *owl_function_start_question(const char *line) 1979 1978 { 1980 1979 owl_editwin *tw; … … 1991 1990 } 1992 1991 1993 CALLER_OWNowl_editwin *owl_function_start_password(const char *line)1992 owl_editwin *owl_function_start_password(const char *line) 1994 1993 { 1995 1994 owl_editwin *tw; … … 2188 2187 f = owl_filter_new(argv[1], argc-2, argv+2); 2189 2188 if (f == NULL) { 2190 owl_function_error("Invalid filter ");2189 owl_function_error("Invalid filter: %s", argv[1]); 2191 2190 return false; 2192 2191 } … … 3088 3087 idle=owl_buddy_get_idle_time(b); 3089 3088 if (idle!=0) { 3090 timestr=owl_util_ minutes_to_timestr(idle);3089 timestr=owl_util_format_minutes(idle); 3091 3090 } else { 3092 3091 timestr=g_strdup(""); … … 3417 3416 3418 3417 now = time(NULL); 3419 date = owl_util_ time_to_timestr(localtime(&now));3418 date = owl_util_format_time(localtime(&now)); 3420 3419 3421 3420 buff = g_strdup_printf("%s %s", date, string); -
global.c
rdde1b4d r6383920 1 #include "owl.h" 1 2 #include <stdio.h> 2 #include <unistd.h>3 #include <stdlib.h>4 #include <string.h>5 #include <netdb.h>6 #include <termios.h>7 3 #include <sys/ioctl.h> 8 #include <time.h>9 #include "owl.h"10 4 11 5 static void _owl_global_init_windows(owl_global *g); … … 15 9 const char *homedir; 16 10 11 #if !GLIB_CHECK_VERSION(2, 35, 0) 17 12 g_type_init(); 13 #endif 14 #if !GLIB_CHECK_VERSION(2, 31, 0) 18 15 g_thread_init(NULL); 16 #endif 19 17 20 18 owl_select_init(); … … 81 79 g_free(cd); 82 80 83 owl_messagelist_create(&(g->msglist));81 g->msglist = owl_messagelist_new(); 84 82 85 83 _owl_global_init_windows(g); … … 106 104 107 105 g->interrupt_count = 0; 106 #if GLIB_CHECK_VERSION(2, 31, 0) 107 g_mutex_init(&g->interrupt_lock); 108 #else 108 109 g->interrupt_lock = g_mutex_new(); 110 #endif 109 111 } 110 112 … … 115 117 116 118 /* Create the widgets */ 117 owl_mainwin_init(&(g->mw),g->mainpanel.recwin);119 g->mw = owl_mainwin_new(g->mainpanel.recwin); 118 120 owl_msgwin_init(&(g->msgwin), g->mainpanel.msgwin); 119 121 owl_sepbar_init(g->mainpanel.sepwin); … … 247 249 /* windows */ 248 250 249 owl_mainwin *owl_global_get_mainwin(owl_global *g) { 250 return(&(g->mw)); 251 owl_mainwin *owl_global_get_mainwin(owl_global *g) 252 { 253 return g->mw; 251 254 } 252 255 … … 262 265 263 266 owl_messagelist *owl_global_get_msglist(owl_global *g) { 264 return (&(g->msglist));267 return g->msglist; 265 268 } 266 269 … … 846 849 } filters[] = { 847 850 { "personal", 848 "isprivate ^true$ and ( not type ^zephyr$ or ( class ^message 851 "isprivate ^true$ and ( not type ^zephyr$ or ( class ^message$ ) )" }, 849 852 { "trash", 850 853 "class ^mail$ or opcode ^ping$ or type ^admin$ or ( not login ^none$ )" }, … … 853 856 { "auto", "opcode ^auto$" }, 854 857 { "login", "not login ^none$" }, 855 { "reply-lockout", "class ^ noc or class ^mail$" },858 { "reply-lockout", "class ^mail$ or class ^filsrv$" }, 856 859 { "out", "direction ^out$" }, 857 860 { "aim", "type ^aim$" }, … … 904 907 } 905 908 909 static GMutex *owl_global_get_interrupt_lock(owl_global *g) 910 { 911 #if GLIB_CHECK_VERSION(2, 31, 0) 912 return &g->interrupt_lock; 913 #else 914 return g->interrupt_lock; 915 #endif 916 } 917 906 918 void owl_global_add_interrupt(owl_global *g) { 907 919 /* TODO: This can almost certainly be done with atomic 908 920 * operations. Whatever. */ 909 g_mutex_lock( g->interrupt_lock);921 g_mutex_lock(owl_global_get_interrupt_lock(g)); 910 922 g->interrupt_count++; 911 g_mutex_unlock( g->interrupt_lock);923 g_mutex_unlock(owl_global_get_interrupt_lock(g)); 912 924 } 913 925 914 926 bool owl_global_take_interrupt(owl_global *g) { 915 927 bool ans = false; 916 g_mutex_lock( g->interrupt_lock);928 g_mutex_lock(owl_global_get_interrupt_lock(g)); 917 929 if (g->interrupt_count > 0) { 918 930 ans = true; 919 931 g->interrupt_count--; 920 932 } 921 g_mutex_unlock( g->interrupt_lock);933 g_mutex_unlock(owl_global_get_interrupt_lock(g)); 922 934 return ans; 923 935 } -
help.c
r820e852 r8258ea5 1 1 #include "owl.h" 2 #include <string.h>3 2 4 3 void owl_help(void) … … 74 73 " : , M-x Enter command mode\n" 75 74 "\n" 76 " / Fo ward search\n"75 " / Forward search\n" 77 76 " ? Reverse search\n" 78 77 "\n\n" … … 108 107 " unsuball Unsubscribe from all zephyr classes\n" 109 108 " load-subs Load zephyr subscriptions from a file\n" 110 " zpunt Sup ress messages from a zephyr triplet\n"109 " zpunt Suppress messages from a zephyr triplet\n" 111 110 " zlog Send a login or logout notification\n" 112 111 " zlist Print a list of zephyr buddies logged in\n" -
keybinding.c
r6829afc rf271129 1 #include <ctype.h>2 #include <string.h>3 1 #include "owl.h" 4 2 -
keymap.c
rce68f23 rf271129 1 #include <string.h>2 1 #include "owl.h" 3 2 -
keypress.c
r2560529 rf271129 1 #include <ctype.h>2 #include <string.h>3 1 #include "owl.h" 4 2 -
libfaim/Makefile.am
r215c119 rb80bae0 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
rdde1b4d r0792d99 1 1 #include "owl.h" 2 #include <stdlib.h> 3 #include <string.h> 4 #include <ctype.h> 5 #include <sys/param.h> 2 #include <stdio.h> 6 3 7 4 typedef struct _owl_log_entry { /* noproto */ … … 432 429 static gpointer owl_log_thread_func(gpointer data) 433 430 { 434 log_context = g_main_context_new();435 431 log_loop = g_main_loop_new(log_context, FALSE); 436 432 g_main_loop_run(log_loop); … … 440 436 void owl_log_init(void) 441 437 { 438 log_context = g_main_context_new(); 439 #if GLIB_CHECK_VERSION(2, 31, 0) 440 logging_thread = g_thread_new("logging", 441 owl_log_thread_func, 442 NULL); 443 #else 442 444 GError *error = NULL; 443 445 logging_thread = g_thread_create(owl_log_thread_func, … … 451 453 exit(1); 452 454 } 455 #endif 453 456 454 457 } -
m4/ax_cflags_warn_all.m4
r378ede7 re9b4a2c 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. 27 29 # 28 30 # LICENSE … … 57 59 # exception to the GPL to apply to your modified version as well. 58 60 59 #serial 1 061 #serial 14 60 62 61 AC_DEFUN([AX_ CFLAGS_WARN_ALL],[dnl62 AS_VAR_PUSHDEF([FLAGS],[ CFLAGS])dnl63 AS_VAR_PUSHDEF([VAR],[ac_cv_ cflags_warn_all])dnl63 AC_DEFUN([AX_FLAGS_WARN_ALL],[dnl 64 AS_VAR_PUSHDEF([FLAGS],[_AC_LANG_PREFIX[]FLAGS])dnl 65 AS_VAR_PUSHDEF([VAR],[ac_cv_[]_AC_LANG_ABBREV[]flags_warn_all])dnl 64 66 AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings], 65 67 VAR,[VAR="no, unknown" 66 AC_LANG_PUSH([C]) 67 ac_save_[]FLAGS="$[]FLAGS" 68 for ac_arg dnl 69 in "-pedantic % -Wall" dnl GCC 70 "-xstrconst % -v" dnl Solaris C 71 "-std1 % -verbose -w0 -warnprotos" dnl Digital Unix 72 "-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX 73 "-ansi -ansiE % -fullwarn" dnl IRIX 74 "+ESlit % +w1" dnl HP-UX C 75 "-Xc % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10) 76 "-h conform % -h msglevel 2" dnl Cray C (Unicos) 77 # 78 do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` 79 AC_COMPILE_IFELSE([AC_LANG_PROGRAM], 80 [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) 81 done 82 FLAGS="$ac_save_[]FLAGS" 83 AC_LANG_POP([C]) 84 ]) 85 case ".$VAR" in 86 .ok|.ok,*) m4_ifvaln($3,$3) ;; 87 .|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[ 88 AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"]) 89 m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])]) ;; 90 *) m4_ifvaln($3,$3,[ 91 if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null 92 then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR]) 93 else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"]) 94 m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR" 95 fi ]) ;; 96 esac 97 AS_VAR_POPDEF([VAR])dnl 98 AS_VAR_POPDEF([FLAGS])dnl 99 ]) 100 101 dnl the only difference - the LANG selection... and the default FLAGS 102 103 AC_DEFUN([AX_CXXFLAGS_WARN_ALL],[dnl 104 AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl 105 AS_VAR_PUSHDEF([VAR],[ax_cv_cxxflags_warn_all])dnl 106 AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings], 107 VAR,[VAR="no, unknown" 108 AC_LANG_PUSH([C++]) 109 ac_save_[]FLAGS="$[]FLAGS" 110 for ac_arg dnl 111 in "-pedantic % -Wall" dnl GCC 112 "-xstrconst % -v" dnl Solaris C 113 "-std1 % -verbose -w0 -warnprotos" dnl Digital Unix 114 "-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX 115 "-ansi -ansiE % -fullwarn" dnl IRIX 116 "+ESlit % +w1" dnl HP-UX C 117 "-Xc % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10) 118 "-h conform % -h msglevel 2" dnl Cray C (Unicos) 119 # 120 do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` 121 AC_COMPILE_IFELSE([AC_LANG_PROGRAM], 122 [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) 123 done 124 FLAGS="$ac_save_[]FLAGS" 125 AC_LANG_POP([C++]) 126 ]) 127 case ".$VAR" in 128 .ok|.ok,*) m4_ifvaln($3,$3) ;; 129 .|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[ 130 AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"]) 131 m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])]) ;; 132 *) m4_ifvaln($3,$3,[ 133 if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null 134 then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR]) 135 else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"]) 136 m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR" 137 fi ]) ;; 138 esac 139 AS_VAR_POPDEF([VAR])dnl 140 AS_VAR_POPDEF([FLAGS])dnl 141 ]) 142 143 dnl the only difference - the LANG selection... and the default FLAGS 144 145 AC_DEFUN([AX_FCFLAGS_WARN_ALL],[dnl 146 AS_VAR_PUSHDEF([FLAGS],[FCFLAGS])dnl 147 AS_VAR_PUSHDEF([VAR],[ax_cv_fcflags_warn_all])dnl 148 AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings], 149 VAR,[VAR="no, unknown" 150 AC_LANG_PUSH([Fortran]) 151 ac_save_[]FLAGS="$[]FLAGS" 68 ac_save_[]FLAGS="$[]FLAGS" 152 69 for ac_arg dnl 153 70 in "-warn all % -warn all" dnl Intel … … 165 82 [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) 166 83 done 167 FLAGS="$ac_save_[]FLAGS" 168 AC_LANG_POP([Fortran]) 84 FLAGS="$ac_save_[]FLAGS" 169 85 ]) 86 AS_VAR_POPDEF([FLAGS])dnl 87 AC_REQUIRE([AX_APPEND_FLAG]) 170 88 case ".$VAR" in 171 89 .ok|.ok,*) m4_ifvaln($3,$3) ;; 172 .|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[ 173 AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"]) 174 m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])]) ;; 175 *) m4_ifvaln($3,$3,[ 176 if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null 177 then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR]) 178 else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"]) 179 m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR" 180 fi ]) ;; 90 .|.no|.no,*) m4_default($4,[m4_ifval($2,[AX_APPEND_FLAG([$2], [$1])])]) ;; 91 *) m4_default($3,[AX_APPEND_FLAG([$VAR], [$1])]) ;; 181 92 esac 182 93 AS_VAR_POPDEF([VAR])dnl 183 AS_VAR_POPDEF([FLAGS])dnl 184 ]) 185 94 ])dnl AX_FLAGS_WARN_ALL 186 95 dnl implementation tactics: 187 96 dnl the for-argument contains a list of options. The first part of … … 194 103 dnl delimiter. A non-option comment can be given after "%%" marks 195 104 dnl which will be shown but not added to the respective C/CXXFLAGS. 105 106 AC_DEFUN([AX_CFLAGS_WARN_ALL],[dnl 107 AC_LANG_PUSH([C]) 108 AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4]) 109 AC_LANG_POP([C]) 110 ]) 111 112 AC_DEFUN([AX_CXXFLAGS_WARN_ALL],[dnl 113 AC_LANG_PUSH([C++]) 114 AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4]) 115 AC_LANG_POP([C++]) 116 ]) 117 118 AC_DEFUN([AX_FCFLAGS_WARN_ALL],[dnl 119 AC_LANG_PUSH([Fortran]) 120 AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4]) 121 AC_LANG_POP([Fortran]) 122 ]) -
m4/pkg.m4
r650fb2c r13a39ae8 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 module 165 # should install pkg-config .pc files. By default the directory is 166 # $libdir/pkgconfig, but the default can be changed by passing 167 # DIRECTORY. The user can override through the --with-pkgconfigdir 168 # parameter. 169 AC_DEFUN([PKG_INSTALLDIR], 170 [m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])]) 171 m4_pushdef([pkg_description], 172 [pkg-config installation directory @<:@]pkg_default[@:>@]) 173 AC_ARG_WITH([pkgconfigdir], 174 [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],, 175 [with_pkgconfigdir=]pkg_default) 176 AC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) 177 m4_popdef([pkg_default]) 178 m4_popdef([pkg_description]) 179 ]) dnl PKG_INSTALLDIR 180 181 182 # PKG_NOARCH_INSTALLDIR(DIRECTORY) 183 # ------------------------- 184 # Substitutes the variable noarch_pkgconfigdir as the location where a 185 # module should install arch-independent pkg-config .pc files. By 186 # default the directory is $datadir/pkgconfig, but the default can be 187 # changed by passing DIRECTORY. The user can override through the 188 # --with-noarch-pkgconfigdir parameter. 189 AC_DEFUN([PKG_NOARCH_INSTALLDIR], 190 [m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])]) 191 m4_pushdef([pkg_description], 192 [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@]) 193 AC_ARG_WITH([noarch-pkgconfigdir], 194 [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],, 195 [with_noarch_pkgconfigdir=]pkg_default) 196 AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir]) 197 m4_popdef([pkg_default]) 198 m4_popdef([pkg_description]) 199 ]) dnl PKG_NOARCH_INSTALLDIR 200 201 202 # PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, 203 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) 204 # ------------------------------------------- 205 # Retrieves the value of the pkg-config variable for the given module. 206 AC_DEFUN([PKG_CHECK_VAR], 207 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl 208 AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl 209 210 _PKG_CONFIG([$1], [variable="][$3]["], [$2]) 211 AS_VAR_COPY([$1], [pkg_cv_][$1]) 212 213 AS_VAR_IF([$1], [""], [$5], [$4])dnl 214 ])# PKG_CHECK_VAR -
mainwin.c
r099597c rab88b05 4 4 static void owl_mainwin_resized(owl_window *w, void *user_data); 5 5 6 void owl_mainwin_init(owl_mainwin *mw,owl_window *window)6 CALLER_OWN owl_mainwin *owl_mainwin_new(owl_window *window) 7 7 { 8 owl_mainwin *mw = g_new(owl_mainwin, 1); 8 9 mw->curtruncated=0; 9 10 mw->lastdisplayed=-1; … … 16 17 /* For now, we do not bother with connecting up dependencies; that'll be a 17 18 * future refactor of the mainwin */ 19 20 return mw; 18 21 } 19 22 -
message.c
r4ebbfbc r2354e9a 1 #include <stdlib.h>2 #include <unistd.h>3 #include <string.h>4 #include <sys/socket.h>5 #include <netdb.h>6 #include <sys/types.h>7 #include <sys/socket.h>8 #include <netinet/in.h>9 #include <arpa/inet.h>10 #include <time.h>11 1 #include "owl.h" 12 2 #include "filterproc.h" 3 #include <sys/socket.h> 4 #include <arpa/inet.h> 13 5 14 6 static owl_fmtext_cache fmtext_cache[OWL_FMTEXT_CACHE_SIZE]; … … 42 34 m->delete=0; 43 35 36 #ifdef HAVE_LIBZEPHYR 37 m->has_notice = false; 38 #endif 39 44 40 owl_message_set_hostname(m, ""); 45 41 m->attributes = g_ptr_array_new(); … … 47 43 /* save the time */ 48 44 m->time = time(NULL); 49 m->timestr = owl_util_time_to_timestr(localtime(&m->time)); 45 m->timestr = g_strdup(ctime(&m->time)); 46 m->timestr[strlen(m->timestr)-1] = '\0'; 50 47 51 48 m->fmtext = NULL; … … 350 347 } 351 348 349 CALLER_OWN char *owl_message_format_time(const owl_message *m) 350 { 351 return owl_util_format_time(localtime(&m->time)); 352 } 353 352 354 void owl_message_set_type_admin(owl_message *m) 353 355 { … … 498 500 const ZNotice_t *owl_message_get_notice(const owl_message *m) 499 501 { 500 return (&(m->notice));502 return m->has_notice ? &m->notice : NULL; 501 503 } 502 504 #else … … 789 791 /* first save the full notice */ 790 792 m->notice = *n; 793 m->has_notice = true; 791 794 792 795 /* a little gross, we'll replace \r's with ' ' for now */ … … 796 799 if (m->timestr) g_free(m->timestr); 797 800 m->time = n->z_time.tv_sec; 798 m->timestr = owl_util_time_to_timestr(localtime(&m->time)); 801 m->timestr = g_strdup(ctime(&m->time)); 802 m->timestr[strlen(m->timestr)-1] = '\0'; 799 803 800 804 /* set other info */ … … 832 836 833 837 834 /* set the "isprivate" attribute if it's a private zephyr. 835 ``private'' means recipient is non-empty and doesn't start wit 836 `@' */ 837 if (*n->z_recipient && *n->z_recipient != '@') { 838 /* set the "isprivate" attribute if it's a private zephyr. */ 839 if (owl_zwrite_recip_is_personal(n->z_recipient)) { 838 840 owl_message_set_isprivate(m); 839 841 } … … 873 875 if (owl_global_is_zcrypt(&g) && !strcasecmp(n->z_opcode, "crypt")) { 874 876 const char *argv[] = { 875 "zcrypt",877 NULL, 876 878 "-D", 877 879 "-c", owl_message_get_class(m), … … 879 881 NULL 880 882 }; 881 char *out ;883 char *out = NULL; 882 884 int rv; 883 885 int status; … … 885 887 886 888 zcrypt = g_build_filename(owl_get_bindir(), "zcrypt", NULL); 887 888 rv = call_filter(zcrypt, argv, owl_message_get_body(m), &out, &status); 889 argv[0] = zcrypt; 890 891 rv = call_filter(argv, owl_message_get_body(m), &out, &status); 889 892 g_free(zcrypt); 890 893 … … 895 898 } 896 899 owl_message_set_body(m, out); 897 g_free(out); 898 } else if(out) { 899 g_free(out); 900 } 900 } else { 901 /* Replace the opcode. Otherwise the UI and other bits of code think the 902 * message was encrypted. */ 903 owl_message_set_opcode(m, "failed-decrypt"); 904 } 905 g_free(out); 901 906 } 902 907 … … 1004 1009 owl_pair *p; 1005 1010 #ifdef HAVE_LIBZEPHYR 1006 if ( owl_message_is_type_zephyr(m) && owl_message_is_direction_in(m)) {1011 if (m->has_notice) { 1007 1012 ZFreeNotice(&(m->notice)); 1008 1013 } -
messagelist.c
refeec7f r219f52c 1 1 #include "owl.h" 2 #include <stdlib.h>3 #include <string.h>4 2 5 void owl_messagelist_create(owl_messagelist *ml)3 CALLER_OWN owl_messagelist *owl_messagelist_new(void) 6 4 { 5 owl_messagelist *ml = g_new(owl_messagelist, 1); 7 6 ml->list = g_ptr_array_new(); 7 return ml; 8 8 } 9 9 10 void owl_messagelist_ cleanup(owl_messagelist *ml, bool free_messages)10 void owl_messagelist_delete(owl_messagelist *ml, bool free_messages) 11 11 { 12 12 if (free_messages) 13 13 g_ptr_array_foreach(ml->list, (GFunc)owl_message_delete, NULL); 14 14 g_ptr_array_free(ml->list, true); 15 g_free(ml); 15 16 } 16 17 -
owl.c
ra7fac14 r499224d 7 7 */ 8 8 9 #include "owl.h" 9 10 #include <stdio.h> 10 #include <unistd.h>11 11 #include <getopt.h> 12 #include <stdlib.h>13 #include <string.h>14 #include <signal.h>15 #include <time.h>16 #include <sys/param.h>17 #include <sys/types.h>18 #include <sys/time.h>19 #include <termios.h>20 12 #include <sys/stat.h> 21 13 #include <locale.h> 22 #include "owl.h" 23 14 #include <unistd.h> 24 15 25 16 #if OWL_STDERR_REDIR … … 43 34 } owl_options; 44 35 45 void usage( void)36 void usage(FILE *file) 46 37 { 47 fprintf( stderr, "Barnowl version %s\n", OWL_VERSION_STRING);48 fprintf( stderr, "Usage: barnowl [-n] [-d] [-D] [-v] [-h] [-c <configfile>] [-s <confdir>] [-t <ttyname>]\n");49 fprintf( stderr, " -n,--no-subs don't load zephyr subscriptions\n");50 fprintf( stderr, " -d,--debug enable debugging\n");51 fprintf( stderr, " -v,--version print the Barnowl version number and exit\n");52 fprintf( stderr, " -h,--help print this help message\n");53 fprintf( stderr, " -c,--config-file specify an alternate config file\n");54 fprintf( stderr, " -s,--config-dir specify an alternate config dir (default ~/.owl)\n");55 fprintf( stderr, " -t,--tty set the tty name\n");38 fprintf(file, "Barnowl version %s\n", OWL_VERSION_STRING); 39 fprintf(file, "Usage: barnowl [-n] [-d] [-D] [-v] [-h] [-c <configfile>] [-s <confdir>] [-t <ttyname>]\n"); 40 fprintf(file, " -n,--no-subs don't load zephyr subscriptions\n"); 41 fprintf(file, " -d,--debug enable debugging\n"); 42 fprintf(file, " -v,--version print the Barnowl version number and exit\n"); 43 fprintf(file, " -h,--help print this help message\n"); 44 fprintf(file, " -s,--config-dir specify an alternate config dir (default ~/.owl)\n"); 45 fprintf(file, " -c,--config-file specify an alternate config file (default ~/.owl/init.pl)\n"); 46 fprintf(file, " -t,--tty set the tty name\n"); 56 47 } 57 48 … … 92 83 exit(0); 93 84 case 'h': 85 usage(stdout); 86 exit(0); 94 87 default: 95 usage( );88 usage(stderr); 96 89 exit(1); 97 90 } … … 272 265 /* follow the last message if we're supposed to */ 273 266 if (followlast) 274 owl_function_lastmsg _noredisplay();267 owl_function_lastmsg(); 275 268 276 269 /* do the newmsgproc thing */ … … 437 430 if (0 != pipe(pipefds)) { 438 431 perror("pipe"); 439 owl_function_debugmsg("stderr_replace: pipe FAILED \n");432 owl_function_debugmsg("stderr_replace: pipe FAILED"); 440 433 return -1; 441 434 } 442 owl_function_debugmsg("stderr_replace: pipe: %d,%d \n", pipefds[0], pipefds[1]);443 if (-1 == dup2(pipefds[1], 2 /*stderr*/)) {444 owl_function_debugmsg("stderr_replace: dup2 FAILED (%s) \n", strerror(errno));435 owl_function_debugmsg("stderr_replace: pipe: %d,%d", pipefds[0], pipefds[1]); 436 if (-1 == dup2(pipefds[1], STDERR_FILENO)) { 437 owl_function_debugmsg("stderr_replace: dup2 FAILED (%s)", strerror(errno)); 445 438 perror("dup2"); 446 439 return -1; … … 524 517 #if OWL_STDERR_REDIR 525 518 /* Do this only after we've started curses up... */ 526 owl_function_debugmsg("startup: doing stderr redirection"); 527 channel = g_io_channel_unix_new(stderr_replace()); 528 g_io_add_watch(channel, G_IO_IN | G_IO_HUP | G_IO_ERR, &stderr_redirect_handler, NULL); 529 g_io_channel_unref(channel); 519 if (isatty(STDERR_FILENO)) { 520 owl_function_debugmsg("startup: doing stderr redirection"); 521 channel = g_io_channel_unix_new(stderr_replace()); 522 g_io_add_watch(channel, G_IO_IN | G_IO_HUP | G_IO_ERR, &stderr_redirect_handler, NULL); 523 g_io_channel_unref(channel); 524 } 530 525 #endif 531 526 … … 595 590 ); 596 591 592 owl_function_debugmsg("startup: setting context interactive"); 593 594 owl_global_pop_context(&g); 595 owl_global_push_context(&g, OWL_CTX_INTERACTIVE|OWL_CTX_RECV, NULL, "recv", NULL); 596 597 597 /* process the startup file */ 598 598 owl_function_debugmsg("startup: processing startup file"); … … 606 606 owl_function_error("No such style: %s", owl_global_get_default_style(&g)); 607 607 608 owl_function_debugmsg("startup: setting context interactive");609 610 owl_global_pop_context(&g);611 owl_global_push_context(&g, OWL_CTX_INTERACTIVE|OWL_CTX_RECV, NULL, "recv", NULL);612 613 608 source = owl_window_redraw_source_new(); 614 609 g_source_attach(source, NULL); -
owl.h
rcbc8657 r6249a88f 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" … … 22 22 #endif 23 23 #include <sys/param.h> 24 #include <sys/types.h> 25 #include <ctype.h> 26 #include <errno.h> 24 27 #include <EXTERN.h> 28 #include <fcntl.h> 25 29 #include <netdb.h> 26 30 #include <regex.h> 27 31 #include <time.h> 28 32 #include <signal.h> 33 #include <stdlib.h> 34 #include <string.h> 29 35 #include <termios.h> 36 #include <unistd.h> 30 37 #include "libfaim/aim.h" 31 38 #include <wchar.h> 32 #include "glib.h"39 #include <glib.h> 33 40 #ifdef HAVE_LIBZEPHYR 34 41 #include <zephyr/zephyr.h> … … 40 47 /* Perl and curses don't play nice. */ 41 48 #ifdef OWL_PERL 42 typedef voidWINDOW;43 typedef voidPANEL;49 typedef struct _owl_fake_WINDOW WINDOW; 50 typedef struct _owl_fake_PANEL PANEL; 44 51 /* logout is defined in FreeBSD. */ 45 52 #define logout logout_ … … 50 57 #include "XSUB.h" 51 58 #else 52 typedef voidSV;53 typedef voidAV;54 typedef voidHV;59 typedef struct _owl_fake_SV SV; 60 typedef struct _owl_fake_AV AV; 61 typedef struct _owl_fake_HV HV; 55 62 #endif 56 63 … … 228 235 char *name; 229 236 int type; /* OWL_VARIABLE_* */ 230 void *pval_default; /* for types other and string */ 231 int ival_default; /* for types int and bool */ 232 const char *validsettings; /* documentation of valid settings */ 237 char *default_str; /* the default value as a string */ 238 char *validsettings; /* documentation of valid settings */ 233 239 char *summary; /* summary of usage */ 234 240 char *description; /* detailed description */ 235 void *val; /* current value */ 236 int (*validate_fn)(const struct _owl_variable *v, const void *newval); 241 bool takes_on_off; /* allow passing on/off in argument-less set/unset */ 242 GClosure *set_fromstring_fn; 243 /* sets the variable to a value 244 * of the appropriate type. 245 * unless documented, this 246 * should make a copy. 247 * returns 0 on success. */ 248 GClosure *get_tostring_fn; 249 /* converts val to a string; 250 * caller must free the result */ 251 252 /* These are only valid for OWL_VARIABLE_{INT,BOOL,STRING} */ 253 GValue val; /* current value, if default get_fn/set_fn */ 254 255 GCallback get_fn; 256 /* returns a reference to the current value. 257 * WARNING: this approach is hard to make 258 * thread-safe... */ 259 GCallback validate_fn; 237 260 /* returns 1 if newval is valid */ 238 int (*set_fn)(struct _owl_variable *v, const void *newval);261 GCallback set_fn; 239 262 /* sets the variable to a value 240 * of the appropriate type. 241 * unless documented, this 242 * should make a copy. 243 * returns 0 on success. */ 244 int (*set_fromstring_fn)(struct _owl_variable *v, const char *newval); 245 /* sets the variable to a value 246 * of the appropriate type. 247 * unless documented, this 248 * should make a copy. 249 * returns 0 on success. */ 250 const void *(*get_fn)(const struct _owl_variable *v); 251 /* returns a reference to the current value. 252 * WARNING: this approach is hard to make 253 * thread-safe... */ 254 CALLER_OWN char *(*get_tostring_fn)(const struct _owl_variable *v, const void *val); 255 /* converts val to a string; 256 * caller must free the result */ 257 void (*delete_fn)(struct _owl_variable *v); 258 /* frees val as needed */ 263 * of the appropriate type. 264 * unless documented, this 265 * should make a copy. 266 * returns 0 on success. */ 259 267 } owl_variable; 268 260 269 261 270 typedef struct _owl_input { … … 349 358 int direction; 350 359 #ifdef HAVE_LIBZEPHYR 360 bool has_notice; 351 361 ZNotice_t notice; 352 362 #endif … … 444 454 char *name; 445 455 owl_filter *filter; 446 owl_messagelist ml;456 owl_messagelist *ml; 447 457 const owl_style *style; 448 458 int cachedmsgid; … … 525 535 526 536 typedef struct _owl_global { 527 owl_mainwin mw;537 owl_mainwin *mw; 528 538 owl_popwin *pw; 529 539 owl_msgwin msgwin; … … 543 553 int curmsg_vert_offset; 544 554 owl_view current_view; 545 owl_messagelist msglist;555 owl_messagelist *msglist; 546 556 WINDOW *input_pad; 547 557 owl_mainpanel mainpanel; … … 588 598 char *kill_buffer; 589 599 int interrupt_count; 600 #if GLIB_CHECK_VERSION(2, 31, 0) 601 GMutex interrupt_lock; 602 #else 590 603 GMutex *interrupt_lock; 604 #endif 591 605 } owl_global; 592 606 … … 594 608 extern owl_global g; 595 609 596 #include "owl_prototypes.h"610 #include <owl_prototypes.h> 597 611 598 612 /* These were missing from the Zephyr includes before Zephyr 3. */ … … 602 616 #endif 603 617 618 /* We have to dynamically bind these ourselves */ 619 extern gboolean (*gvalue_from_sv) (GValue * value, SV * sv); 620 extern SV * (*sv_from_gvalue) (const GValue * value); 621 extern GClosure * (*perl_closure_new) (SV * callback, SV * data, gboolean swap); 622 623 604 624 #endif /* INC_BARNOWL_OWL_H */ -
owl_perl.h
rb8a3e00 r92ffd89 2 2 #define INC_BARNOWL_OWL_PERL_H 3 3 4 #define OWL_PERL_VOID_CALL (void)POPs; 4 #include <stdio.h> 5 6 /* 7 * This macro defines a convenience wrapper around the boilerplate 8 * of pushing char * arguments on to the stack for perl calling. 9 * 10 * Arguments are 11 * * i - the counter variable to use, which must be declared prior 12 * to calling this macro 13 * * argc - the number of arguments 14 * * argv - an array of char*s, of length at least argc; the arguments 15 * to push on to the stack 16 */ 17 #define OWL_PERL_PUSH_ARGS(i, argc, argv) { \ 18 for (i = 0; i < argc; i++) { \ 19 XPUSHs(sv_2mortal(owl_new_sv(argv[i]))); \ 20 } \ 21 } 5 22 6 23 /* 7 24 * This macro defines a convenience wrapper around the boilerplate of 8 * calling a method on a perl object (SV*) from C.25 * the perlcall methods. 9 26 * 10 27 * Arguments are 11 * * obj - the SV* to call the method on 12 * * meth - a char* method name 13 * * args - a code block responsible for pushing args (other than the object) 14 * * err - a string with a %s format specifier to log in case of error 15 * * fatalp - if true, perl errors terminate BarnOwl 16 * * ret - a code block executed if the call succeeded 28 * * call - the line of code to make the perl call 29 * * args - a code block responsible for pushing args 30 * * err - a string with a %s format specifier to log in case of error 31 * * fatalp - if true, perl errors terminate BarnOwl 32 * * discardret - should be true if no return is expected 33 * (if the call is passed the flag G_DISCARD or G_VOID) 34 * * ret - a code block executed if the call succeeded 17 35 * 18 36 * See also: `perldoc perlcall', `perldoc perlapi' 19 37 */ 20 #define OWL_PERL_CALL_METHOD(obj, meth, args, err, fatalp, ret) { \ 21 int count; \ 22 dSP; \ 23 ENTER; \ 24 SAVETMPS; \ 25 PUSHMARK(SP); \ 26 XPUSHs(obj); \ 27 {args} \ 28 PUTBACK; \ 29 \ 30 count = call_method(meth, G_SCALAR|G_EVAL); \ 31 \ 32 SPAGAIN; \ 33 \ 34 if(count != 1) { \ 35 fprintf(stderr, "perl returned wrong count: %d\n", count); \ 36 abort(); \ 38 #define OWL_PERL_CALL(call, args, err, fatalp, discardret, ret) { \ 39 int count; \ 40 dSP; \ 41 \ 42 ENTER; \ 43 SAVETMPS; \ 44 \ 45 PUSHMARK(SP); \ 46 {args} \ 47 PUTBACK; \ 48 \ 49 count = call; \ 50 \ 51 SPAGAIN; \ 52 \ 53 if (!discardret && count != 1) { \ 54 croak("Perl returned wrong count: %d\n", count); \ 55 } \ 56 \ 57 if (SvTRUE(ERRSV)) { \ 58 if (fatalp) { \ 59 fprintf(stderr, err, SvPV_nolen(ERRSV)); \ 60 exit(-1); \ 61 } else { \ 62 owl_function_error(err, SvPV_nolen(ERRSV)); \ 63 if (!discardret) (void)POPs; \ 64 sv_setsv(ERRSV, &PL_sv_undef); \ 37 65 } \ 38 if (SvTRUE(ERRSV)) { \ 39 if(fatalp) { \ 40 printf(err, SvPV_nolen(ERRSV)); \ 41 exit(-1); \ 42 } else { \ 43 owl_function_error(err, SvPV_nolen(ERRSV)); \ 44 (void)POPs; \ 45 sv_setsv(ERRSV, &PL_sv_undef); \ 46 } \ 47 } else { \ 48 ret; \ 49 } \ 50 PUTBACK; \ 51 FREETMPS; \ 52 LEAVE; \ 66 } else if (!discardret) { \ 67 ret; \ 68 } \ 69 PUTBACK; \ 70 FREETMPS; \ 71 LEAVE; \ 53 72 } 54 73 -
perl/Makefile.am
r10557e6 ra870319 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
ra130fc5 r1ced34f 5 5 6 6 use base qw(Exporter); 7 our @EXPORT_OK = qw(command getcurmsg getnumcols get idletime7 our @EXPORT_OK = qw(command getcurmsg getnumcols getnumlines getidletime 8 8 zephyr_getsender zephyr_getrealm zephyr_zwrite 9 9 zephyr_stylestrip zephyr_smartstrip_user zephyr_getsubs 10 10 queue_message admin_message 11 start_edit 11 12 start_question start_password start_edit_win 12 13 get_data_dir get_config_dir popless_text popless_ztext 13 14 error debug 14 15 create_style getnumcolors wordwrap 16 message_matches_filter 15 17 add_dispatch remove_dispatch 16 18 add_io_dispatch remove_io_dispatch 17 19 new_command 18 20 new_variable_int new_variable_bool new_variable_string 21 new_variable_enum 19 22 quote redisplay); 20 23 our %EXPORT_TAGS = (all => \@EXPORT_OK); … … 92 95 command line, and C<MESSAGE> is the zephyr body to send. 93 96 97 =cut 98 99 sub zephyr_zwrite { 100 my ($command, $message) = @_; 101 my $ret = BarnOwl::Internal::zephyr_zwrite($command, $message); 102 die "Error sending zephyr" unless $ret == 0; 103 } 104 94 105 =head2 ztext_stylestrip STRING 95 106 … … 105 116 Enqueue a message in the BarnOwl message list, logging it and 106 117 processing it appropriately. C<MESSAGE> should be an instance of 107 BarnOwl::Message or a subclass. Returns the queued message. This 108 is useful for, e.g., deleting a message from the message list. 118 BarnOwl::Message or a subclass. 109 119 110 120 =head2 admin_message HEADER BODY … … 112 122 Display a BarnOwl B<Admin> message, with the given header and body. 113 123 124 =head2 start_edit %ARGS 125 126 Displays a prompt on the screen and lets the user enter text, 127 and calls a callback when the editwin is closed. 128 129 C<%ARGS> must contain the following keys: 130 131 =over 4 132 133 =item prompt 134 135 The line to display on the screen 136 137 =item type 138 139 One of: 140 141 =over 4 142 143 =item edit_win 144 145 Displays the prompt on a line of its own and opens the edit_win. 146 147 =item question 148 149 Displays prompt on the screen and lets the user enter a line of 150 text. 151 152 =item password 153 154 Like question, but echoes the user's input as C<*>s when they 155 input. 156 157 =back 158 159 =item callback 160 161 A Perl subroutine that is called when the user closes the edit_win. 162 C<CALLBACK> gets called with two parameters: the text the user entered, 163 and a C<SUCCESS> boolean parameter which is false if the user canceled 164 the edit_win and true otherwise. 165 166 =back 167 114 168 =head2 start_question PROMPT CALLBACK 115 169 116 Displays C<PROMPT> on the screen and lets the user enter a line of117 text, and calls C<CALLBACK>, which must be a perl subroutine118 reference, with the text the user entered119 120 170 =head2 start_password PROMPT CALLBACK 121 171 122 Like C<start_question>, but echoes the user's input as C<*>s when they123 input.124 125 172 =head2 start_edit_win PROMPT CALLBACK 126 173 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. 174 Roughly equivalent to C<start_edit> called with the appropriate parameters. 175 C<CALLBACK> is only called on success, for compatibility. 176 177 These are deprecated wrappers around L<BarnOwl::start_edit>, and should not 178 be uesd in new code. 179 180 =cut 181 182 sub start_edit { 183 my %args = (@_); 184 BarnOwl::Internal::start_edit($args{type}, $args{prompt}, $args{callback}); 185 } 186 187 sub start_question { 188 my ($prompt, $callback) = @_; 189 BarnOwl::start_edit(type => 'question', prompt => $prompt, callback => sub { 190 my ($text, $success) = @_; 191 $callback->($text) if $success; 192 }); 193 } 194 195 sub start_password { 196 my ($prompt, $callback) = @_; 197 BarnOwl::start_edit(type => 'password', prompt => $prompt, callback => sub { 198 my ($text, $success) = @_; 199 $callback->($text) if $success; 200 }); 201 } 202 203 sub start_edit_win { 204 my ($prompt, $callback) = @_; 205 BarnOwl::start_edit(type => 'edit_win', prompt => $prompt, callback => sub { 206 my ($text, $success) = @_; 207 $callback->($text) if $success; 208 }); 209 } 130 210 131 211 =head2 get_data_dir … … 160 240 161 241 Returns the number of colors this BarnOwl is capable of displaying 242 243 =head2 message_matches_filter MESSAGE FILTER_NAME [QUIET = 0] 244 245 Returns 1 if C<FILTER_NAME> is the name of a valid filter, and 246 C<MESSAGE> matches that filter. Returns 0 otherwise. If 247 C<QUIET> is false, this method displays an error message if 248 if C<FILTER_NAME> does not name a valid filter. 162 249 163 250 =head2 add_dispatch FD CALLBACK … … 259 346 our @all_commands; 260 347 261 if(!$configfile && -f $ENV{HOME} . "/.barnowlconf") { 262 $configfile = $ENV{HOME} . "/.barnowlconf"; 263 } 264 $configfile ||= $ENV{HOME}."/.owlconf"; 348 if(!$configfile) { 349 if (-f get_config_dir() . "/init.pl") { 350 $configfile = get_config_dir() . "/init.pl"; 351 } elsif (-f $ENV{HOME} . "/.barnowlconf") { 352 $configfile = $ENV{HOME} . "/.barnowlconf"; 353 } else { 354 $configfile = $ENV{HOME}."/.owlconf"; 355 } 356 } 265 357 266 358 # populate global variable space for legacy owlconf files … … 319 411 =head2 new_variable_string NAME [{ARGS}] 320 412 321 Add a new owl variable, either an int, a bool, or a string, with the 413 =head2 new_variable_enum NAME [{ARGS}] 414 415 Add a new owl variable, either an int, a bool, a string, or an enum with the 322 416 specified name. 323 417 324 ARGS can optionally contain the following keys: 418 For new_variable_enum, ARGS is required to contain a validsettings key pointing 419 to an array reference. For all four, it can optionally contain the following 420 keys: 325 421 326 422 =over 4 … … 340 436 =back 341 437 438 In addition, new_variable_string optionally accepts a string validsettings 439 parameter, in case people want to set it to "<path>". 440 342 441 =cut 343 442 344 443 sub new_variable_int { 345 unshift @_, \&BarnOwl::Internal::new_variable_int, 0; 346 goto \&_new_variable; 444 my ($name, $args) = @_; 445 my $storage = defined($args->{default}) ? $args->{default} : 0; 446 BarnOwl::new_variable_full($name, { 447 %{$args}, 448 get_tostring => sub { "$storage" }, 449 set_fromstring => sub { 450 die "Expected integer" unless $_[0] =~ /^-?[0-9]+$/; 451 $storage = 0 + $_[0]; 452 }, 453 validsettings => "<int>", 454 takes_on_off => 0, 455 }); 347 456 } 348 457 349 458 sub new_variable_bool { 350 unshift @_, \&BarnOwl::Internal::new_variable_bool, 0; 351 goto \&_new_variable; 459 my ($name, $args) = @_; 460 my $storage = defined($args->{default}) ? $args->{default} : 0; 461 BarnOwl::new_variable_full($name, { 462 %{$args}, 463 get_tostring => sub { $storage ? "on" : "off" }, 464 set_fromstring => sub { 465 die "Valid settings are on/off" unless $_[0] eq "on" || $_[0] eq "off"; 466 $storage = $_[0] eq "on"; 467 }, 468 validsettings => "on,off", 469 takes_on_off => 1, 470 }); 352 471 } 353 472 354 473 sub new_variable_string { 355 unshift @_, \&BarnOwl::Internal::new_variable_string, ""; 356 goto \&_new_variable; 357 } 358 359 sub _new_variable { 360 my $func = shift; 361 my $default_default = shift; 474 my ($name, $args) = @_; 475 my $storage = defined($args->{default}) ? $args->{default} : ""; 476 BarnOwl::new_variable_full($name, { 477 # Allow people to override this one if they /reaaally/ want to for 478 # some reason. Though we still reserve the right to interpret this 479 # value in interesting ways for tab-completion purposes. 480 validsettings => "<string>", 481 %{$args}, 482 get_tostring => sub { $storage }, 483 set_fromstring => sub { $storage = $_[0]; }, 484 takes_on_off => 0, 485 }); 486 } 487 488 sub new_variable_enum { 489 my ($name, $args) = @_; 490 491 # Gather the valid settings. 492 die "validsettings is required" unless defined($args->{validsettings}); 493 my %valid; 494 map { $valid{$_} = 1 } @{$args->{validsettings}}; 495 496 my $storage = (defined($args->{default}) ? 497 $args->{default} : 498 $args->{validsettings}->[0]); 499 BarnOwl::new_variable_full($name, { 500 %{$args}, 501 get_tostring => sub { $storage }, 502 set_fromstring => sub { 503 die "Invalid input" unless $valid{$_[0]}; 504 $storage = $_[0]; 505 }, 506 validsettings => join(",", @{$args->{validsettings}}) 507 }); 508 } 509 510 =head2 new_variable_full NAME {ARGS} 511 512 Create a variable, in full generality. The keyword arguments have types below: 513 514 get_tostring : () -> string 515 set_fromstring : string -> int 516 -- optional -- 517 summary : string 518 description : string 519 validsettings : string 520 takes_on_off : int 521 522 The get/set functions are required. Note that the caller manages storage for the 523 variable. get_tostring/set_fromstring both convert AND store the value. 524 set_fromstring dies on failure. 525 526 If the variable takes parameters 'on' and 'off' (i.e. is boolean-looking), set 527 takes_on_off to 1. This makes :set VAR and :unset VAR work. set_fromstring will 528 be called with those arguments. 529 530 =cut 531 532 sub new_variable_full { 362 533 my $name = shift; 363 534 my $args = shift || {}; 364 535 my %args = ( 365 summary 536 summary => "", 366 537 description => "", 367 default => $default_default, 538 takes_on_off => 0, 539 validsettings => "<string>", 368 540 %{$args}); 369 $func->($name, $args{default}, $args{summary}, $args{description}); 541 542 die "get_tostring required" unless $args{get_tostring}; 543 die "set_fromstring required" unless $args{set_fromstring}; 544 545 # Strip off the bogus dummy argument. Aargh perl-Glib. 546 my $get_tostring_fn = sub { $args{get_tostring}->() }; 547 my $set_fromstring_fn = sub { 548 my ($dummy, $val) = @_; 549 # Translate from user-supplied die-on-failure callback to expected 550 # non-zero on error. Less of a nuisance than interacting with ERRSV. 551 eval { $args{set_fromstring}->($val) }; 552 # TODO: Consider changing B::I::new_variable to expect string|NULL with 553 # string as the error message. That can then be translated to a GError in 554 # owl_variable_set_fromstring. For now the string is ignored. 555 return ($@ ? -1 : 0); 556 }; 557 558 BarnOwl::Internal::new_variable($name, $args{summary}, $args{description}, $args{validsettings}, 559 $args{takes_on_off}, $get_tostring_fn, $set_fromstring_fn, undef); 370 560 } 371 561 -
perl/lib/BarnOwl/Complete/Client.pm
r58f4fb2 r4626016 20 20 21 21 my %show = ( 22 information => undef,23 22 colors => undef, 24 23 commands => undef, … … 205 204 BarnOwl::Completion::register_completer(set => \&complete_set); 206 205 BarnOwl::Completion::register_completer(unset => \&complete_set); 207 BarnOwl::Completion::register_completer(startup => \&complete_startup); 206 BarnOwl::Completion::register_completer(startup => \&complete_startup); 207 BarnOwl::Completion::register_completer(unstartup => \&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
r3e8625f re6e7842 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); 66 68 67 69 BarnOwl::Completion::register_completer(unsub => \&complete_unsub); -
perl/lib/BarnOwl/Message.pm
ra130fc5 r0adbce1 51 51 sub is_ping { return 0; } 52 52 sub is_mail { return 0; } 53 sub is_personal { return shift->is_private; }53 sub is_personal { return BarnOwl::message_matches_filter(shift, "personal"); } 54 54 sub class { return undef; } 55 55 sub instance { return undef; } -
perl/lib/BarnOwl/Message/Zephyr.pm
redd0be7 r0adbce1 51 51 my ($m) = @_; 52 52 return undef if (!$m->is_loginout); 53 return undef if (!defined($m->fields)); 53 54 return $m->fields->[2]; 54 55 } … … 57 58 my ($m) = @_; 58 59 return undef if (!$m->is_loginout); 60 return undef if (!defined($m->fields)); 59 61 return $m->fields->[0]; 60 62 } … … 63 65 64 66 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 }71 67 72 68 sub is_mail { … … 171 167 $class = $self->class; 172 168 $instance = $self->instance; 173 if ($self->recipient eq '*' || $self->recipient eq '') { 174 $to = ''; 175 } elsif ($self->recipient =~ /^@/) { 169 if ($self->recipient eq '' || $self->recipient =~ /^@/) { 176 170 $to = $self->recipient; 177 171 } else { -
perl/lib/BarnOwl/ModuleLoader.pm
rf544216 rf34728b 127 127 } 128 128 129 sub complete_module_name { 130 return sort(keys %modules); 131 } 132 129 133 sub register_keybindings { 130 134 BarnOwl::new_command('reload-modules', sub {BarnOwl::ModuleLoader->reload}, { … … 138 142 description => q{Reloads a single module located in ~/.owl/modules or the system modules directory} 139 143 }); 144 145 BarnOwl::Completion::register_completer('reload-module', \&complete_module_name); 140 146 } 141 147 -
perl/lib/BarnOwl/Style/Default.pm
r5738650 r732d5c0 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 } 115 118 } 116 119 -
perl/lib/BarnOwl/Zephyr.pm
rdf569c5 r53151d4 12 12 use BarnOwl::Hook; 13 13 14 my$zephyrStartup = BarnOwl::Hook->new;14 our $zephyrStartup = BarnOwl::Hook->new; 15 15 16 16 sub _zephyr_startup { -
perl/lib/Module/Install/BarnOwl.pm
rb8a3e00 re4b8f93 41 41 my $class = ref $self; 42 42 43 my $srcdir = $ENV{BARNOWL_SRCDIR} || '.'; 44 43 45 $self->name("BarnOwl-Module-$name"); 44 $self->all_from("lib/BarnOwl/Module/$name.pm"); 46 $self->all_from("$srcdir/lib/BarnOwl/Module/$name.pm"); 47 $self->makemaker_args(PMLIBDIRS => ["$srcdir/lib"], 48 PMLIBPARENTDIRS => ["$srcdir/lib"]); 45 49 46 50 $self->postamble(<<"END_MAKEFILE"); 47 51 48 52 # --- $class section: 53 54 BARNOWL_SRCDIR = $srcdir 55 export BARNOWL_SRCDIR 49 56 50 57 $name.par: pm_to_blib -
perl/modules/IRC/lib/BarnOwl/Module/IRC.pm
rb8a3e00 r731e921 23 23 use Getopt::Long; 24 24 use Encode; 25 use Text::Wrap; 25 26 26 27 our $VERSION = 0.02; … … 65 66 description => 'If set, each (space-separated) message type ' . 66 67 'provided will be hidden and ignored if received.' 68 }); 69 70 BarnOwl::new_variable_int('irc:max-message-length', { 71 default => 450, 72 summary => 'Split messages to at most this many characters.' . 73 "If non-positive, don't split messages", 74 description => 'If set to a positive number, any paragraph in an ' . 75 'IRC message will be split after this many characters.' 67 76 }); 68 77 … … 427 436 @msgs = split "\n\n", $fullbody; 428 437 map { tr/\n/ / } @msgs; 438 # split each body at irc:max-message-length characters, if that number 439 # is positive. Only split at space boundaries. Start counting a-fresh 440 # at the beginning of each paragraph 441 my $max_len = BarnOwl::getvar('irc:max-message-length'); 442 if ($max_len > 0) { 443 local($Text::Wrap::columns) = $max_len; 444 @msgs = split "\n", wrap("", "", join "\n", @msgs); 445 } 429 446 for my $body (@msgs) { 430 447 if ($body =~ /^\/me (.*)/) { … … 598 615 } 599 616 600 if(! $channel&&617 if(!defined($channel) && 601 618 ($flags & CHANNEL_ARG) && 602 619 !($flags & CHANNEL_OPTIONAL)) { -
perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm
rb8a3e00 r8258ea5 320 320 . "configure [<muc>]\n" 321 321 . " Configures a MUC.\n" 322 . " Necessary to init alize a new MUC.\n"322 . " Necessary to initialize 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" … … 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 1484 1493 BarnOwl::Completion::register_completer(jwrite => sub { BarnOwl::Module::Jabber::complete_jwrite(@_) }); 1494 BarnOwl::Completion::register_completer(jabberlogout => sub { BarnOwl::Module::Jabber::complete_jabberlogout(@_) }); 1485 1495 1486 1496 1; -
perl/modules/Jabber/lib/Net/Jabber/Component.pm
rc2bed55 ra8c55b5 220 220 $self->{STREAM}->SetCallBacks(node=>undef); 221 221 222 $self->Send("<handshake>".Digest::SHA 1::sha1_hex($self->{SESSION}->{id}.$args{secret})."</handshake>");222 $self->Send("<handshake>".Digest::SHA::sha1_hex($self->{SESSION}->{id}.$args{secret})."</handshake>"); 223 223 my $handshake = $self->Process(); 224 224 -
perl/modules/Jabber/lib/Net/Jabber/Key.pm
rc2bed55 ra8c55b5 104 104 $self->{CACHE} = {}; 105 105 106 if (eval "require Digest::SHA 1")106 if (eval "require Digest::SHA") 107 107 { 108 108 $self->{DIGEST} = 1; 109 Digest::SHA 1->import(qw(sha1 sha1_hex sha1_base64));109 Digest::SHA->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 1installed.\n";113 print "ERROR: You cannot use Key.pm unless you have Digest::SHA installed.\n"; 114 114 exit(0); 115 115 } … … 132 132 133 133 my $string = $$.time.rand(1000000); 134 $string = Digest::SHA 1::sha1_hex($string);134 $string = Digest::SHA::sha1_hex($string); 135 135 $self->{DEBUG}->Log1("Generate: key($string)"); 136 136 return $string; -
perl/modules/Jabber/lib/Net/XMPP.pm
rc2bed55 ra8c55b5 213 213 use Time::Local; 214 214 use Carp; 215 use Digest::SHA 1;215 use Digest::SHA; 216 216 use Authen::SASL; 217 217 use MIME::Base64; -
perl/modules/Jabber/lib/Net/XMPP/Protocol.pm
r7f33c18 ra8c55b5 1849 1849 if ($authType eq "zerok") 1850 1850 { 1851 my $hashA = Digest::SHA 1::sha1_hex($password);1852 $args{hash} = Digest::SHA 1::sha1_hex($hashA.$token);1851 my $hashA = Digest::SHA::sha1_hex($password); 1852 $args{hash} = Digest::SHA::sha1_hex($hashA.$token); 1853 1853 1854 1854 for (1..$sequence) 1855 1855 { 1856 $args{hash} = Digest::SHA 1::sha1_hex($args{hash});1856 $args{hash} = Digest::SHA::sha1_hex($args{hash}); 1857 1857 } 1858 1858 } … … 1868 1868 if ($authType eq "digest") 1869 1869 { 1870 $args{digest} = Digest::SHA 1::sha1_hex($self->GetStreamID().$password);1870 $args{digest} = Digest::SHA::sha1_hex($self->GetStreamID().$password); 1871 1871 } 1872 1872 -
perl/modules/Makefile.am
r1fd469d4 re4b8f93 1 MODULES = Jabber IRC WordWrap Twitter 1 MODULES = Jabber IRC WordWrap Twitter Facebook 2 2 3 EXTRA_DIST = $(MODULES:=/Makefile.PL) $(MODULES:=/inc) $(MODULES:=/lib) 3 EXTRA_DIST = $(MODULES:=/Makefile.PL) $(MODULES:=/lib) 4 EXTRA_DIST += \ 5 Facebook/README \ 6 Twitter/README \ 7 Twitter/twitter.example 4 8 5 9 all-local: $(MODULES) … … 7 11 (cd $* && $(MAKE) $*.par) 8 12 13 BARNOWL_PERL := $(shell which perl) -I$(abs_srcdir)/../lib 14 9 15 MODULES_MAKEFILE = $(MODULES:=/Makefile) 10 $(MODULES_MAKEFILE): %/Makefile: %/Makefile.PL 11 $(AM_V_GEN)(cd $* && perl -I../../lib Makefile.PL) 16 $(MODULES_MAKEFILE): %/Makefile: %/Makefile.PL ../lib/Module/Install/BarnOwl.pm 17 $(AM_V_GEN)test -d $* || mkdir $* 18 $(AM_V_at)test $(srcdir) = . || $(LN_S) $(abs_srcdir)/$*/Makefile.PL $*/Makefile.PL 19 $(AM_V_at)(cd $* && BARNOWL_SRCDIR='$(abs_srcdir)/$*' && export BARNOWL_SRCDIR && $(BARNOWL_PERL) Makefile.PL 'PERL=$(BARNOWL_PERL)') 12 20 13 21 MODULES_CLEAN = $(MODULES:%=clean_%) 14 22 clean-local: $(MODULES_CLEAN) 15 23 $(MODULES_CLEAN): clean_%: 16 (cd $* && (test ! -f Makefile || $(MAKE) clean)) 24 (cd $* && { test ! -f Makefile || $(MAKE) realclean; }) 25 rm -f $*/$*.par 26 rm -rf $*/inc 27 test $(srcdir) = . || rm -f $*/Makefile.PL 17 28 18 29 MODULES_INSTALL = $(MODULES:%=module_install_%) … … 23 34 ${INSTALL_DATA} $*/$*.par ${DESTDIR}${pkgdatadir}/modules/$*.par 24 35 36 uninstall-local: 37 rm -f $(MODULES:%=${DESTDIR}${pkgdatadir}/modules/%.par) 38 25 39 .PHONY: $(MODULES) $(MODULES_CLEAN) $(MODULES_INSTALL) -
perlconfig.c
rdde1b4d r96d80e9 1 #include <stdio.h>2 #include <stdlib.h>3 #include <string.h>4 #include <sys/types.h>5 #include <sys/stat.h>6 #include <errno.h>7 1 #define OWL_PERL 8 2 #include "owl.h" 3 #include <stdio.h> 9 4 10 5 extern XS(boot_BarnOwl); … … 80 75 const char *type; 81 76 char *ptr, *utype, *blessas; 82 int i, j; 77 const char *f; 78 int i; 83 79 const owl_pair *pair; 84 80 const owl_filter *wrap; … … 96 92 owl_new_sv(owl_message_get_##field(m)), 0) 97 93 98 if (owl_message_is_type_zephyr(m) 99 && owl_message_is_direction_in(m)) { 94 if (owl_message_is_type_zephyr(m) && owl_message_is_direction_in(m)) { 100 95 /* Handle zephyr-specific fields... */ 101 AV *av_zfields; 102 103 av_zfields = newAV(); 104 j=owl_zephyr_get_num_fields(owl_message_get_notice(m)); 105 for (i=0; i<j; i++) { 106 ptr=owl_zephyr_get_field_as_utf8(owl_message_get_notice(m), i+1); 107 av_push(av_zfields, owl_new_sv(ptr)); 108 g_free(ptr); 96 AV *av_zfields = newAV(); 97 if (owl_message_get_notice(m)) { 98 for (f = owl_zephyr_first_raw_field(owl_message_get_notice(m)); f != NULL; 99 f = owl_zephyr_next_raw_field(owl_message_get_notice(m), f)) { 100 ptr = owl_zephyr_field_as_utf8(owl_message_get_notice(m), f); 101 av_push(av_zfields, owl_new_sv(ptr)); 102 g_free(ptr); 103 } 104 (void)hv_store(h, "auth", strlen("auth"), 105 owl_new_sv(owl_zephyr_get_authstr(owl_message_get_notice(m))), 0); 106 } else { 107 /* Incoming zephyrs without a ZNotice_t are pseudo-logins. To appease 108 * existing styles, put in bogus 'auth' and 'fields' keys. */ 109 (void)hv_store(h, "auth", strlen("auth"), owl_new_sv("NO"), 0); 109 110 } 110 111 (void)hv_store(h, "fields", strlen("fields"), newRV_noinc((SV*)av_zfields), 0); 111 112 (void)hv_store(h, "auth", strlen("auth"),113 owl_new_sv(owl_zephyr_get_authstr(owl_message_get_notice(m))),0);114 112 } 115 113 … … 178 176 message2hashref and hashref2message. Currently we lose 179 177 zephyr-specific properties stored in the ZNotice_t 180 181 This has been somewhat addressed, but is still not lossless.182 178 */ 183 179 CALLER_OWN owl_message *owl_perlconfig_hashref2message(SV *msg) … … 225 221 owl_message_set_attribute(m, "adminheader", ""); 226 222 } 227 #ifdef HAVE_LIBZEPHYR228 if (owl_message_is_type_zephyr(m)) {229 ZNotice_t *n = &(m->notice);230 n->z_kind = ACKED;231 n->z_port = 0;232 n->z_auth = ZAUTH_NO;233 n->z_checked_auth = 0;234 n->z_class = zstr(owl_message_get_class(m));235 n->z_class_inst = zstr(owl_message_get_instance(m));236 n->z_opcode = zstr(owl_message_get_opcode(m));237 n->z_sender = zstr(owl_message_get_sender(m));238 n->z_recipient = zstr(owl_message_get_recipient(m));239 n->z_default_format = zstr("[zephyr created from perl]");240 n->z_multinotice = zstr("[zephyr created from perl]");241 n->z_num_other_fields = 0;242 n->z_message = g_strdup_printf("%s%c%s", owl_message_get_zsig(m), '\0', owl_message_get_body(m));243 n->z_message_len = strlen(owl_message_get_zsig(m)) + strlen(owl_message_get_body(m)) + 1;244 }245 #endif246 223 return m; 247 224 } … … 251 228 CALLER_OWN char *owl_perlconfig_call_with_message(const char *subname, const owl_message *m) 252 229 { 253 dSP ; 254 int count; 255 SV *msgref, *srv; 256 char *out; 257 258 ENTER ; 259 SAVETMPS; 260 261 PUSHMARK(SP) ; 230 SV *msgref, *rv; 231 char *out = NULL; 232 262 233 msgref = owl_perlconfig_message2hashref(m); 263 XPUSHs(sv_2mortal(msgref)); 264 PUTBACK ; 265 266 count = call_pv(subname, G_SCALAR|G_EVAL); 267 268 SPAGAIN ; 269 270 if (SvTRUE(ERRSV)) { 271 owl_function_error("Perl Error: '%s'", SvPV_nolen(ERRSV)); 272 /* and clear the error */ 273 sv_setsv (ERRSV, &PL_sv_undef); 274 } 275 276 if (count != 1) { 277 fprintf(stderr, "bad perl! no biscuit! returned wrong count!\n"); 278 abort(); 279 } 280 281 srv = POPs; 282 283 if (srv) { 284 out = g_strdup(SvPV_nolen(srv)); 285 } else { 286 out = NULL; 287 } 288 289 PUTBACK ; 290 FREETMPS ; 291 LEAVE ; 292 234 235 OWL_PERL_CALL((call_pv(subname, G_SCALAR|G_EVAL)) 236 , 237 XPUSHs(sv_2mortal(msgref)); 238 , 239 "Perl Error: '%s'" 240 , 241 false 242 , 243 false 244 , 245 rv = POPs; 246 if (rv && SvPOK(rv)) 247 out = g_strdup(SvPV_nolen(rv)); 248 ); 293 249 return out; 294 250 } … … 300 256 CALLER_OWN char *owl_perlconfig_message_call_method(const owl_message *m, const char *method, int argc, const char **argv) 301 257 { 302 dSP; 303 unsigned int count, i; 304 SV *msgref, *srv; 305 char *out; 258 SV *msgref, *rv; 259 char *out = NULL; 260 int i; 306 261 307 262 msgref = owl_perlconfig_message2hashref(m); 308 263 309 ENTER; 310 SAVETMPS; 311 312 PUSHMARK(SP); 313 XPUSHs(sv_2mortal(msgref)); 314 for(i=0;i<argc;i++) { 315 XPUSHs(sv_2mortal(owl_new_sv(argv[i]))); 316 } 317 PUTBACK; 318 319 count = call_method(method, G_SCALAR|G_EVAL); 320 321 SPAGAIN; 322 323 if(count != 1) { 324 fprintf(stderr, "perl returned wrong count %u\n", count); 325 abort(); 326 } 327 328 if (SvTRUE(ERRSV)) { 329 owl_function_error("Error: '%s'", SvPV_nolen(ERRSV)); 330 /* and clear the error */ 331 sv_setsv (ERRSV, &PL_sv_undef); 332 } 333 334 srv = POPs; 335 336 if (srv) { 337 out = g_strdup(SvPV_nolen(srv)); 338 } else { 339 out = NULL; 340 } 341 342 PUTBACK; 343 FREETMPS; 344 LEAVE; 345 264 OWL_PERL_CALL(call_method(method, G_SCALAR|G_EVAL) 265 , 266 XPUSHs(sv_2mortal(msgref)); 267 OWL_PERL_PUSH_ARGS(i, argc, argv); 268 , 269 "Perl Error: '%s'" 270 , 271 false 272 , 273 false 274 , 275 rv = POPs; 276 if (rv && SvPOK(rv)) 277 out = g_strdup(SvPV_nolen(rv)); 278 ); 346 279 return out; 347 280 } … … 354 287 char *err; 355 288 const char *args[4] = {"", "-e", "0;", NULL}; 289 const char *dlerr; 356 290 AV *inc; 357 291 char *path; … … 411 345 g_free(path); 412 346 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. */ 413 357 eval_pv("use BarnOwl;", FALSE); 414 358 … … 482 426 void owl_perlconfig_new_command(const char *name) 483 427 { 484 dSP; 485 486 ENTER; 487 SAVETMPS; 488 489 PUSHMARK(SP); 490 XPUSHs(sv_2mortal(owl_new_sv(name))); 491 PUTBACK; 492 493 call_pv("BarnOwl::Hooks::_new_command", G_VOID|G_EVAL); 494 495 SPAGAIN; 496 497 if(SvTRUE(ERRSV)) { 498 owl_function_error("%s", SvPV_nolen(ERRSV)); 499 } 500 501 FREETMPS; 502 LEAVE; 428 OWL_PERL_CALL(call_pv("BarnOwl::Hooks::_new_command", G_VOID|G_EVAL); 429 , 430 XPUSHs(sv_2mortal(owl_new_sv(name))); 431 , 432 "Perl Error: '%s'" 433 , 434 false 435 , 436 true 437 , 438 ); 439 } 440 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 ); 503 521 } 504 522 … … 506 524 CALLER_OWN char *owl_perlconfig_perlcmd(const owl_cmd *cmd, int argc, const char *const *argv) 507 525 { 508 int i, count; 509 char * ret = NULL; 510 SV *rv; 511 dSP; 512 513 ENTER; 514 SAVETMPS; 515 516 PUSHMARK(SP); 517 for(i=0;i<argc;i++) { 518 XPUSHs(sv_2mortal(owl_new_sv(argv[i]))); 519 } 520 PUTBACK; 521 522 count = call_sv(cmd->cmd_perl, G_SCALAR|G_EVAL); 523 524 SPAGAIN; 525 526 if(SvTRUE(ERRSV)) { 527 owl_function_error("%s", SvPV_nolen(ERRSV)); 528 (void)POPs; 529 } else { 530 if(count != 1) 531 croak("Perl command %s returned more than one value!", cmd->name); 532 rv = POPs; 533 if(SvTRUE(rv)) { 534 ret = g_strdup(SvPV_nolen(rv)); 535 } 536 } 537 538 FREETMPS; 539 LEAVE; 540 541 return ret; 526 int i; 527 SV* rv; 528 char *out = NULL; 529 530 OWL_PERL_CALL(call_sv(cmd->cmd_perl, G_SCALAR|G_EVAL) 531 , 532 OWL_PERL_PUSH_ARGS(i, argc, argv); 533 , 534 "Perl Error: '%s'" 535 , 536 false 537 , 538 false 539 , 540 rv = POPs; 541 if (rv && SvPOK(rv)) 542 out = g_strdup(SvPV_nolen(rv)); 543 ); 544 return out; 542 545 } 543 546 … … 547 550 } 548 551 549 void owl_perlconfig_edit_callback(owl_editwin *e )552 void owl_perlconfig_edit_callback(owl_editwin *e, bool success) 550 553 { 551 554 SV *cb = owl_editwin_get_cbdata(e); 552 SV *text; 553 dSP; 554 555 if(cb == NULL) { 555 SV *text = owl_new_sv(owl_editwin_get_text(e)); 556 557 if (cb == NULL) { 556 558 owl_function_error("Perl callback is NULL!"); 557 559 return; 558 560 } 559 text = owl_new_sv(owl_editwin_get_text(e)); 560 561 ENTER; 562 SAVETMPS; 563 564 PUSHMARK(SP); 565 XPUSHs(sv_2mortal(text)); 566 PUTBACK; 567 568 call_sv(cb, G_DISCARD|G_EVAL); 569 570 if(SvTRUE(ERRSV)) { 571 owl_function_error("%s", SvPV_nolen(ERRSV)); 572 } 573 574 FREETMPS; 575 LEAVE; 561 562 OWL_PERL_CALL(call_sv(cb, G_DISCARD|G_EVAL) 563 , 564 XPUSHs(sv_2mortal(text)); 565 XPUSHs(sv_2mortal(newSViv(success))); 566 , 567 "Perl Error: '%s'" 568 , 569 false 570 , 571 true 572 , 573 ); 576 574 } 577 575 -
perlglue.xs
ra130fc5 r1ced34f 1 1 /* -*- mode: c; indent-tabs-mode: t; c-basic-offset: 8 -*- */ 2 #ifdef HAVE_LIBZEPHYR3 #include <zephyr/zephyr.h>4 #endif5 #include <EXTERN.h>6 7 2 #define OWL_PERL 8 3 #include "owl.h" … … 72 67 OUTPUT: 73 68 RETVAL 74 69 70 int 71 getnumlines() 72 CODE: 73 RETVAL = owl_global_get_lines(&g); 74 OUTPUT: 75 RETVAL 76 75 77 time_t 76 78 getidletime() … … 93 95 OUTPUT: 94 96 RETVAL 95 96 void97 zephyr_zwrite(cmd,msg)98 const char *cmd99 const char *msg100 PREINIT:101 int i;102 CODE:103 i = owl_zwrite_create_and_send_from_line(cmd, msg);104 97 105 98 const utf8 * … … 170 163 { 171 164 owl_function_adminmsg(header, body); 172 }173 174 void175 start_question(line, callback)176 const char *line177 SV *callback178 PREINIT:179 owl_editwin *e;180 CODE:181 {182 if(!SV_IS_CODEREF(callback))183 croak("Callback must be a subref");184 185 e = owl_function_start_question(line);186 187 owl_editwin_set_cbdata(e,188 newSVsv(callback),189 owl_perlconfig_dec_refcnt);190 owl_editwin_set_callback(e, owl_perlconfig_edit_callback);191 }192 193 void194 start_password(line, callback)195 const char *line196 SV *callback197 PREINIT:198 owl_editwin *e;199 CODE:200 {201 if(!SV_IS_CODEREF(callback))202 croak("Callback must be a subref");203 204 e = owl_function_start_password(line);205 206 owl_editwin_set_cbdata(e,207 newSVsv(callback),208 owl_perlconfig_dec_refcnt);209 owl_editwin_set_callback(e, owl_perlconfig_edit_callback);210 }211 212 void213 start_edit_win(line, callback)214 const char *line215 SV *callback216 CODE:217 {218 if(!SV_IS_CODEREF(callback))219 croak("Callback must be a subref");220 221 owl_function_start_edit_win(line,222 owl_perlconfig_edit_callback,223 newSVsv(callback),224 owl_perlconfig_dec_refcnt);225 165 } 226 166 … … 315 255 } 316 256 } 257 258 bool 259 message_matches_filter(message, filter_name, quiet = false) 260 SV *message 261 const char *filter_name 262 bool quiet 263 PREINIT: 264 owl_message *m; 265 const owl_filter *f; 266 CODE: 267 { 268 if (!SvROK(message) || SvTYPE(SvRV(message)) != SVt_PVHV) { 269 croak("Usage: BarnOwl::message_matches_filter($message, $filter_name[, $quiet])"); 270 } 271 272 m = owl_perlconfig_hashref2message(message); 273 f = owl_global_get_filter(&g, filter_name); 274 if (!f && !quiet) { 275 owl_function_error("%s filter is not defined", filter_name); 276 } 277 RETVAL = f && owl_filter_message_match(f, m); 278 } 279 OUTPUT: 280 RETVAL 281 CLEANUP: 282 owl_message_delete(m); 317 283 318 284 const utf8 * … … 462 428 } 463 429 464 void 465 new_variable_string(name, ival, summ, desc) 466 const char * name 467 const char * ival 468 const char * summ 469 const char * desc 470 CODE: 471 owl_variable_dict_newvar_string(owl_global_get_vardict(&g), 472 name, 473 summ, 474 desc, 475 ival); 476 477 void 478 new_variable_int(name, ival, summ, desc) 479 const char * name 480 int ival 481 const char * summ 482 const char * desc 483 CODE: 484 owl_variable_dict_newvar_int(owl_global_get_vardict(&g), 485 name, 486 summ, 487 desc, 488 ival); 489 490 void 491 new_variable_bool(name, ival, summ, desc) 492 const char * name 493 int ival 494 const char * summ 495 const char * desc 496 CODE: 497 owl_variable_dict_newvar_bool(owl_global_get_vardict(&g), 498 name, 499 summ, 500 desc, 501 ival); 430 431 MODULE = BarnOwl PACKAGE = BarnOwl::Internal 432 433 void 434 new_variable(name, summary, description, validsettings, takes_on_off, get_tostring_fn, set_fromstring_fn, data) 435 const char *name 436 const char *summary 437 const char *description 438 const char *validsettings 439 int takes_on_off 440 SV *get_tostring_fn 441 SV *set_fromstring_fn 442 SV *data 443 CODE: 444 { 445 /* data is somewhat redundant given we can create closures, but oh 446 * well. Might be convenient sometimes. */ 447 if(!SV_IS_CODEREF(get_tostring_fn)) { 448 croak("To-string function must be a coderef!"); 449 } 450 if(!SV_IS_CODEREF(set_fromstring_fn)) { 451 croak("From-string function must be a coderef!"); 452 } 453 454 owl_variable_dict_newvar_other(owl_global_get_vardict(&g), 455 name, summary, description, validsettings, takes_on_off, 456 perl_closure_new(get_tostring_fn, data, false), 457 perl_closure_new(set_fromstring_fn, data, false)); 458 } 459 460 void 461 start_edit(edit_type, line, callback) 462 const char *edit_type 463 const char *line 464 SV *callback 465 PREINIT: 466 owl_editwin *e; 467 CODE: 468 { 469 if (!SV_IS_CODEREF(callback)) 470 croak("Callback must be a subref"); 471 472 if (!strcmp(edit_type, "question")) 473 e = owl_function_start_question(line); 474 else if (!strcmp(edit_type, "password")) 475 e = owl_function_start_password(line); 476 else if (!strcmp(edit_type, "edit_win")) 477 e = owl_function_start_edit_win(line); 478 else 479 croak("edit_type must be one of 'password', 'question', 'edit_win', not '%s'", edit_type); 480 481 owl_editwin_set_cbdata(e, newSVsv(callback), owl_perlconfig_dec_refcnt); 482 owl_editwin_set_callback(e, owl_perlconfig_edit_callback); 483 } 484 485 int 486 zephyr_zwrite(cmd,msg) 487 const char *cmd 488 const char *msg 489 CODE: 490 RETVAL = owl_zwrite_create_and_send_from_line(cmd, msg); 491 OUTPUT: 492 RETVAL 502 493 503 494 MODULE = BarnOwl PACKAGE = BarnOwl::Editwin -
regex.c
rcbc8657 rf271129 1 #include <string.h>2 1 #include "owl.h" 3 2 -
runtests.sh
rf6ab6ee r5db8835 1 1 #!/bin/sh 2 exec env HARNESS_PERL=./tester prove --failures t/2 exec env HARNESS_PERL=./tester prove --failures "${srcdir:=$(dirname "$0")}/t/" -
style.c
r14be3a5 r92ffd89 23 23 { 24 24 SV *sv = NULL; 25 OWL_PERL_CALL _METHOD(s->perlobj,26 "description",27 ;,28 "Error in style_get_description: %s",29 0,30 31 32 if (sv) {25 OWL_PERL_CALL(call_method("description", G_SCALAR|G_EVAL), 26 XPUSHs(s->perlobj);, 27 "Error in style_get_description: %s", 28 0, 29 false, 30 sv = SvREFCNT_inc(POPs); 31 ); 32 if (sv) { 33 33 return SvPV_nolen(sv_2mortal(sv)); 34 34 } else { … … 50 50 51 51 /* Call the perl object */ 52 OWL_PERL_CALL_METHOD(s->perlobj, 53 "format_message", 54 XPUSHs(sv_2mortal(owl_perlconfig_message2hashref(m)));, 55 "Error in format_message: %s", 56 0, 57 sv = SvREFCNT_inc(POPs); 58 ); 52 OWL_PERL_CALL(call_method("format_message", G_SCALAR|G_EVAL), 53 XPUSHs(s->perlobj); 54 XPUSHs(sv_2mortal(owl_perlconfig_message2hashref(m)));, 55 "Error in format_message: %s", 56 0, 57 false, 58 sv = SvREFCNT_inc(POPs); 59 ); 59 60 60 if (sv) {61 if (sv) { 61 62 body = SvPV_nolen(sv); 62 63 } else { -
t/00-core-tests.t
r95414bf r5db8835 1 1 #!/usr/bin/env perl 2 use File::Basename; 3 system(dirname($0) . "/../tester", "--builtin"); 2 system("./tester", "--builtin"); -
tester.c
r67e5ba36 r6a8b519 3 3 #include "owl.h" 4 4 #undef WINDOW 5 6 #include <unistd.h> 5 #include "filterproc.h" 6 7 7 #include <stdio.h> 8 #include <stdlib.h>9 #include <string.h>10 8 11 9 #undef instr … … 26 24 int owl_smartfilter_regtest(void); 27 25 int owl_history_regtest(void); 26 int call_filter_regtest(void); 28 27 29 28 extern void owl_perl_xs_init(pTHX); … … 116 115 numfailures += owl_smartfilter_regtest(); 117 116 numfailures += owl_history_regtest(); 117 numfailures += call_filter_regtest(); 118 118 if (numfailures) { 119 119 fprintf(stderr, "# *** WARNING: %d failures total\n", numfailures); … … 133 133 { 134 134 int numfailed=0; 135 char * s, *path, *home;135 char *path, *home; 136 136 137 137 printf("# BEGIN testing owl_util\n"); … … 229 229 230 230 231 s = owl_util_baseclass("barnowl"); 232 FAIL_UNLESS("baseclass barnowl", !strcmp("barnowl", s)); 233 g_free(s); 234 s = owl_util_baseclass("unbarnowl"); 235 FAIL_UNLESS("baseclass unbarnowl", !strcmp("barnowl", s)); 236 g_free(s); 237 s = owl_util_baseclass("unununbarnowl.d.d"); 238 FAIL_UNLESS("baseclass unununbarnowl.d.d", !strcmp("barnowl", s)); 239 g_free(s); 240 s = owl_util_baseclass("ununun.d.d"); 241 FAIL_UNLESS("baseclass ununun.d.d", !strcmp("", s)); 242 g_free(s); 243 s = owl_util_baseclass("d.d.d.d"); 244 FAIL_UNLESS("baseclass d.d.d.d", !strcmp("d", s)); 245 g_free(s); 246 s = owl_util_baseclass("n.d.d.d"); 247 FAIL_UNLESS("baseclass n.d.d.d", !strcmp("n", s)); 248 g_free(s); 249 s = owl_util_baseclass("ununun."); 250 FAIL_UNLESS("baseclass ununun.", !strcmp(".", s)); 251 g_free(s); 252 s = owl_util_baseclass("unununu"); 253 FAIL_UNLESS("baseclass unununu", !strcmp("u", s)); 254 g_free(s); 255 256 257 s = owl_util_makepath("foo/bar"); 258 FAIL_UNLESS("makepath foo/bar", !strcmp("foo/bar", s)); 259 g_free(s); 260 s = owl_util_makepath("//foo///bar"); 261 FAIL_UNLESS("makepath //foo///bar", !strcmp("/foo/bar", s)); 262 g_free(s); 263 s = owl_util_makepath("foo/~//bar/"); 264 FAIL_UNLESS("makepath foo/~//bar/", !strcmp("foo/~/bar/", s)); 265 g_free(s); 266 s = owl_util_makepath("~thisuserhadreallybetternotexist/foobar/"); 267 FAIL_UNLESS("makepath ~thisuserhadreallybetternotexist/foobar/", 268 !strcmp("~thisuserhadreallybetternotexist/foobar/", s)); 269 g_free(s); 231 CHECK_STR_AND_FREE("baseclass barnowl", 232 "barnowl", owl_util_baseclass("barnowl")); 233 CHECK_STR_AND_FREE("baseclass unbarnowl", 234 "barnowl", owl_util_baseclass("unbarnowl")); 235 CHECK_STR_AND_FREE("baseclass unununbarnowl.d.d", 236 "barnowl", owl_util_baseclass("unununbarnowl.d.d")); 237 CHECK_STR_AND_FREE("baseclass ununun.d.d", 238 "", owl_util_baseclass("ununun.d.d")); 239 CHECK_STR_AND_FREE("baseclass d.d.d.d", 240 "d", owl_util_baseclass("d.d.d.d")); 241 CHECK_STR_AND_FREE("baseclass n.d.d.d", 242 "n", owl_util_baseclass("n.d.d.d")); 243 CHECK_STR_AND_FREE("baseclass ununun.", 244 ".", owl_util_baseclass("ununun.")); 245 CHECK_STR_AND_FREE("baseclass unununu", 246 "u", owl_util_baseclass("unununu")); 247 248 249 CHECK_STR_AND_FREE("makepath foo/bar", 250 "foo/bar", owl_util_makepath("foo/bar")); 251 CHECK_STR_AND_FREE("makepath //foo///bar", 252 "/foo/bar", owl_util_makepath("//foo///bar")); 253 CHECK_STR_AND_FREE("makepath foo/~//bar/", 254 "foo/~/bar/", owl_util_makepath("foo/~//bar/")); 255 CHECK_STR_AND_FREE("makepath ~thisuserhadreallybetternotexist/foobar/", 256 "~thisuserhadreallybetternotexist/foobar/", 257 owl_util_makepath("~thisuserhadreallybetternotexist/foobar/")); 270 258 271 259 home = g_strdup(owl_global_get_homedir(&g)); 272 s = owl_util_makepath("~"); 273 FAIL_UNLESS("makepath ~", !strcmp(home, s)); 274 g_free(s); 260 CHECK_STR_AND_FREE("makepath ~", 261 home, owl_util_makepath("~")); 275 262 276 263 path = g_build_filename(home, "foo/bar/baz", NULL); 277 s = owl_util_makepath("~///foo/bar//baz"); 278 FAIL_UNLESS("makepath ~///foo/bar//baz", !strcmp(path, s)); 279 g_free(s); 264 CHECK_STR_AND_FREE("makepath ~///foo/bar//baz", 265 path, owl_util_makepath("~///foo/bar//baz")); 280 266 g_free(path); 281 267 g_free(home); … … 288 274 } 289 275 290 s = owl_util_makepath("~root"); 291 FAIL_UNLESS("makepath ~root", !strcmp(home, s)); 292 g_free(s); 276 CHECK_STR_AND_FREE("makepath ~root", 277 home, owl_util_makepath("~root")); 293 278 294 279 path = g_build_filename(home, "foo/bar/baz", NULL); 295 s = owl_util_makepath("~root///foo/bar//baz"); 296 FAIL_UNLESS("makepath ~root///foo/bar//baz", !strcmp(path, s)); 297 g_free(s); 280 CHECK_STR_AND_FREE("makepath ~root///foo/bar//baz", 281 path, owl_util_makepath("~root///foo/bar//baz")); 298 282 g_free(path); 299 283 g_free(home); … … 353 337 int numfailed=0; 354 338 char *value; 355 const void *v;356 339 357 340 printf("# BEGIN testing owl_variable\n"); 358 FAIL_UNLESS("setup", 0==owl_variable_dict_setup(&vd));341 owl_variable_dict_setup(&vd); 359 342 360 343 FAIL_UNLESS("get bool var", NULL != (var = owl_variable_get_var(&vd, "rxping"))); … … 393 376 FAIL_UNLESS("get int 7", 9 == owl_variable_get_int(var)); 394 377 395 owl_variable_dict_newvar_string(&vd, "stringvar", "", "", "testval"); 378 FAIL_UNLESS("get enum var", NULL != (var = owl_variable_get_var(&vd, "scrollmode"))); 379 FAIL_UNLESS("get enum", OWL_SCROLLMODE_NORMAL == owl_variable_get_int(var)); 380 FAIL_UNLESS("get enum as string", 381 !strcmp((value = owl_variable_get_tostring(var)), "normal")); 382 g_free(value); 383 FAIL_UNLESS("set enum 1", 0 == owl_variable_set_int(var, OWL_SCROLLMODE_TOP)); 384 FAIL_UNLESS("get enum 1", OWL_SCROLLMODE_TOP == owl_variable_get_int(var)); 385 FAIL_UNLESS("set enum 2a", -1 == owl_variable_set_int(var, -1)); 386 FAIL_UNLESS("set enum 2b", -1 == owl_variable_set_int(var, OWL_SCROLLMODE_PAGEDCENTER + 1)); 387 FAIL_UNLESS("get enum 2", OWL_SCROLLMODE_TOP == owl_variable_get_int(var)); 388 FAIL_UNLESS("set enum 3", 0 == owl_variable_set_fromstring(var, "center", 0)); 389 FAIL_UNLESS("get enum 4", OWL_SCROLLMODE_CENTER == owl_variable_get_int(var)); 390 FAIL_UNLESS("set enum 5", -1 == owl_variable_set_fromstring(var, "bogus", 0)); 391 FAIL_UNLESS("set enum 6", -1 == owl_variable_set_fromstring(var, "", 0)); 392 FAIL_UNLESS("get enum 7", OWL_SCROLLMODE_CENTER == owl_variable_get_int(var)); 393 394 owl_variable_dict_newvar_string(&vd, "stringvar", "testval", "", ""); 396 395 FAIL_UNLESS("get new string var", NULL != (var = owl_variable_get_var(&vd, "stringvar"))); 397 FAIL_UNLESS("get new string var", NULL != (v = owl_variable_get(var)));398 396 FAIL_UNLESS("get new string val", !strcmp("testval", owl_variable_get_string(var))); 399 397 owl_variable_set_string(var, "new val"); 400 398 FAIL_UNLESS("update string val", !strcmp("new val", owl_variable_get_string(var))); 401 399 402 owl_variable_dict_newvar_int(&vd, "intvar", "", "", 47);400 owl_variable_dict_newvar_int(&vd, "intvar", 47, "", ""); 403 401 FAIL_UNLESS("get new int var", NULL != (var = owl_variable_get_var(&vd, "intvar"))); 404 FAIL_UNLESS("get new int var", NULL != (v = owl_variable_get(var)));405 402 FAIL_UNLESS("get new int val", 47 == owl_variable_get_int(var)); 406 403 owl_variable_set_int(var, 17); 407 404 FAIL_UNLESS("update int val", 17 == owl_variable_get_int(var)); 408 405 409 owl_variable_dict_newvar_bool(&vd, "boolvar", "", "", 1);406 owl_variable_dict_newvar_bool(&vd, "boolvar", true, "", ""); 410 407 FAIL_UNLESS("get new bool var", NULL != (var = owl_variable_get_var(&vd, "boolvar"))); 411 FAIL_UNLESS("get new bool var", NULL != (v = owl_variable_get(var)));412 408 FAIL_UNLESS("get new bool val", owl_variable_get_bool(var)); 413 409 owl_variable_set_bool_off(var); 414 410 FAIL_UNLESS("update bool val", !owl_variable_get_bool(var)); 415 411 416 owl_variable_dict_newvar_string(&vd, "nullstringvar", "", "", NULL);412 owl_variable_dict_newvar_string(&vd, "nullstringvar", NULL, "", ""); 417 413 FAIL_UNLESS("get new string (NULL) var", NULL != (var = owl_variable_get_var(&vd, "nullstringvar"))); 418 414 FAIL_UNLESS("get string (NULL)", NULL == (value = owl_variable_get_tostring(var))); … … 421 417 FAIL_UNLESS("get string (NULL) 2", NULL == (value = owl_variable_get_tostring(var))); 422 418 g_free(value); 419 420 owl_variable_dict_newvar_enum(&vd, "enumvar", 0, "", "", "a,b,c,d"); 421 FAIL_UNLESS("get new enum var", NULL != (var = owl_variable_get_var(&vd, "enumvar"))); 422 FAIL_UNLESS("get new enum val", 0 == owl_variable_get_int(var)); 423 owl_variable_set_fromstring(var, "c", 0); 424 FAIL_UNLESS("update enum val", 2 == owl_variable_get_int(var)); 423 425 424 426 owl_variable_dict_cleanup(&vd); … … 515 517 FAIL_UNLESS("DAG", (f5 = owl_filter_new_fromstring("dag", "filter f1 or filter f1")) != NULL); 516 518 owl_filter_delete(f5); 519 520 owl_message_cleanup(&m); 517 521 518 522 return 0; … … 982 986 return numfailed; 983 987 } 988 989 int call_filter_regtest(void) 990 { 991 int numfailed = 0; 992 int ret; 993 char *out = NULL; 994 int status; 995 996 printf("# BEGIN testing call_filter\n"); 997 998 const char *cat_argv[] = { "cat", NULL }; 999 ret = call_filter(cat_argv, "Mangos!", &out, &status); 1000 FAIL_UNLESS("call_filter cat", (ret == 0 && 1001 status == 0 && 1002 strcmp(out, "Mangos!") == 0)); 1003 g_free(out); out = NULL; 1004 1005 ret = call_filter(cat_argv, "", &out, &status); 1006 FAIL_UNLESS("call_filter cat", (ret == 0 && 1007 status == 0 && 1008 strcmp(out, "") == 0)); 1009 g_free(out); out = NULL; 1010 1011 ret = call_filter(cat_argv, NULL, &out, &status); 1012 FAIL_UNLESS("call_filter cat", (ret == 0 && 1013 status == 0 && 1014 strcmp(out, "") == 0)); 1015 g_free(out); out = NULL; 1016 1017 printf("# END testing call_filter (%d failures)\n", numfailed); 1018 return numfailed; 1019 } -
text.c
r14be3a5 rf271129 1 #include <stdio.h>2 #include <string.h>3 #include <stdlib.h>4 #include <ctype.h>5 1 #include "owl.h" 6 2 -
util.c
r4ebbfbc r7b89e8c 1 1 #include "owl.h" 2 #include <stdlib.h>3 #include <string.h>4 #include <unistd.h>5 #include <ctype.h>6 2 #include <pwd.h> 7 3 #include <sys/stat.h> 8 #include <sys/types.h>9 #include <assert.h>10 4 #include <stdarg.h> 11 #include <glib.h>12 5 #include <glib/gstdio.h> 13 6 #include <glib-object.h> … … 269 262 CALLER_OWN char *owl_arg_quote(const char *arg) 270 263 { 271 GString *buf = g_string_new(""); ;264 GString *buf = g_string_new(""); 272 265 owl_string_append_quoted_arg(buf, arg); 273 266 return g_string_free(buf, false); 274 267 } 275 268 269 /* Returns a quoted version of argv. owl_parseline on the result should give 270 * back the input. */ 271 CALLER_OWN char *owl_argv_quote(int argc, const char *const *argv) 272 { 273 int i; 274 GString *buf = g_string_new(""); 275 for (i = 0; i < argc; i++) { 276 if (i > 0) 277 g_string_append_c(buf, ' '); 278 owl_string_append_quoted_arg(buf, argv[i]); 279 } 280 return g_string_free(buf, false); 281 } 282 276 283 /* caller must free the return */ 277 CALLER_OWN char *owl_util_ minutes_to_timestr(int in)284 CALLER_OWN char *owl_util_format_minutes(int in) 278 285 { 279 286 int days, hours; … … 296 303 } 297 304 298 CALLER_OWN char *owl_util_ time_to_timestr(const struct tm *time)305 CALLER_OWN char *owl_util_format_time(const struct tm *time) 299 306 { 300 307 /* 32 chosen for first attempt because timestr will end up being -
variable.c
r6f7d4f6 r9d4dfdc 1 #include "owl.h" 1 2 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 #include <unistd.h> 5 #include <ctype.h> 6 #include "owl.h" 7 8 #define OWLVAR_BOOL(name,default,summary,description) \ 9 { g_strdup(name), OWL_VARIABLE_BOOL, NULL, default, "on,off", g_strdup(summary), g_strdup(description), NULL, \ 10 NULL, NULL, NULL, NULL, NULL, NULL } 11 12 #define OWLVAR_BOOL_FULL(name,default,summary,description,validate,set,get) \ 13 { g_strdup(name), OWL_VARIABLE_BOOL, NULL, default, "on,off", g_strdup(summary), g_strdup(description), NULL, \ 14 validate, set, NULL, get, NULL, NULL } 15 16 #define OWLVAR_INT(name,default,summary,description) \ 17 { g_strdup(name), OWL_VARIABLE_INT, NULL, default, "<int>", g_strdup(summary), g_strdup(description), NULL, \ 18 NULL, NULL, NULL, NULL, NULL, NULL } 3 #include "gmarshal_funcs.h" 4 5 /* TODO(davidben): When we can require 2.30 and up, remove this. */ 6 #ifndef G_VALUE_INIT 7 #define G_VALUE_INIT { 0, { { 0 } } } 8 #endif 9 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) 19 70 20 71 #define OWLVAR_INT_FULL(name,default,summary,description,validset,validate,set,get) \ 21 { g_strdup(name), OWL_VARIABLE_INT, NULL, default, validset, g_strdup(summary), g_strdup(description), NULL, \ 22 validate, set, NULL, get, NULL, NULL } 23 24 #define OWLVAR_PATH(name,default,summary,description) \ 25 { g_strdup(name), OWL_VARIABLE_STRING, g_strdup(default), 0, "<path>", g_strdup(summary), g_strdup(description), NULL, \ 26 NULL, NULL, NULL, NULL, NULL, NULL } 27 28 #define OWLVAR_STRING(name,default,summary,description) \ 29 { g_strdup(name), OWL_VARIABLE_STRING, g_strdup(default), 0, "<string>", g_strdup(summary), g_strdup(description), NULL, \ 30 NULL, NULL, NULL, NULL, NULL, NULL } 31 32 #define OWLVAR_STRING_FULL(name,default,validset,summary,description,validate,set,get) \ 33 { g_strdup(name), OWL_VARIABLE_STRING, g_strdup(default), 0, validset, g_strdup(summary), g_strdup(description), NULL, \ 34 validate, set, NULL, get, NULL, NULL } 72 owl_variable_dict_newvar_int_full(vd, name, default, summary, description, \ 73 validset, validate, set, get) 74 75 #define OWLVAR_PATH(name, default, summary, description) \ 76 owl_variable_dict_newvar_path(vd, name, default, summary, description) 77 78 #define OWLVAR_STRING(name, default, summary, description) \ 79 owl_variable_dict_newvar_string(vd, name, default, summary, description) 80 81 #define OWLVAR_STRING_FULL(name, default, validset, summary, description, validate, set, get) \ 82 owl_variable_dict_newvar_string_full(vd, name, default, summary, description, \ 83 validset, validate, set, get) 35 84 36 85 /* enums are really integers, but where validset is a comma-separated 37 86 * list of strings which can be specified. The tokens, starting at 0, 38 87 * correspond to the values that may be specified. */ 39 #define OWLVAR_ENUM(name,default,summary,description,validset) \ 40 { g_strdup(name), OWL_VARIABLE_INT, NULL, default, validset, g_strdup(summary), g_strdup(description), NULL, \ 41 owl_variable_enum_validate, \ 42 NULL, owl_variable_enum_set_fromstring, \ 43 NULL, owl_variable_enum_get_tostring, \ 44 NULL } 88 #define OWLVAR_ENUM(name, default, summary, description, validset) \ 89 owl_variable_dict_newvar_enum(vd, name, default, summary, description, validset) 45 90 46 91 #define OWLVAR_ENUM_FULL(name,default,summary,description,validset,validate, set, get) \ 47 { g_strdup(name), OWL_VARIABLE_INT, NULL, default, validset, g_strdup(summary), g_strdup(description), NULL, \ 48 validate, \ 49 set, owl_variable_enum_set_fromstring, \ 50 get, owl_variable_enum_get_tostring, \ 51 NULL } 52 53 int owl_variable_add_defaults(owl_vardict *vd) 54 { 55 owl_variable variables_to_init[] = { 56 92 owl_variable_dict_newvar_enum_full(vd, name, default, summary, description, \ 93 validset, validate, set, get) 94 95 void owl_variable_add_defaults(owl_vardict *vd) 96 { 57 97 OWLVAR_STRING( "personalbell" /* %OwlVarStub */, "off", 58 98 "ring the terminal bell when personal messages are received", 59 99 "Can be set to 'on', 'off', or the name of a filter which\n" 60 "messages need to match in order to ring the bell") ,100 "messages need to match in order to ring the bell"); 61 101 62 102 OWLVAR_BOOL( "bell" /* %OwlVarStub */, 1, 63 "enable / disable the terminal bell", "" ) ,103 "enable / disable the terminal bell", "" ); 64 104 65 105 OWLVAR_BOOL_FULL( "debug" /* %OwlVarStub */, OWL_DEBUG, … … 67 107 "If set to 'on', debugging messages are logged to the\n" 68 108 "file specified by the debugfile variable.\n", 69 NULL, owl_variable_debug_set, NULL) ,109 NULL, owl_variable_debug_set, NULL); 70 110 71 111 OWLVAR_BOOL( "startuplogin" /* %OwlVarStub */, 1, 72 "send a login message when BarnOwl starts", "" ) ,112 "send a login message when BarnOwl starts", "" ); 73 113 74 114 OWLVAR_BOOL( "shutdownlogout" /* %OwlVarStub */, 1, 75 "send a logout message when BarnOwl exits", "" ) ,115 "send a logout message when BarnOwl exits", "" ); 76 116 77 117 OWLVAR_BOOL( "rxping" /* %OwlVarStub */, 0, 78 "display received pings", "" ) ,118 "display received pings", "" ); 79 119 80 120 OWLVAR_BOOL( "txping" /* %OwlVarStub */, 1, 81 "send pings", "" ) ,121 "send pings", "" ); 82 122 83 123 OWLVAR_BOOL( "sepbar_disable" /* %OwlVarStub */, 0, 84 "disable printing information in the separator bar", "" ) ,124 "disable printing information in the separator bar", "" ); 85 125 86 126 OWLVAR_BOOL( "smartstrip" /* %OwlVarStub */, 1, 87 "strip kerberos instance for reply", "") ,127 "strip kerberos instance for reply", ""); 88 128 89 129 OWLVAR_BOOL( "newlinestrip" /* %OwlVarStub */, 1, 90 "strip leading and trailing newlines", "") ,130 "strip leading and trailing newlines", ""); 91 131 92 132 OWLVAR_BOOL( "displayoutgoing" /* %OwlVarStub */, 1, 93 "display outgoing messages", "" ) ,133 "display outgoing messages", "" ); 94 134 95 135 OWLVAR_BOOL( "loginsubs" /* %OwlVarStub */, 1, 96 "load logins from .anyone on startup", "" ) ,136 "load logins from .anyone on startup", "" ); 97 137 98 138 OWLVAR_BOOL( "logging" /* %OwlVarStub */, 0, … … 101 141 "logged in the directory specified\n" 102 142 "by the 'logpath' variable. The filename in that\n" 103 "directory is derived from the sender of the message.\n" ) ,143 "directory is derived from the sender of the message.\n" ); 104 144 105 145 OWLVAR_BOOL( "classlogging" /* %OwlVarStub */, 0, … … 109 149 "by the 'classlogpath' variable.\n" 110 150 "The filename in that directory is derived from\n" 111 "the name of the class to which the message was sent.\n" ) ,151 "the name of the class to which the message was sent.\n" ); 112 152 113 153 OWLVAR_ENUM( "loggingdirection" /* %OwlVarStub */, OWL_LOGGING_DIRECTION_BOTH, … … 118 158 "is selected both incoming and outgoing messages are\n" 119 159 "logged.", 120 "both,in,out"), 121 122 OWLVAR_BOOL( "colorztext" /* %OwlVarStub */, 1, 123 "allow @color() in zephyrs to change color", 124 "Note that only messages received after this variable\n" 125 "is set will be affected." ), 160 "both,in,out"); 161 162 OWLVAR_BOOL_FULL( "colorztext" /* %OwlVarStub */, 1, 163 "allow @color() in zephyrs to change color", 164 NULL, NULL, owl_variable_colorztext_set, NULL); 126 165 127 166 OWLVAR_BOOL( "fancylines" /* %OwlVarStub */, 1, … … 129 168 "If turned off, dashes, pipes and pluses will be used\n" 130 169 "to draw lines on the screen. Useful when the terminal\n" 131 "is causing problems" ) ,170 "is causing problems" ); 132 171 133 172 OWLVAR_BOOL( "zcrypt" /* %OwlVarStub */, 1, 134 173 "Do automatic zcrypt processing", 135 "" ) ,174 "" ); 136 175 137 176 OWLVAR_BOOL_FULL( "pseudologins" /* %OwlVarStub */, 0, … … 141 180 "but sent no login message, or a user is not present that sent no\n" 142 181 "logout message, a pseudo login or logout message will be created\n", 143 NULL, owl_variable_pseudologins_set, NULL) ,182 NULL, owl_variable_pseudologins_set, NULL); 144 183 145 184 OWLVAR_BOOL( "ignorelogins" /* %OwlVarStub */, 0, … … 147 186 "When this is enabled, BarnOwl will print login and logout notifications\n" 148 187 "for AIM, zephyr, or other protocols. If disabled BarnOwl will not print\n" 149 "login or logout notifications.\n") ,188 "login or logout notifications.\n"); 150 189 151 190 OWLVAR_STRING( "logfilter" /* %OwlVarStub */, "", … … 156 195 "variables like logging, classlogging, loglogins, loggingdirection,\n" 157 196 "etc. If you want this variable to control all logging, make sure\n" 158 "all other logging variables are in their default state.\n") ,197 "all other logging variables are in their default state.\n"); 159 198 160 199 OWLVAR_BOOL( "loglogins" /* %OwlVarStub */, 0, … … 162 201 "When this is enabled, BarnOwl will log login and logout notifications\n" 163 202 "for AIM, zephyr, or other protocols. If disabled BarnOwl will not print\n" 164 "login or logout notifications.\n") ,203 "login or logout notifications.\n"); 165 204 166 205 OWLVAR_ENUM_FULL( "disable-ctrl-d" /* %OwlVarStub:lockout_ctrld */, 1, 167 206 "don't send zephyrs on C-d", 168 "If set to 'o ff', C-d won't send a zephyr from the edit\n"169 "window. If set to 'o n', C-d will always send a zephyr\n"207 "If set to 'on', C-d won't send a zephyr from the edit\n" 208 "window. If set to 'off', C-d will always send a zephyr\n" 170 209 "being composed in the edit window. If set to 'middle',\n" 171 210 "C-d will only ever send a zephyr if the cursor is at\n" … … 174 213 "in the editmulti keymap.\n", 175 214 "off,middle,on", 176 NULL, owl_variable_disable_ctrl_d_set, NULL) ,215 NULL, owl_variable_disable_ctrl_d_set, NULL); 177 216 178 217 OWLVAR_PATH( "logpath" /* %OwlVarStub */, "~/zlog/people", 179 218 "path for logging personal zephyrs", 180 219 "Specifies a directory which must exist.\n" 181 "Files will be created in the directory for each sender.\n") ,220 "Files will be created in the directory for each sender.\n"); 182 221 183 222 OWLVAR_PATH( "classlogpath" /* %OwlVarStub:classlogpath */, "~/zlog/class", 184 223 "path for logging class zephyrs", 185 224 "Specifies a directory which must exist.\n" 186 "Files will be created in the directory for each class.\n") ,225 "Files will be created in the directory for each class.\n"); 187 226 188 227 OWLVAR_PATH( "debug_file" /* %OwlVarStub */, OWL_DEBUG_FILE, 189 228 "path for logging debug messages when debugging is enabled", 190 229 "This file will be logged to if 'debug' is set to 'on'.\n" 191 "BarnOwl will append a dot and the current process's pid to the filename.") ,230 "BarnOwl will append a dot and the current process's pid to the filename."); 192 231 193 232 OWLVAR_PATH( "zsigproc" /* %OwlVarStub:zsigproc */, NULL, … … 197 236 "See the documentation for 'zsig' for more information about\n" 198 237 "how the outgoing zsig is chosen." 199 ) ,238 ); 200 239 201 240 OWLVAR_PATH( "newmsgproc" /* %OwlVarStub:newmsgproc */, NULL, … … 203 242 "The named program will be run when BarnOwl receives new\n" 204 243 "messages. It will not be run again until the first\n" 205 "instance exits") ,244 "instance exits"); 206 245 207 246 OWLVAR_STRING( "zsender" /* %OwlVarStub */, "", … … 210 249 "zephyrs. If this is unset, it will use your Kerberos\n" 211 250 "principal. Note that customizing the sender name will\n" 212 "cause your zephyrs to be sent unauthenticated.") ,251 "cause your zephyrs to be sent unauthenticated."); 213 252 214 253 OWLVAR_STRING( "zsigfunc" /* %OwlVarStub */, "BarnOwl::default_zephyr_signature()", … … 217 256 "explicit zsig. The default setting implements the policy\n" 218 257 "described in the documentation for the 'zsig' variable.\n" 219 "See also BarnOwl::random_zephyr_signature().\n") ,258 "See also BarnOwl::random_zephyr_signature().\n"); 220 259 221 260 OWLVAR_STRING( "zsig" /* %OwlVarStub */, "", … … 224 263 "unset, 'zsigproc' will be run to generate a zsig. If that is\n" 225 264 "also unset, the 'zwrite-signature' zephyr variable will be\n" 226 "used instead.\n") ,265 "used instead.\n"); 227 266 228 267 OWLVAR_STRING( "appendtosepbar" /* %OwlVarStub */, "", … … 230 269 "The sepbar is the bar separating the top and bottom\n" 231 270 "of the BarnOwl screen. Any string specified here will\n" 232 "be displayed on the right of the sepbar\n") ,271 "be displayed on the right of the sepbar\n"); 233 272 234 273 OWLVAR_BOOL( "zaway" /* %OwlVarStub */, 0, 235 "turn zaway on or off", "" ) ,274 "turn zaway on or off", "" ); 236 275 237 276 OWLVAR_STRING( "zaway_msg" /* %OwlVarStub */, 238 277 OWL_DEFAULT_ZAWAYMSG, 239 "zaway msg for responding to zephyrs when away", "" ) ,278 "zaway msg for responding to zephyrs when away", "" ); 240 279 241 280 OWLVAR_STRING( "zaway_msg_default" /* %OwlVarStub */, 242 281 OWL_DEFAULT_ZAWAYMSG, 243 "default zaway message", "" ) ,282 "default zaway message", "" ); 244 283 245 284 OWLVAR_BOOL_FULL( "aaway" /* %OwlVarStub */, 0, 246 285 "Set AIM away status", 247 286 "", 248 NULL, owl_variable_aaway_set, NULL) ,287 NULL, owl_variable_aaway_set, NULL); 249 288 250 289 OWLVAR_STRING( "aaway_msg" /* %OwlVarStub */, 251 290 OWL_DEFAULT_AAWAYMSG, 252 "AIM away msg for responding when away", "" ) ,291 "AIM away msg for responding when away", "" ); 253 292 254 293 OWLVAR_STRING( "aaway_msg_default" /* %OwlVarStub */, 255 294 OWL_DEFAULT_AAWAYMSG, 256 "default AIM away message", "" ) ,295 "default AIM away message", "" ); 257 296 258 297 OWLVAR_STRING( "view_home" /* %OwlVarStub */, "all", 259 298 "home view to switch to after 'X' and 'V'", 260 "SEE ALSO: view, filter\n" ) ,299 "SEE ALSO: view, filter\n" ); 261 300 262 301 OWLVAR_STRING( "alert_filter" /* %OwlVarStub */, "none", 263 302 "filter on which to trigger alert actions", 264 "" ) ,303 "" ); 265 304 266 305 OWLVAR_STRING( "alert_action" /* %OwlVarStub */, "nop", 267 306 "BarnOwl command to execute for alert actions", 268 "" ) ,307 "" ); 269 308 270 309 OWLVAR_STRING_FULL( "tty" /* %OwlVarStub */, "", "<string>", "tty name for zephyr location", "", 271 NULL, owl_variable_tty_set, NULL) ,310 NULL, owl_variable_tty_set, NULL); 272 311 273 312 OWLVAR_STRING( "default_style" /* %OwlVarStub */, "default", … … 280 319 " perl - legacy perl interface\n" 281 320 "\nSEE ALSO: style, show styles, view -s <style>\n" 282 ) ,321 ); 283 322 284 323 … … 287 326 "This specifies the maximum number of columns for M-q to fill text\n" 288 327 "to. If set to 0, M-q will wrap to the width of the window, and\n" 289 "values less than 0 disable M-q entirely.\n") ,328 "values less than 0 disable M-q entirely.\n"); 290 329 291 330 OWLVAR_INT( "edit:maxwrapcols" /* %OwlVarStub:edit_maxwrapcols */, 70, … … 296 335 "\n" 297 336 "As a courtesy to recipients, it is recommended that outgoing\n" 298 "Zephyr messages be no wider than 70 columns.\n") ,337 "Zephyr messages be no wider than 70 columns.\n"); 299 338 300 339 OWLVAR_INT( "aim_ignorelogin_timer" /* %OwlVarStub */, 15, … … 303 342 "AIM login before allowing the receipt of AIM login notifications.\n" 304 343 "By default this is set to 15. If you would like to view login\n" 305 "notifications of buddies as soon as you login, set it to 0 instead.") ,344 "notifications of buddies as soon as you login, set it to 0 instead."); 306 345 307 346 … … 316 355 owl_variable_typewinsize_set, 317 356 NULL /* use default for get */ 318 ) ,357 ); 319 358 320 359 OWLVAR_INT( "typewindelta" /* %OwlVarStub */, 0, … … 326 365 "typewinsize to 1.\n\n" 327 366 "This works a lot better with a non-default scrollmode;\n" 328 "try :set scrollmode pagedcenter.\n") ,367 "try :set scrollmode pagedcenter.\n"); 329 368 330 369 OWLVAR_ENUM( "scrollmode" /* %OwlVarStub */, OWL_SCROLLMODE_NORMAL, … … 355 394 " the screen will be paged up or down and\n" 356 395 " the cursor will be near the center.\n", 357 "normal,top,neartop,center,paged,pagedcenter" ) ,396 "normal,top,neartop,center,paged,pagedcenter" ); 358 397 359 398 OWLVAR_BOOL( "narrow-related" /* %OwlVarStub:narrow_related */, 1, 360 399 "Make smartnarrow use broader filters", 361 "Causes smartfil er to narrow to messages \"related\" to \n"400 "Causes smartfilter to narrow to messages \"related\" to \n" 362 401 "the current message, as well as ones to the same place.\n\n" 363 402 "for Zephyr, this controls whether to narrow to e.g. class-help or\n" 364 403 "class-help.d alone, or to related-class-help, which includes\n" 365 "help, unhelp, help.d, etc.\n\nDefault is true (include unclasses, etc.).\n" ) ,404 "help, unhelp, help.d, etc.\n\nDefault is true (include unclasses, etc.).\n" ); 366 405 367 406 OWLVAR_BOOL( "_followlast" /* %OwlVarStub */, 0, … … 370 409 "continue to follow the last message if this is set.\n" 371 410 "Note that this is currently risky as you might accidentally\n" 372 "delete a message right as it came in.\n" ) ,411 "delete a message right as it came in.\n" ); 373 412 374 413 OWLVAR_STRING_FULL( "default_exposure" /* %OwlVarStub */, "", … … 379 418 "~/.zephyr.vars.\n" 380 419 "See the description of exposure for the values this can be.", 381 NULL, owl_variable_default_exposure_set, owl_variable_default_exposure_get ) ,420 NULL, owl_variable_default_exposure_set, owl_variable_default_exposure_get ); 382 421 383 422 OWLVAR_STRING_FULL( "exposure" /* %OwlVarStub */, "", … … 435 474 " personal subscriptions will be entered for the\n" 436 475 " user.\n", 437 NULL, owl_variable_exposure_set, NULL /* use default for get */ ), 438 439 /* This MUST be last... */ 440 { NULL, 0, NULL, 0, NULL, NULL, NULL, NULL, 441 NULL, NULL, NULL, NULL, NULL, NULL } 442 443 }; 444 445 int ret = owl_variable_dict_add_from_list(vd, variables_to_init); 446 owl_variable *var; 447 for (var = variables_to_init; var->name != NULL; var++) 448 owl_variable_cleanup(var); 449 return ret; 476 NULL, owl_variable_exposure_set, NULL /* use default for get */ ); 450 477 } 451 478 … … 457 484 /* commonly useful */ 458 485 459 int owl_variable_int_validate_gt0(const owl_variable *v, const void *newval) 460 { 461 if (newval == NULL) return(0); 462 else if (*(const int*)newval < 1) return(0); 463 else return (1); 464 } 465 466 int owl_variable_int_validate_positive(const owl_variable *v, const void *newval) 467 { 468 if (newval == NULL) return(0); 469 else if (*(const int*)newval < 0) return(0); 470 else return (1); 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); 471 494 } 472 495 473 496 /* typewinsize */ 474 int owl_variable_typewinsize_set(owl_variable *v, const void *newval)497 int owl_variable_typewinsize_set(owl_variable *v, int newval) 475 498 { 476 499 int rv; … … 481 504 482 505 /* debug (cache value in g->debug) */ 483 int owl_variable_debug_set(owl_variable *v, const void *newval) 484 { 485 if (newval && (*(const int*)newval == 1 || *(const int*)newval == 0)) { 486 g.debug = *(const int*)newval; 506 int owl_variable_debug_set(owl_variable *v, bool newval) 507 { 508 g.debug = newval; 509 return owl_variable_bool_set_default(v, newval); 510 } 511 512 /* When 'aaway' is changed, need to notify the AIM server */ 513 int owl_variable_aaway_set(owl_variable *v, bool newval) 514 { 515 if (newval) { 516 owl_aim_set_awaymsg(owl_global_get_aaway_msg(&g)); 517 } else { 518 owl_aim_set_awaymsg(""); 487 519 } 488 520 return owl_variable_bool_set_default(v, newval); 489 521 } 490 522 491 /* When 'aaway' is changed, need to notify the AIM server */ 492 int owl_variable_aaway_set(owl_variable *v, const void *newval) 493 { 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) 537 { 538 static guint timer = 0; 494 539 if (newval) { 495 if (*(const int*)newval == 1) { 496 owl_aim_set_awaymsg(owl_global_get_aaway_msg(&g)); 497 } else if (*(const int*)newval == 0) { 498 owl_aim_set_awaymsg(""); 540 owl_function_zephyr_buddy_check(0); 541 if (timer == 0) { 542 timer = g_timeout_add_seconds(180, owl_zephyr_buddycheck_timer, NULL); 543 } 544 } else { 545 if (timer != 0) { 546 g_source_remove(timer); 547 timer = 0; 499 548 } 500 549 } … … 502 551 } 503 552 504 int owl_variable_pseudologins_set(owl_variable *v, const void *newval)505 {506 static guint timer = 0;507 if (newval) {508 if (*(const int*)newval == 1) {509 owl_function_zephyr_buddy_check(0);510 if (timer == 0) {511 timer = g_timeout_add_seconds(180, owl_zephyr_buddycheck_timer, NULL);512 }513 } else {514 if (timer != 0) {515 g_source_remove(timer);516 timer = 0;517 }518 }519 }520 return owl_variable_bool_set_default(v, newval);521 }522 523 553 /* note that changing the value of this will clobber 524 554 * any user setting of this */ 525 int owl_variable_disable_ctrl_d_set(owl_variable *v, const void *newval)526 { 527 if ( newval &&!owl_context_is_startup(owl_global_get_context(&g))) {528 if ( *(const int*)newval == 2) {555 int owl_variable_disable_ctrl_d_set(owl_variable *v, int newval) 556 { 557 if (!owl_context_is_startup(owl_global_get_context(&g))) { 558 if (newval == 2) { 529 559 owl_function_command_norv("bindkey editmulti C-d command edit:delete-next-char"); 530 } else if ( *(const int*)newval == 1) {560 } else if (newval == 1) { 531 561 owl_function_command_norv("bindkey editmulti C-d command edit:done-or-delete"); 532 562 } else { … … 534 564 } 535 565 } 536 return owl_variable_int_set_default(v, newval); 537 } 538 539 int owl_variable_tty_set(owl_variable *v, const void*newval)566 return owl_variable_int_set_default(v, newval); 567 } 568 569 int owl_variable_tty_set(owl_variable *v, const char *newval) 540 570 { 541 571 owl_zephyr_set_locationinfo(g_get_host_name(), newval); 542 return (owl_variable_string_set_default(v, newval));543 } 544 545 int owl_variable_default_exposure_set(owl_variable *v, const void*newval)572 return owl_variable_string_set_default(v, newval); 573 } 574 575 int owl_variable_default_exposure_set(owl_variable *v, const char *newval) 546 576 { 547 577 return owl_zephyr_set_default_exposure(newval); 548 578 } 549 579 550 const void*owl_variable_default_exposure_get(const owl_variable *v)580 const char *owl_variable_default_exposure_get(const owl_variable *v) 551 581 { 552 582 return owl_zephyr_get_default_exposure(); 553 583 } 554 584 555 int owl_variable_exposure_set(owl_variable *v, const void*newval)585 int owl_variable_exposure_set(owl_variable *v, const char *newval) 556 586 { 557 587 int ret = owl_zephyr_set_exposure(newval); … … 565 595 /**************************************************************************/ 566 596 567 intowl_variable_dict_setup(owl_vardict *vd) {597 void owl_variable_dict_setup(owl_vardict *vd) { 568 598 owl_dict_create(vd); 569 return owl_variable_add_defaults(vd); 570 } 571 572 int owl_variable_dict_add_from_list(owl_vardict *vd, owl_variable *variables_to_init) 573 { 574 owl_variable *var, *cur; 575 for (var = variables_to_init; var->name != NULL; var++) { 576 cur = g_new(owl_variable, 1); 577 *cur = *var; 578 /* strdup all the strings so we can delete them consistently. */ 579 cur->name = g_strdup(var->name); 580 cur->summary = g_strdup(var->summary); 581 cur->description = g_strdup(var->description); 582 switch (cur->type) { 583 case OWL_VARIABLE_OTHER: 584 cur->set_fn(cur, cur->pval_default); 585 break; 586 case OWL_VARIABLE_STRING: 587 if (!cur->validate_fn) 588 cur->validate_fn = owl_variable_string_validate_default; 589 if (!cur->set_fn) 590 cur->set_fn = owl_variable_string_set_default; 591 if (!cur->set_fromstring_fn) 592 cur->set_fromstring_fn = owl_variable_string_set_fromstring_default; 593 if (!cur->get_fn) 594 cur->get_fn = owl_variable_get_default; 595 if (!cur->get_tostring_fn) 596 cur->get_tostring_fn = owl_variable_string_get_tostring_default; 597 if (!cur->delete_fn) 598 cur->delete_fn = owl_variable_delete_default; 599 cur->pval_default = g_strdup(var->pval_default); 600 cur->set_fn(cur, cur->pval_default); 601 break; 602 case OWL_VARIABLE_BOOL: 603 if (!cur->validate_fn) 604 cur->validate_fn = owl_variable_bool_validate_default; 605 if (!cur->set_fn) 606 cur->set_fn = owl_variable_bool_set_default; 607 if (!cur->set_fromstring_fn) 608 cur->set_fromstring_fn = owl_variable_bool_set_fromstring_default; 609 if (!cur->get_fn) 610 cur->get_fn = owl_variable_get_default; 611 if (!cur->get_tostring_fn) 612 cur->get_tostring_fn = owl_variable_bool_get_tostring_default; 613 if (!cur->delete_fn) 614 cur->delete_fn = owl_variable_delete_default; 615 cur->val = g_new(int, 1); 616 cur->set_fn(cur, &cur->ival_default); 617 break; 618 case OWL_VARIABLE_INT: 619 if (!cur->validate_fn) 620 cur->validate_fn = owl_variable_int_validate_default; 621 if (!cur->set_fn) 622 cur->set_fn = owl_variable_int_set_default; 623 if (!cur->set_fromstring_fn) 624 cur->set_fromstring_fn = owl_variable_int_set_fromstring_default; 625 if (!cur->get_fn) 626 cur->get_fn = owl_variable_get_default; 627 if (!cur->get_tostring_fn) 628 cur->get_tostring_fn = owl_variable_int_get_tostring_default; 629 if (!cur->delete_fn) 630 cur->delete_fn = owl_variable_delete_default; 631 cur->val = g_new(int, 1); 632 cur->set_fn(cur, &cur->ival_default); 633 break; 634 default: 635 fprintf(stderr, "owl_variable_setup: invalid variable type\n"); 636 return(-2); 637 } 638 owl_dict_insert_element(vd, cur->name, cur, NULL); 639 } 640 return 0; 599 owl_variable_add_defaults(vd); 600 } 601 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; 641 610 } 642 611 643 612 void owl_variable_dict_add_variable(owl_vardict * vardict, 644 613 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 } 645 620 owl_dict_insert_element(vardict, var->name, var, (void (*)(void *))owl_variable_delete); 646 } 647 648 CALLER_OWN owl_variable *owl_variable_newvar(const char *name, const char *summary, const char *description) 649 { 650 owl_variable * var = g_new0(owl_variable, 1); 621 /* Restore the old value. */ 622 if (oldvalue) { 623 owl_variable_set_fromstring(var, oldvalue, 0); 624 g_free(oldvalue); 625 } 626 } 627 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_new0(owl_variable, 1); 630 var->type = type; 651 631 var->name = g_strdup(name); 652 632 var->summary = g_strdup(summary); 653 633 var->description = g_strdup(description); 634 var->validsettings = g_strdup(validsettings); 654 635 return var; 655 636 } 656 637 657 void owl_variable_update(owl_variable *var, const char *summary, const char *desc) { 658 g_free(var->summary); 659 var->summary = g_strdup(summary); 660 g_free(var->description); 661 var->description = g_strdup(desc); 662 } 663 664 void owl_variable_dict_newvar_string(owl_vardict *vd, const char *name, const char *summ, const char *desc, const char *initval) 665 { 666 owl_variable *old = owl_variable_get_var(vd, name); 667 if (old && owl_variable_get_type(old) == OWL_VARIABLE_STRING) { 668 owl_variable_update(old, summ, desc); 669 g_free(old->pval_default); 670 old->pval_default = g_strdup(initval); 671 } else { 672 owl_variable * var = owl_variable_newvar(name, summ, desc); 673 var->type = OWL_VARIABLE_STRING; 674 var->validsettings = "<string>"; 675 var->pval_default = g_strdup(initval); 676 var->set_fn = owl_variable_string_set_default; 677 var->set_fromstring_fn = owl_variable_string_set_fromstring_default; 678 var->get_fn = owl_variable_get_default; 679 var->get_tostring_fn = owl_variable_string_get_tostring_default; 680 var->delete_fn = owl_variable_delete_default; 681 var->set_fn(var, initval); 682 owl_variable_dict_add_variable(vd, var); 683 } 684 } 685 686 void owl_variable_dict_newvar_int(owl_vardict *vd, const char *name, const char *summ, const char *desc, int initval) 687 { 688 owl_variable *old = owl_variable_get_var(vd, name); 689 if (old && owl_variable_get_type(old) == OWL_VARIABLE_INT) { 690 owl_variable_update(old, summ, desc); 691 old->ival_default = initval; 692 } else { 693 owl_variable * var = owl_variable_newvar(name, summ, desc); 694 var->type = OWL_VARIABLE_INT; 695 var->validsettings = "<int>"; 696 var->ival_default = initval; 697 var->validate_fn = owl_variable_int_validate_default; 698 var->set_fn = owl_variable_int_set_default; 699 var->set_fromstring_fn = owl_variable_int_set_fromstring_default; 700 var->get_fn = owl_variable_get_default; 701 var->get_tostring_fn = owl_variable_int_get_tostring_default; 702 var->delete_fn = owl_variable_delete_default; 703 var->val = g_new(int, 1); 704 var->set_fn(var, &initval); 705 owl_variable_dict_add_variable(vd, var); 706 } 707 } 708 709 void owl_variable_dict_newvar_bool(owl_vardict *vd, const char *name, const char *summ, const char *desc, int initval) 710 { 711 owl_variable *old = owl_variable_get_var(vd, name); 712 if (old && owl_variable_get_type(old) == OWL_VARIABLE_BOOL) { 713 owl_variable_update(old, summ, desc); 714