Changeset 825953e
- Timestamp:
- Jun 22, 2013, 9:49:39 PM (11 years ago)
- Parents:
- 96d80e9 (diff), 33501b2 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Files:
-
- 37 added
- 39 deleted
- 75 edited
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
r2ff0693 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 40 1.8 41 * Compute the home directory in zcrypt consistently with BarnOwl -davidben@mit.edu 42 * Make help show the correct keybinding for A -jgross@mit.edu 43 * Add a delete-and-expunge command. -jgross@mit.edu 44 * Fix a bug in the expunge command -jgross@mit.edu 45 * Replace 'Owl' with 'BarnOwl' in user visible places -jgross@mit.edu 46 * Allow zsigs to be '0' -jgross@mit.edu 47 * Reformat the man page to look more like others -davidben@mit.edu 48 * Consistently use BarnOwl or barnowl -davidben@mit.edu 49 * Update autoconf macros -andersk@mit.edu 50 * history: Do not deduplicate a partial entry -andersk@mit.edu 51 * Drop show timers feature -davidben@mit.edu 52 * Add new dependencies, AnyEvent and perl-Glib -davidben@mit.edu 53 * Bump required glib version to 2.16 -davidben@mit.edu 54 * Don't leak timestr when setting time in a perl message -asedeno@mit.edu 55 * Build with -Wwrite-strings -andersk@mit.edu 56 * Build with C99 -davidben@mit.edu 57 * Jabber: Handle nicks with leading dashes (e.g. Facebook XMPP) -ezyang@mit.edu 58 * Move log-writing onto a background thread. -adam@crossproduct.net 59 * Remove the length limit on field values in :info -jgross@mit.edu 60 * Show how far you are in a long message -jgross@mit.edu 61 * stderr_redirect_handler: Handle partial or failed reads -andersk@mit.edu 62 * Inform the user when an unpunt command does nothing -davidben@mit.edu 63 * Replace custom event loop with GLib's GMainLoop -davidben@mit.edu 64 * Encode glib version requirements in pkg-config check -asedeno@mit.edu 65 * Fix color pair usage on ncurses builds without ext-color -davidben@mit.edu 66 * IRC: Fix reconnect behavior. -nelhage@mit.edu 67 * IRC: Make nick-change events LOGIN messages instead of ADMIN. -nelhage@mit.edu 68 * IRC: Port module to AnyEvent::IRC. -asedeno@mit.edu, nelhage@nelhage.com 69 * Ability to set exposure arbitrarily (like "zctl set exposure") -jgross@mit.edu 70 * Kill --remove-debug option -davidben@mit.edu 71 * exec: Fix input redirection of multistatement commands -andersk@mit.edu 72 * Correctly set the realm in outgoing zwrite errors -davidben@mit.edu 73 * Correctly compute the realm for outgoing messages -davidben@mit.edu 74 * In duplicated outgoing zephyrs only reply on the relevant recipient -davidben@mit.edu 75 * Create per-recipient copies of outgoing messages for non-CC'd personals -liudi@mit.edu 76 * Add black to :show colors -andersk@mit.edu 77 * Fix reporting of errors from libzephyr -kcr@1ts.org 78 * Load Encode module for IRC. -timhill@alum.mit.edu 79 * IRC: Sort the output of :irc-names -nelhage@mit.edu 80 * Prepend "UNAUTH: " to displayed sender for unauthenticated zephyrs -adam@crossproduct.net 81 * For ‘punt’ with one argument, quote the filter name -andersk@mit.edu 82 * Fix spurious error running ‘punt’ with no arguments -andersk@mit.edu 83 * Only handle CCs in messages sent directly to you. -davidben@mit.edu 84 * Update copyright notices for 2011 -davidben@mit.edu 85 * If a smartfilter fails to parse, handle the error -davidben@mit.edu 86 * Replace per-editwin killbuf with a global one. -adam@crossproduct.net 87 * Don't use error_message if we are building without Zephyr. -nelhage@mit.edu 88 * Fix replying to outgoing zwrite when -m is passed -davidben@mit.edu 89 * Fix a number of quoting bugs -davidben@mit.edu 90 * Check passwd entries to determine home dir -davidben@mit.edu 91 92 1.7.1 93 * Append sender's realm to CC'd unqualified names when replying. -adam@crossproduct.net 94 * Don't reset ncurses colorpairs in the middle of drawing. -davidben@mit.edu 95 * Fix viewuser when an unqualified name is given. -davidben@mit.edu 96 1 97 1.7 98 * Fix quoting bugs in smartfilter, zpunt, and numerous other commands. -davidben@mit.edu 2 99 * Download Twitter consumer keys from barnowl.mit.edu. -nelhage@MIT.EDU 3 100 * Fix unsub when .zephyr.subs is a symlink. -jgross@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
r9179fd7 r1c22155 7 7 Notes: 8 8 ----- 9 This project's perl/ lib/ contains the lib directories from the9 This project's perl/modules/ contains the lib directories from the 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: 19 20 20 21 AnyEvent 22 Class::Accessor 23 ExtUtils::Depends 21 24 Glib 25 Module::Install 22 26 PAR 23 Net::DNS24 Authen::SASL::Perl25 IO::Socket::SSL26 Digest::SHA127 27 28 28 (Note that these are all available as Debian packages) … … 30 30 these for you. 31 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 43 32 44 The IRC module requires: 33 45 34 46 AnyEvent::IRC 35 Class::Accessor 47 48 The Jabber module requires: 49 50 Net::DNS 51 Authen::SASL::Perl 52 IO::Socket::SSL 53 Digest::SHA 54 55 The Twitter module requires: 56 57 HTML::Entities 58 Net::Twitter::Lite 36 59 37 60 The WordWrap module requires: -
aim.c
r33501b2 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 … … 1064 1061 g_free(wrapmsg); 1065 1062 g_free(nz_screenname); 1063 g_free(realmsg); 1066 1064 1067 1065 return(1); 1068 1066 1069 owl_function_debugmsg("faimtest_parse_incoming_im_chan1: icbm: message: %s\n", realmsg); 1070 1071 if (args->icbmflags & AIM_IMFLAGS_MULTIPART) { 1072 aim_mpmsg_section_t *sec; 1073 int z; 1074 1075 owl_function_debugmsg("faimtest_parse_incoming_im_chan1: icbm: multipart: this message has %d parts\n", args->mpmsg.numparts); 1076 1077 for (sec = args->mpmsg.parts, z = 0; sec; sec = sec->next, z++) { 1078 if ((sec->charset == 0x0000) || (sec->charset == 0x0003) || (sec->charset == 0xffff)) { 1079 owl_function_debugmsg("faimtest_parse_incoming_im_chan1: icbm: multipart: part %d: charset 0x%04x, subset 0x%04x, msg = %s\n", z, sec->charset, sec->charsubset, sec->data); 1080 } else { 1081 owl_function_debugmsg("faimtest_parse_incoming_im_chan1: icbm: multipart: part %d: charset 0x%04x, subset 0x%04x, binary or UNICODE data\n", z, sec->charset, sec->charsubset); 1082 } 1083 } 1084 } 1085 1086 if (args->icbmflags & AIM_IMFLAGS_HASICON) { 1087 /* aim_send_im(sess, userinfo->sn, AIM_IMFLAGS_BUDDYREQ, "You have an icon"); */ 1088 owl_function_debugmsg("faimtest_parse_incoming_im_chan1: icbm: their icon: iconstamp = %ld, iconlen = 0x%08x, iconsum = 0x%04x\n", args->iconstamp, args->iconlen, args->iconsum); 1089 } 1090 1091 g_free(realmsg); 1092 1093 return(1); 1067 /* TODO: Multipart? See history from before 1.8 release. */ 1094 1068 } 1095 1069 … … 1852 1826 fd = event_source->fds->pdata[i]; 1853 1827 fd->fd = cur->fd; 1854 fd->events |= G_IO_IN | G_IO_HUP | G_IO_ERR;1828 fd->events = G_IO_IN | G_IO_HUP | G_IO_ERR; 1855 1829 if (cur->status & AIM_CONN_STATUS_INPROGRESS) { 1856 /* Yes, we're checking writable sockets here. Without it, AIM 1857 login is really slow. */ 1830 /* AIM login requires checking writable sockets. See aim_select. */ 1858 1831 fd->events |= G_IO_OUT; 1859 1832 } … … 1891 1864 { 1892 1865 owl_aim_event_source *event_source = (owl_aim_event_source*)source; 1893 truncate_pollfd_list(event_source, 0); 1894 g_ptr_array_free(event_source->fds, TRUE); 1866 /* Don't remove the GPollFDs. We are being finalized, so they'll be removed 1867 * for us. Moreover, glib will fire asserts if g_source_remove_poll is called 1868 * on a source which has been destroyed (which occurs when g_source_remove is 1869 * called on it). */ 1870 owl_ptr_array_free(event_source->fds, g_free); 1895 1871 } 1896 1872 -
cmd.c
rce68f23 rf271129 1 #include <stdio.h>2 #include <stdlib.h>3 #include <string.h>4 #include <unistd.h>5 1 #include "owl.h" 6 2 … … 260 256 if (cmd->usage && *cmd->usage) { 261 257 s = cmd->usage; 262 indent = owl_text_indent(s, OWL_TAB );258 indent = owl_text_indent(s, OWL_TAB, true); 263 259 owl_fmtext_append_bold(fm, "\nSYNOPSIS\n"); 264 260 owl_fmtext_append_normal(fm, indent); … … 274 270 if (cmd->description && *cmd->description) { 275 271 s = cmd->description; 276 indent = owl_text_indent(s, OWL_TAB );272 indent = owl_text_indent(s, OWL_TAB, true); 277 273 owl_fmtext_append_bold(fm, "\nDESCRIPTION\n"); 278 274 owl_fmtext_append_normal(fm, indent); -
commands.c
refeec7f 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"); … … 2165 2161 myargv[i]=argv[i]; 2166 2162 } 2167 owl_function_create_filter(argc, myargv); 2168 owl_function_change_currentview_filter("owl-dynamic"); 2163 if (owl_function_create_filter(argc, myargv)) { 2164 owl_function_change_currentview_filter("owl-dynamic"); 2165 } 2169 2166 g_free(myargv); 2170 2167 return NULL; … … 2193 2190 if (!strcmp(argv[0], "-f")) { 2194 2191 if (argc<2) { 2195 owl_function_makemsg("Too few arg ments to the view command");2192 owl_function_makemsg("Too few arguments to the view command"); 2196 2193 return(NULL); 2197 2194 } … … 2205 2202 } else if (!strcmp(argv[0], "-s")) { 2206 2203 if (argc<2) { 2207 owl_function_makemsg("Too few arg ments to the view command");2204 owl_function_makemsg("Too few arguments to the view command"); 2208 2205 return(NULL); 2209 2206 } … … 2212 2209 argv+=2; 2213 2210 } else { 2214 owl_function_makemsg("Too few arg ments to the view command");2211 owl_function_makemsg("Too few arguments to the view command"); 2215 2212 return(NULL); 2216 2213 } … … 2799 2796 owl_history_store(hist, owl_editwin_get_text(e), false); 2800 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); 2801 2803 owl_global_pop_context(&g); 2804 2805 owl_editwin_do_callback(e, false); 2806 owl_editwin_unref(e); 2802 2807 } 2803 2808 … … 2859 2864 owl_global_pop_context(&g); 2860 2865 2861 owl_editwin_do_callback(e );2866 owl_editwin_do_callback(e, true); 2862 2867 owl_editwin_unref(e); 2863 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
rf2a96c0 re4b8f93 1 1 dnl Process this file with autoconf to produce a configure script. 2 AC_INIT([BarnOwl],[1.8dev],[bug-barnowl@mit.edu]) 3 AM_INIT_AUTOMAKE([1.7.0 -Wall -Wno-portability foreign]) 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}) … … 109 137 AC_CHECK_LIB([perl], [perl_alloc],, AC_MSG_ERROR([No libperl found])) 110 138 139 AX_PROG_PERL_MODULES([AnyEvent],, 140 [AC_MSG_ERROR([cannot find perl module AnyEvent.])]) 111 141 AX_PROG_PERL_MODULES([Class::Accessor::Fast],, 112 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])]) 145 AX_PROG_PERL_MODULES([Glib],, 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])]) 113 149 AX_PROG_PERL_MODULES([PAR],, 114 150 [AC_MSG_WARN([PAR.pm not found. Loadable modules will be disabled.])]) … … 125 161 prefix="${ac_default_prefix}" 126 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}" 127 168 128 169 dnl Checks for typedefs, structures, and compiler characteristics. … … 164 205 AC_REPLACE_FUNCS([memrchr]) 165 206 207 AC_SUBST([abs_builddir]) 208 AC_SUBST([abs_srcdir]) 209 166 210 AC_CONFIG_FILES([Makefile compat/Makefile libfaim/Makefile perl/Makefile perl/modules/Makefile]) 167 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
r6829afc 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 } … … 1151 1147 { 1152 1148 oe_excursion x; 1153 gunichar ch; 1149 gunichar ch = 0; 1150 gunichar last_ch; 1154 1151 int sentence; 1155 1152 … … 1184 1181 } 1185 1182 1183 last_ch = ch; 1186 1184 ch = owl_editwin_get_char_at_point(e); 1187 1185 … … 1201 1199 } 1202 1200 1203 if(ch == '.' || ch == '!' || ch == '?') 1201 if (ch == '.' || ch == '!' || ch == '?' || 1202 (ch == '"' && (last_ch == '.' || last_ch == '!' || last_ch == '?'))) 1204 1203 sentence = 1; 1205 1204 else -
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
r2560529 rf271129 1 1 #include "owl.h" 2 #include <stdlib.h>3 #include <string.h>4 2 5 3 /* initialize an fmtext with no data */ … … 186 184 static void _owl_fmtext_wcolor_set(WINDOW *w, short pair) 187 185 { 186 cchar_t background; 187 wchar_t blank[2] = { ' ', 0 }; 188 188 if (has_colors()) { 189 wcolor_set(w,pair,NULL); 190 wbkgdset(w, COLOR_PAIR(pair)); 189 wcolor_set(w, pair, NULL); 190 /* Set the background with wbkgrndset so that we can handle color-pairs 191 * past 256 on ncurses ABI 6 and later. */ 192 setcchar(&background, blank, 0, pair, NULL); 193 wbkgrndset(w, &background); 191 194 } 192 195 } … … 686 689 * but zwgc seems to be smarter about some screw cases than I am 687 690 */ 691 g_free(buff); 688 692 owl_fmtext_append_attr(f, "@", curattrs, curcolor, OWL_COLOR_DEFAULT); 689 693 txtptr++; -
functions.c
refeec7f 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 … … 410 404 old_msg = g_strdup(owl_zwrite_get_message(z)); 411 405 412 zcrypt = g_ strdup_printf("%s/zcrypt", owl_get_bindir());413 argv[0] = "zcrypt";406 zcrypt = g_build_filename(owl_get_bindir(), "zcrypt", NULL); 407 argv[0] = zcrypt; 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, … … 1223 1216 void G_GNUC_PRINTF(1, 2) owl_function_debugmsg(const char *fmt, ...) 1224 1217 { 1218 char *tmpbuff; 1225 1219 FILE *file; 1226 1220 time_t now; … … 1237 1231 now = time(NULL); 1238 1232 1239 fprintf(file, "[%d - %.24s - %lds]: ", 1240 (int) getpid(), ctime(&now), now - owl_global_get_starttime(&g)); 1233 tmpbuff = owl_util_format_time(localtime(&now)); 1234 fprintf(file, "[%d - %s - %lds]: ", 1235 (int) getpid(), tmpbuff, now - owl_global_get_starttime(&g)); 1236 g_free(tmpbuff); 1241 1237 vfprintf(file, fmt, ap); 1242 1238 putc('\n', file); … … 1385 1381 owl_fmtext fm, attrfm; 1386 1382 const owl_view *v; 1383 char *time; 1387 1384 #ifdef HAVE_LIBZEPHYR 1388 1385 const ZNotice_t *n; … … 1415 1412 } 1416 1413 1417 owl_fmtext_appendf_normal(&fm, " Time : %s\n", owl_message_get_timestr(m)); 1414 time = owl_message_format_time(m); 1415 owl_fmtext_appendf_normal(&fm, " Time : %s\n", time); 1416 g_free(time); 1418 1417 1419 1418 if (!owl_message_is_type_admin(m)) { … … 1429 1428 owl_fmtext_appendf_normal(&fm, " Opcode : %s\n", owl_message_get_opcode(m)); 1430 1429 #ifdef HAVE_LIBZEPHYR 1431 if (owl_message_is_direction_in(m)) { 1432 char *tmpbuff; 1430 n = owl_message_get_notice(m); 1431 if (n != NULL) { 1432 char *tmpbuff, *tmpbuff2; 1433 1433 int i, fields; 1434 1435 n=owl_message_get_notice(m); 1434 const char *f; 1436 1435 1437 1436 if (!owl_message_is_pseudo(m)) { … … 1475 1474 owl_fmtext_appendf_normal(&fm, " Fields : %i\n", fields); 1476 1475 1477 for (i = 0; i < fields; i++) { 1478 tmpbuff = owl_zephyr_get_field_as_utf8(n, i + 1); 1479 1480 g_strdelimit(tmpbuff, "\n", '~'); 1481 g_strdelimit(tmpbuff, "\r", '!'); 1482 1483 owl_fmtext_appendf_normal(&fm, " Field %i : %s\n", i + 1, tmpbuff); 1484 g_free(tmpbuff); 1476 for (i = 0, f = owl_zephyr_first_raw_field(n); f != NULL; 1477 i++, f = owl_zephyr_next_raw_field(n, f)) { 1478 tmpbuff = owl_zephyr_field_as_utf8(n, f); 1479 tmpbuff2 = owl_text_indent(tmpbuff, 14, false); 1480 owl_fmtext_appendf_normal(&fm, " Field %i : %s\n", i + 1, tmpbuff2); 1481 g_free(tmpbuff2); 1482 g_free(tmpbuff); 1485 1483 } 1486 owl_fmtext_appendf_normal(&fm, " Default Fm: %s\n", n->z_default_format); 1484 tmpbuff = owl_text_indent(n->z_default_format, 14, false); 1485 owl_fmtext_appendf_normal(&fm, " Default Fm: %s\n", tmpbuff); 1486 g_free(tmpbuff); 1487 1487 } 1488 1488 … … 1761 1761 void owl_function_status(void) 1762 1762 { 1763 char *tmpbuff; 1763 1764 char buff[MAXPATHLEN+1]; 1764 1765 time_t start; … … 1788 1789 owl_fmtext_append_normal(&fm, "\n"); 1789 1790 1790 owl_fmtext_appendf_normal(&fm, " Startup Time: %s", ctime(&start)); 1791 tmpbuff = owl_util_format_time(localtime(&start)); 1792 owl_fmtext_appendf_normal(&fm, " Startup Time: %s\n", tmpbuff); 1793 g_free(tmpbuff); 1791 1794 1792 1795 up=owl_global_get_runtime(&g); … … 1941 1944 } 1942 1945 1943 void owl_callback_command(owl_editwin *e) 1944 { 1946 void owl_callback_command(owl_editwin *e, bool success) 1947 { 1948 if (!success) return; 1945 1949 char *rv; 1946 1950 const char *line = owl_editwin_get_text(e); … … 1953 1957 } 1954 1958 1955 voidowl_function_start_command(const char *line)1959 owl_editwin *owl_function_start_command(const char *line) 1956 1960 { 1957 1961 owl_editwin *tw; … … 1968 1972 owl_global_push_context_obj(&g, ctx); 1969 1973 owl_editwin_set_callback(tw, owl_callback_command); 1970 } 1971 1972 CALLER_OWN owl_editwin *owl_function_start_question(const char *line) 1974 return tw; 1975 } 1976 1977 owl_editwin *owl_function_start_question(const char *line) 1973 1978 { 1974 1979 owl_editwin *tw; … … 1985 1990 } 1986 1991 1987 CALLER_OWNowl_editwin *owl_function_start_password(const char *line)1992 owl_editwin *owl_function_start_password(const char *line) 1988 1993 { 1989 1994 owl_editwin *tw; … … 2126 2131 2127 2132 /* Create a new filter, or replace an existing one 2128 * with a new definition. 2133 * with a new definition. Returns true on success. 2129 2134 */ 2130 voidowl_function_create_filter(int argc, const char *const *argv)2135 bool owl_function_create_filter(int argc, const char *const *argv) 2131 2136 { 2132 2137 owl_filter *f; … … 2136 2141 if (argc < 2) { 2137 2142 owl_function_error("Wrong number of arguments to filter command"); 2138 return ;2143 return false; 2139 2144 } 2140 2145 … … 2146 2151 if (!strcmp(argv[1], "all")) { 2147 2152 owl_function_error("You may not change the 'all' filter."); 2148 return ;2153 return false; 2149 2154 } 2150 2155 … … 2154 2159 if (!f) { 2155 2160 owl_function_error("The filter '%s' does not exist.", argv[1]); 2156 return ;2161 return false; 2157 2162 } 2158 2163 if (owl_util_string_to_color(argv[3])==OWL_COLOR_INVALID) { 2159 2164 owl_function_error("The color '%s' is not available.", argv[3]); 2160 return ;2165 return false; 2161 2166 } 2162 2167 owl_filter_set_fgcolor(f, owl_util_string_to_color(argv[3])); 2163 2168 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 2164 return ;2169 return false; 2165 2170 } 2166 2171 if (argc==4 && !strcmp(argv[2], "-b")) { … … 2168 2173 if (!f) { 2169 2174 owl_function_error("The filter '%s' does not exist.", argv[1]); 2170 return ;2175 return false; 2171 2176 } 2172 2177 if (owl_util_string_to_color(argv[3])==OWL_COLOR_INVALID) { 2173 2178 owl_function_error("The color '%s' is not available.", argv[3]); 2174 return ;2179 return false; 2175 2180 } 2176 2181 owl_filter_set_bgcolor(f, owl_util_string_to_color(argv[3])); 2177 2182 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 2178 return ;2183 return true; 2179 2184 } 2180 2185 … … 2182 2187 f = owl_filter_new(argv[1], argc-2, argv+2); 2183 2188 if (f == NULL) { 2184 owl_function_error("Invalid filter ");2185 return ;2189 owl_function_error("Invalid filter: %s", argv[1]); 2190 return false; 2186 2191 } 2187 2192 … … 2204 2209 } 2205 2210 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 2211 return true; 2206 2212 } 2207 2213 … … 2455 2461 /* if it already exists then go with it. This lets users override */ 2456 2462 if (owl_global_get_filter(&g, filtname)) { 2457 return (g_strdup(filtname));2463 return filtname; 2458 2464 } 2459 2465 … … 3081 3087 idle=owl_buddy_get_idle_time(b); 3082 3088 if (idle!=0) { 3083 timestr=owl_util_ minutes_to_timestr(idle);3089 timestr=owl_util_format_minutes(idle); 3084 3090 } else { 3085 3091 timestr=g_strdup(""); … … 3226 3232 } else if (myargc > 0) { 3227 3233 /* Spawn the child. */ 3228 pid_tpid;3234 GPid pid; 3229 3235 GError *error = NULL; 3230 3236 owl_function_debugmsg("About to exec \"%s\" with %d arguments", argv[0], myargc); … … 3409 3415 char *buff; 3410 3416 3411 now=time(NULL); 3412 date=g_strdup(ctime(&now)); 3413 date[strlen(date)-1]='\0'; 3417 now = time(NULL); 3418 date = owl_util_format_time(localtime(&now)); 3414 3419 3415 3420 buff = g_strdup_printf("%s %s", date, string); … … 3474 3479 3475 3480 anyone = owl_zephyr_get_anyone_list(NULL); 3476 for (i = 0; i < anyone->len; i++) { 3477 user = anyone->pdata[i]; 3478 zald = g_new(ZAsyncLocateData_t, 1); 3479 if (ZRequestLocations(zstr(user), zald, UNACKED, ZAUTH) == ZERR_NONE) { 3480 *zaldlist = g_list_append(*zaldlist, zald); 3481 } else { 3482 g_free(zald); 3483 } 3484 } 3485 3486 owl_ptr_array_free(anyone, g_free); 3481 if (anyone != NULL) { 3482 for (i = 0; i < anyone->len; i++) { 3483 user = anyone->pdata[i]; 3484 zald = g_new(ZAsyncLocateData_t, 1); 3485 if (ZRequestLocations(zstr(user), zald, UNACKED, ZAUTH) == ZERR_NONE) { 3486 *zaldlist = g_list_append(*zaldlist, zald); 3487 } else { 3488 g_free(zald); 3489 } 3490 } 3491 owl_ptr_array_free(anyone, g_free); 3492 } 3487 3493 #endif 3488 3494 } -
global.c
r16cf182d 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(); … … 77 75 g->confdir = NULL; 78 76 g->startupfile = NULL; 79 cd = g_ strdup_printf("%s/%s", g->homedir, OWL_CONFIG_DIR);77 cd = g_build_filename(g->homedir, OWL_CONFIG_DIR, NULL); 80 78 owl_global_set_confdir(g, cd); 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 … … 364 367 g->confdir = g_strdup(cd); 365 368 g_free(g->startupfile); 366 g->startupfile = g_ strdup_printf("%s/startup", cd);369 g->startupfile = g_build_filename(cd, "startup", NULL); 367 370 } 368 371 … … 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
r6829afc 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 */ … … 224 221 while (cc != NULL) { 225 222 temp = short_zuser(cc->data); 226 filename = g_ strdup_printf("%s/%s", logpath, temp);223 filename = g_build_filename(logpath, temp, NULL); 227 224 owl_log_append(m, filename); 228 225 … … 248 245 } 249 246 250 filename = g_ strdup_printf("%s/%s", logpath, to);247 filename = g_build_filename(logpath, to, NULL); 251 248 owl_log_append(m, filename); 252 249 g_free(to); 253 250 g_free(filename); 254 251 255 filename = g_ strdup_printf("%s/all", logpath);252 filename = g_build_filename(logpath, "all", NULL); 256 253 owl_log_append(m, filename); 257 254 g_free(logpath); … … 285 282 /* expand ~ in path names */ 286 283 logpath = owl_util_makepath(owl_global_get_logpath(&g)); 287 filename = g_ strdup_printf("%s/%s", logpath, tobuff);284 filename = g_build_filename(logpath, tobuff, NULL); 288 285 msgbuf = g_string_new(""); 289 286 g_string_printf(msgbuf, "ERROR (owl): %s\n%s\n", tobuff, text); … … 294 291 g_string_free(msgbuf, TRUE); 295 292 296 filename = g_ strdup_printf("%s/all", logpath);293 filename = g_build_filename(logpath, "all", NULL); 297 294 g_free(logpath); 298 295 msgbuf = g_string_new(""); … … 393 390 if (personal) { 394 391 logpath = owl_util_makepath(owl_global_get_logpath(&g)); 395 filename = g_ strdup_printf("%s/%s", logpath, from);396 allfilename = g_ strdup_printf("%s/all", logpath);392 filename = g_build_filename(logpath, from, NULL); 393 allfilename = g_build_filename(logpath, "all", NULL); 397 394 owl_log_append(m, allfilename); 398 395 g_free(allfilename); 399 396 } else { 400 397 logpath = owl_util_makepath(owl_global_get_classlogpath(&g)); 401 filename = g_ strdup_printf("%s/%s", logpath, from);398 filename = g_build_filename(logpath, from, NULL); 402 399 } 403 400 … … 415 412 temp = short_zuser(cc->data); 416 413 if (strcasecmp(temp, frombuff) != 0) { 417 filename = g_ strdup_printf("%s/%s", logpath, temp);414 filename = g_build_filename(logpath, temp, NULL); 418 415 owl_log_append(m, filename); 419 416 g_free(filename); … … 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
rf9df2f0 r2354e9a 1 #include <stdlib.h>2 #include <unistd.h>3 #include <string.h>4 #include <sys/socket.h>5 #include <netdb.h>6 #include <sys/types.h>7 #include <sys/socket.h>8 #include <netinet/in.h>9 #include <arpa/inet.h>10 #include <time.h>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(); 46 42 47 43 /* save the time */ 48 m->time =time(NULL);49 m->timestr =g_strdup(ctime(&(m->time)));50 m->timestr[strlen(m->timestr)-1] ='\0';44 m->time = time(NULL); 45 m->timestr = g_strdup(ctime(&m->time)); 46 m->timestr[strlen(m->timestr)-1] = '\0'; 51 47 52 48 m->fmtext = NULL; … … 125 121 p = m->attributes->pdata[i]; 126 122 127 tmpbuff = g_strdup(owl_pair_get_value(p)); 128 g_strdelimit(tmpbuff, "\n", '~'); 129 g_strdelimit(tmpbuff, "\r", '!'); 130 buff = g_strdup_printf(" %-15.15s: %s\n", owl_pair_get_key(p), tmpbuff); 131 g_free(tmpbuff); 123 buff = g_strdup(owl_pair_get_value(p)); 124 if (buff) { 125 tmpbuff = owl_text_indent(buff, 19, false); 126 g_free(buff); 127 buff = g_strdup_printf(" %-15.15s: %s\n", owl_pair_get_key(p), tmpbuff); 128 g_free(tmpbuff); 129 } 132 130 133 131 if(buff == NULL) { … … 349 347 } 350 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 351 354 void owl_message_set_type_admin(owl_message *m) 352 355 { … … 497 500 const ZNotice_t *owl_message_get_notice(const owl_message *m) 498 501 { 499 return (&(m->notice));502 return m->has_notice ? &m->notice : NULL; 500 503 } 501 504 #else … … 788 791 /* first save the full notice */ 789 792 m->notice = *n; 793 m->has_notice = true; 790 794 791 795 /* a little gross, we'll replace \r's with ' ' for now */ … … 794 798 /* save the time, we need to nuke the string saved by message_init */ 795 799 if (m->timestr) g_free(m->timestr); 796 m->time =n->z_time.tv_sec;797 m->timestr =g_strdup(ctime(&(m->time)));798 m->timestr[strlen(m->timestr)-1] ='\0';800 m->time = n->z_time.tv_sec; 801 m->timestr = g_strdup(ctime(&m->time)); 802 m->timestr[strlen(m->timestr)-1] = '\0'; 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; 884 886 char *zcrypt; 885 887 886 zcrypt = g_strdup_printf("%s/zcrypt", owl_get_bindir()); 887 888 rv = call_filter(zcrypt, argv, owl_message_get_body(m), &out, &status); 888 zcrypt = g_build_filename(owl_get_bindir(), "zcrypt", NULL); 889 argv[0] = zcrypt; 890 891 rv = call_filter(argv, owl_message_get_body(m), &out, &status); 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
rb8a3e00 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 */ … … 389 382 } 390 383 391 #define CHECK_RESULT(s, syscall)\384 #define OR_DIE(s, syscall) \ 392 385 G_STMT_START { \ 393 if ((syscall) != 0) { \386 if ((syscall) == -1) { \ 394 387 perror((s)); \ 395 388 exit(1); \ … … 402 395 sigset_t sigset; 403 396 int ret, i; 404 const int signals[] = { SIGABRT, SIGBUS, SIGCHLD, SIGFPE, SIGHUP, SIGILL, 405 SIGINT, SIGQUIT, SIGSEGV, SIGTERM, SIGWINCH }; 397 const int reset_signals[] = { SIGABRT, SIGBUS, SIGCHLD, SIGFPE, SIGILL, 398 SIGQUIT, SIGSEGV, }; 399 /* Don't bother resetting watched ones because owl_signal_init will. */ 400 const int watch_signals[] = { SIGWINCH, SIGTERM, SIGHUP, SIGINT, }; 406 401 407 402 /* Sanitize our signals; the mask and dispositions from our parent 408 403 * aren't really useful. Signal list taken from equivalent code in 409 404 * Chromium. */ 410 CHECK_RESULT("sigemptyset", sigemptyset(&sigset));405 OR_DIE("sigemptyset", sigemptyset(&sigset)); 411 406 if ((ret = pthread_sigmask(SIG_SETMASK, &sigset, NULL)) != 0) { 412 407 errno = ret; 413 408 perror("pthread_sigmask"); 414 } 415 for (i = 0; i < G_N_ELEMENTS(signals); i++) { 416 CHECK_RESULT("sigaction", sigaction(signals[i], &sig_default, NULL)); 409 exit(1); 410 } 411 for (i = 0; i < G_N_ELEMENTS(reset_signals); i++) { 412 OR_DIE("sigaction", sigaction(reset_signals[i], &sig_default, NULL)); 417 413 } 418 414 419 415 /* Turn off SIGPIPE; we check the return value of write. */ 420 CHECK_RESULT("sigaction", sigaction(SIGPIPE, &sig_ignore, NULL));416 OR_DIE("sigaction", sigaction(SIGPIPE, &sig_ignore, NULL)); 421 417 422 418 /* Register some signals with the signal thread. */ 423 CHECK_RESULT("sigaddset", sigaddset(&sigset, SIGWINCH)); 424 CHECK_RESULT("sigaddset", sigaddset(&sigset, SIGTERM)); 425 CHECK_RESULT("sigaddset", sigaddset(&sigset, SIGHUP)); 426 CHECK_RESULT("sigaddset", sigaddset(&sigset, SIGINT)); 427 owl_signal_init(&sigset, sig_handler, NULL); 419 owl_signal_init(watch_signals, G_N_ELEMENTS(watch_signals), 420 sig_handler, NULL); 428 421 } 429 422 … … 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
r16cf182d 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" … … 18 18 #ifndef OWL_PERL 19 19 #define NCURSES_ENABLE_STDBOOL_H 1 20 #include < curses.h>21 #include < panel.h>20 #include <ncursesw/curses.h> 21 #include <ncursesw/panel.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 … … 75 82 76 83 #define OWL_CONFIG_DIR "/.owl" /* this is relative to the user's home directory */ 77 #define OWL_STARTUP_FILE "/.owl/startup" /* this is relative to the user's home directory */78 84 79 85 #define OWL_FMTEXT_ATTR_NONE 0 … … 207 213 /* OWL_CTRL is definied in kepress.c */ 208 214 209 #define LINE 2048210 211 215 #ifdef HAVE_LIBZEPHYR 212 216 /* libzephyr doesn't use const, so we appease the type system with this kludge. … … 231 235 char *name; 232 236 int type; /* OWL_VARIABLE_* */ 233 void *pval_default; /* for types other and string */ 234 int ival_default; /* for types int and bool */ 235 const char *validsettings; /* documentation of valid settings */ 237 char *default_str; /* the default value as a string */ 238 char *validsettings; /* documentation of valid settings */ 236 239 char *summary; /* summary of usage */ 237 240 char *description; /* detailed description */ 238 void *val; /* current value */ 239 int (*validate_fn)(const struct _owl_variable *v, const void *newval); 241 bool takes_on_off; /* allow passing on/off in argument-less set/unset */ 242 GClosure *set_fromstring_fn; 243 /* sets the variable to a value 244 * of the appropriate type. 245 * unless documented, this 246 * should make a copy. 247 * returns 0 on success. */ 248 GClosure *get_tostring_fn; 249 /* converts val to a string; 250 * caller must free the result */ 251 252 /* These are only valid for OWL_VARIABLE_{INT,BOOL,STRING} */ 253 GValue val; /* current value, if default get_fn/set_fn */ 254 255 GCallback get_fn; 256 /* returns a reference to the current value. 257 * WARNING: this approach is hard to make 258 * thread-safe... */ 259 GCallback validate_fn; 240 260 /* returns 1 if newval is valid */ 241 int (*set_fn)(struct _owl_variable *v, const void *newval);261 GCallback set_fn; 242 262 /* sets the variable to a value 243 * of the appropriate type. 244 * unless documented, this 245 * should make a copy. 246 * returns 0 on success. */ 247 int (*set_fromstring_fn)(struct _owl_variable *v, const char *newval); 248 /* sets the variable to a value 249 * of the appropriate type. 250 * unless documented, this 251 * should make a copy. 252 * returns 0 on success. */ 253 const void *(*get_fn)(const struct _owl_variable *v); 254 /* returns a reference to the current value. 255 * WARNING: this approach is hard to make 256 * thread-safe... */ 257 CALLER_OWN char *(*get_tostring_fn)(const struct _owl_variable *v, const void *val); 258 /* converts val to a string; 259 * caller must free the result */ 260 void (*delete_fn)(struct _owl_variable *v); 261 /* frees val as needed */ 263 * of the appropriate type. 264 * unless documented, this 265 * should make a copy. 266 * returns 0 on success. */ 262 267 } owl_variable; 268 263 269 264 270 typedef struct _owl_input { … … 352 358 int direction; 353 359 #ifdef HAVE_LIBZEPHYR 360 bool has_notice; 354 361 ZNotice_t notice; 355 362 #endif … … 447 454 char *name; 448 455 owl_filter *filter; 449 owl_messagelist ml;456 owl_messagelist *ml; 450 457 const owl_style *style; 451 458 int cachedmsgid; … … 528 535 529 536 typedef struct _owl_global { 530 owl_mainwin mw;537 owl_mainwin *mw; 531 538 owl_popwin *pw; 532 539 owl_msgwin msgwin; … … 546 553 int curmsg_vert_offset; 547 554 owl_view current_view; 548 owl_messagelist msglist;555 owl_messagelist *msglist; 549 556 WINDOW *input_pad; 550 557 owl_mainpanel mainpanel; … … 591 598 char *kill_buffer; 592 599 int interrupt_count; 600 #if GLIB_CHECK_VERSION(2, 31, 0) 601 GMutex interrupt_lock; 602 #else 593 603 GMutex *interrupt_lock; 604 #endif 594 605 } owl_global; 595 606 … … 597 608 extern owl_global g; 598 609 599 #include "owl_prototypes.h"610 #include <owl_prototypes.h> 600 611 601 612 /* These were missing from the Zephyr includes before Zephyr 3. */ … … 605 616 #endif 606 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 607 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) -
perl/modules/Twitter/lib/BarnOwl/Module/Twitter/Handle.pm
r7aa1fa5 r4ebbfbc 29 29 use BarnOwl; 30 30 use BarnOwl::Message::Twitter; 31 use POSIX qw( asctime);31 use POSIX qw(strftime); 32 32 33 33 use LWP::UserAgent; … … 247 247 ($self->{cfg}->{account_nickname} ? 248 248 "[$self->{cfg}->{account_nickname}]" : "") . 249 ": ratelimited until " . asctime(localtime($timeout)));249 ": ratelimited until " . strftime('%c', localtime($timeout))); 250 250 } elsif(exists($ratelimit->{error})) { 251 251 $self->sleep(60*20); -
perlconfig.c
rce68f23 r96d80e9 1 #include <stdio.h>2 #include <stdlib.h>3 #include <string.h>4 #include <sys/types.h>5 #include <sys/stat.h>6 #include <errno.h>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; … … 406 340 /* Add the system lib path to @INC */ 407 341 inc = get_av("INC", 0); 408 path = g_ strdup_printf("%s/lib", owl_get_datadir());342 path = g_build_filename(owl_get_datadir(), "lib", NULL); 409 343 av_unshift(inc, 1); 410 344 av_store(inc, 0, owl_new_sv(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
rd427f08 rf271129 1 #include <string.h>2 1 #include "owl.h" 3 2 … … 11 10 { 12 11 int ret; 13 char buff1[LINE]; 12 size_t errbuf_size; 13 char *errbuf; 14 14 const char *ptr; 15 15 … … 26 26 ret=regcomp(&(re->re), ptr, REG_EXTENDED|REG_ICASE); 27 27 if (ret) { 28 regerror(ret, NULL, buff1, LINE); 29 owl_function_makemsg("Error in regular expression: %s", buff1); 28 errbuf_size = regerror(ret, NULL, NULL, 0); 29 errbuf = g_new(char, errbuf_size); 30 regerror(ret, NULL, errbuf, errbuf_size); 31 owl_function_error("Error in regular expression: %s", errbuf); 32 g_free(errbuf); 30 33 g_free(re->string); 31 34 re->string=NULL; -
runtests.sh
r786a410 r5db8835 1 1 #!/bin/sh 2 SRCDIR=`dirname "${0}"` 3 4 export BARNOWL_DATA_DIR="$SRCDIR/perl/" 5 export BARNOWL_BIN_DIR="$SRCDIR/" 6 7 HARNESS_PERL=./tester exec prove --failures t/ 2 exec env HARNESS_PERL=./tester prove --failures "${srcdir:=$(dirname "$0")}/t/" -
scripts/locker-build
r401752a r055e366 85 85 BARNOWL="/afs/sipb.mit.edu/project/barnowl/arch/$ATHENA_SYS" 86 86 export PKG_CONFIG_PATH="$BARNOWL/lib/pkgconfig" 87 eval $("$BARNOWL/bin/barnowl-perl-config") 87 88 88 89 SUFFIX= -
signal.c
r1d21d9f ra7fac14 1 1 #include <errno.h> 2 #include <glib.h> 2 3 #include <pthread.h> 3 4 #include <signal.h> … … 13 14 static void *signal_thread_func(void *data); 14 15 15 /* Initializes the signal thread to listen for 'set' on a dedicated 16 static void dummy_handler(int signum) 17 { 18 /* Do nothing. This should never get called. It'd be nice to report the error 19 * or something, but you can't have nice things in a signal handler. */ 20 } 21 22 #define OR_DIE(s, syscall) \ 23 G_STMT_START { \ 24 if ((syscall) == -1) { \ 25 perror((s)); \ 26 exit(1); \ 27 } \ 28 } G_STMT_END 29 30 /* Initializes the signal thread to listen for 'signals' on a dedicated 16 31 * thread. 'callback' is called *on the signal thread* when a signal 17 32 * is received. … … 19 34 * This function /must/ be called before any other threads are 20 35 * created. (Otherwise the signals will not get blocked correctly.) */ 21 void owl_signal_init(const sigset_t *set, void (*callback)(const siginfo_t*, void*), void *data) { 36 void owl_signal_init(const int *signals, int num_signals, void (*callback)(const siginfo_t*, void*), void *data) { 37 struct sigaction sig_dummy = { .sa_handler = dummy_handler }; 22 38 int ret; 39 int i; 23 40 24 signal_set = *set;25 41 signal_cb = callback; 26 42 signal_cbdata = data; 43 44 /* Stuff the signals into our sigset_t. Also assign all of them to a dummy 45 * handler. Otherwise, if their default is SIG_IGN, they will get dropped if 46 * delivered while processing. On Solaris, they will not get delivered at 47 * all. */ 48 OR_DIE("sigemptyset", sigemptyset(&signal_set)); 49 for (i = 0; i < num_signals; i++) { 50 OR_DIE("sigaddset", sigaddset(&signal_set, signals[i])); 51 OR_DIE("sigaction", sigaction(signals[i], &sig_dummy, NULL)); 52 } 53 27 54 /* Block these signals in all threads, so we can get them. */ 28 if ((ret = pthread_sigmask(SIG_BLOCK, set, NULL)) != 0) {55 if ((ret = pthread_sigmask(SIG_BLOCK, &signal_set, NULL)) != 0) { 29 56 errno = ret; 30 57 perror("pthread_sigmask"); 58 exit(1); 31 59 } 32 60 /* Spawn a dedicated thread to sigwait. */ -
style.c
rd4927a7 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 { … … 65 66 66 67 /* indent and ensure ends with a newline */ 67 indent = owl_text_indent(body, OWL_TAB );68 indent = owl_text_indent(body, OWL_TAB, true); 68 69 curlen = strlen(indent); 69 if (curlen==0 || indent[curlen-1] != '\n') { 70 indent[curlen] = '\n'; 71 indent[curlen+1] = '\0'; 70 if (curlen == 0 || indent[curlen-1] != '\n') { 71 char *tmp = indent; 72 indent = g_strconcat(tmp, "\n", NULL); 73 g_free(tmp); 72 74 } 73 75 -
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"); -
t/completion.t
r3001c11 re59d775 323 323 } 324 324 325 mkpath( "$tmpdir/.owl/",326 "$tmpdir/.owl/modules/",327 "$tmpdir/Public/",328 "$tmpdir/Private/",329 "$tmpdir/.ours",330 "$tmpdir/www",331 {mode => 0700});325 mkpath(["$tmpdir/.owl/", 326 "$tmpdir/.owl/modules/", 327 "$tmpdir/Public/", 328 "$tmpdir/Private/", 329 "$tmpdir/.ours", 330 "$tmpdir/www"], 331 0, 0700); 332 332 touch("$tmpdir/.zephyr.subs"); 333 333 touch("$tmpdir/wheee"); -
t/unicode.t
r09ff1eb rf415f83 5 5 use Encode; 6 6 7 BEGIN { bootstrap BarnOwl; };7 use Test::More qw(no_plan); 8 8 9 use Test::More qw(no_plan);9 use BarnOwl; 10 10 11 11 my $unicode = "“hello”"; -
tester.c
r14c9e05 r6a8b519 3 3 #include "owl.h" 4 4 #undef WINDOW 5 6 #include <errno.h> 7 #include <unistd.h> 8 #include <pwd.h> 5 #include "filterproc.h" 6 9 7 #include <stdio.h> 10 #include <stdlib.h>11 #include <string.h>12 #include <sys/types.h>13 8 14 9 #undef instr 15 #include < curses.h>10 #include <ncursesw/curses.h> 16 11 17 12 owl_global g; … … 29 24 int owl_smartfilter_regtest(void); 30 25 int owl_history_regtest(void); 26 int call_filter_regtest(void); 31 27 32 28 extern void owl_perl_xs_init(pTHX); … … 119 115 numfailures += owl_smartfilter_regtest(); 120 116 numfailures += owl_history_regtest(); 117 numfailures += call_filter_regtest(); 121 118 if (numfailures) { 122 119 fprintf(stderr, "# *** WARNING: %d failures total\n", numfailures); … … 136 133 { 137 134 int numfailed=0; 138 const char *home; 139 char *s, *path; 140 struct passwd *pw; 135 char *path, *home; 141 136 142 137 printf("# BEGIN testing owl_util\n"); … … 227 222 "\""); 228 223 229 GString * g= g_string_new("");230 owl_string_appendf_quoted( g, "%q foo %q%q %s %", "hello", "world is", "can't");224 GString *quoted = g_string_new(""); 225 owl_string_appendf_quoted(quoted, "%q foo %q%q %s %", "hello", "world is", "can't"); 231 226 FAIL_UNLESS("owl_string_appendf", 232 !strcmp(g->str, "hello foo 'world is'\"can't\" %s %")); 233 g_string_free(g, true); 234 235 236 s = owl_util_baseclass("barnowl"); 237 FAIL_UNLESS("baseclass barnowl", !strcmp("barnowl", s)); 238 g_free(s); 239 s = owl_util_baseclass("unbarnowl"); 240 FAIL_UNLESS("baseclass unbarnowl", !strcmp("barnowl", s)); 241 g_free(s); 242 s = owl_util_baseclass("unununbarnowl.d.d"); 243 FAIL_UNLESS("baseclass unununbarnowl.d.d", !strcmp("barnowl", s)); 244 g_free(s); 245 s = owl_util_baseclass("ununun.d.d"); 246 FAIL_UNLESS("baseclass ununun.d.d", !strcmp("", s)); 247 g_free(s); 248 s = owl_util_baseclass("d.d.d.d"); 249 FAIL_UNLESS("baseclass d.d.d.d", !strcmp("d", s)); 250 g_free(s); 251 s = owl_util_baseclass("n.d.d.d"); 252 FAIL_UNLESS("baseclass n.d.d.d", !strcmp("n", s)); 253 g_free(s); 254 s = owl_util_baseclass("ununun."); 255 FAIL_UNLESS("baseclass ununun.", !strcmp(".", s)); 256 g_free(s); 257 s = owl_util_baseclass("unununu"); 258 FAIL_UNLESS("baseclass unununu", !strcmp("u", s)); 259 g_free(s); 260 261 262 s = owl_util_makepath("foo/bar"); 263 FAIL_UNLESS("makepath foo/bar", !strcmp("foo/bar", s)); 264 g_free(s); 265 s = owl_util_makepath("//foo///bar"); 266 FAIL_UNLESS("makepath //foo///bar", !strcmp("/foo/bar", s)); 267 g_free(s); 268 s = owl_util_makepath("foo/~//bar/"); 269 FAIL_UNLESS("makepath foo/~//bar/", !strcmp("foo/~/bar/", s)); 270 g_free(s); 271 s = owl_util_makepath("~thisuserhadreallybetternotexist/foobar/"); 272 FAIL_UNLESS("makepath ~thisuserhadreallybetternotexist/foobar/", 273 !strcmp("~thisuserhadreallybetternotexist/foobar/", s)); 274 g_free(s); 275 276 errno = 0; 277 pw = getpwuid(getuid()); 278 if (pw) { 279 home = pw->pw_dir; 280 } else { 227 !strcmp(quoted->str, "hello foo 'world is'\"can't\" %s %")); 228 g_string_free(quoted, true); 229 230 231 CHECK_STR_AND_FREE("baseclass barnowl", 232 "barnowl", owl_util_baseclass("barnowl")); 233 CHECK_STR_AND_FREE("baseclass unbarnowl", 234 "barnowl", owl_util_baseclass("unbarnowl")); 235 CHECK_STR_AND_FREE("baseclass unununbarnowl.d.d", 236 "barnowl", owl_util_baseclass("unununbarnowl.d.d")); 237 CHECK_STR_AND_FREE("baseclass ununun.d.d", 238 "", owl_util_baseclass("ununun.d.d")); 239 CHECK_STR_AND_FREE("baseclass d.d.d.d", 240 "d", owl_util_baseclass("d.d.d.d")); 241 CHECK_STR_AND_FREE("baseclass n.d.d.d", 242 "n", owl_util_baseclass("n.d.d.d")); 243 CHECK_STR_AND_FREE("baseclass ununun.", 244 ".", owl_util_baseclass("ununun.")); 245 CHECK_STR_AND_FREE("baseclass unununu", 246 "u", owl_util_baseclass("unununu")); 247 248 249 CHECK_STR_AND_FREE("makepath foo/bar", 250 "foo/bar", owl_util_makepath("foo/bar")); 251 CHECK_STR_AND_FREE("makepath //foo///bar", 252 "/foo/bar", owl_util_makepath("//foo///bar")); 253 CHECK_STR_AND_FREE("makepath foo/~//bar/", 254 "foo/~/bar/", owl_util_makepath("foo/~//bar/")); 255 CHECK_STR_AND_FREE("makepath ~thisuserhadreallybetternotexist/foobar/", 256 "~thisuserhadreallybetternotexist/foobar/", 257 owl_util_makepath("~thisuserhadreallybetternotexist/foobar/")); 258 259 home = g_strdup(owl_global_get_homedir(&g)); 260 CHECK_STR_AND_FREE("makepath ~", 261 home, owl_util_makepath("~")); 262 263 path = g_build_filename(home, "foo/bar/baz", NULL); 264 CHECK_STR_AND_FREE("makepath ~///foo/bar//baz", 265 path, owl_util_makepath("~///foo/bar//baz")); 266 g_free(path); 267 g_free(home); 268 269 home = owl_util_homedir_for_user("root"); 270 if (home == NULL) { 281 271 /* Just make some noise so we notice. */ 282 home = "<WHAT>"; 283 fprintf(stderr, "getpwuid: %s", errno ? strerror(errno) : "No such user"); 284 } 285 s = owl_util_makepath("~"); 286 FAIL_UNLESS("makepath ~", !strcmp(home, s)); 287 g_free(s); 288 289 path = g_strconcat(home, "/foo/bar/baz", NULL); 290 s = owl_util_makepath("~///foo/bar//baz"); 291 FAIL_UNLESS("makepath ~///foo/bar//baz", !strcmp(path, s)); 292 g_free(s); 272 home = g_strdup("<WHAT>"); 273 fprintf(stderr, "owl_util_homedir_for_user failed"); 274 } 275 276 CHECK_STR_AND_FREE("makepath ~root", 277 home, owl_util_makepath("~root")); 278 279 path = g_build_filename(home, "foo/bar/baz", NULL); 280 CHECK_STR_AND_FREE("makepath ~root///foo/bar//baz", 281 path, owl_util_makepath("~root///foo/bar//baz")); 293 282 g_free(path); 294 295 errno = 0; 296 pw = getpwnam("root"); 297 if (pw) { 298 home = pw->pw_dir; 299 } else { 300 /* Just make some noise so we notice. */ 301 home = "<WHAT>"; 302 fprintf(stderr, "getpwnam: %s", errno ? strerror(errno) : "No such user"); 303 } 304 305 s = owl_util_makepath("~root"); 306 FAIL_UNLESS("makepath ~root", !strcmp(home, s)); 307 g_free(s); 308 309 path = g_strconcat(home, "/foo/bar/baz", NULL); 310 s = owl_util_makepath("~root///foo/bar//baz"); 311 FAIL_UNLESS("makepath ~root///foo/bar//baz", !strcmp(path, s)); 312 g_free(s); 313 g_free(path); 283 g_free(home); 314 284 315 285 /* if (numfailed) printf("*** WARNING: failures encountered with owl_util\n"); */ … … 367 337 int numfailed=0; 368 338 char *value; 369 const void *v;370 339 371 340 printf("# BEGIN testing owl_variable\n"); 372 FAIL_UNLESS("setup", 0==owl_variable_dict_setup(&vd));341 owl_variable_dict_setup(&vd); 373 342 374 343 FAIL_UNLESS("get bool var", NULL != (var = owl_variable_get_var(&vd, "rxping"))); … … 407 376 FAIL_UNLESS("get int 7", 9 == owl_variable_get_int(var)); 408 377 409 owl_variable_dict_newvar_string(&vd, "stringvar", "", "", "testval"); 378 FAIL_UNLESS("get enum var", NULL != (var = owl_variable_get_var(&vd, "scrollmode"))); 379 FAIL_UNLESS("get enum", OWL_SCROLLMODE_NORMAL == owl_variable_get_int(var)); 380 FAIL_UNLESS("get enum as string", 381 !strcmp((value = owl_variable_get_tostring(var)), "normal")); 382 g_free(value); 383 FAIL_UNLESS("set enum 1", 0 == owl_variable_set_int(var, OWL_SCROLLMODE_TOP)); 384 FAIL_UNLESS("get enum 1", OWL_SCROLLMODE_TOP == owl_variable_get_int(var)); 385 FAIL_UNLESS("set enum 2a", -1 == owl_variable_set_int(var, -1)); 386 FAIL_UNLESS("set enum 2b", -1 == owl_variable_set_int(var, OWL_SCROLLMODE_PAGEDCENTER + 1)); 387 FAIL_UNLESS("get enum 2", OWL_SCROLLMODE_TOP == owl_variable_get_int(var)); 388 FAIL_UNLESS("set enum 3", 0 == owl_variable_set_fromstring(var, "center", 0)); 389 FAIL_UNLESS("get enum 4", OWL_SCROLLMODE_CENTER == owl_variable_get_int(var)); 390 FAIL_UNLESS("set enum 5", -1 == owl_variable_set_fromstring(var, "bogus", 0)); 391 FAIL_UNLESS("set enum 6", -1 == owl_variable_set_fromstring(var, "", 0)); 392 FAIL_UNLESS("get enum 7", OWL_SCROLLMODE_CENTER == owl_variable_get_int(var)); 393 394 owl_variable_dict_newvar_string(&vd, "stringvar", "testval", "", ""); 410 395 FAIL_UNLESS("get new string var", NULL != (var = owl_variable_get_var(&vd, "stringvar"))); 411 FAIL_UNLESS("get new string var", NULL != (v = owl_variable_get(var)));412 396 FAIL_UNLESS("get new string val", !strcmp("testval", owl_variable_get_string(var))); 413 397 owl_variable_set_string(var, "new val"); 414 398 FAIL_UNLESS("update string val", !strcmp("new val", owl_variable_get_string(var))); 415 399 416 owl_variable_dict_newvar_int(&vd, "intvar", "", "", 47);400 owl_variable_dict_newvar_int(&vd, "intvar", 47, "", ""); 417 401 FAIL_UNLESS("get new int var", NULL != (var = owl_variable_get_var(&vd, "intvar"))); 418 FAIL_UNLESS("get new int var", NULL != (v = owl_variable_get(var)));419 402 FAIL_UNLESS("get new int val", 47 == owl_variable_get_int(var)); 420 403 owl_variable_set_int(var, 17); 421 404 FAIL_UNLESS("update int val", 17 == owl_variable_get_int(var)); 422 405 423 owl_variable_dict_newvar_bool(&vd, "boolvar", "", "", 1);406 owl_variable_dict_newvar_bool(&vd, "boolvar", true, "", ""); 424 407 FAIL_UNLESS("get new bool var", NULL != (var = owl_variable_get_var(&vd, "boolvar"))); 425 FAIL_UNLESS("get new bool var", NULL != (v = owl_variable_get(var)));426 408 FAIL_UNLESS("get new bool val", owl_variable_get_bool(var)); 427 409 owl_variable_set_bool_off(var); 428 410 FAIL_UNLESS("update bool val", !owl_variable_get_bool(var)); 429 411 430 owl_variable_dict_newvar_string(&vd, "nullstringvar", "", "", NULL);412 owl_variable_dict_newvar_string(&vd, "nullstringvar", NULL, "", ""); 431 413 FAIL_UNLESS("get new string (NULL) var", NULL != (var = owl_variable_get_var(&vd, "nullstringvar"))); 432 414 FAIL_UNLESS("get string (NULL)", NULL == (value = owl_variable_get_tostring(var))); … … 435 417 FAIL_UNLESS("get string (NULL) 2", NULL == (value = owl_variable_get_tostring(var))); 436 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)); 437 425 438 426 owl_variable_dict_cleanup(&vd); … … 529 517 FAIL_UNLESS("DAG", (f5 = owl_filter_new_fromstring("dag", "filter f1 or filter f1")) != NULL); 530 518 owl_filter_delete(f5); 519 520 owl_message_cleanup(&m); 531 521 532 522 return 0; … … 996 986 return numfailed; 997 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
r6829afc rf271129 1 #include <stdio.h>2 #include <string.h>3 #include <stdlib.h>4 #include <ctype.h>5 1 #include "owl.h" 6 2 7 3 /* Returns a copy of 'in' with each line indented 'n' 8 4 * characters. Result must be freed with g_free. */ 9 CALLER_OWN char *owl_text_indent(const char *in, int n )5 CALLER_OWN char *owl_text_indent(const char *in, int n, bool indent_first_line) 10 6 { 11 7 const char *ptr1, *ptr2, *last; 12 8 GString *out = g_string_new(""); 13 9 int i; 10 bool indent_this_line = indent_first_line; 14 11 15 12 last=in+strlen(in)-1; 16 13 ptr1=in; 17 14 while (ptr1<=last) { 18 for (i=0; i<n; i++) { 19 g_string_append_c(out, ' '); 20 } 15 if (indent_this_line) { 16 for (i = 0; i < n; i++) { 17 g_string_append_c(out, ' '); 18 } 19 } 20 indent_this_line = true; 21 21 ptr2=strchr(ptr1, '\n'); 22 22 if (!ptr2) { -
util.c
rc0c48d14 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> … … 32 25 } 33 26 27 CALLER_OWN char *owl_util_homedir_for_user(const char *name) 28 { 29 int err; 30 struct passwd pw_buf; 31 struct passwd *pw; 32 33 char *pw_strbuf, *ret; 34 long pw_strbuf_len = sysconf(_SC_GETPW_R_SIZE_MAX); 35 if (pw_strbuf_len < 0) { 36 /* If we really hate ourselves, we can be fancy and loop until we stop 37 * getting ERANGE. For now just pick a random number. */ 38 owl_function_error("owl_util_homedir_for_user: Could not get _SC_GETPW_R_SIZE_MAX"); 39 pw_strbuf_len = 16384; 40 } 41 pw_strbuf = g_new0(char, pw_strbuf_len); 42 err = getpwnam_r(name, &pw_buf, pw_strbuf, pw_strbuf_len, &pw); 43 if (err) { 44 owl_function_error("getpwuid_r: %s", strerror(err)); 45 /* Fall through; pw will be NULL. */ 46 } 47 ret = pw ? g_strdup(pw->pw_dir) : NULL; 48 g_free(pw_strbuf); 49 return ret; 50 } 51 34 52 /* Return a "nice" version of the path. Tilde expansion is done, and 35 53 * duplicate slashes are removed. Caller must free the return. … … 42 60 /* Attempt tilde-expansion of the first component. Get the 43 61 tilde-prefix, which goes up to the next slash. */ 44 struct passwd *pw;45 62 const char *end = strchr(in + 1, '/'); 46 63 if (end == NULL) 47 64 end = in + strlen(in); 48 65 66 /* Patch together a new path. Replace the ~ and tilde-prefix with 67 the homedir, if available. */ 49 68 if (end == in + 1) { 50 /* My home directory. */ 51 pw = getpwuid(getuid()); 69 /* My home directory. Use the one in owl_global for consistency with 70 * owl_zephyr_dotfile. */ 71 out = g_strconcat(owl_global_get_homedir(&g), end, NULL); 52 72 } else { 53 73 /* Someone else's home directory. */ 54 74 char *user = g_strndup(in + 1, end - (in + 1)); 55 pw = getpwnam(user); 75 char *home = owl_util_homedir_for_user(user); 76 if (home) { 77 out = g_strconcat(home, end, NULL); 78 } else { 79 out = g_strdup(in); 80 } 81 g_free(home); 56 82 g_free(user); 57 83 } 58 59 /* Patch together a new path. Replace the ~ and tilde-prefix with60 the homedir. */61 if (pw) {62 out = g_strconcat(pw->pw_dir, end, NULL);63 } else {64 out = g_strdup(in);65 }66 84 } else { 67 85 out = g_strdup(in); 68 86 } 69 87 … … 244 262 CALLER_OWN char *owl_arg_quote(const char *arg) 245 263 { 246 GString *buf = g_string_new(""); ;264 GString *buf = g_string_new(""); 247 265 owl_string_append_quoted_arg(buf, arg); 248 266 return g_string_free(buf, false); 249 267 } 250 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 251 283 /* caller must free the return */ 252 CALLER_OWN char *owl_util_ minutes_to_timestr(int in)284 CALLER_OWN char *owl_util_format_minutes(int in) 253 285 { 254 286 int days, hours; … … 269 301 } 270 302 return(out); 303 } 304 305 CALLER_OWN char *owl_util_format_time(const struct tm *time) 306 { 307 /* 32 chosen for first attempt because timestr will end up being 308 * something like "Www Mmm dd hh:mm:ss AM yyyy UTC\0" */ 309 size_t timestr_size = 16; 310 char *timestr = NULL; 311 do { 312 timestr_size *= 2; 313 timestr = g_renew(char, timestr, timestr_size); 314 } while (strftime(timestr, timestr_size, "%c", time) == 0); 315 return timestr; 271 316 } 272 317 … … 388 433 if (!g_path_is_absolute(link_path)) { 389 434 char *last_dir = g_path_get_dirname(last_path); 390 char *tmp = g_build_path(G_DIR_SEPARATOR_S, 391 last_dir, 392 link_path, 393 NULL); 435 char *tmp = g_build_filename(last_dir, link_path, NULL); 394 436 g_free(last_dir); 395 437 g_free(link_path); -
variable.c
ra16d7e5 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,