pax_global_header00006660000000000000000000000064135071167010014513gustar00rootroot0000000000000052 comment=940c2e71187073433daad5c50bdfb780fd81151d ytree-1.99pl1/000077500000000000000000000000001350711670100132225ustar00rootroot00000000000000ytree-1.99pl1/CHANGES000066400000000000000000000115571350711670100142260ustar00rootroot00000000000000New in 1.61 Clock Support Enhanced Sort Display Directory Attributes Viewer Configuration Color support Command line history Visual directory selection Helper-Applications now configurable in ~/.ytree Force removing of non-empty directories Dynamic directory scanning New in 1.62: Better escaping of meta-characters Some minor bugfixes New in 1.63: Bzip2 Support 8bit file/directory-names Bugfixes... New in 1.64: rpm Support Bugfixes... New in 1.65 FreeBSD Port DJGPP Port "jar" Support minor changes New in 1.66 User defined view spm Support New in 1.67 rar support No 4GB freespace limit New in 1.70 Large file support New spanish man-page Dynamic resize window support Bugfixes... New in 1.71 ia64 ready port to QNX 4.25 using ncurses 4.2 native X11 port using PDCurses (still working on window resizing) added configuration items: NOSMALLWINDOW - bypass small file window NUMBERSEP - number seperator in DIR statistics FILEMODE - default file mode on startup New in 1.72 Added fully user-configurable commands and menu text in user mode and file mode. Ytree may now be used as a user interface with fully customized actions tailored to the user's application and environment. New command-line arguments: -p - Instead of reading ($HOME)/.ytree (still the default), read for ytree profile configuration -h - Instead of using ($HOME)/.ytree-hst (still the default), use for ytree history added configuration items: INITIALDIR - Start in file window mode, not dir window mode. If "INITIALDIR=." open file window in startup directory. If "INITIALDIR=" where is a valid directory path under the startup directory, open at . [MENU] - New section specifying user-defined menu text on menu lines 1 and 2 in the DIR and FILE windows. and FILE mode [DIRCMD] - New section specifying user-defined commands to be associated with keyboard keys in dir window mode. [DIRMAP] - New section specifying user-defined keyboard key remapping and unmapping in dir window mode. [FILECMD] - New section specifying user-defined commands to be associated with keyboard keys in file window mode. [FILEMAP] - New section specifying user-defined keyboard key remapping and unmapping in file window mode. New in 1.73 Show all tagged files added Makefile update Layout adjustments New in 1.74 Sort by extension now with secondary key Port to GNU Hurd New in 1.75 Port to OpenBSD New in 1.76 Added QuitTo feature New in 1.77 Builtin hexdump New in 1.78 Bugfix: Copy to rel. nonexisting path does not work (Thanks to ZP Gu) New in 1.78-cbf Securityfix: ~/.ytree-hst now honors umask. Bugfix: some window sizes and layout adjustments. New builtin hexdump with some code to do the editing of hex files. Readline integration into InputString including tilde expansion. Cleanup dirwin.c and others to make it more readeable. New in 1.79 Libreadline support optional. Changed license from GPL 1 to GPL 2 due to use of libreadline. New in 1.80 ^Search command to untag files using an external program New in 1.81 Hex-Editor New in 1.82 Removed character mangling bug in "Path:" line on certain platforms (at least Solaris) Ported to Mac OS X New in 1.83 Bugfixes in Hex-Editor UTF-8 support New in 1.84 Enhanced UTF-8 support + russian man-page New in 1.85 Hopefully compiles again on sun architecture New in 1.86 Fixed crash when deleting last file in a directory New in 1.87 Removed warning in util.c New in 1.88 Changes for OpenBSD New in 1.89 Changes for NetBSD New in 1.90 Changes for NetBSD New in 1.91 Compiles on Mac OS 10.5.4 Debug crash for tagged delete New in 1.92 Compile on DJGPP Debug archive read if clock is enabled New in 1.93 Debug Crash during switch to file window (Fedora 11) New in 1.94 Adapted Makefile to respect environment CC and LDFLAGS New login to parent node ('p') command New in 1.95 Improved UTF-8 support New in 1.96 Bugfix for long usernames in /etc/passwd New in 1.97 Bugfixing in pathcopy / allow cancel during tagged copy New in 1.98 Bugfix for crash during showall with empty subfolders New function "ListJump" (F12) Removed some compiler warnings New in 1.99 Debug crash when switching directory view Support large disks New in 1.99PL1 Debug Path display for non color mode (Thanks to Ali) ytree-1.99pl1/COPYING000066400000000000000000000430741350711670100142650ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. ytree-1.99pl1/Makefile000066400000000000000000000210231350711670100146600ustar00rootroot00000000000000############################################################################ # # $Header: /usr/local/cvsroot/utils/ytree/Makefile,v 1.54 2012/09/11 16:40:02 werner Exp $ # # Makefile fuer ytree # ############################################################################ CC ?= cc # # ADD_CFLAGS: Add -DVI_KEYS if you want vi-cursor-keys # DESTDIR = /usr ADD_CFLAGS = -O # -DVI_KEYS BINDIR = $(DESTDIR)/bin MANDIR = $(DESTDIR)/share/man/man1 MANESDIR = $(DESTDIR)/share/man/es/man1 # Uncomment the lines for your system (default is linux) ########################### # LINUX (testet with ncurses 5.6) # Attention Slackware users: # Maybe you have to change the MANDIR to $(DESTDIR)/man/man1 ########################### COLOR = -DCOLOR_SUPPORT #CLOCK = -DCLOCK_SUPPORT # Experimental! READLINE = -DREADLINE_SUPPORT CFLAGS += -D_GNU_SOURCE $(COLOR) $(CLOCK) $(READLINE) $(ADD_CFLAGS) LDFLAGS += -lncurses -lreadline ########################### # LINUX with Wide character support (testet with ncurses 5.4) # Requires libncursesw! ########################### #COLOR = -DCOLOR_SUPPORT ##CLOCK = -DCLOCK_SUPPORT # Experimental! #READLINE = -DREADLINE_SUPPORT #CFLAGS = -D_GNU_SOURCE -DWITH_UTF8 $(ADD_CFLAGS) $(COLOR) $(CLOCK) $(READLINE) #LDFLAGS = -lncursesw -lreadline ########################### # LINUX without libreadline (testet with ncurses 5.2) # Attention Slackware users: # Maybe you have to change the MANDIR to $(DESTDIR)/man/man1 ########################### #COLOR = -DCOLOR_SUPPORT #CLOCK = -DCLOCK_SUPPORT # Experimental! #CFLAGS = $(ADD_CFLAGS) $(COLOR) $(CLOCK) #LDFLAGS = -lncurses ########################### # LINUX (X11 using PDCurses) thanks to Mark Hessling # see http://www.lightlink.com/hessling/ ########################### #COLOR = -DCOLOR_SUPPORT -DXCURSES #CLOCK = -DCLOCK_SUPPORT # Experimental! #CFLAGS = $(ADD_CFLAGS) $(COLOR) $(CLOCK) #LDFLAGS = -lXCurses -L/usr/X11R6/lib -lXaw -lXmu -lXt -lX11 -lSM -lICE -lXext ########################### # The Hurd (GNU) (testet with ncurses 5.0) ########################### #COLOR = -DCOLOR_SUPPORT ##CLOCK = -DCLOCK_SUPPORT # Experimental! #CFLAGS = $(ADD_CFLAGS) $(COLOR) $(CLOCK) #LDFLAGS = -lncurses ########################### # OpenBSD / NetBSD ########################### #COLOR = -DCOLOR_SUPPORT ##CLOCK = -DCLOCK_SUPPORT # Experimental! #READLINE = -DREADLINE_SUPPORT #CFLAGS = $(ADD_CFLAGS) $(COLOR) $(CLOCK) #LDFLAGS = -lcurses -lcompat -ledit #MANDIR = /usr/share/man/man1 #BINDIR = /usr/local/bin ########################### # FreeBSD (Thanks to Peter Brevik) ########################### #CFLAGS = -DCOLOR_SUPPORT -DNCURSES #LDFLAGS = -lncurses -lcompat ########################### # MAC OS X ########################### #CFLAGS = -DCOLOR_SUPPORT -DNCURSES #LDFLAGS = -lncurses ########################### # DOS/Windows with DJGPP ########################### #CC = gcc #CFLAGS = $(ADD_CFLAGS) $(COLOR) #LDFLAGS = -lpdcurses -lpanel -lreadline ########################### # NeXT (Thanks to fifi) ########################### #CFLAGS = -DTERMCAP $(ADD_CFLAGS) #LDFLAGS = -lcurses -ltermcap ############################ # UNIX SVR3 (or SCO3.2v4.2) ############################ #CFLAGS = -DSVR3 $(ADD_CFLAGS) #LDFLAGS = -lcurses -lPW # -lc_s ############################ # SCO OpenServer "SCO_SV s90909 3.2 5.0.5 i386" (Thanks to BKS) ############################ #CFLAGS = -DSVR3 $(ADD_CFLAGS) $(COLOR) $(CLOCK) -I/usr/local/bks-V3_SCO/ncurses-5.0-elf/include #COLOR = -DCOLOR_SUPPORT #LDFLAGS = -lncurses -L/usr/local/bks-V3_SCO/ncurses-5.0-elf/lib -belf ########################### # Interactive ########################### #CFLAGS = -DSVR3 -Disc386 $(ADD_CFLAGS) #LDFLAGS = -lcurses -lPW ########################### # UNIX SVR4 ########################### #CFLAGS = -DSVR4 $(ADD_CFLAGS) #LDFLAGS = -lcurses -lgen ########################### # OSF1 ########################### #CFLAGS = -DOSF1 $(ADD_CFLAGS) #LDFLAGS = -lcurses ########################### # HPUX ########################### #CFLAGS = -Dhpux $(ADD_CFLAGS) #LDFLAGS = -lcurses -lc -lPW #CC = cc -Ae ########################### # HPUX-10.x ########################### #CFLAGS = -Dhpux $(ADD_CFLAGS) #LDFLAGS = -lcur_colr -lc -lPW #CC = cc -Ae ########################### # SGI IRIX Rel. 5.2 ########################### #CFLAGS = -Dsgi $(ADD_CFLAGS) #LDFLAGS = -lcurses -lgen ########################### # Solaris 2 ########################### #CFLAGS = $(ADD_CFLAGS) -DSVR4 #LDFLAGS = -lcurses ########################### # SUN ########################### #CFLAGS = $(ADD_CFLAGS) #CC = acc -Xa -strconst -sys5 #LDFLAGS = -lcurses ########################### # SUN (gcc) ########################### #CFLAGS = $(ADD_CFLAGS) #CC = gcc -I/usr/5include -L/usr/5lib #LDFLAGS = -lcurses ########################### # SUNOS 5.6 (gcc) Thanks to Fabiano Silos Reis ########################### #CFLAGS = $(ADD_CFLAGS) -Dsun56 #CC = gcc -I/usr/include -L/usr/lib #LDFLAGS = -lcurses ########################### # IBM RS/6000 (Thanks to jum) ########################### #CFLAGS = $(ADD_CFLAGS) #LDFLAGS = -lcurses -lPW ########################### # ULTRIX V4.3 ########################### #CFLAGS = -Dultrix $(ADD_CFLAGS) #LDFLAGS = -lcursesX ########################### # QNX (tested with ncurses 4.2) ########################### #COLOR = -DCOLOR_SUPPORT #CLOCK = -DCLOCK_SUPPORT # Experimental! #CFLAGS = $(ADD_CFLAGS) $(COLOR) $(CLOCK) -DHAS_REGCOMP #LDFLAGS = -L/home/mhes/lib -lncurses ############################################################################## MAIN = ytree OBJS = arc.o archive.o chgrp.o chmod.o chown.o clock.o color.o copy.o \ delete.o dirwin.o disp.o edit.o error.o execute.o filespec.o \ filewin.o freesp.o global.o group.o hex.o history.o init.o input.o keyhtab.o lha.o \ login.o main.o match.o mkdir.o mktime.o move.o passwd.o pipe.o \ print.o profile.o quit.o rar.o readtree.o rename.o rmdir.o rpm.o \ sort.o stat.o system.o tar.o termcap.o tilde.o usermode.o util.o view.o xmalloc.o zip.o zoo.o # $(MAIN): $(OBJS) $(CC) $(LFLAGS) -o $@ $(OBJS) $(LDFLAGS) install: $(MAIN) install $(MAIN) $(BINDIR) gzip -9c ytree.1 > ytree.1.gz if [ -d $(MANDIR) ]; then install -m 0644 ytree.1.gz $(MANDIR)/; fi gzip -9c ytree.1.es > ytree.1.es.gz if [ -d $(MANESDIR) ]; then install -m 0644 ytree.1.es.gz $(MANESDIR)/; fi clean: rm -f core *.o *~ *.orig *.bak clobber: clean rm -f $(MAIN) ytree.1.es.gz ytree.1.gz ################################################## arc.o: config.h ytree.h arc.c archive.o: config.h ytree.h archive.c chgrp.o: config.h ytree.h chgrp.c chmod.o: config.h ytree.h chmod.c chown.o: config.h ytree.h chown.c color.o: config.h ytree.h color.c copy.o: config.h ytree.h copy.c delete.o: config.h ytree.h delete.c dirwin.o: config.h ytree.h dirwin.c disp.o: config.h ytree.h patchlev.h disp.c edit.o: config.h ytree.h edit.c error.o: config.h ytree.h error.c execute.o: config.h ytree.h execute.c filespec.o: config.h ytree.h filespec.c filewin.o: config.h ytree.h filewin.c freesp.o: config.h ytree.h freesp.c global.o: config.h ytree.h global.c group.o: config.h ytree.h group.c hex.o: config.h ytree.h hex.c history.o: config.h ytree.h history.c init.o: config.h ytree.h init.c input.o: config.h ytree.h tilde.h xmalloc.h input.c keyhtab.o: config.h ytree.h keyhtab.c lha.o: config.h ytree.h lha.c login.o: config.h ytree.h login.c main.o: config.h ytree.h main.c match.o: config.h ytree.h match.c mkdir.o: config.h ytree.h mkdir.c mktime.o: config.h ytree.h mktime.c move.o: config.h ytree.h move.c passwd.o: config.h ytree.h passwd.c pipe.o: config.h ytree.h pipe.c print.o: ytree.h print.c config.h profile.o: config.h ytree.h profile.c quit.o: config.h ytree.h quit.c rar.o: config.h ytree.h rar.c readtree.o: config.h ytree.h readtree.c rename.o: config.h ytree.h rename.c rmdir.o: config.h ytree.h rmdir.c rpm.o: config.h ytree.h rpm.c sort.o: config.h ytree.h sort.c stat.o: config.h ytree.h stat.c system.o: config.h ytree.h system.c tar.o: config.h ytree.h tar.c termcap.o: config.h ytree.h termcap.c tilde.o: config.h xmalloc.h tilde.h tilde.c usermode.o: config.h ytree.h usermode.c util.o: config.h ytree.h util.c view.o: config.h ytree.h view.c xmalloc.o: config.h ytree.h xmalloc.h xmalloc.c zip.o: config.h ytree.h zip.c zoo.o: config.h ytree.h zoo.c ytree-1.99pl1/README000066400000000000000000000024371350711670100141100ustar00rootroot00000000000000 # ## ## ## ##### ## ### #### #### ## ## ## ## ## ## ## ## ## ## ## ## ## ## ###### ###### ##### ## # ## ## ## ## ### #### #### #### ##### Description ytree is a DOS-XTREE(tm) similar file manager. Author Werner Bregulla eMail: werner@frolix.han.de Platforms - SYSV R3.2/R4 - Interactive - Linux - The Hurd - NeXTstep 2.1 - Irix 5.2 - AIX 3.2 - HPUX - SUNOS 4.1 / Solaris 2 - ULTRIX 4.3 - DEC-UNIX / OSF1 - WIN32 with DJGPP (see http://www.lightlink.com/hessling/ and http://www.delorie.com/djgpp) - FreeBSD - OpenBSD - NetBSD - QNX - Apple Mac OS X Building In most instances, it should be sufficient to modify the Makefile (Default is linux) type make su ...enter password... make install exit ytree For customizing ytree edit ytree.conf and copy it to $HOME/.ytree For using the "QuitTo" feature you have to add a bash wrapper to your ~/.bashrc. See the man page for details. Copyright This program is distributed as free software under the GNU license (see COPYING for more information). ytree-1.99pl1/THANKS000066400000000000000000000017221350711670100141370ustar00rootroot00000000000000 Many thanks to all who helped developing ytree: Andrew Cottrell ( DJGPP - port ) Andrey Zakhvatov / Peter Brevik ( FreeBSD - port ) Axel F. Zinser ( NeXT - port ) Carlos Barros ( Color / history&keyF2 / viewer configurable / spanish man-page / list all tagged files / hex viewer/editor / readline ) C. R. Bryan III ( QuitTo/hexdump ) Jens-Uwe Mager ( RS/6000 - port / Configuration ) Mark Hessling ( QNX - port / PDCurses configuration addons ) Marcus Brinkmann ( Port to GNU Hurd ) Norman Fahlbusch ( test and "marketing" :-) ) Roger Knobbe ( secondary key for sort by ext. ) S.Addams (SJA) ( OpenBSD - port) Martynas Venckus ( OpenBSD/NetBSD - port ) Valere Monseur aka Dobedo ( NetBSD ) Scott Wagner ( command/menu configurable ) Siegfried Salomon ( SCO OpenServer 5 (5.0.5) ) Tina Hoeltig ( man-page / tips ) Victor Vislobokov ( UTF-8 support ) Thank you! Werner ytree-1.99pl1/arc.c000066400000000000000000000074761350711670100141510ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/arc.c,v 1.11 2000/05/20 20:41:11 werner Exp $ * * Funktionen zum Lesen des Dateibaumes aus ARC-Dateien * ***************************************************************************/ #include "ytree.h" static int GetStatFromARC(char *arc_line, char *name, struct stat *stat); /* Dateibaum aus ARC-Listing lesen */ /*---------------------------------*/ int ReadTreeFromARC(DirEntry *dir_entry, FILE *f) { char arc_line[ARC_LINE_LENGTH + 1]; char path_name[PATH_LENGTH +1]; struct stat stat; BOOL dir_flag = FALSE; *dir_entry->name = '\0'; while( fgets( arc_line, ARC_LINE_LENGTH, f ) != NULL ) { /* \n loeschen */ /*-------------*/ arc_line[ strlen( arc_line ) - 1 ] = '\0'; if( strlen( arc_line ) > (unsigned) 63 && arc_line[63] == ':' ) { /* gueltiger Eintrag */ /*-------------------*/ if( GetStatFromARC( arc_line, path_name, &stat ) ) { (void) sprintf( message, "unknown arcinfo*%s", arc_line ); MESSAGE( message ); } else { /* File */ /*------*/ #ifdef DEBUG fprintf( stderr, "FILE: \"%s\"\n", path_name ); #endif (void) InsertArchiveFileEntry( dir_entry, path_name, &stat ); } } } if( dir_flag == FALSE ) { statistic.disk_total_directories++; (void) memset( (char *) &dir_entry->stat_struct, 0, sizeof( struct stat ) ); dir_entry->stat_struct.st_mode = S_IFDIR; } return( MinimizeArchiveTree( dir_entry ) ); } static int GetStatFromARC(char *arc_line, char *name, struct stat *stat) { char *t, *old; int i, id; struct tm tm_struct; static char *month[] = { "Jan", "Feb", "Mar", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; (void) memset( stat, 0, sizeof( struct stat ) ); stat->st_nlink = 1; t = Strtok_r( arc_line, " \t", &old ); if( t == NULL ) return( -1 ); /* Dateiname */ /*-----------*/ (void) strcpy( name, t ); t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); /* Dateilaenge */ /*-------------*/ if( !isdigit( *t ) ) return( -1 ); stat->st_size = AtoLL( t ); t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); /* Stowage */ /*---------*/ t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); /* SF */ /*----*/ t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); /* Size Now */ /*----------*/ if( !isdigit( *t ) ) return( -1 ); t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); /* M-Datum */ /*---------*/ tm_struct.tm_mday = atoi( t ); t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); for( i=0; i < 12; i++ ) { if( !strcmp( t, month[i] ) ) break; } if( i >= 12 ) i = 0; tm_struct.tm_mon = i; t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); tm_struct.tm_year = atoi( t ); if(tm_struct.tm_year < 70) tm_struct.tm_year += 100; t = Strtok_r( NULL, " \t:", &old ); if( t == NULL ) return( -1 ); tm_struct.tm_hour = atoi( t ); t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); if( t[strlen(t)-1] == 'p' ) tm_struct.tm_hour += 12; t[strlen(t)-1] ='\0'; tm_struct.tm_min = atoi( t ); t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); tm_struct.tm_sec = 0; tm_struct.tm_isdst = -1; stat->st_atime = 0; stat->st_ctime = 0; stat->st_mtime = Mktime( &tm_struct ); /* Attributes */ /*------------*/ stat->st_mode = S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; /* Owner */ /*-------*/ id = getuid(); if( id == -1 ) id = atoi( t ); stat->st_uid = (unsigned) id; /* Group */ /*-------*/ id = getgid(); stat->st_gid = (unsigned) id; return( 0 ); } ytree-1.99pl1/archive.c000066400000000000000000000351531350711670100150160ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/archive.c,v 1.16 2000/05/20 20:41:11 werner Exp $ * * Allg. Funktionen zum Bearbeiten von Archiven * ***************************************************************************/ #include "ytree.h" static int GetArchiveDirEntry(DirEntry *tree, char *path, DirEntry **dir_entry); static int InsertArchiveDirEntry(DirEntry *tree, char *path, struct stat *stat) { DirEntry *df_ptr, *de_ptr, *ds_ptr; char father_path[PATH_LENGTH + 1]; char *p; char name[PATH_LENGTH + 1]; #ifdef DEBUG fprintf( stderr, "Insert Dir \"%s\"\n", path ); #endif /* Format: .../dir/ */ /*------------------*/ (void) strcpy( father_path, path ); if( ( p = strrchr( father_path, FILE_SEPARATOR_CHAR ) ) ) *p = '\0'; else { (void) sprintf( message, "path mismatch*missing '%c' in*%s", FILE_SEPARATOR_CHAR, path ); ERROR_MSG( message ); return( -1 ); } p = strrchr( father_path, FILE_SEPARATOR_CHAR ); if( p == NULL ) { df_ptr = tree; if( !strcmp( path, FILE_SEPARATOR_STRING ) ) (void) strcpy( name, path ); else (void) strcpy( name, father_path ); } else { (void) strcpy( name, ++p ); *p = '\0'; if( GetArchiveDirEntry( tree, father_path, &df_ptr ) ) { (void) sprintf( message, "can't find subdir*%s", father_path ); ERROR_MSG( message ); return( -1 ); } } if( ( de_ptr = (DirEntry *) malloc( sizeof( DirEntry ) + strlen( name ) ) ) == NULL ) { ERROR_MSG( "Malloc failed*ABORT" ); exit( 1 ); } (void) memset( (char *) de_ptr, 0, sizeof( DirEntry ) ); (void) strcpy( de_ptr->name, name ); (void) memcpy( (char *) &de_ptr->stat_struct, (char *) stat, sizeof( struct stat ) ); #ifdef DEBUG fprintf( stderr, "new dir: \"%s\"\n", name ); #endif /* Directory einklinken */ /*----------------------*/ if( p == NULL ) { /* in tree (=df_ptr) einklinken */ /*------------------------------*/ de_ptr->up_tree = df_ptr->up_tree; for( ds_ptr = df_ptr; ds_ptr; ds_ptr = ds_ptr->next ) { if( strcmp( ds_ptr->name, de_ptr->name ) > 0 ) { /* ds-Element ist groesser */ /*-------------------------*/ de_ptr->next = ds_ptr; de_ptr->prev = ds_ptr->prev; if( ds_ptr->prev) ds_ptr->prev->next = de_ptr; ds_ptr->prev = de_ptr; if( de_ptr->up_tree && de_ptr->up_tree->sub_tree == de_ptr->next ) de_ptr->up_tree->sub_tree = de_ptr; break; } if( ds_ptr->next == NULL ) { /* Ende der Liste erreicht; ==> einfuegen */ /*----------------------------------------*/ de_ptr->prev = ds_ptr; de_ptr->next = ds_ptr->next; ds_ptr->next = de_ptr; break; } } } else if( df_ptr->sub_tree == NULL ) { de_ptr->up_tree = df_ptr; df_ptr->sub_tree = de_ptr; } else { de_ptr->up_tree = df_ptr; for( ds_ptr = df_ptr->sub_tree; ds_ptr; ds_ptr = ds_ptr->next ) { if( strcmp( ds_ptr->name, de_ptr->name ) > 0 ) { /* ds-Element ist groesser */ /*-------------------------*/ de_ptr->next = ds_ptr; de_ptr->prev = ds_ptr->prev; if( ds_ptr->prev ) ds_ptr->prev->next = de_ptr; ds_ptr->prev = de_ptr; if( de_ptr->up_tree->sub_tree == de_ptr->next ) de_ptr->up_tree->sub_tree = de_ptr; break; } if( ds_ptr->next == NULL ) { /* Ende der Liste erreicht; ==> einfuegen */ /*----------------------------------------*/ de_ptr->prev = ds_ptr; de_ptr->next = ds_ptr->next; ds_ptr->next = de_ptr; break; } } } statistic.disk_total_directories++; return( 0 ); } int InsertArchiveFileEntry(DirEntry *tree, char *path, struct stat *stat) { char dir[PATH_LENGTH + 1]; char file[PATH_LENGTH + 1]; DirEntry *de_ptr; FileEntry *fs_ptr, *fe_ptr; struct stat stat_struct; int n; if( KeyPressed() ) { Quit(); /* Abfrage, ob ytree verlassen werden soll */ } Fnsplit( path, dir, file ); if( GetArchiveDirEntry( tree, dir, &de_ptr ) ) { #ifdef DEBUG fprintf( stderr, "can't get directory for file*%s*trying recover", path ); #endif (void) memset( (char *) &stat_struct, 0, sizeof( struct stat ) ); stat_struct.st_mode = S_IFDIR; if( TryInsertArchiveDirEntry( tree, dir, &stat_struct ) ) { ERROR_MSG( "inserting directory failed" ); return( -1 ); } if( GetArchiveDirEntry( tree, dir, &de_ptr ) ) { (void) sprintf( message, "again: can't get directory for file*%s*giving up", path ); ERROR_MSG( message ); return( -1 ); } } if( S_ISLNK( stat->st_mode ) ) n = strlen( &path[ strlen( path ) + 1 ] ) + 1; else n = 0; if( ( fe_ptr = (FileEntry *) malloc( sizeof( FileEntry ) + strlen( file ) + n ) ) == NULL ) { ERROR_MSG( "Malloc failed*ABORT" ); exit( 1 ); } (void) memset( fe_ptr, 0, sizeof( FileEntry ) ); (void) memcpy( (char *) &fe_ptr->stat_struct, (char *) stat, sizeof( struct stat ) ); (void) strcpy( fe_ptr->name, file ); if( S_ISLNK( stat->st_mode ) ) { (void) strcpy( &fe_ptr->name[ strlen( fe_ptr->name ) + 1 ], &path[ strlen( path ) + 1 ] ); } fe_ptr->dir_entry = de_ptr; de_ptr->total_files++; de_ptr->total_bytes += stat->st_size; statistic.disk_total_files++; statistic.disk_total_bytes += stat->st_size; /* Einklinken */ /*------------*/ if( de_ptr->file == NULL ) { de_ptr->file = fe_ptr; } else { for( fs_ptr = de_ptr->file; fs_ptr->next; fs_ptr = fs_ptr->next ) ; fe_ptr->prev = fs_ptr; fs_ptr->next = fe_ptr; } return( 0 ); } static int GetArchiveDirEntry(DirEntry *tree, char *path, DirEntry **dir_entry) { int n; DirEntry *de_ptr; BOOL is_root = FALSE; #ifdef DEBUG fprintf( stderr, "GetArchiveDirEntry: tree=%s, path=%s\n", (tree) ? tree->name : "NULL", path ); #endif if( strchr( path, FILE_SEPARATOR_CHAR ) != NULL ) { for( de_ptr = tree; de_ptr; de_ptr = de_ptr->next ) { n = strlen( de_ptr->name ); if( !strcmp( de_ptr->name, FILE_SEPARATOR_STRING ) ) is_root = TRUE; if( n && !strncmp( de_ptr->name, path, n ) && (is_root || path[n] == '\0' || path[n] == FILE_SEPARATOR_CHAR ) ) { if( ( is_root && path[n] == '\0' ) || ( path[n] == FILE_SEPARATOR_CHAR && path[n+1] == '\0' ) ) { /* Pfad abgearbeitet; ==> fertig */ /*-------------------------------*/ *dir_entry = de_ptr; return( 0 ); } else { return( GetArchiveDirEntry( de_ptr->sub_tree, ( is_root ) ? &path[n] : &path[n+1], dir_entry ) ); } } } } if( *path == '\0' ) { *dir_entry = tree; return( 0 ); } return( -1 ); } int TryInsertArchiveDirEntry(DirEntry *tree, char *dir, struct stat *stat) { DirEntry *de_ptr; char dir_path[PATH_LENGTH + 1]; char *s, *t; (void) memset( dir_path, 0, sizeof( dir_path ) ); #ifdef DEBUG fprintf( stderr, "Try install start \n" ); #endif for( s=dir, t=dir_path; *s; s++, t++ ) { if( (*t = *s) == FILE_SEPARATOR_CHAR ) { if( GetArchiveDirEntry( tree, dir_path, &de_ptr ) == -1 ) { /* Evtl. fehlender teil; ==> einfuegen */ /*-------------------------------------*/ if( InsertArchiveDirEntry( tree, dir_path, stat ) ) return( -1 ); } } } #ifdef DEBUG fprintf( stderr, "Try install end\n" ); #endif return( 0 ); } int MinimizeArchiveTree(DirEntry *tree) { DirEntry *de_ptr, *de1_ptr; DirEntry *next_ptr; FileEntry *fe_ptr; /* Falls tree einen Nachfolger hat und * tree selbst leer ist, wird tree gestrichen */ if( tree->prev == NULL && tree->next != NULL && tree->file == NULL ) { next_ptr = tree->next; (void) memcpy( (char *) tree, (char *) tree->next, sizeof( DirEntry ) + strlen( tree->next->name ) ); tree->prev = NULL; if( tree->next ) tree->next->prev = tree; statistic.disk_total_directories--; free( next_ptr ); for( fe_ptr=tree->file; fe_ptr; fe_ptr=fe_ptr->next) fe_ptr->dir_entry = tree; for( de_ptr=tree->sub_tree; de_ptr; de_ptr=de_ptr->next) de_ptr->up_tree = tree; } /* Test, ob *de_ptr weder Vorgaenger noch Nachfolger noch Dateien hat */ /*--------------------------------------------------------------------*/ for( de_ptr = tree->sub_tree; de_ptr; de_ptr = next_ptr ) { if( de_ptr->prev == NULL && de_ptr->next == NULL && de_ptr->file == NULL ) { /* Zusammenfassung moeglich */ /*--------------------------*/ if( strcmp( tree->name, FILE_SEPARATOR_STRING ) ) (void) strcat( tree->name, FILE_SEPARATOR_STRING ); (void) strcat( tree->name, de_ptr->name ); statistic.disk_total_directories--; tree->sub_tree = de_ptr->sub_tree; for( de1_ptr = de_ptr->sub_tree; de1_ptr; de1_ptr = de1_ptr->next ) de1_ptr->up_tree = tree; next_ptr = de_ptr->sub_tree; free( de_ptr ); #ifdef DEBUG fprintf( stderr, "new root-dir: \"%s\"\n", tree->name ); #endif continue; } break; } /* Letzter Optimierungsschritt: * Falls tree weder Vorgaenger noch Nachfolger hat, aber * einen Subtree der Files hat, wird zusammengefasst */ if( tree->prev == NULL && tree->next == NULL && tree->file == NULL && tree->sub_tree && tree->sub_tree->prev == NULL && tree->sub_tree->next == NULL ) { de_ptr = tree->sub_tree; (void) strcat( tree->name, FILE_SEPARATOR_STRING ); (void) strcat( tree->name, de_ptr->name ); tree->file = de_ptr->file; for( fe_ptr=tree->file; fe_ptr; fe_ptr=fe_ptr->next ) fe_ptr->dir_entry = tree; (void) memcpy( (char *) &tree->stat_struct, (char *) &de_ptr->stat_struct, sizeof( struct stat ) ); statistic.disk_total_directories--; tree->sub_tree = de_ptr->sub_tree; for( de1_ptr = de_ptr->sub_tree; de1_ptr; de1_ptr = de1_ptr->next ) de1_ptr->up_tree = tree; free( de_ptr ); } return( 0 ); } void MakeExtractCommandLine(char *command_line, char *path, char *file, char *cmd) { int l; char cat_path[PATH_LENGTH+1]; int compress_method; compress_method = GetFileMethod( path ); l = strlen( path ); if( compress_method == ZOO_COMPRESS ) { /* zoo xp FILE ?? */ /*----------------*/ (void) sprintf( command_line, "%s '%s' '%s' %s", ZOOEXPAND, path, file, cmd ); } else if( compress_method == LHA_COMPRESS ) { /* xlharc p FILE ?? */ /*------------------*/ (void) sprintf( command_line, "%s '%s' '%s' %s", LHAEXPAND, path, file, cmd ); } else if( compress_method == ZIP_COMPRESS ) { /* unzip -c FILE ?? */ /*------------------*/ (void) sprintf( command_line, "%s '%s' '%s' %s", ZIPEXPAND, path, file, cmd ); } else if( compress_method == ARC_COMPRESS ) { /* arc p FILE ?? */ /*---------------*/ (void) sprintf( command_line, "%s '%s' '%s' %s", ARCEXPAND, path, file, cmd ); } else if( compress_method == RPM_COMPRESS ) { /* TF=/tmp/ytree.$$; mkdir $TF; cd $TF; rpm2cpio RPM_FILE | cpio -id FILE; * cat $TF/$2; cd /tmp; rm -rf $TF; exit 0 */ if(!strcmp(RPMEXPAND, "builtin")) { (void) sprintf( command_line, "(TF=/tmp/ytree.$$; mkdir $TF; rpm2cpio '%s' | (cd $TF; cpio --no-absolute-filenames -i -d '%s'); cat \"$TF/%s\"; cd /tmp; rm -rf $TF; exit 0) %s", path, (*file == FILE_SEPARATOR_CHAR) ? &file[1] : file, file, cmd ); } else { (void) sprintf( command_line, "%s '%s' '%s' %s", RPMEXPAND, path, file, cmd ); } } else if( compress_method == RAR_COMPRESS ) { /* rar p FILE ?? */ /*---------------*/ (void) sprintf( command_line, "%s '%s' '%s' %s", RAREXPAND, path, file, cmd ); } else if( compress_method == FREEZE_COMPRESS ) { /* melt < TAR_FILE | gtar xOf - FILE ?? */ /*--------------------------------------*/ (void) sprintf( command_line, "%s < '%s' | %s '%s' %s", MELT, path, TAREXPAND, file, cmd ); } else if( compress_method == MULTIPLE_FREEZE_COMPRESS ) { /* CAT TAR_FILEs | melt | gtar xOf - FILE ?? */ /*-------------------------------------------*/ (void) strncpy( cat_path, path, l - 2 ); (void) strcpy( &cat_path[l-2], "*" ); (void) sprintf( command_line, "%s %s | %s | %s '%s' %s", CAT, cat_path, MELT, TAREXPAND, file, cmd ); } else if( compress_method == COMPRESS_COMPRESS ) { /* uncompress < TAR_FILE | gtar xOf - FILE ?? */ /*--------------------------------------------*/ (void) sprintf( command_line, "%s < %s | %s '%s' %s", UNCOMPRESS, path, TAREXPAND, file, cmd ); } else if( compress_method == MULTIPLE_COMPRESS_COMPRESS ) { /* CAT TAR_FILEs | uncompress | gtar xOf - FILE ?? */ /*-------------------------------------------------*/ (void) strncpy( cat_path, path, l - 2 ); (void) strcpy( &cat_path[l-2], "*" ); (void) sprintf( command_line, "%s %s | %s | %s '%s' %s", CAT, cat_path, UNCOMPRESS, TAREXPAND, file, cmd ); } else if( compress_method == GZIP_COMPRESS ) { /* gunzip < TAR_FILE | gtar xOf - FILE ?? */ /*----------------------------------------*/ (void) sprintf( command_line, "%s < '%s' | %s '%s' %s", GNUUNZIP, path, TAREXPAND, file, cmd ); } else if( compress_method == MULTIPLE_GZIP_COMPRESS ) { /* CAT TAR_FILEs | gunzip | gtar xOf - FILE ?? */ /*---------------------------------------------*/ (void) strncpy( cat_path, path, l - 2 ); (void) strcpy( &cat_path[l-2], "*" ); (void) sprintf( command_line, "%s %s | %s | %s '%s' %s", CAT, cat_path, GNUUNZIP, TAREXPAND, file, cmd ); } else if( compress_method == BZIP_COMPRESS ) { /* bunzip2 < TAR_FILE | gtar xOf - FILE ?? */ /*----------------------------------------*/ (void) sprintf( command_line, "%s < '%s' | %s '%s' %s", BUNZIP, path, TAREXPAND, file, cmd ); } else { /* gtar xOf - FILE < TAR_FILE ?? */ /*-------------------------------*/ (void) sprintf( command_line, "%s '%s' < '%s' %s", TAREXPAND, file, path, cmd ); } #ifdef DEBUG fprintf( stderr, "system( \"%s\" )\n", command_line ); #endif } ytree-1.99pl1/chgrp.c000066400000000000000000000063761350711670100145050ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/chgrp.c,v 1.13 2005/01/22 16:32:29 werner Exp $ * * Change Group * ***************************************************************************/ #include "ytree.h" static int SetDirGroup(DirEntry *de_ptr, int new_group_id); int ChangeFileGroup(FileEntry *fe_ptr) { WalkingPackage walking_package; int group_id; int result; result = -1; if( mode != DISK_MODE && mode != USER_MODE ) { beep(); return( result ); } if( ( group_id = GetNewGroup( fe_ptr->stat_struct.st_gid ) ) >= 0 ) { walking_package.function_data.change_group.new_group_id = group_id; result = SetFileGroup( fe_ptr, &walking_package ); } return( result ); } int GetNewGroup(int st_gid) { char group[GROUP_NAME_MAX * 2 +1]; char *group_name_ptr; int id; int group_id; group_id = -1; id = ( st_gid == -1 ) ? (int) getgid() : st_gid; group_name_ptr = GetGroupName( id ); if( group_name_ptr == NULL ) { (void) sprintf( group, "%d", id ); } else { (void) strcpy( group, group_name_ptr ); } ClearHelp(); MvAddStr( LINES - 2, 1, "New Group:" ); if( InputString( group, LINES - 2, 12, 0, GROUP_NAME_MAX, "\r\033" ) == CR ) { if( (group_id = GetGroupId( group )) == -1 ) { (void) sprintf( message, "Can't read Group-ID:*\"%s\"", group ); MESSAGE( message ); } } move( LINES - 2, 1 ); clrtoeol(); return( group_id ); } int SetFileGroup(FileEntry *fe_ptr, WalkingPackage *walking_package) { struct stat stat_struct; char buffer[PATH_LENGTH+1]; int result; int new_group_id; result = -1; walking_package->new_fe_ptr = fe_ptr; /* unchanged */ new_group_id = walking_package->function_data.change_group.new_group_id; if( !chown( GetFileNamePath( fe_ptr, buffer ), fe_ptr->stat_struct.st_uid , new_group_id ) ) { /* Erfolgreich modifiziert */ /*-------------------------*/ if( STAT_( buffer, &stat_struct ) ) { ERROR_MSG( "Stat Failed" ); } else { fe_ptr->stat_struct = stat_struct; } result = 0; } else { (void) sprintf( message, "Can't change owner:*%s", strerror(errno) ); MESSAGE( message ); } return( result ); } int ChangeDirGroup(DirEntry *de_ptr) { int group_id; int result; result = -1; if( mode != DISK_MODE && mode != USER_MODE ) { beep(); return( result ); } if( ( group_id = GetNewGroup( de_ptr->stat_struct.st_gid ) ) >= 0 ) { result = SetDirGroup( de_ptr, group_id ); } return( result ); } static int SetDirGroup(DirEntry *de_ptr, int new_group_id) { struct stat stat_struct; char buffer[PATH_LENGTH+1]; int result; result = -1; if( !chown( GetPath( de_ptr, buffer ), de_ptr->stat_struct.st_uid , new_group_id ) ) { /* Erfolgreich modifiziert */ /*-------------------------*/ if( STAT_( buffer, &stat_struct ) ) { Warning( "stat failed" ); } else { de_ptr->stat_struct = stat_struct; } result = 0; } else { (void) sprintf( message, "Can't change owner:*%s", strerror(errno) ); MESSAGE( message ); } return( result ); } ytree-1.99pl1/chmod.c000066400000000000000000000137651350711670100144740ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/chmod.c,v 1.14 2001/06/15 16:36:36 werner Exp $ * * Change Modus * ***************************************************************************/ #include "ytree.h" static int SetDirModus(DirEntry *de_ptr, WalkingPackage *walking_package); static int GetNewModus(int old_modus, char *new_modus ); int ChangeFileModus(FileEntry *fe_ptr) { char modus[11]; WalkingPackage walking_package; int result; result = -1; if( mode != DISK_MODE && mode != USER_MODE ) { beep(); return( result ); } (void) GetAttributes( fe_ptr->stat_struct.st_mode, modus ); if( GetNewFileModus( LINES - 2, 1, modus, "\r\033" ) == CR ) { (void) strcpy( walking_package.function_data.change_modus.new_modus, modus ); result = SetFileModus( fe_ptr, &walking_package ); } move( LINES - 2, 1 ); clrtoeol(); return( result ); } int ChangeDirModus(DirEntry *de_ptr) { char modus[11]; WalkingPackage walking_package; int result; result = -1; if( mode != DISK_MODE && mode != USER_MODE ) { beep(); return( result ); } (void) GetAttributes( de_ptr->stat_struct.st_mode, modus ); if( GetNewFileModus( LINES - 2, 1, modus, "\r\033" ) == CR ) { (void) strcpy( walking_package.function_data.change_modus.new_modus, modus ); result = SetDirModus( de_ptr, &walking_package ); } move( LINES - 2, 1 ); clrtoeol(); return( result ); } int GetNewFileModus(int y, int x, char *modus, char *term) { int c, p; static char rwx[] = "rwx"; ClearHelp(); curs_set(1); MvAddStr( y, x, "New Filemodus:" ); x += 16; p = 0; MvAddStr(y, x, modus ); leaveok(stdscr, FALSE); do { move( y, x + p ); RefreshWindow( stdscr ); doupdate(); c = Getch(); #ifdef VI_KEYS c = ViKey( c ); #endif /* VI_KEYS */ if( c == LF ) c = CR; if( p > 0 && ( c == '?' || c == '-' || c == rwx[(p-1) % 3] ) ) { /* gueltige Eingabe */ /*------------------*/ modus[p] = (char) c; addch( c ); if( p < 9 ) p++; } else if( c == 's' && ( p == 3 || p == 6 ) ) { /* Set-ID */ /*--------*/ if( modus[p] != 'x' && modus[p] != 's' ) { MESSAGE( "Execute-Permission required*for set-ID" ); } else { modus[p] = (char) c; addch( c ); if( p < 9 ) p++; } } else { if( c == ' ' && p < 9 ) p++; else if( c == KEY_LEFT && p > 0 ) p--; else if( c == KEY_RIGHT && p < 9 ) p++; else if( strrchr( term, c ) == NULL ) beep(); } } while( c != -1 && strrchr( term, c ) == NULL ); leaveok(stdscr, TRUE); move( y, x ); clrtoeol(); curs_set(0); return( c ); } int SetFileModus(FileEntry *fe_ptr, WalkingPackage *walking_package) { struct stat stat_struct; char buffer[PATH_LENGTH+1]; int result; int new_modus; result = -1; walking_package->new_fe_ptr = fe_ptr; /* unchanged */ new_modus = GetNewModus( fe_ptr->stat_struct.st_mode, walking_package->function_data.change_modus.new_modus ); new_modus = new_modus | ( fe_ptr->stat_struct.st_mode & ~( S_IRWXO | S_IRWXG | S_IRWXU | S_ISGID | S_ISUID ) ); if( !chmod( GetFileNamePath( fe_ptr, buffer ), new_modus ) ) { /* Erfolgreich modifiziert */ /*-------------------------*/ if( STAT_( buffer, &stat_struct ) ) { ERROR_MSG( "Stat Failed" ); } else { fe_ptr->stat_struct = stat_struct; } result = 0; } else { (void) sprintf( message, "Cant't change modus:*%s", strerror(errno) ); MESSAGE( message ); } return( result ); } static int SetDirModus(DirEntry *de_ptr, WalkingPackage *walking_package) { struct stat stat_struct; char buffer[PATH_LENGTH+1]; int result; int new_modus; result = -1; new_modus = GetNewModus( de_ptr->stat_struct.st_mode, walking_package->function_data.change_modus.new_modus ); new_modus = new_modus | ( de_ptr->stat_struct.st_mode & ~( S_IRWXO | S_IRWXG | S_IRWXU | S_ISGID | S_ISUID ) ); if( !chmod( GetPath( de_ptr, buffer ), new_modus ) ) { /* Erfolgreich modifiziert */ /*-------------------------*/ if( STAT_( buffer, &stat_struct ) ) { ERROR_MSG( "Stat Failed" ); } else { de_ptr->stat_struct = stat_struct; } result = 0; } else { (void) sprintf( message, "Cant't change modus:*%s", strerror(errno) ); MESSAGE( message ); } return( result ); } static int GetNewModus(int old_modus, char *modus ) { int new_modus; new_modus = 0; if( *modus == '-' ) new_modus |= S_IFREG; if( *modus == 'd' ) new_modus |= S_IFDIR; #ifdef S_IFLNK if( *modus == 'l' ) new_modus |= S_IFLNK; #endif /* S_IFLNK */ if( *modus == '?' ) new_modus |= old_modus & S_IFMT; modus++; if( *modus == 'r' ) new_modus |= S_IRUSR; if( *modus++ == '?' ) new_modus |= old_modus & S_IRUSR; if( *modus == 'w' ) new_modus |= S_IWUSR; if( *modus++ == '?' ) new_modus |= old_modus & S_IWUSR; if( *modus == 'x' ) new_modus |= S_IXUSR; if( *modus == 's' ) new_modus |= S_ISUID | S_IXUSR; if( *modus++ == '?' ) new_modus |= old_modus & (S_ISUID | S_IXUSR); if( *modus == 'r' ) new_modus |= S_IRGRP; if( *modus++ == '?' ) new_modus |= old_modus & S_IRGRP; if( *modus == 'w' ) new_modus |= S_IWGRP; if( *modus++ == '?' ) new_modus |= old_modus & S_IWGRP; if( *modus == 'x' ) new_modus |= S_IXGRP; if( *modus == 's' ) new_modus |= S_ISGID | S_IXGRP; if( *modus++ == '?' ) new_modus |= old_modus & (S_ISGID | S_IXGRP); if( *modus == 'r' ) new_modus |= S_IROTH; if( *modus++ == '?' ) new_modus |= old_modus & S_IROTH; if( *modus == 'w' ) new_modus |= S_IWOTH; if( *modus++ == '?' ) new_modus |= old_modus & S_IWOTH; if( *modus == 'x' ) new_modus |= S_IXOTH; if( *modus++ == '?' ) new_modus |= old_modus & S_IXOTH; return( new_modus ); } int GetModus(char *modus) { return( GetNewModus( 0, modus ) ); } ytree-1.99pl1/chown.c000066400000000000000000000063771350711670100145210ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/chown.c,v 1.13 2005/01/22 16:32:29 werner Exp $ * * Change Owner * ***************************************************************************/ #include "ytree.h" static int SetDirOwner(DirEntry *de_ptr, int new_owner_id); int ChangeFileOwner(FileEntry *fe_ptr) { WalkingPackage walking_package; int owner_id; int result; result = -1; if( mode != DISK_MODE && mode != USER_MODE ) { beep(); return( result ); } if( ( owner_id = GetNewOwner( fe_ptr->stat_struct.st_uid ) ) >= 0 ) { walking_package.function_data.change_owner.new_owner_id = owner_id; result = SetFileOwner( fe_ptr, &walking_package ); } return( result ); } int GetNewOwner(int st_uid) { char owner[OWNER_NAME_MAX * 2 +1]; char *owner_name_ptr; int owner_id; int id; owner_id = -1; id = (st_uid == -1) ? (int) getuid() : st_uid; owner_name_ptr = GetPasswdName( id ); if( owner_name_ptr == NULL ) { (void) sprintf( owner, "%d", id ); } else { (void) strcpy( owner, owner_name_ptr ); } ClearHelp(); MvAddStr( LINES - 2, 1, "New Owner:" ); if( InputString( owner, LINES - 2, 12, 0, OWNER_NAME_MAX, "\r\033" ) == CR ) { if( (owner_id = GetPasswdUid( owner )) == -1 ) { (void) sprintf( message, "Can't read Owner-ID:*%s", owner ); MESSAGE( message ); } } move( LINES - 2, 1 ); clrtoeol(); return( owner_id ); } int SetFileOwner(FileEntry *fe_ptr, WalkingPackage *walking_package) { struct stat stat_struct; char buffer[PATH_LENGTH+1]; int result; int new_owner_id; result = -1; walking_package->new_fe_ptr = fe_ptr; /* unchanged */ new_owner_id = walking_package->function_data.change_owner.new_owner_id; if( !chown( GetFileNamePath( fe_ptr, buffer ), new_owner_id, fe_ptr->stat_struct.st_gid ) ) { /* Erfolgreich modifiziert */ /*-------------------------*/ if( STAT_( buffer, &stat_struct ) ) { ERROR_MSG( "Stat Failed" ); } else { fe_ptr->stat_struct = stat_struct; } result = 0; } else { (void) sprintf( message, "Can't change Owner:*%s", strerror(errno) ); MESSAGE( message ); } return( result ); } int ChangeDirOwner(DirEntry *de_ptr) { int owner_id; int result; result = -1; if( mode != DISK_MODE && mode != USER_MODE ) { beep(); return( result ); } if( ( owner_id = GetNewOwner( de_ptr->stat_struct.st_uid ) ) >= 0 ) { result = SetDirOwner( de_ptr, owner_id ); } return( result ); } static int SetDirOwner(DirEntry *de_ptr, int new_owner_id) { struct stat stat_struct; char buffer[PATH_LENGTH+1]; int result; result = -1; if( !chown( GetPath( de_ptr, buffer ), new_owner_id, de_ptr->stat_struct.st_gid ) ) { /* Erfolgreich modifiziert */ /*-------------------------*/ if( STAT_( buffer, &stat_struct ) ) { ERROR_MSG( "Stat Failed" ); } else { de_ptr->stat_struct = stat_struct; } result = 0; } else { (void) sprintf( message, "Can't change Owner:*%s", strerror(errno) ); MESSAGE( message ); } return( result ); } ytree-1.99pl1/clock.c000066400000000000000000000034331350711670100144640ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/clock.c,v 1.4 2003/08/31 11:11:00 werner Exp $ * * Clock Module * ***************************************************************************/ #include "ytree.h" void InitClock() { #ifdef CLOCK_SUPPORT struct itimerval value, ovalue; print_time = TRUE; if (getitimer(ITIMER_REAL, &value)!= 0) { sprintf(message,"getitimer() failed: %s", strerror(errno)); ERROR_MSG(message); } value.it_interval.tv_sec = CLOCK_INTERVAL; value.it_value.tv_sec = CLOCK_INTERVAL; value.it_interval.tv_usec = 0; if (setitimer(ITIMER_REAL, &value, &ovalue)!= 0) { sprintf(message,"setitimer() failed: %s", strerror(errno)); ERROR_MSG(message); } ClockHandler(0); #endif } void ClockHandler(int sig) { #ifdef CLOCK_SUPPORT char strtm[23]; time_t HORA; struct tm *hora; if(COLS > 15 && print_time) { time(&HORA); hora = localtime(&HORA); *strtm = '\0'; sprintf(strtm,"[time %.2d:%.2d:%.2d]",hora->tm_hour,hora->tm_min,hora->tm_sec); #ifdef COLOR_SUPPORT mvwaddch(time_window, 0, 0, ACS_RTEE| COLOR_PAIR(MENU_COLOR)|A_BOLD); mvwaddch(time_window, 0, 14, ACS_LTEE| COLOR_PAIR(MENU_COLOR)|A_BOLD); #else mvwaddch(time_window, 0, 0, ACS_RTEE); mvwaddch(time_window, 0, 14, ACS_LTEE); #endif PrintMenuOptions(time_window,0, 1, strtm, MENU_COLOR, HIMENUS_COLOR); } signal(SIGALRM, ClockHandler ); #endif } void SuspendClock(void) { #ifdef CLOCK_SUPPORT struct itimerval value, ovalue; value.it_interval.tv_sec = 0; value.it_value.tv_sec = 0; value.it_interval.tv_usec = 0; setitimer(ITIMER_REAL, &value, &ovalue); signal(SIGALRM, SIG_IGN); #endif return; } ytree-1.99pl1/color.c000066400000000000000000000035411350711670100145070ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/color.c,v 1.2 1997/08/13 12:24:58 werner Rel $ * * Dynamic Colors-Support * ***************************************************************************/ #include "ytree.h" #ifdef COLOR_SUPPORT static BOOL color_enabled = FALSE; void StartColors() { start_color(); if ((COLORS < 8) || (COLOR_PAIRS < 17)) { ESCAPE; /* no color support */ } init_pair(DIR_COLOR, COLOR_WHITE, COLOR_BLUE); init_pair(HIDIR_COLOR, COLOR_BLACK, COLOR_WHITE); init_pair(WINDIR_COLOR, COLOR_CYAN, COLOR_BLUE); init_pair(FILE_COLOR, COLOR_WHITE, COLOR_BLUE); init_pair(HIFILE_COLOR, COLOR_BLACK, COLOR_WHITE); init_pair(WINFILE_COLOR, COLOR_CYAN, COLOR_BLUE); init_pair(STATS_COLOR, COLOR_BLUE, COLOR_CYAN); init_pair(WINSTATS_COLOR,COLOR_BLUE, COLOR_CYAN); init_pair(BORDERS_COLOR, COLOR_BLUE, COLOR_CYAN); init_pair(HIMENUS_COLOR, COLOR_WHITE, COLOR_BLUE); init_pair(MENU_COLOR, COLOR_CYAN, COLOR_BLUE); init_pair(WINERR_COLOR, COLOR_BLUE, COLOR_WHITE); init_pair(HST_COLOR, COLOR_YELLOW, COLOR_CYAN); init_pair(HIHST_COLOR, COLOR_WHITE, COLOR_WHITE); init_pair(WINHST_COLOR, COLOR_YELLOW, COLOR_CYAN); init_pair(HIGLOBAL_COLOR,COLOR_BLUE, COLOR_WHITE); init_pair(GLOBAL_COLOR, COLOR_YELLOW, COLOR_CYAN); color_enabled = TRUE; FNC_XIT: ; } void WbkgdSet(WINDOW *w, chtype c) { if(color_enabled) { wbkgdset(w, c); } else { c &= ~A_BOLD; if(c == COLOR_PAIR(HIDIR_COLOR) || c == COLOR_PAIR(HIFILE_COLOR) || c == COLOR_PAIR(HISTATS_COLOR) || c == COLOR_PAIR(HIMENUS_COLOR) || c == COLOR_PAIR(HIHST_COLOR)) { wattrset(w, A_REVERSE); } else { wattrset(w, 0); } } } #endif /* COLOR_SUPPORT */ ytree-1.99pl1/config.h000066400000000000000000000071771350711670100146540ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/config.h,v 1.26 2014/12/26 09:53:11 werner Exp $ * * Header-Datei fuer YTREE * ***************************************************************************/ /* Default (max) TreeDepth on startup */ #define DEFAULT_TREEDEPTH "1" #define DEFAULT_FILEMODE "2" #define DEFAULT_NOSMALLWINDOW "0" #define DEFAULT_NUMBERSEP "." #define DEFAULT_INITIALDIR NULL #define DEFAULT_DIR1 NULL #define DEFAULT_DIR2 NULL #define DEFAULT_FILE1 NULL #define DEFAULT_FILE2 NULL #define DEFAULT_HEXEDITOFFSET "HEX" /* UNIX-Kommandos */ /*----------------*/ #define DEFAULT_CAT "cat" #define DEFAULT_EDITOR "vi" #define DEFAULT_MELT "melt" #define DEFAULT_UNCOMPRESS "uncompress" #define DEFAULT_GNUUNZIP "gunzip -c" #define DEFAULT_BUNZIP "bunzip2" #define DEFAULT_MANROFF "nroff -man" #define DEFAULT_ZOOLIST "zoo vm" #define DEFAULT_ZOOEXPAND "zoo xp" #define DEFAULT_ZIPLIST "zipinfo -l" #define DEFAULT_ZIPEXPAND "unzip -p" #define DEFAULT_LHALIST "xlharc v" #define DEFAULT_LHAEXPAND "xlharc p" #define DEFAULT_ARCLIST "arc v" #define DEFAULT_ARCEXPAND "arc p" #define DEFAULT_RARLIST "unrar l" #define DEFAULT_RAREXPAND "unrar p -c- -INUL" #define DEFAULT_TAPEDEV "/dev/rmt0" #define DEFAULT_SEARCHCOMMAND "grep {}" #define DEFAULT_LISTJUMPSEARCH "0" /* Attention! You must use GNU TAR, because only GNU TAR is able to * extract to stdout! */ #define DEFAULT_TARLIST "gtar tvf -" #define DEFAULT_TAREXPAND "gtar xOPf -" #define DEFAULT_RPMLIST "rpm -q -l --dump -p" #define DEFAULT_RPMEXPAND "builtin" #define DEFAULT_HEXDUMP "hd" #define DEFAULT_PAGER "more" #ifdef __DJGPP__ #undef DEFAULT_PAGER #define DEFAULT_PAGER "view" #endif #ifdef sgi #undef DEFAULT_HEXDUMP #undef DEFAULT_PAGER #define DEFAULT_HEXDUMP "od -h" #define DEFAULT_PAGER "pg" #endif /* sgi */ #ifdef linux #undef DEFAULT_TARLIST #undef DEFAULT_TAREXPAND #undef DEFAULT_HEXDUMP #undef DEFAULT_PAGER #undef DEFAULT_LHALIST #undef DEFAULT_LHAEXPAND #undef DEFAULT_TAPEDEV #undef DEFAULT_UNCOMPRESS #define DEFAULT_TARLIST "tar tvf -" #define DEFAULT_TAREXPAND "tar xOPf -" #define DEFAULT_HEXDUMP "hexdump" #define DEFAULT_PAGER "less" #define DEFAULT_LHALIST "lharc v" #define DEFAULT_LHAEXPAND "lharc p" #define DEFAULT_TAPEDEV "/dev/rmt0" #define DEFAULT_UNCOMPRESS "gunzip" #endif /* linux */ #ifdef __GNU__ #undef DEFAULT_TARLIST #undef DEFAULT_TAREXPAND #undef DEFAULT_HEXDUMP #undef DEFAULT_PAGER #undef DEFAULT_LHALIST #undef DEFAULT_LHAEXPAND #undef DEFAULT_TAPEDEV #undef DEFAULT_UNCOMPRESS #define DEFAULT_TARLIST "tar tvf -" #define DEFAULT_TAREXPAND "tar xOPf -" #define DEFAULT_HEXDUMP "hexdump" #define DEFAULT_PAGER "less" #define DEFAULT_LHALIST "lharc v" #define DEFAULT_LHAEXPAND "lharc p" #define DEFAULT_TAPEDEV "/dev/rmt0" #define DEFAULT_UNCOMPRESS "gunzip" #endif /* __GNU__ */ #ifdef __NeXT__ /* fifi's NeXT! */ # undef DEFAULT_TARLIST # undef DEFAULT_TAREXPAND # undef DEFAULT_HEXDUMP # undef DEFAULT_PAGER # define DEFAULT_TARLIST "gtar tvf -" # define DEFAULT_TAREXPAND "gtar xOPf -" # define DEFAULT_HEXDUMP "hd" # define DEFAULT_PAGER "less" #endif /* __NeXT__ */ #if defined(__OpenBSD__) || defined(__NetBSD__) || defined( __FreeBSD__) || defined(__NetBSD__) #undef DEFAULT_TARLIST #undef DEFAULT_TAREXPAND #undef DEFAULT_TAPEDEV #define DEFAULT_TARLIST "tar tvf -" #define DEFAULT_TAREXPAND "tar xOPf -" #define DEFAULT_TAPEDEV "/dev/rst0" #endif /* __FreeBSD__ */ ytree-1.99pl1/copy.c000066400000000000000000000235701350711670100143470ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/copy.c,v 1.22 2011/01/09 12:28:01 werner Exp $ * * Kopieren von Dateien / Verzeichnissen * ***************************************************************************/ #include "ytree.h" static int Copy(char *to_path, char *from_path); static int CopyArchiveFile(char *to_path, char *from_path); int CopyFile(Statistic *statistic_ptr, FileEntry *fe_ptr, unsigned char confirm, char *to_file, DirEntry *dest_dir_entry, char *to_dir_path, /* absoluter Pfad */ BOOL path_copy ) { LONGLONG file_size; char from_path[PATH_LENGTH+1]; char from_dir[PATH_LENGTH+1]; char to_path[PATH_LENGTH+1]; char temp_path[PATH_LENGTH+1]; char abs_path[PATH_LENGTH+1]; char buffer[20]; FileEntry *dest_file_entry; FileEntry *fen_ptr; struct stat stat_struct; int term; int result; DIR *tmpdir = NULL; int refresh_dirwindow = FALSE; result = -1; (void) GetRealFileNamePath( fe_ptr, from_path ); (void) GetPath(fe_ptr->dir_entry, from_dir); *to_path = '\0'; if( strcmp( to_dir_path, FILE_SEPARATOR_STRING ) ) { /* not ROOT */ /*----------*/ (void) strcat( to_path, to_dir_path ); } if( path_copy ) { (void) GetPath( fe_ptr->dir_entry, &to_path[strlen(to_path)] ); /* Create destination folder (if neccessary) */ /*-------------------------------------------*/ strcat(to_path, FILE_SEPARATOR_STRING ); if(*to_path != FILE_SEPARATOR_CHAR) { strcpy(abs_path, from_dir); strcat(abs_path, FILE_SEPARATOR_STRING); strcat(abs_path, to_path); strcpy(to_path, abs_path); } if( MakePath( statistic_ptr->tree, to_path, &dest_dir_entry ) ) { (void) sprintf( message, "Can't create path*\"%s\"*%s", to_path, strerror(errno) ); MESSAGE( message ); return( result ); } } (void) strcat( to_path, FILE_SEPARATOR_STRING ); if ((tmpdir = opendir(to_path)) == NULL) if (errno == ENOENT) { if ( (term =InputChoise( "Directory does not exist; create (y/N) ? ", "YN\033" ))== 'Y') { if(*to_path != FILE_SEPARATOR_CHAR) { strcpy(abs_path, from_dir); strcat(abs_path, FILE_SEPARATOR_STRING); strcat(abs_path, to_path); strcpy(to_path, abs_path); } if (MakePath(statistic_ptr->tree, to_path, &dest_dir_entry ) ) { closedir(tmpdir); (void) sprintf( message, "Can't create path*\"%s\"*%s", to_path, strerror(errno) ); MESSAGE( message ); return( result ); } else { refresh_dirwindow = TRUE; } } else { if( tmpdir) closedir(tmpdir); return ( result ); } } (void) strcat( to_path, to_file ); #ifdef DEBUG fprintf( stderr, "Copy: \"%s\" --> \"%s\"\n", from_path, to_path ); #endif /* DEBUG */ if( !strcmp( to_path, from_path ) ) { MESSAGE( "Can't copy file into itself" ); return( result ); } if( dest_dir_entry ) { /* Ziel befindet sich im Sub-Tree */ /*--------------------------------*/ (void) GetFileEntry( dest_dir_entry, to_file, &dest_file_entry ); if( dest_file_entry ) { /* Datei existiert */ /*-----------------*/ if( confirm ) { term = InputChoise( "file exist; overwrite (Y/N) ? ", "YN\033" ); if( term != 'Y' ) { result = (term == 'N' ) ? 0 : -1; /* Abort on escape */ ESCAPE; } } (void) DeleteFile( dest_file_entry ); } } else { /* access benutzen */ /*-----------------*/ if( !access( to_path, F_OK ) ) { /* Datei existiert */ /*-----------------*/ if( confirm ) { term = InputChoise( "file exist; overwrite (Y/N) ? ", "YN\033" ); if( term != 'Y' ) { result = (term == 'N' ) ? 0 : -1; /* Abort on escape */ ESCAPE; } } } } if( !Copy( to_path, from_path ) ) { /* File wurde kopiert */ /*--------------------*/ if( chmod( to_path, fe_ptr->stat_struct.st_mode ) == -1 ) { sprintf( message, "Can't chmod file*\"%s\"*to mode %s*IGNORED", to_path, GetAttributes(fe_ptr->stat_struct.st_mode, buffer) ); WARNING( message ); } if( dest_dir_entry ) { if( STAT_( to_path, &stat_struct ) ) { ERROR_MSG( "Stat Failed*ABORT" ); exit( 1 ); } file_size = stat_struct.st_size; dest_dir_entry->total_bytes += file_size; dest_dir_entry->total_files++; statistic_ptr->disk_total_bytes += file_size; statistic_ptr->disk_total_files++; dest_dir_entry->matching_bytes += file_size; dest_dir_entry->matching_files++; statistic_ptr->disk_matching_bytes += file_size; statistic_ptr->disk_matching_files++; /* File eintragen */ /*----------------*/ if( ( fen_ptr = (FileEntry *) malloc( sizeof( FileEntry ) + strlen( to_file ) ) ) == NULL ) { ERROR_MSG( "Malloc Failed*ABORT" ); exit( 1 ); } (void) strcpy( fen_ptr->name, to_file ); (void) memcpy( &fen_ptr->stat_struct, &stat_struct, sizeof( stat_struct ) ); fen_ptr->dir_entry = dest_dir_entry; fen_ptr->tagged = FALSE; fen_ptr->matching = Match( fen_ptr->name ); fen_ptr->next = dest_dir_entry->file; fen_ptr->prev = NULL; if( dest_dir_entry->file ) dest_dir_entry->file->prev = fen_ptr; dest_dir_entry->file = fen_ptr; } (void) GetAvailBytes( &statistic_ptr->disk_space ); result = 0; } if( refresh_dirwindow) { RefreshDirWindow(); } FNC_XIT: move( LINES - 3, 1 ); clrtoeol(); move( LINES - 2, 1 ); clrtoeol(); move( LINES - 1, 1 ); clrtoeol(); return( result ); } int GetCopyParameter(char *from_file, BOOL path_copy, char *to_file, char *to_dir) { char buffer[PATH_LENGTH + 1]; if( from_file == NULL ) { from_file = "TAGGED FILES"; (void) strcpy( to_file, "*" ); } else { (void) strcpy( to_file, from_file ); } if( path_copy ) { (void) sprintf( buffer, "PATHCOPY %s", from_file ); } else { (void) sprintf( buffer, "COPY %s", from_file ); } ClearHelp(); MvAddStr( LINES - 3, 1, buffer ); MvAddStr( LINES - 2, 1, "AS "); if( InputString(to_file, LINES - 2, 6, 0, COLS - 6, "\r\033" ) == CR){ MvAddStr( LINES - 1, 1, "TO " ); if( InputString( to_dir, LINES - 1, 6, 0, COLS - 6, "\r\033" ) == CR ) return( 0 ); } ClearHelp(); return( -1 ); } static int Copy(char *to_path, char *from_path) { int i, o, n; char buffer[2048]; if( mode != DISK_MODE && mode != USER_MODE ) { return( CopyArchiveFile( to_path, from_path ) ); } #ifdef DEBUG fprintf( stderr, "Copy: \"%s\" --> \"%s\"\n", from_path, to_path ); #endif /* DEBUG */ if( !strcmp( to_path, from_path ) ) { MESSAGE( "Can't copy file into itself" ); return( -1 ); } if( ( i = open( from_path, O_RDONLY ) ) == -1 ) { (void) sprintf( message, "Can't open file*\"%s\"*%s", from_path, strerror(errno) ); MESSAGE( message ); return( -1 ); } if( ( o = open( to_path, O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH ) ) == -1 ) { (void) sprintf( message, "Can't open file*\"%s\"*%s", to_path, strerror(errno) ); MESSAGE( message ); (void) close( i ); return( -1 ); } while( ( n = read( i, buffer, sizeof( buffer ) ) ) > 0 ) { if( write( o, buffer, n ) != n ) { (void) sprintf( message, "Write-Error!*%s", strerror(errno) ); MESSAGE( message ); (void) close( i ); (void) close( o ); (void) unlink( to_path ); return( -1 ); } } (void) close( i ); (void) close( o ); return( 0 ); } int CopyTaggedFiles(FileEntry *fe_ptr, WalkingPackage *walking_package) { char new_name[PATH_LENGTH+1]; int result = -1; walking_package->new_fe_ptr = fe_ptr; /* unchanged */ if( BuildFilename( fe_ptr->name, walking_package->function_data.copy.to_file, new_name ) == 0 ) { if( *new_name == '\0' ) { MESSAGE( "Can't copy file to*empty name" ); } result = CopyFile( walking_package->function_data.copy.statistic_ptr, fe_ptr, walking_package->function_data.copy.confirm, new_name, walking_package->function_data.copy.dest_dir_entry, walking_package->function_data.copy.to_path, walking_package->function_data.copy.path_copy ); } return( result ); } static int CopyArchiveFile(char *to_path, char *from_path) { char *command_line; char buffer[PATH_LENGTH + 3]; char from_p_aux[PATH_LENGTH + 3]; char to_p_aux[PATH_LENGTH + 3]; char *archive; int result = -1; if( ( command_line = (char *)malloc( COMMAND_LINE_LENGTH + 1 ) ) == NULL ) { ERROR_MSG( "Malloc failed*ABORT" ); exit( 1 ); } (void) StrCp( to_p_aux, to_path ); (void) sprintf( buffer, "> %s", to_p_aux ); archive = (mode == TAPE_MODE) ? statistic.tape_name : statistic.login_path; (void) StrCp( from_p_aux, from_path); MakeExtractCommandLine( command_line, archive, from_p_aux, buffer ); result = SilentSystemCall( command_line ); free( command_line ); if( result ) { (void) sprintf( message, "can't copy file*%s*to file*%s", from_p_aux, to_p_aux ); WARNING( message ); } return( result ); } ytree-1.99pl1/delete.c000066400000000000000000000047141350711670100146360ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/delete.c,v 1.12 2001/06/15 16:36:36 werner Exp $ * * Loeschen von Dateien / Verzeichnissen * ***************************************************************************/ #include "ytree.h" extern int unlink(const char *); extern int rmdir(const char *); int DeleteFile(FileEntry *fe_ptr) { char filepath[PATH_LENGTH+1]; char buffer[PATH_LENGTH+1]; int result; int term; result = -1; (void) GetFileNamePath( fe_ptr, filepath ); if( !S_ISLNK( fe_ptr->stat_struct.st_mode ) ) { if( access( filepath, W_OK ) ) { if( access( filepath, F_OK ) ) { /* Datei existiert nicht ==> fertig */ goto UNLINK_DONE; } sprintf( buffer, "overriding mode %04o for \"%s\" (Y/N) ? ", fe_ptr->stat_struct.st_mode & 0777, fe_ptr->name); term = InputChoise( buffer, "YN\033" ); if( term != 'Y' ) { (void) sprintf( message, "Can't delete file*\"%s\"*%s", filepath, strerror(errno) ); MESSAGE( message ); ESCAPE; } } } if( unlink( filepath ) ) { (void) sprintf( message, "Can't delete file*\"%s\"*%s", filepath, strerror(errno) ); MESSAGE( message ); ESCAPE; } UNLINK_DONE: /* File austragen */ /*----------------*/ result = RemoveFile( fe_ptr ); (void) GetAvailBytes( &statistic.disk_space ); FNC_XIT: return( result ); } int RemoveFile(FileEntry *fe_ptr) { DirEntry *de_ptr; LONGLONG file_size; de_ptr = fe_ptr->dir_entry; file_size = fe_ptr->stat_struct.st_size; de_ptr->total_bytes -= file_size; de_ptr->total_files--; statistic.disk_total_bytes -= file_size; statistic.disk_total_files--; if( fe_ptr->matching ) { de_ptr->matching_bytes -= file_size; de_ptr->matching_files--; statistic.disk_matching_bytes -= file_size; statistic.disk_matching_files--; } if( fe_ptr->tagged ) { de_ptr->tagged_bytes -= file_size; de_ptr->tagged_files--; statistic.disk_tagged_bytes -= file_size; statistic.disk_tagged_files--; } /* File austragen */ /*----------------*/ if( fe_ptr->next ) fe_ptr->next->prev = fe_ptr->prev; if( fe_ptr->prev ) fe_ptr->prev->next = fe_ptr->next; else de_ptr->file = fe_ptr->next; free( (char *) fe_ptr ); return( 0 ); } ytree-1.99pl1/dirwin.c000066400000000000000000001177311350711670100146740ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/dirwin.c,v 1.27 2016/09/04 14:41:12 werner Exp $ * * Funktionen zur Handhabung des DIR-Windows * ***************************************************************************/ #include "ytree.h" static DirEntryList *dir_entry_list; static int current_dir_entry; static int total_dirs; static int window_height, window_width; static void ReadDirList(DirEntry *dir_entry); static void PrintDirEntry(WINDOW *win, int entry_no, int y, unsigned char hilight); static void BuildDirEntryList(DirEntry *dir_entry); static int dir_mode; static void BuildDirEntryList(DirEntry *dir_entry) { if( dir_entry_list ) { free( dir_entry_list ); dir_entry_list = NULL; } /* fuer !ANSI-Systeme.. */ /*----------------------*/ if( statistic.disk_total_directories == 0 ) { dir_entry_list = NULL; } else { if( ( dir_entry_list = ( DirEntryList *) calloc( statistic.disk_total_directories, sizeof( DirEntryList ) ) ) == NULL ) { ERROR_MSG( "Calloc Failed*ABORT" ); exit( 1 ); } } current_dir_entry = 0; ReadDirList( dir_entry ); total_dirs = current_dir_entry; } static void RotateDirMode(void) { switch( dir_mode ) { case MODE_1: dir_mode = MODE_2 ; break; case MODE_2: dir_mode = MODE_4 ; break; case MODE_3: dir_mode = MODE_1 ; break; case MODE_4: dir_mode = MODE_3 ; break; } if( (mode != DISK_MODE && mode != USER_MODE ) && dir_mode == MODE_4 ) RotateDirMode(); } static void ReadDirList(DirEntry *dir_entry) { DirEntry *de_ptr; static int level = 0; static unsigned long indent = 0L; for( de_ptr = dir_entry; de_ptr; de_ptr = de_ptr->next ) { indent &= ~( 1L << level ); if( de_ptr->next ) indent |= ( 1L << level ); dir_entry_list[current_dir_entry].dir_entry = de_ptr; dir_entry_list[current_dir_entry].level = (unsigned short) level; dir_entry_list[current_dir_entry].indent = indent; current_dir_entry++; if( !de_ptr->not_scanned && de_ptr->sub_tree ) { level++; ReadDirList( de_ptr->sub_tree ); level--; } } } static void PrintDirEntry(WINDOW *win, int entry_no, int y, unsigned char hilight) { unsigned int j, l1, l2; int n; int aux=0; int color, hi_color; char buffer[32*3+PATH_LENGTH+1]; char format[60]; char *line_buffer = NULL; char *dir_name; char attributes[11]; char modify_time[13]; char change_time[13]; char access_time[13]; char owner[OWNER_NAME_MAX + 1]; char group[GROUP_NAME_MAX + 1]; char *owner_name_ptr; char *group_name_ptr; DirEntry *de_ptr; BOOL suppress_output = FALSE; if(win == f2_window) { color = HST_COLOR; hi_color = HIHST_COLOR; } else { color = DIR_COLOR; hi_color = HIDIR_COLOR; } buffer[0] = '\0'; for(j=0; j < dir_entry_list[entry_no].level; j++) { if( dir_entry_list[entry_no].indent & ( 1L << j ) ) (void) strcat( buffer, "| " ); else (void) strcat( buffer, " " ); } de_ptr = dir_entry_list[entry_no].dir_entry; if( de_ptr->next ) (void) strcat( buffer, "6-" ); else (void) strcat( buffer, "3-" ); switch( dir_mode ) { case MODE_1 : (void)GetAttributes(de_ptr->stat_struct.st_mode, attributes); (void)CTime( de_ptr->stat_struct.st_mtime, modify_time ); if ((line_buffer = (char *) malloc(38)) == NULL) { ERROR_MSG("malloc() Failed*Abort"); exit(1); } #ifdef HAS_LONGLONG (void) strcpy( format, "%10s %3d %8lld %12s"); (void) sprintf( line_buffer, format, attributes, de_ptr->stat_struct.st_nlink, (LONGLONG) de_ptr->stat_struct.st_size, modify_time ); #else (void) strcpy( format, "%10s %3d %8d %12s"); (void) sprintf( line_buffer, format, attributes, de_ptr->stat_struct.st_nlink, de_ptr->stat_struct.st_size, modify_time ); #endif break; case MODE_2 : (void)GetAttributes(de_ptr->stat_struct.st_mode, attributes); owner_name_ptr = GetDisplayPasswdName(de_ptr->stat_struct.st_uid); group_name_ptr = GetDisplayGroupName(de_ptr->stat_struct.st_gid); if( owner_name_ptr == NULL ) { (void)sprintf(owner,"%d",(int)de_ptr->stat_struct.st_uid); owner_name_ptr = owner; } if( group_name_ptr == NULL ) { (void) sprintf( group, "%d", (int) de_ptr->stat_struct.st_gid ); group_name_ptr = group; } if ((line_buffer = (char *) malloc(40)) == NULL) { ERROR_MSG("malloc() Failed*Abort"); exit(1); } (void) strcpy( format, "%12u %-12s %-12s"); (void) sprintf( line_buffer, format, /*attributes, */ de_ptr->stat_struct.st_ino, owner_name_ptr, group_name_ptr); break; case MODE_3 : break; case MODE_4 : (void) CTime( de_ptr->stat_struct.st_ctime, change_time ); (void) CTime( de_ptr->stat_struct.st_atime, access_time ); (void) strcpy( format, "Chg.: %12s Acc.: %12s"); if ((line_buffer = (char *) malloc(40)) == NULL) { ERROR_MSG("malloc() Failed*Abort"); exit(1); } (void)sprintf(line_buffer, format, change_time, access_time); break; } if(window_width == 1) suppress_output = TRUE; aux = 0; /* Output optional Attributes */ if (!suppress_output) { WbkgdSet(win, COLOR_PAIR(color)| A_BOLD ); if(line_buffer) { aux = strlen(line_buffer); if(window_width <= aux) { line_buffer[window_width - 1] = '\0'; suppress_output = TRUE; } mvwaddstr(win, y, 0, line_buffer ); } } if(!suppress_output) { /* Output Graph */ l1 = strlen(buffer); n = window_width - aux; if((int)l1 > n) { buffer[MAXIMUM(n-1, 0)] = '\0'; suppress_output = TRUE; } PrintSpecialString( win, y, aux, buffer, color ); } if(!suppress_output) { /* Output Dirname */ dir_name = de_ptr->name; (void) strcpy( buffer, ( *dir_name ) ? dir_name : "." ); if( de_ptr->not_scanned ) { (void) strcat( buffer, "/" ); } #ifdef NO_HIGHLIGHT (void) strcat( buffer, (hilight) ? " <" : " " ); #else /* NO_HIGHLIGHT */ #ifdef COLOR_SUPPORT if( hilight ) WbkgdSet(win, COLOR_PAIR(hi_color)|A_BOLD); else WbkgdSet(win, COLOR_PAIR(color)); n = window_width - aux - l1; l2 = strlen(buffer); if((int)l2 > n) buffer[MAXIMUM(n-1, 0)] = '\0'; /* waddstr( win, buffer );*/ mvwaddstr( win, y, aux + l1, buffer); WbkgdSet(win, COLOR_PAIR(color)|A_BOLD); #else if( hilight ) wattrset( win, A_REVERSE ); /* waddstr( win, buffer );*/ mvwaddstr( win, y, aux + l1, buffer); if( hilight ) wattrset( win, 0 ); #endif /* COLOR_SUPPORT */ #endif /* NO_HIGHLIGHT */ } if (line_buffer) free(line_buffer); } void DisplayTree(WINDOW *win, int start_entry_no, int hilight_no) { int i, y; int width, height; y = -1; GetMaxYX(win, &height, &width); if(win == dir_window) { window_width = width; window_height = height; } for(i=0; i < height; i++) { wmove(win, i, 0); wclrtoeol(win); } for(i=0; i < height; i++) { if( start_entry_no + i >= (int)statistic.disk_total_directories ) break; if( start_entry_no + i != hilight_no ) PrintDirEntry( win, start_entry_no + i, i, FALSE ); else y = i; } if( y >= 0 ) PrintDirEntry( win, start_entry_no + y, y, TRUE ); } static void Movedown(int *disp_begin_pos, int *cursor_pos, DirEntry **dir_entry) { if( *disp_begin_pos + *cursor_pos + 1 >= total_dirs ) { /* Element nicht vorhanden */ /*-------------------------*/ beep(); } else { /* Element vorhanden */ /*-------------------*/ if( *cursor_pos + 1 < window_height ) { /* Element ist ohne scrollen erreichbar */ /*--------------------------------------*/ PrintDirEntry( dir_window, *disp_begin_pos + *cursor_pos, *cursor_pos, FALSE ); (*cursor_pos)++; PrintDirEntry( dir_window, *disp_begin_pos + *cursor_pos, *cursor_pos, TRUE ); } else { /* Es muss gescrollt werden */ /*--------------------------*/ PrintDirEntry( dir_window, *disp_begin_pos + *cursor_pos, *cursor_pos, FALSE ); scroll( dir_window ); (*disp_begin_pos)++; PrintDirEntry( dir_window, *disp_begin_pos + *cursor_pos, *cursor_pos, TRUE ); } *dir_entry = dir_entry_list[*disp_begin_pos + *cursor_pos].dir_entry; (*dir_entry)->start_file = 0; (*dir_entry)->cursor_pos = -1; DisplayFileWindow( *dir_entry ); RefreshWindow( file_window ); } return; } static void Moveup(int *disp_begin_pos, int *cursor_pos, DirEntry **dir_entry) { if( *disp_begin_pos + *cursor_pos - 1 < 0 ) { /* Element nicht vorhanden */ /*-------------------------*/ beep(); } else { /* Element vorhanden */ /*-------------------*/ if( *cursor_pos - 1 >= 0 ) { /* Element ist ohne scrollen erreichbar */ /*--------------------------------------*/ PrintDirEntry( dir_window, *disp_begin_pos + *cursor_pos, *cursor_pos, FALSE ); (*cursor_pos)--; PrintDirEntry( dir_window, *disp_begin_pos + *cursor_pos, *cursor_pos, TRUE ); } else { /* Es muss gescrollt werden */ /*--------------------------*/ PrintDirEntry( dir_window, *disp_begin_pos + *cursor_pos, *cursor_pos, FALSE ); wmove( dir_window, 0, 0 ); winsertln( dir_window ); (*disp_begin_pos)--; PrintDirEntry( dir_window, *disp_begin_pos + *cursor_pos, *cursor_pos, TRUE ); } *dir_entry = dir_entry_list[*disp_begin_pos + *cursor_pos].dir_entry; (*dir_entry)->start_file = 0; (*dir_entry)->cursor_pos = -1; DisplayFileWindow( *dir_entry ); RefreshWindow( file_window ); } return; } static void Movenpage(int *disp_begin_pos, int *cursor_pos, DirEntry **dir_entry) { if( *disp_begin_pos + *cursor_pos >= total_dirs - 1 ) { /* Letzte Position */ /*-----------------*/ beep(); } else { if( *cursor_pos < window_height - 1 ) { /* Cursor steht nicht auf letztem Eintrag * der Seite */ PrintDirEntry( dir_window, *disp_begin_pos + *cursor_pos, *cursor_pos, FALSE ); if( *disp_begin_pos + window_height > total_dirs - 1 ) *cursor_pos = total_dirs - *disp_begin_pos - 1; else *cursor_pos = window_height - 1; *dir_entry = dir_entry_list[*disp_begin_pos + *cursor_pos].dir_entry; (*dir_entry)->start_file = 0; (*dir_entry)->cursor_pos = -1; DisplayFileWindow( *dir_entry ); RefreshWindow( file_window ); PrintDirEntry( dir_window, *disp_begin_pos + *cursor_pos, *cursor_pos, TRUE ); } else { /* Scrollen */ /*----------*/ if( *disp_begin_pos + *cursor_pos + window_height < total_dirs ) { *disp_begin_pos += window_height; *cursor_pos = window_height - 1; } else { *disp_begin_pos = total_dirs - window_height; if( *disp_begin_pos < 0 ) *disp_begin_pos = 0; *cursor_pos = total_dirs - *disp_begin_pos - 1; } *dir_entry = dir_entry_list[*disp_begin_pos + *cursor_pos].dir_entry; (*dir_entry)->start_file = 0; (*dir_entry)->cursor_pos = -1; DisplayFileWindow( *dir_entry ); RefreshWindow( file_window ); DisplayTree(dir_window,*disp_begin_pos,*disp_begin_pos+*cursor_pos); } } return; } static void Moveppage(int *disp_begin_pos, int *cursor_pos, DirEntry **dir_entry) { if( *disp_begin_pos + *cursor_pos <= 0 ) { /* Erste Position */ /*----------------*/ beep(); } else { if( *cursor_pos > 0 ) { /* Cursor steht nicht auf erstem Eintrag * der Seite */ PrintDirEntry( dir_window, *disp_begin_pos + *cursor_pos, *cursor_pos, FALSE ); *cursor_pos = 0; *dir_entry = dir_entry_list[*disp_begin_pos + *cursor_pos].dir_entry; (*dir_entry)->start_file = 0; (*dir_entry)->cursor_pos = -1; DisplayFileWindow( *dir_entry ); RefreshWindow( file_window ); PrintDirEntry( dir_window, *disp_begin_pos + *cursor_pos, *cursor_pos, TRUE ); } else { /* Scrollen */ /*----------*/ if( (*disp_begin_pos -= window_height) < 0 ) { *disp_begin_pos = 0; } *cursor_pos = 0; *dir_entry = dir_entry_list[*disp_begin_pos + *cursor_pos].dir_entry; (*dir_entry)->start_file = 0; (*dir_entry)->cursor_pos = -1; DisplayFileWindow( *dir_entry ); RefreshWindow( file_window ); DisplayTree(dir_window,*disp_begin_pos,*disp_begin_pos+*cursor_pos); } } return; } void MoveEnd(DirEntry **dir_entry) { statistic.disp_begin_pos = MAXIMUM(0, total_dirs - window_height); statistic.cursor_pos = total_dirs - statistic.disp_begin_pos - 1; *dir_entry = dir_entry_list[statistic.disp_begin_pos + statistic.cursor_pos].dir_entry; (*dir_entry)->start_file = 0; (*dir_entry)->cursor_pos = -1; DisplayFileWindow( *dir_entry ); RefreshWindow( file_window ); DisplayTree( dir_window, statistic.disp_begin_pos, statistic.disp_begin_pos + statistic.cursor_pos); return; } void MoveHome(DirEntry **dir_entry) { if( statistic.disp_begin_pos == 0 && statistic.cursor_pos == 0 ) { /* Position 1 bereits errecht */ /*----------------------------*/ beep(); } else { statistic.disp_begin_pos = 0; statistic.cursor_pos = 0; *dir_entry = dir_entry_list[statistic.disp_begin_pos + statistic.cursor_pos].dir_entry; (*dir_entry)->start_file = 0; (*dir_entry)->cursor_pos = -1; DisplayFileWindow( *dir_entry ); RefreshWindow( file_window ); DisplayTree( dir_window, statistic.disp_begin_pos, statistic.disp_begin_pos + statistic.cursor_pos); } return; } void HandlePlus(DirEntry *dir_entry, DirEntry *de_ptr, char *new_login_path, DirEntry *start_dir_entry, BOOL *need_dsp_help) { if( !dir_entry->not_scanned ) { beep(); } else { for( de_ptr=dir_entry->sub_tree; de_ptr; de_ptr=de_ptr->next) { GetPath( de_ptr, new_login_path ); ReadTree( de_ptr, new_login_path, 0 ); SetMatchingParam( de_ptr ); } dir_entry->not_scanned = FALSE; BuildDirEntryList( start_dir_entry ); DisplayTree( dir_window, statistic.disp_begin_pos, statistic.disp_begin_pos + statistic.cursor_pos ); DisplayDiskStatistic(); DisplayAvailBytes(); *need_dsp_help = TRUE; } } void HandleReadSubTree(DirEntry *dir_entry, DirEntry *start_dir_entry, BOOL *need_dsp_help) { ScanSubTree( dir_entry ); BuildDirEntryList( start_dir_entry ); DisplayTree( dir_window, statistic.disp_begin_pos, statistic.disp_begin_pos + statistic.cursor_pos ); DisplayDiskStatistic(); DisplayAvailBytes(); *need_dsp_help = TRUE; } void HandleUnreadSubTree(DirEntry *dir_entry, DirEntry *de_ptr, DirEntry *start_dir_entry, BOOL *need_dsp_help) { if( dir_entry->not_scanned || (dir_entry->sub_tree == NULL) ) { beep(); } else { for( de_ptr=dir_entry->sub_tree; de_ptr; de_ptr=de_ptr->next) { UnReadTree( de_ptr ); } dir_entry->not_scanned = TRUE; BuildDirEntryList( start_dir_entry ); DisplayTree( dir_window, statistic.disp_begin_pos, statistic.disp_begin_pos + statistic.cursor_pos ); DisplayAvailBytes(); *need_dsp_help = TRUE; } return; } void HandleTagDir(DirEntry *dir_entry, BOOL value) { FileEntry *fe_ptr; for(fe_ptr=dir_entry->file; fe_ptr; fe_ptr=fe_ptr->next) { if( (fe_ptr->matching) && (fe_ptr->tagged != value )) { fe_ptr->tagged = value; if (value) { dir_entry->tagged_files++; dir_entry->tagged_bytes += fe_ptr->stat_struct.st_size; statistic.disk_tagged_files++; statistic.disk_tagged_bytes += fe_ptr->stat_struct.st_size; }else{ dir_entry->tagged_files--; dir_entry->tagged_bytes -= fe_ptr->stat_struct.st_size; statistic.disk_tagged_files--; statistic.disk_tagged_bytes -= fe_ptr->stat_struct.st_size; } } } dir_entry->start_file = 0; dir_entry->cursor_pos = -1; DisplayFileWindow( dir_entry ); RefreshWindow( file_window ); DisplayDiskStatistic(); return; } void HandleTagAllDirs(DirEntry *dir_entry, BOOL value ) { FileEntry *fe_ptr; long i; for(i=0; i < total_dirs; i++) { for(fe_ptr=dir_entry_list[i].dir_entry->file; fe_ptr; fe_ptr=fe_ptr->next) { if( (fe_ptr->matching) && (fe_ptr->tagged != value) ) { if (value) { fe_ptr->tagged = value; dir_entry->tagged_files++; dir_entry->tagged_bytes += fe_ptr->stat_struct.st_size; statistic.disk_tagged_files++; statistic.disk_tagged_bytes += fe_ptr->stat_struct.st_size; }else{ fe_ptr->tagged = value; dir_entry->tagged_files--; dir_entry->tagged_bytes -= fe_ptr->stat_struct.st_size; statistic.disk_tagged_files--; statistic.disk_tagged_bytes -= fe_ptr->stat_struct.st_size; } } } } dir_entry->start_file = 0; dir_entry->cursor_pos = -1; DisplayFileWindow( dir_entry ); RefreshWindow( file_window ); DisplayDiskStatistic(); return; } void HandleShowAllTagged(DirEntry *dir_entry,DirEntry *start_dir_entry, BOOL *need_dsp_help, int *ch) { if( statistic.disk_tagged_files ) { if(dir_entry->login_flag) { dir_entry->login_flag = FALSE; } else { dir_entry->big_window = TRUE; dir_entry->global_flag = TRUE; dir_entry->tagged_flag = TRUE; dir_entry->start_file = 0; dir_entry->cursor_pos = 0; } if( HandleFileWindow(dir_entry) != LOGIN_ESC ) { DisplayDiskStatistic(); dir_entry->start_file = 0; dir_entry->cursor_pos = -1; DisplayFileWindow( dir_entry ); RefreshWindow( small_file_window ); RefreshWindow( big_file_window ); BuildDirEntryList( start_dir_entry ); DisplayTree( dir_window, statistic.disp_begin_pos, statistic.disp_begin_pos + statistic.cursor_pos); }else{ BuildDirEntryList( statistic.tree ); DisplayTree( dir_window, statistic.disp_begin_pos, statistic.disp_begin_pos + statistic.cursor_pos); *ch = 'L'; } }else{ dir_entry->login_flag = FALSE; beep(); } *need_dsp_help = TRUE; return; } void HandleShowAll(DirEntry *dir_entry, DirEntry *start_dir_entry, BOOL *need_dsp_help, int *ch) { if( statistic.disk_matching_files ) { if(dir_entry->login_flag) { dir_entry->login_flag = FALSE; } else { dir_entry->big_window = TRUE; dir_entry->global_flag = TRUE; dir_entry->tagged_flag = FALSE; dir_entry->start_file = 0; dir_entry->cursor_pos = 0; } if( HandleFileWindow(dir_entry) != LOGIN_ESC ) { DisplayDiskStatistic(); dir_entry->start_file = 0; dir_entry->cursor_pos = -1; DisplayFileWindow( dir_entry ); RefreshWindow( small_file_window ); RefreshWindow( big_file_window ); BuildDirEntryList( start_dir_entry ); DisplayTree( dir_window, statistic.disp_begin_pos, statistic.disp_begin_pos + statistic.cursor_pos); } else { BuildDirEntryList( statistic.tree ); DisplayTree( dir_window, statistic.disp_begin_pos, statistic.disp_begin_pos + statistic.cursor_pos ); *ch = 'L'; } } else { dir_entry->login_flag = FALSE; beep(); } *need_dsp_help = TRUE; return; } void HandleSwitchWindow(DirEntry *dir_entry, DirEntry *start_dir_entry, BOOL *need_dsp_help, int *ch) { if( dir_entry->matching_files ) { if(dir_entry->login_flag) { dir_entry->login_flag = FALSE; } else { dir_entry->global_flag = FALSE; dir_entry->tagged_flag = FALSE; dir_entry->big_window = bypass_small_window; dir_entry->start_file = 0; dir_entry->cursor_pos = 0; } if( HandleFileWindow( dir_entry ) != LOGIN_ESC ) { dir_entry->start_file = 0; dir_entry->cursor_pos = -1; DisplayFileWindow( dir_entry ); RefreshWindow( small_file_window ); RefreshWindow( big_file_window ); BuildDirEntryList( start_dir_entry ); DisplayTree( dir_window, statistic.disp_begin_pos, statistic.disp_begin_pos + statistic.cursor_pos); DisplayDiskStatistic(); } else { BuildDirEntryList( statistic.tree ); DisplayTree( dir_window, statistic.disp_begin_pos, statistic.disp_begin_pos + statistic.cursor_pos); *ch = 'L'; } DisplayAvailBytes(); *need_dsp_help = TRUE; } else { dir_entry->login_flag = FALSE; beep(); } return; } int HandleDirWindow(DirEntry *start_dir_entry) { DirEntry *dir_entry, *de_ptr; int i, ch, unput_char; BOOL need_dsp_help; char new_name[PATH_LENGTH + 1]; char new_login_path[PATH_LENGTH + 1]; char *home, *p; struct stat fdstat; unput_char = 0; de_ptr = NULL; GetMaxYX(dir_window, &window_height, &window_width); /* Merker loeschen */ /*-----------------*/ dir_mode = MODE_3; need_dsp_help = TRUE; BuildDirEntryList( start_dir_entry ); if ( initial_directory != NULL ) { if ( !strcmp( initial_directory, "." ) ) /* Entry just a single "." */ { statistic.disp_begin_pos = 0; statistic.cursor_pos = 0; unput_char = CR; } else { if ( *initial_directory == '.' ) { /* Entry of form "./alpha/beta" */ strcpy( new_login_path, start_dir_entry->name ); strcat( new_login_path, initial_directory+1 ); } else if ( *initial_directory == '~' && ( home = getenv("HOME") ) ) { /* Entry of form "~/alpha/beta" */ strcpy( new_login_path, home ); strcat( new_login_path, initial_directory+1 ); } else { /* Entry of form "beta" or "/full/path/alpha/beta" */ strcpy(new_login_path, initial_directory); } for ( i = 0; i < (int)statistic.disk_total_directories; i++ ) { if ( *new_login_path == FILE_SEPARATOR_CHAR ) GetPath( dir_entry_list[i].dir_entry, new_name ); else strcpy( new_name, dir_entry_list[i].dir_entry->name ); if ( !strcmp( new_login_path, new_name ) ) { statistic.disp_begin_pos = i; statistic.cursor_pos = 0; unput_char = CR; break; } } } initial_directory = NULL; } dir_entry = dir_entry_list[statistic.disp_begin_pos + statistic.cursor_pos].dir_entry; DisplayDiskStatistic(); if(!dir_entry->login_flag) { dir_entry->start_file = 0; dir_entry->cursor_pos = -1; } DisplayFileWindow( dir_entry ); RefreshWindow( file_window ); DisplayTree( dir_window, statistic.disp_begin_pos, statistic.disp_begin_pos + statistic.cursor_pos ); touchwin(dir_window); if( dir_entry->login_flag ) { if( (dir_entry->global_flag ) || (dir_entry->tagged_flag) ) { unput_char = 'S'; } else { unput_char = CR; } } do { if( need_dsp_help ) { need_dsp_help = FALSE; DisplayDirHelp(); } DisplayDirParameter( dir_entry ); RefreshWindow( dir_window ); if( unput_char ) { ch = unput_char; unput_char = '\0'; } else { doupdate(); ch = (resize_request) ? -1 : Getch(); if( ch == LF ) ch = CR; } #ifdef VI_KEYS ch = ViKey( ch ); #endif /* VI_KEYS */ if(resize_request) { ReCreateWindows(); DisplayMenu(); GetMaxYX(dir_window, &window_height, &window_width); while(statistic.cursor_pos >= window_height) { statistic.cursor_pos--; statistic.disp_begin_pos++; } DisplayTree( dir_window, statistic.disp_begin_pos, statistic.disp_begin_pos + statistic.cursor_pos ); DisplayFileWindow(dir_entry); DisplayDiskStatistic(); DisplayDirParameter( dir_entry ); need_dsp_help = TRUE; DisplayAvailBytes(); DisplayFileSpec(); DisplayDiskName(); resize_request = FALSE; } if (mode == USER_MODE) { /* DirUserMode returns (possibly remapped) ch, or -1 if it handles ch */ ch = DirUserMode(dir_entry, ch); } switch( ch ) { #ifdef KEY_RESIZE case KEY_RESIZE: resize_request = TRUE; break; #endif case -1: break; case ' ': /*break; Quick-Key */ case KEY_DOWN: Movedown(&statistic.disp_begin_pos, &statistic.cursor_pos, &dir_entry); break; case KEY_UP : Moveup(&statistic.disp_begin_pos, &statistic.cursor_pos, &dir_entry); break; case KEY_NPAGE:Movenpage(&statistic.disp_begin_pos, &statistic.cursor_pos, &dir_entry); break; case KEY_PPAGE:Moveppage(&statistic.disp_begin_pos, &statistic.cursor_pos, &dir_entry); break; case KEY_HOME: MoveHome(&dir_entry); break; case KEY_END : MoveEnd(&dir_entry); break; case KEY_RIGHT: case '+': HandlePlus(dir_entry, de_ptr, new_login_path, start_dir_entry, &need_dsp_help); break; case '\t': case '*': HandleReadSubTree(dir_entry, start_dir_entry, &need_dsp_help); break; case KEY_LEFT: case '-': case KEY_BTAB: HandleUnreadSubTree(dir_entry, de_ptr, start_dir_entry, &need_dsp_help); break; case 'F': case 'f': if(ReadFileSpec() == 0) { dir_entry->start_file = 0; dir_entry->cursor_pos = -1; DisplayFileWindow( dir_entry ); RefreshWindow( file_window ); DisplayDiskStatistic(); } need_dsp_help = TRUE; break; case 'T' : case 't' : HandleTagDir(dir_entry, TRUE); break; case 'U' : case 'u' : HandleTagDir(dir_entry, FALSE); break; case 'T' & 0x1F : HandleTagAllDirs(dir_entry,TRUE); break; case 'U' & 0x1F : HandleTagAllDirs(dir_entry,FALSE); break; case 'F' & 0x1F : RotateDirMode(); /*DisplayFileWindow( dir_entry, 0, -1 );*/ DisplayTree( dir_window, statistic.disp_begin_pos, statistic.disp_begin_pos + statistic.cursor_pos ); /*RefreshWindow( file_window );*/ DisplayDiskStatistic(); need_dsp_help = TRUE; break; case 'S' & 0x1F : HandleShowAllTagged(dir_entry, start_dir_entry, &need_dsp_help, &ch); break; case 'S': case 's': HandleShowAll(dir_entry, start_dir_entry, &need_dsp_help, &ch); break; case LF : case CR : HandleSwitchWindow(dir_entry, start_dir_entry, &need_dsp_help, &ch); break; case 'X': case 'x': (void) Execute( dir_entry, NULL ); need_dsp_help = TRUE; DisplayAvailBytes(); break; case 'M': case 'm': if( !MakeDirectory( dir_entry ) ) { BuildDirEntryList( start_dir_entry ); DisplayTree( dir_window, statistic.disp_begin_pos, statistic.disp_begin_pos + statistic.cursor_pos ); DisplayAvailBytes(); } need_dsp_help = TRUE; break; case 'D': case 'd': if( !DeleteDirectory( dir_entry ) ) { if( statistic.disp_begin_pos + statistic.cursor_pos > 0 ) { if( statistic.cursor_pos > 0 ) statistic.cursor_pos--; else statistic.disp_begin_pos--; } } /* Unabhaengig vom Erfolg aktualisieren */ BuildDirEntryList( start_dir_entry ); dir_entry = dir_entry_list[statistic.disp_begin_pos + statistic.cursor_pos].dir_entry; dir_entry->start_file = 0; dir_entry->cursor_pos = -1; DisplayFileWindow( dir_entry ); RefreshWindow( file_window ); DisplayTree( dir_window, statistic.disp_begin_pos, statistic.disp_begin_pos + statistic.cursor_pos ); DisplayAvailBytes(); need_dsp_help = TRUE; break; case 'r': case 'R': if( !GetRenameParameter( dir_entry->name, new_name ) ) { if( !RenameDirectory( dir_entry, new_name ) ) { /* Rename OK */ /*-----------*/ BuildDirEntryList( start_dir_entry ); DisplayTree( dir_window, statistic.disp_begin_pos, statistic.disp_begin_pos + statistic.cursor_pos ); DisplayAvailBytes(); dir_entry = dir_entry_list[statistic.disp_begin_pos + statistic.cursor_pos].dir_entry; } } need_dsp_help = TRUE; break; case 'G': case 'g': (void) ChangeDirGroup( dir_entry ); DisplayTree( dir_window, statistic.disp_begin_pos, statistic.disp_begin_pos + statistic.cursor_pos ); need_dsp_help = TRUE; break; case 'O': case 'o': (void) ChangeDirOwner( dir_entry ); DisplayTree( dir_window, statistic.disp_begin_pos, statistic.disp_begin_pos + statistic.cursor_pos ); need_dsp_help = TRUE; break; case 'A': case 'a': (void) ChangeDirModus( dir_entry ); DisplayTree( dir_window, statistic.disp_begin_pos, statistic.disp_begin_pos + statistic.cursor_pos ); need_dsp_help = TRUE; break; case 'Q' & 0x1F: need_dsp_help = TRUE; QuitTo(dir_entry); break; case 'Q': case 'q': need_dsp_help = TRUE; break; #ifndef VI_KEYS case 'l': #endif /* VI_KEYS */ case 'L': if( mode != DISK_MODE && mode != USER_MODE ) (void) strcpy( new_login_path, disk_statistic.login_path ); else (void) GetPath( dir_entry, new_login_path ); if( !GetNewLoginPath( new_login_path ) ) { DisplayMenu(); doupdate(); (void) LoginDisk( new_login_path ); } need_dsp_help = TRUE; break; case 'L' & 0x1F: clearok( stdscr, TRUE ); break; case 'P': /* press 'p' or 'P' to log parent of current root */ case 'p': MoveHome(&dir_entry); (void) GetPath(dir_entry, new_login_path); /* char *p; defined before this current switch */ if((p = strrchr(new_login_path, FILE_SEPARATOR_CHAR)) == NULL) break; /* p is now pointing to rightmost file separator */ /* in new_login_path, just truncate this path */ *p='\0'; /* rightmost slash was first and only character? */ if(!strlen(new_login_path)) { new_login_path[0]=FILE_SEPARATOR_CHAR; new_login_path[1]='\0'; } /* following needed to ignore old tree in memory */ *disk_statistic.login_path = '\0'; (void) LoginDisk(new_login_path); need_dsp_help = TRUE; return ch; default : beep(); break; } /* switch */ } while( (ch != 'q') && (ch != 'Q') && (ch != 'l') && (ch != 'L') ); return( ch ); } int ScanSubTree( DirEntry *dir_entry ) { DirEntry *de_ptr; char new_login_path[PATH_LENGTH + 1]; if( dir_entry->not_scanned ) { for( de_ptr=dir_entry->sub_tree; de_ptr; de_ptr=de_ptr->next) { GetPath( de_ptr, new_login_path ); ReadTree( de_ptr, new_login_path, 999 ); SetMatchingParam( de_ptr ); } dir_entry->not_scanned = FALSE; } else { for( de_ptr=dir_entry->sub_tree; de_ptr; de_ptr=de_ptr->next) { ScanSubTree( de_ptr ); } } return( 0 ); } int KeyF2Get(DirEntry *start_dir_entry, int disp_begin_pos, int cursor_pos, char *path) { DirEntry *dir_entry; int ch; int result = -1; int win_width, win_height; dir_entry = start_dir_entry; GetMaxYX(f2_window, &win_height, &win_width); MapF2Window(); DisplayTree( f2_window, disp_begin_pos, disp_begin_pos + cursor_pos ); do { RefreshWindow( f2_window ); doupdate(); ch = Getch(); GetMaxYX(f2_window, &win_height, &win_width); /* Maybe changed... */ if( ch == LF ) ch = CR; #ifdef VI_KEYS ch = ViKey( ch ); #endif /* VI_KEYS */ switch( ch ) { case -1: break; case ' ': break; /* Quick-Key */ case KEY_DOWN: if( disp_begin_pos + cursor_pos + 1 >= total_dirs ) { beep(); } else { if( cursor_pos + 1 < win_height ) { PrintDirEntry( f2_window, disp_begin_pos + cursor_pos, cursor_pos, FALSE); cursor_pos++; PrintDirEntry( f2_window, disp_begin_pos + cursor_pos, cursor_pos, TRUE); } else { disp_begin_pos++; DisplayTree( f2_window, disp_begin_pos, disp_begin_pos + cursor_pos); } } break; case KEY_UP : if( disp_begin_pos + cursor_pos - 1 < 0 ) { beep(); } else { if( cursor_pos - 1 >= 0 ) { PrintDirEntry( f2_window, disp_begin_pos + cursor_pos, cursor_pos, FALSE ); cursor_pos--; PrintDirEntry( f2_window, disp_begin_pos + cursor_pos, cursor_pos, TRUE ); } else { disp_begin_pos--; DisplayTree( f2_window, disp_begin_pos, disp_begin_pos + cursor_pos); } } break; case KEY_NPAGE: if( disp_begin_pos + cursor_pos >= total_dirs - 1 ) { beep(); } else { if( cursor_pos < win_height - 1 ) { PrintDirEntry( f2_window, disp_begin_pos + cursor_pos, cursor_pos, FALSE ); if( disp_begin_pos + win_height > total_dirs - 1 ) cursor_pos = total_dirs - disp_begin_pos - 1; else cursor_pos = win_height - 1; PrintDirEntry( f2_window, disp_begin_pos + cursor_pos, cursor_pos, TRUE ); } else { if( disp_begin_pos + cursor_pos + win_height < total_dirs ) { disp_begin_pos += win_height; cursor_pos = win_height - 1; } else { disp_begin_pos = total_dirs - win_height; if( disp_begin_pos < 0 ) disp_begin_pos = 0; cursor_pos = total_dirs - disp_begin_pos - 1; } DisplayTree( f2_window, disp_begin_pos, disp_begin_pos + cursor_pos); } } break; case KEY_PPAGE: if( disp_begin_pos + cursor_pos <= 0 ) { beep(); } else { if( cursor_pos > 0 ) { PrintDirEntry( f2_window, disp_begin_pos + cursor_pos, cursor_pos, FALSE ); cursor_pos = 0; PrintDirEntry( f2_window, disp_begin_pos + cursor_pos, cursor_pos, TRUE ); } else { if( (disp_begin_pos -= win_height) < 0 ) { disp_begin_pos = 0; } cursor_pos = 0; DisplayTree( f2_window, disp_begin_pos, disp_begin_pos + cursor_pos); } } break; case KEY_HOME: if( disp_begin_pos == 0 && cursor_pos == 0 ) { beep(); } else { disp_begin_pos = 0; cursor_pos = 0; DisplayTree( f2_window, disp_begin_pos, disp_begin_pos + cursor_pos); } break; case KEY_END : disp_begin_pos = MAXIMUM(0, total_dirs - win_height); cursor_pos = total_dirs - disp_begin_pos - 1; DisplayTree( f2_window, disp_begin_pos, disp_begin_pos + cursor_pos); break; case LF : case CR : GetPath(dir_entry_list[cursor_pos + disp_begin_pos].dir_entry, path); result = 0; break; case ESC: case 'Q': case 'q': break; default : beep(); break; } /* switch */ } while( (ch != 'q') && (ch != ESC) && (ch != 'Q') && (ch != CR) && (ch != -1) ); UnmapF2Window(); return( result ); } int RefreshDirWindow() { DirEntry *de_ptr; int i, n; int result = -1; int window_width, window_height; de_ptr = dir_entry_list[statistic.disp_begin_pos + statistic.cursor_pos].dir_entry; BuildDirEntryList( dir_entry_list[0].dir_entry ); /* Search old entry */ for(n=-1, i=0;i < total_dirs; i++) { if(dir_entry_list[i].dir_entry == de_ptr) { n = i; break; } } if(n == -1) { /* Directory disapeared */ ERROR_MSG( "Current directory disappeared" ); result = -1; } else { if( n != (statistic.disp_begin_pos + statistic.cursor_pos)) { /* Position changed */ if((n - statistic.disp_begin_pos) >= 0) { statistic.cursor_pos = n - statistic.disp_begin_pos; } else { statistic.disp_begin_pos = n; statistic.cursor_pos = 0; } } GetMaxYX(dir_window, &window_height, &window_width); while(statistic.cursor_pos >= window_height) { statistic.cursor_pos--; statistic.disp_begin_pos++; } DisplayTree( dir_window, statistic.disp_begin_pos, statistic.disp_begin_pos + statistic.cursor_pos ); DisplayAvailBytes(); result = 0; } return(result); } ytree-1.99pl1/disp.c000066400000000000000000000276501350711670100143370ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/disp.c,v 1.21 2016/09/04 14:41:12 werner Exp $ * * Menue-Geruest anzeigen * ***************************************************************************/ #include "ytree.h" #include "patchlev.h" static void PrintMenuLine(WINDOW *win, int y, int x, char *line); static void PrintLine(WINDOW *win, int y, int x, char *line, int len); static void DisplayVersion(void); static char *mask[] = { "5-----------------------2", "|FILE: |", "6-----------------------7", "|DISK: |", "| Avail |", "6-----------------------7", "|DISK Statistics |", "|[Total] |", "| Files: |", "| Bytes: |", "|[Matching] |", "| Files: |", "| Bytes: |", "|[Tagged] |", "| Files: |", "| Bytes: |", "|[Current Directory] |", "| |", "| Bytes: |" }; static char *logo[] = { " # ", " ## ", " ## ## ##### ## ### #### ####", " ## ## ## ## ## ## ## ## ##", " ## ## ## ## ## ###### ###### ", " ##### ## # ## ## ## ", " ## ### #### #### #### ", "##### " }; static char *extended_line = "| | |"; static char *last_line = "3-8-----------------------4"; static char *first_line ="1-5"; static char dir_help_disk_mode_0[] = "DIR (A)ttribute (D)elete (F)ilespec (G)roup (L)og (M)akedir (Q)uit"; static char dir_help_disk_mode_1[] = "COMMANDS (O)wner (R)ename (S)howall (^S)how-tagged (T)ag (U)ntag e(X)ecute (^F) dirmode"; static char *dir_help[MAX_MODES][2] = { { /* DISK_MODE */ dir_help_disk_mode_0, dir_help_disk_mode_1 }, { /* LL_FILE_MODE */ "DIR (F)ilespec (L)ogin (S)howall (T)ag (U)ntag e(X)ecute (^F) dirmode (Q)uit ", "COMMANDS " }, { /* TAR_FILE_MODE */ "TAR-DIR (F)ilespec (L)og (S)howall (T)ag (U)ntag e(X)ecute (^F) dirmode (Q)uit ", "COMMANDS " }, { /* ZOO_FILE_MODE */ "ZOO-DIR (F)ilespec (L)og (S)howall (T)ag (U)ntag e(X)ecute (^F) dirmode (Q)uit ", "COMMANDS " }, { /* ZIP_FILE_MODE */ "ZIP-DIR (F)ilespec (L)og (S)howall (T)ag (U)ntag e(X)ecute (^F) dirmode (Q)uit ", "COMMANDS " }, { /* LHA_FILE_MODE */ "LHA-DIR (F)ilespec (L)og (S)howall (T)ag (U)ntag e(X)ecute (^F) dirmode (Q)uit ", "COMMANDS " }, { /* ARC_FILE_MODE */ "ARC-DIR (F)ilespec (L)og (S)howall (T)ag (U)ntag e(X)ecute (^F) dirmode (Q)uit ", "COMMANDS " }, { /* RPM_FILE_MODE */ "RPM-DIR (F)ilespec (L)og (S)howall (T)ag (U)ntag e(X)ecute (^F) dirmode (Q)uit ", "COMMANDS " }, { /* RAR_FILE_MODE */ "RAR-DIR (F)ilespec (L)og (S)howall (T)ag (U)ntag e(X)ecute (^F) dirmode (Q)uit ", "COMMANDS " }, { /* TAPE_MODE */ "TAPE-DIR (F)ilespec (L)og (S)howall (T)ag (U)ntag e(X)ecute (^F) dirmode (Q)uit ", "COMMANDS " }, { /* USER_MODE */ dir_help_disk_mode_0, /* Default unless changed by user prefs */ dir_help_disk_mode_1 } }; static char file_help_disk_mode_0[] = "FILE (A)ttribute (C)opy (D)elete (E)dit (F)ilespec (G)roup (H)ex (L)ogin (M)ove (Q)uit "; static char file_help_disk_mode_1[] = "COMMANDS (O)wner (P)ipe (R)ename (S)ort (T)ag (U)ntag (V)iew e(X)ecute pathcop(Y) (^F)ilemode "; static char *file_help[MAX_MODES][2] = { { /* DISK_MODE */ file_help_disk_mode_0, file_help_disk_mode_1 }, { /* LL_FILE_MODE */ "FILE (F)ilespec (L)ogin (S)ort (T)ag (U)ntag e(X)ecute (^F)ilemode (Q)uit ", "COMMANDS " }, { /* TAR_FILE_MODE */ "TAR-FILE (C)opy (F)ilespec (H)ex (P)ipe (S)ort (T)ag (U)ntag (V)iew pathcop(Y) (Q)uit ", "COMMANDS (^F)ilemode " }, { /* ZOO_FILE_MODE */ "ZOO-FILE (C)opy (F)ilespec (H)ex (P)ipe (S)ort (T)ag (U)ntag (V)iew pathcop(Y) (Q)uit ", "COMMANDS (^F)ilemode " }, { /* ZIP_FILE_MODE */ "ZIP-FILE (C)opy (F)ilespec (H)ex (P)ipe (S)ort (T)ag (U)ntag (V)iew pathcop(Y) (Q)uit ", "COMMANDS (^F)ilemode " }, { /* LHA_FILE_MODE */ "LHA-FILE (C)opy (F)ilespec (H)ex (P)ipe (S)ort (T)ag (U)ntag (V)iew pathcop(Y) (Q)uit ", "COMMANDS (^F)ilemode " }, { /* ARC_FILE_MODE */ "ARC-FILE (C)opy (F)ilespec (H)ex (P)ipe (S)ort (T)ag (U)ntag (V)iew pathcop(Y) (Q)uit ", "COMMANDS (^F)ilemode " }, { /* RPM_FILE_MODE */ "RPM-FILE (C)opy (F)ilespec (H)ex (P)ipe (S)ort (T)ag (U)ntag (V)iew pathcop(Y) (Q)uit ", "COMMANDS (^F)ilemode " }, { /* RAR_FILE_MODE */ "RAR-FILE (C)opy (F)ilespec (H)ex (P)ipe (S)ort (T)ag (U)ntag (V)iew pathcop(Y) (Q)uit ", "COMMANDS (^F)ilemode " }, { /* TAPE_MODE */ "TAPE-FILE (C)opy (F)ilespec (H)ex (P)ipe (S)ort (T)ag (U)ntag (V)iew pathcop(Y) (Q)uit ", "COMMANDS (^F)ilemode " }, { /* USER_MODE */ file_help_disk_mode_0, /* Default unless changed by user prefs */ file_help_disk_mode_1 } }; static void DisplayVersion(void) { static char version[80]; ClearHelp(); (void) sprintf( version, "ytree Version %sPL%d %s (Werner Bregulla)", VERSION, PATCHLEVEL, VERSIONDATE ); MvAddStr( LINES - 2, (unsigned) (COLS - strlen( version )) >> 1, version ); } void DisplayDirHelp(void) { int i; char *cptr; if (mode == USER_MODE) { if (dir_help[mode][0] == dir_help_disk_mode_0 && (cptr = DIR1) != NULL) dir_help[mode][0] = cptr; if (dir_help[mode][1] == dir_help_disk_mode_1 && (cptr = DIR2) != NULL) dir_help[mode][1] = cptr; } for( i=0; i < (int)(sizeof(dir_help[mode]) / sizeof(dir_help[mode][0])); i++) { PrintOptions( stdscr, LINES - 2 + i, 0, dir_help[mode][i] ); clrtoeol(); } } void DisplayFileHelp(void) { int i; char *cptr; if (mode == USER_MODE) { if (file_help[mode][0] == file_help_disk_mode_0 && (cptr = FILE1) != NULL) file_help[mode][0] = cptr; if (file_help[mode][1] == file_help_disk_mode_1 && (cptr = FILE2) != NULL) file_help[mode][1] = cptr; } for( i=0; i < (int)(sizeof(file_help[mode]) / sizeof(file_help[mode][0])); i++) { PrintOptions( stdscr, LINES - 2 + i, 0, file_help[mode][i] ); clrtoeol(); } } void ClearHelp(void) { int i; for( i=0; i < 3; i++ ) { wmove( stdscr, LINES - 3 + i, 0 ); clrtoeol(); } } void DisplayMenu(void) { int y; int l, c; PrintSpecialString( stdscr, 0, 0, "Path: ", MENU_COLOR ); #ifdef COLOR_SUPPORT clrtoeol(); #endif werase( dir_window ); werase( big_file_window ); werase( small_file_window ); for( y=1; y <= (int)(sizeof(mask) / sizeof(mask[0])); y++){ PrintOptions( stdscr, y, 0, "|"); PrintOptions( stdscr, y, COLS - 25 , mask[y-1] ); } for( ; y < LINES - 4; y++ ) PrintMenuLine( stdscr, y, 0, extended_line ); PrintLine( stdscr, DIR_WINDOW_HEIGHT + 2, 0, "6-7", COLS - 25 ); PrintLine( stdscr, 1, 0, first_line, COLS - 25); PrintMenuLine( stdscr, y, 0, last_line ); l = sizeof(logo) / sizeof(logo[0]); c = strlen( logo[0] ); for( y=0; y < l; y++ ) { MvWAddStr( dir_window, y + ((DIR_WINDOW_HEIGHT - l) >> 1), (DIR_WINDOW_WIDTH - c) >> 1, logo[y] ); } DisplayVersion(); touchwin( dir_window ); /* refresh(); */ } void SwitchToSmallFileWindow(void) { werase( file_window ); PrintLine( stdscr, DIR_WINDOW_HEIGHT + 2, 0, "6-7", COLS - 25 ); file_window = small_file_window; RefreshWindow( stdscr ); } void SwitchToBigFileWindow(void) { werase( file_window ); RefreshWindow( file_window ); #ifdef COLOR_SUPPORT mvaddch(DIR_WINDOW_Y + DIR_WINDOW_HEIGHT, DIR_WINDOW_X - 1, ACS_VLINE | COLOR_PAIR(MENU_COLOR)| A_BOLD); mvaddch(DIR_WINDOW_Y + DIR_WINDOW_HEIGHT, DIR_WINDOW_X + DIR_WINDOW_WIDTH, ACS_VLINE | COLOR_PAIR(MENU_COLOR)| A_BOLD); #else mvwaddch( stdscr, DIR_WINDOW_Y + DIR_WINDOW_HEIGHT, DIR_WINDOW_X - 1, ACS_VLINE ); mvwaddch( stdscr, DIR_WINDOW_Y + DIR_WINDOW_HEIGHT, DIR_WINDOW_X + DIR_WINDOW_WIDTH, ACS_VLINE ); #endif /* COLOR_SUPPORT */ file_window = big_file_window; RefreshWindow( stdscr ); } void MapF2Window(void) { char *buffer; if( ( buffer = (char *)malloc( F2_WINDOW_WIDTH + 1 ) ) == NULL ) { ERROR_MSG( "Malloc failed*ABORT" ); exit( 1 ); } werase( f2_window ); memset(buffer, '=', F2_WINDOW_WIDTH); buffer[F2_WINDOW_WIDTH] = '\0'; PrintSpecialString( f2_window, F2_WINDOW_HEIGHT - 1, 0, buffer, HST_COLOR ); RefreshWindow( f2_window ); free(buffer); } void UnmapF2Window(void) { werase( f2_window ); if(file_window == big_file_window) { #ifdef COLOR_SUPPORT mvaddch(DIR_WINDOW_Y + DIR_WINDOW_HEIGHT, DIR_WINDOW_X - 1, ACS_VLINE | COLOR_PAIR(MENU_COLOR)| A_BOLD); mvaddch(DIR_WINDOW_Y + DIR_WINDOW_HEIGHT, DIR_WINDOW_X + DIR_WINDOW_WIDTH, ACS_VLINE | COLOR_PAIR(MENU_COLOR)| A_BOLD); #else mvwaddch( stdscr, DIR_WINDOW_Y + DIR_WINDOW_HEIGHT, DIR_WINDOW_X - 1, ACS_VLINE ); mvwaddch( stdscr, DIR_WINDOW_Y + DIR_WINDOW_HEIGHT, DIR_WINDOW_X + DIR_WINDOW_WIDTH, ACS_VLINE ); #endif /* COLOR_SUPPORT */ } touchwin(stdscr); } static void PrintMenuLine(WINDOW *win, int y, int x, char *line) { int i; int p, l; char *buffer; if (strchr(line,'(')) p = 2; else p = 0; l = COLS + 2 + p; if( ( buffer = (char *)malloc( l ) ) == NULL ) { ERROR_MSG( "Malloc failed*ABORT" ); exit( 1 ); } buffer[0] = line[0]; if (p == 0) p = COLS - 25; else p = COLS - 27; for(i=1; i < p; i++) buffer[i] = line[1]; (void) strncpy( &buffer[i], &line[2], l - i ); buffer[l-1] = '\0'; PrintOptions( stdscr, y, x , buffer ); free( buffer ); } static void PrintLine(WINDOW *win, int y, int x, char *line, int len) { int i; char *buffer; if(len > 0) { if( ( buffer = (char *)malloc( len + 2 ) ) == NULL ) { ERROR_MSG( "Malloc failed*ABORT" ); exit( 1 ); } buffer[0] = line[0]; for(i=1; i < (len); i++) buffer[i] = line[1]; (void) strcpy( &buffer[i], &line[2] ); PrintOptions( stdscr, y, x , buffer ); free( buffer ); } } void RefreshWindow(WINDOW *win) { wnoutrefresh(win); } ytree-1.99pl1/edit.c000066400000000000000000000044221350711670100143150ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/edit.c,v 1.15 2014/12/26 09:53:11 werner Exp $ * * Edit-Kommando-Bearbeitung * ***************************************************************************/ #include "ytree.h" int Edit(DirEntry * dir_entry, char *file_path) { char *command_line; int result = -1; char *file_p_aux=NULL; char cwd[PATH_LENGTH + 1]; char path[PATH_LENGTH + 1]; if( mode != DISK_MODE && mode != USER_MODE ) { beep(); return( -1 ); } if( access( file_path, R_OK ) ) { (void) sprintf( message, "Edit not possible!*\"%s\"*%s", file_path, strerror(errno) ); MESSAGE( message ); ESCAPE; } if( ( file_p_aux = (char *)malloc( COMMAND_LINE_LENGTH ) ) == NULL ) { ERROR_MSG( "Malloc failed*ABORT" ); exit( 1 ); } StrCp(file_p_aux, file_path); if( ( command_line = (char *)malloc( COMMAND_LINE_LENGTH ) ) == NULL ) { ERROR_MSG( "Malloc failed*ABORT" ); exit( 1 ); } (void) strcpy( command_line, EDITOR ); (void) strcat( command_line, " \"" ); (void) strcat( command_line, file_p_aux ); (void) strcat( command_line, "\"" ); free( file_p_aux); /* result = SystemCall(command_line); --crb3 29apr02: perhaps finally eliminate the problem with jstar writing new files to the ytree starting cwd. new code grabbed from execute.c. --crb3 01oct02: move Getcwd operation within the IF DISKMODE stuff. */ if (mode == DISK_MODE) { if (Getcwd(cwd, PATH_LENGTH) == NULL) { WARNING("Getcwd failed*\".\"assumed"); (void) strcpy(cwd, "."); } if (chdir(GetPath(dir_entry, path))) { (void) sprintf(message, "Can't change directory to*\"%s\"", path); MESSAGE(message); }else{ result = SystemCall(command_line); } if(chdir(cwd)) { (void) sprintf(message, "Can't change directory to*\"%s\"", cwd); MESSAGE(message); } }else{ result = SystemCall(command_line); } free( command_line ); FNC_XIT: return( result ); } ytree-1.99pl1/error.c000066400000000000000000000064261350711670100145270ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/error.c,v 1.12 2003/06/06 19:47:26 werner Exp $ * * Ausgabe von Fehlermeldungen * ***************************************************************************/ #include "ytree.h" static void MapErrorWindow(char *header); static void MapNoticeWindow(char *header); static void UnmapErrorWindow(void); static void PrintErrorLine(int y, char *str); static void DisplayErrorMessage(char *msg); static int PrintErrorMessage(char *msg); void Message(char *msg) { MapErrorWindow( "E R R O R" ); (void) PrintErrorMessage( msg ); } void Notice(char *msg) { MapNoticeWindow( "N O T I C E" ); DisplayErrorMessage( msg ); RefreshWindow( error_window ); refresh(); } void Warning(char *msg) { MapErrorWindow( "W A R N I N G" ); (void) PrintErrorMessage( msg ); } void Error(char *msg, char *module, int line) { char buffer[MESSAGE_LENGTH + 1]; MapErrorWindow( "INTERNAL ERROR" ); (void) sprintf( buffer, "%s*In Module \"%s\"*Line %d", msg, module, line ); (void) PrintErrorMessage( buffer ); } static void MapErrorWindow(char *header) { werase( error_window ); box( error_window, 0, 0 ); PrintSpecialString( error_window, ERROR_WINDOW_HEIGHT - 3, 0, "6--------------------------------------7", WINERR_COLOR ); wattrset( error_window, A_REVERSE | A_BLINK ); MvWAddStr( error_window, ERROR_WINDOW_HEIGHT - 2, 1, " PRESS ENTER " ); wattrset( error_window, 0 ); PrintErrorLine( 1, header ); } static void MapNoticeWindow(char *header) { werase( error_window ); box( error_window, 0, 0 ); PrintSpecialString( error_window, ERROR_WINDOW_HEIGHT - 3, 0, "6--------------------------------------7", WINERR_COLOR ); wattrset( error_window, A_REVERSE | A_BLINK ); MvWAddStr( error_window, ERROR_WINDOW_HEIGHT - 2, 1, " PLEASE WAIT " ); wattrset( error_window, 0 ); PrintErrorLine( 1, header ); } static void UnmapErrorWindow(void) { werase( error_window ); touchwin( stdscr ); doupdate(); } void UnmapNoticeWindow(void) { werase( error_window ); touchwin( stdscr ); doupdate(); } static void PrintErrorLine(int y, char *str) { int l; l = strlen( str ); MvWAddStr( error_window, y, (ERROR_WINDOW_WIDTH - l) >> 1, str ); } static void DisplayErrorMessage(char *msg) { int y, i, j, count; char buffer[ERROR_WINDOW_WIDTH - 2 + 1]; for(i=0, count=0; msg[i]; i++) if( msg[i] == '*' ) count++; if( count > 3 ) y = 2; else if( count > 1 ) y = 3; else y = 4; for( i=0,j=0; msg[i]; i++ ) { if( msg[i] == '*' ) { buffer[j] = '\0'; PrintErrorLine( y++, buffer ); j=0; } else { if( j < (int)((sizeof( buffer) - 1)) ) buffer[j++] = msg[i]; } } buffer[j] = '\0'; PrintErrorLine( y, buffer ); } static int PrintErrorMessage(char *msg) { int c; DisplayErrorMessage( msg ); beep(); RefreshWindow( error_window ); doupdate(); c = wgetch(error_window); UnmapErrorWindow(); touchwin( dir_window ); return( c ); } ytree-1.99pl1/execute.c000066400000000000000000000062561350711670100150410ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/execute.c,v 1.15 2014/12/26 09:53:11 werner Exp $ * * Ausfuehren von System-Kommandos * ***************************************************************************/ #include "ytree.h" extern int chdir(const char *); int Execute(DirEntry *dir_entry, FileEntry *file_entry) { static char command_line[COMMAND_LINE_LENGTH + 1]; char cwd[PATH_LENGTH+1]; char path[PATH_LENGTH+1]; int result; result = -1; if( file_entry ) { if( file_entry->stat_struct.st_mode & ( S_IXUSR | S_IXGRP | S_IXOTH ) ) { /* ausfuehrbare Datei */ /*--------------------*/ (void) StrCp( command_line, file_entry->name ); } } MvAddStr( LINES - 2, 1, "Command:" ); if( !GetCommandLine( command_line ) ) { if( Getcwd( cwd, PATH_LENGTH ) == NULL ) { WARNING( "Getcwd failed*\".\"assumed" ); (void) strcpy( cwd, "." ); } if( mode == DISK_MODE || mode == USER_MODE ) { if( chdir( GetPath( dir_entry, path ) ) ) { (void) sprintf( message, "Can't change directory to*\"%s\"", path ); MESSAGE( message ); } else { refresh(); result = QuerySystemCall( command_line ); } if( chdir( cwd ) ) { (void) sprintf( message, "Can't change directory to*\"%s\"", cwd ); MESSAGE( message ); } } else { refresh(); result = QuerySystemCall( command_line ); } } return( result ); } int GetCommandLine(char *command_line) { int result; result = -1; ClearHelp(); MvAddStr( LINES - 2, 1, "Command: " ); if( InputString( command_line, LINES - 2, 10, 0, COLS - 11, "\r\033" ) == CR ) { move( LINES - 2, 1 ); clrtoeol(); result = 0; } move( LINES - 2, 1 ); clrtoeol(); return( result ); } int GetSearchCommandLine(char *command_line) { int result; int pos; char *cptr; result = -1; ClearHelp(); MvAddStr( LINES - 2, 1, "Search untag command: " ); strcpy( command_line, SEARCHCOMMAND ); cptr = strstr( command_line, "{}" ); if(cptr) { pos = (cptr - command_line) - 1; if(pos < 0) pos = 0; } else { pos = 0; } if( InputString( command_line, LINES - 2, 23, pos, COLS - 24, "\r\033" ) == CR ) { move( LINES - 2, 1 ); clrtoeol(); result = 0; } move( LINES - 2, 1 ); clrtoeol(); return( result ); } int ExecuteCommand(FileEntry *fe_ptr, WalkingPackage *walking_package) { char command_line[COMMAND_LINE_LENGTH + 1]; int i, result; char c; char *cptr; command_line[0] = '\0'; cptr = command_line; walking_package->new_fe_ptr = fe_ptr; /* unchanged */ for( i=0; (c = walking_package->function_data.execute.command[i]); i++ ) { if( c == '{' && walking_package->function_data.execute.command[i+1] == '}' ) { (void) GetFileNamePath( fe_ptr, cptr ); cptr = &command_line[ strlen( command_line ) ]; i++; } else { *cptr++ = c; } } *cptr = '\0'; result = SilentSystemCallEx( command_line, FALSE ); /* Ignore Result */ /*---------------*/ return( result ); } ytree-1.99pl1/filespec.c000066400000000000000000000043271350711670100151660ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/filespec.c,v 1.13 2005/01/22 16:32:29 werner Exp $ * * Setzt neue Datei-Spezifikation * ***************************************************************************/ #include "ytree.h" int SetFileSpec(char *file_spec) { if( SetMatchSpec( file_spec ) ) { return( 1 ); } statistic.disk_matching_files = 0L; statistic.disk_matching_bytes = 0L; SetMatchingParam( statistic.tree ); return( 0 ); } void SetMatchingParam(DirEntry *dir_entry) { DirEntry *de_ptr; FileEntry *fe_ptr; unsigned long matching_files; LONGLONG matching_bytes; for( de_ptr = dir_entry; de_ptr; de_ptr = de_ptr->next ) { matching_files = 0L; matching_bytes = 0L; for( fe_ptr = de_ptr->file; fe_ptr; fe_ptr = fe_ptr->next ) { if( Match( fe_ptr->name ) ) { matching_files++; matching_bytes += fe_ptr->stat_struct.st_size; fe_ptr->matching = TRUE; } else { fe_ptr->matching = FALSE; } } de_ptr->matching_files = matching_files; de_ptr->matching_bytes = matching_bytes; statistic.disk_matching_files += matching_files; statistic.disk_matching_bytes += matching_bytes; if( de_ptr->sub_tree ) { SetMatchingParam( de_ptr->sub_tree ); } } } /***************************************************************>> ReadFileSpec. Take in the user-specified new filespec. As modified, it defaults to '*'; the original version offered the current value as default, but that's just an up-arrow away. Returns 0 on success, -1 on failure (empty string). <<***************************************************************/ int ReadFileSpec(void) { int result = -1; char buffer[FILE_SPEC_LENGTH * 2 + 1]; ClearHelp(); (void) strcpy( buffer, "*" ); MvAddStr( LINES - 2, 1, "New filespec:" ); if( InputString( buffer, LINES - 2, 15, 0, FILE_SPEC_LENGTH, "\r\033" ) == CR ) { if( SetFileSpec( buffer ) ) { MESSAGE( "Invalid Filespec" ); } else { (void) strcpy( statistic.file_spec, buffer ); result = 0; } } move( LINES - 2, 1 ); clrtoeol(); return(result); } ytree-1.99pl1/filewin.c000066400000000000000000002354601350711670100150350ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/filewin.c,v 1.36 2016/09/04 14:41:12 werner Exp $ * * Funktionen zur Handhabung des FILE-Windows * ***************************************************************************/ #include "ytree.h" #define MAX( a, b ) ( ( (a) > (b) ) ? (a) : (b) ) #if !defined(__NeXT__) && !defined(ultrix) extern void qsort(void *, size_t, size_t, int (*) (const void *, const void *)); #endif /* __NeXT__ ultrix */ static BOOL reverse_sort; static BOOL order; static BOOL do_case = FALSE; static int file_mode; static int max_column; static int window_height; static int window_width; static int max_disp_files; static int x_step; static int my_x_step; static int hide_left; static int hide_right; static FileEntryList *file_entry_list; static unsigned file_count; static unsigned max_userview_len; static unsigned max_filename_len; static unsigned max_linkname_len; static unsigned global_max_filename_len; static unsigned global_max_linkname_len; static void ReadFileList(DirEntry *dir_entry); static void SortFileEntryList(void); static int SortByName(FileEntryList *e1, FileEntryList *e2); static int SortByChgTime(FileEntryList *e1, FileEntryList *e2); static int SortByAccTime(FileEntryList *e1, FileEntryList *e2); static int SortByModTime(FileEntryList *e1, FileEntryList *e2); static int SortBySize(FileEntryList *e1, FileEntryList *e2); static int SortByOwner(FileEntryList *e1, FileEntryList *e2); static int SortByGroup(FileEntryList *e1, FileEntryList *e2); static int SortByExtension(FileEntryList *e1, FileEntryList *e2); static void DisplayFiles(DirEntry *de_ptr, int start_file_no, int hilight_no, int start_x); static void ReadGlobalFileList(DirEntry *dir_entry); static void WalkTaggedFiles(int start_file, int cursor_pos, int (*fkt) (/* ??? */), WalkingPackage *walking_package); static BOOL IsMatchingTaggedFiles(void); static void RemoveFileEntry(int entry_no); static void ChangeFileEntry(void); static int DeleteTaggedFiles(int max_dispfiles); static void SilentWalkTaggedFiles( int (*fkt) (/* ??? */), WalkingPackage *walking_package ); static void SilentTagWalkTaggedFiles( int (*fkt) (/* ??? */), WalkingPackage *walking_package ); static void RereadWindowSize(DirEntry *dir_entry); static void ListJump( DirEntry * dir_entry, char *str ); void SetFileMode(int new_file_mode) { GetMaxYX( file_window, &window_height, &window_width ); file_mode = new_file_mode; switch( file_mode ) { case MODE_1: if( max_linkname_len) max_column = window_width / (max_filename_len + max_linkname_len + 45); else max_column = window_width / (max_filename_len + 41); break; case MODE_2: if( max_linkname_len) max_column = window_width / (max_filename_len + max_linkname_len + 41); else max_column = window_width / (max_filename_len + 37); break; case MODE_3: max_column = window_width / (max_filename_len + 3); break; case MODE_4: if( max_linkname_len) max_column = window_width / (max_filename_len + max_linkname_len + 44); else max_column = window_width / (max_filename_len + 40); break; case MODE_5: max_userview_len = GetUserFileEntryLength(max_filename_len, max_linkname_len, USERVIEW); if(max_userview_len) max_column = window_width / (max_userview_len + 1); else max_column = 0; break; } if( max_column == 0 ) max_column = 1; } void RotateFileMode(void) { switch( file_mode ) { case MODE_1: SetFileMode( MODE_3 ); break; case MODE_2: SetFileMode( MODE_5 ); break; case MODE_3: SetFileMode( MODE_4 ); break; case MODE_4: SetFileMode( MODE_2 ); break; case MODE_5: SetFileMode( MODE_1 ); break; } if( (mode != DISK_MODE && mode != USER_MODE) && file_mode == MODE_4 ) { RotateFileMode(); } else if(file_mode == MODE_5 && !strcmp(USERVIEW, "")) { RotateFileMode(); } } static void ReadTaggedList(DirEntry *dir_entry) { FileEntry *fe_ptr; unsigned int name_len; unsigned int linkname_len; max_filename_len = 0; max_linkname_len = 0; for( fe_ptr = dir_entry->file; fe_ptr; fe_ptr = fe_ptr->next ) { if (( fe_ptr->matching ) && ( fe_ptr->tagged )) { file_entry_list[file_count++].file = fe_ptr; name_len = strlen( fe_ptr->name ); if( S_ISLNK( fe_ptr->stat_struct.st_mode ) ) { linkname_len = strlen( &fe_ptr->name[name_len+1] ); max_linkname_len = MAX( max_linkname_len, linkname_len ); } max_filename_len = MAX( max_filename_len, name_len ); } } } static void ReadTaggedFileList(DirEntry *dir_entry) { DirEntry *de_ptr; for( de_ptr=dir_entry; de_ptr; de_ptr=de_ptr->next ) { if( de_ptr->sub_tree ) ReadTaggedFileList( de_ptr->sub_tree ); ReadTaggedList( de_ptr ); global_max_filename_len = MAX( global_max_filename_len, max_filename_len ); global_max_linkname_len = MAX( global_max_linkname_len, max_linkname_len ); } max_filename_len = global_max_filename_len; max_linkname_len = global_max_linkname_len; } static void BuildFileEntryList(DirEntry *dir_entry){ if( file_entry_list ) { free( file_entry_list ); file_entry_list = NULL; } if( !dir_entry->global_flag ) { /* ... for !ANSI-Systeme ... */ /*----------------------------*/ if( dir_entry->matching_files == 0 ) { file_entry_list = NULL; } else { if( ( file_entry_list = (FileEntryList *) calloc( dir_entry->matching_files, sizeof( FileEntryList ) ) ) == NULL ) { ERROR_MSG( "Calloc Failed*ABORT" ); exit( 1 ); } } file_count = 0; ReadFileList( dir_entry ); SortFileEntryList(); SetFileMode( file_mode ); /* recalc */ } else if (!dir_entry->tagged_flag) { if( statistic.disk_matching_files == 0 ) { file_entry_list = NULL; } else { if( ( file_entry_list = (FileEntryList *) calloc( statistic.disk_matching_files, sizeof( FileEntryList ) ) ) == NULL ) { ERROR_MSG( "Calloc Failed*ABORT" ); exit( 1 ); } } file_count = 0; global_max_filename_len = 0; global_max_linkname_len = 0; ReadGlobalFileList( statistic.tree ); SortFileEntryList(); SetFileMode( file_mode ); /* recalc */ } else { if( statistic.disk_matching_files == 0 ) { file_entry_list = NULL; } else { if( ( file_entry_list = (FileEntryList *) calloc( statistic.disk_tagged_files, sizeof( FileEntryList ) ) ) == NULL ) { ERROR_MSG( "Calloc Failed*ABORT" ); exit( 1 ); } } file_count = 0; global_max_filename_len = 0; global_max_linkname_len = 0; ReadTaggedFileList( statistic.tree ); SortFileEntryList(); SetFileMode( file_mode ); /* recalc */ } } static void ReadFileList(DirEntry *dir_entry) { FileEntry *fe_ptr; unsigned int name_len; unsigned int linkname_len; max_filename_len = 0; max_linkname_len = 0; for( fe_ptr = dir_entry->file; fe_ptr; fe_ptr = fe_ptr->next ) { if( fe_ptr->matching ) { file_entry_list[file_count++].file = fe_ptr; name_len = strlen( fe_ptr->name ); if( S_ISLNK( fe_ptr->stat_struct.st_mode ) ) { linkname_len = strlen( &fe_ptr->name[name_len+1] ); max_linkname_len = MAX( max_linkname_len, linkname_len ); } max_filename_len = MAX( max_filename_len, name_len ); } } } static void ReadGlobalFileList(DirEntry *dir_entry) { DirEntry *de_ptr; for( de_ptr=dir_entry; de_ptr; de_ptr=de_ptr->next ) { if( de_ptr->sub_tree ) ReadGlobalFileList( de_ptr->sub_tree ); ReadFileList( de_ptr ); global_max_filename_len = MAX( global_max_filename_len, max_filename_len ); global_max_linkname_len = MAX( global_max_linkname_len, max_linkname_len ); } max_filename_len = global_max_filename_len; max_linkname_len = global_max_linkname_len; } static void SortFileEntryList(void) { int aux; int (*compare)(); reverse_sort = FALSE; if ((aux = statistic.kind_of_sort) > SORT_DSC) { order = FALSE; aux -= SORT_DSC; } else { order = TRUE; aux -= SORT_ASC; } switch( aux ) { case SORT_BY_NAME : compare = SortByName; break; case SORT_BY_MOD_TIME : compare = SortByModTime; break; case SORT_BY_CHG_TIME : compare = SortByChgTime; break; case SORT_BY_ACC_TIME : compare = SortByAccTime; break; case SORT_BY_OWNER : compare = SortByOwner; break; case SORT_BY_GROUP : compare = SortByGroup; break; case SORT_BY_SIZE : compare = SortBySize; break; case SORT_BY_EXTENSION : compare = SortByExtension; break; default: compare = SortByName; beep(); } qsort( (char *) file_entry_list, file_count, sizeof( file_entry_list[0] ), compare ); } static int SortByName(FileEntryList *e1, FileEntryList *e2) { if (do_case) if (order) return( strcmp( e1->file->name, e2->file->name ) ); else return( - (strcmp( e1->file->name, e2->file->name ) ) ); else if (order) return( strcasecmp( e1->file->name, e2->file->name ) ); else return( - (strcasecmp( e1->file->name, e2->file->name ) ) ); } static int SortByExtension(FileEntryList *e1, FileEntryList *e2) { char *ext1, *ext2; int cmp, casecmp; /* Ok, this isn't optimized */ ext1 = GetExtension(e1->file->name); ext2 = GetExtension(e2->file->name); cmp=strcmp( ext1, ext2 ); casecmp=strcasecmp( ext1, ext2 ); if (do_case && !cmp) return SortByName( e1, e2 ); if (!do_case && !casecmp) return SortByName( e1, e2 ); if (do_case) if (order) return( strcmp( ext1, ext2 ) ); else return( - (strcmp( ext1, ext2 ) ) ); else if (order) return( strcasecmp( ext1, ext2 ) ); else return( - (strcasecmp( ext1, ext2 ) ) ); } static int SortByModTime(FileEntryList *e1, FileEntryList *e2) { if (order) return( e1->file->stat_struct.st_mtime - e2->file->stat_struct.st_mtime ); else return( - (e1->file->stat_struct.st_mtime - e2->file->stat_struct.st_mtime ) ); } static int SortByChgTime(FileEntryList *e1, FileEntryList *e2) { if (order) return( e1->file->stat_struct.st_ctime - e2->file->stat_struct.st_ctime ); else return( - (e1->file->stat_struct.st_ctime - e2->file->stat_struct.st_ctime ) ); } static int SortByAccTime(FileEntryList *e1, FileEntryList *e2) { if (order) return( e1->file->stat_struct.st_atime - e2->file->stat_struct.st_atime ); else return( - (e1->file->stat_struct.st_atime - e2->file->stat_struct.st_atime ) ); } static int SortBySize(FileEntryList *e1, FileEntryList *e2) { if (order) return( e1->file->stat_struct.st_size - e2->file->stat_struct.st_size ); else return( - (e1->file->stat_struct.st_size - e2->file->stat_struct.st_size) ); } static int SortByOwner(FileEntryList *e1, FileEntryList *e2) { char *o1, *o2; char n1[10], n2[10]; o1 = GetPasswdName( e1->file->stat_struct.st_uid ); o2 = GetPasswdName( e2->file->stat_struct.st_uid ); if( o1 == NULL ) { (void) sprintf( n1, "%d", (int) e1->file->stat_struct.st_uid ); o1 = n1; } if( o2 == NULL ) { (void) sprintf( n2, "%d", (int) e2->file->stat_struct.st_uid ); o2 = n2; } if (do_case) if (order) return( strcmp( o1, o2 ) ); else return( - (strcmp( o1, o2 ) ) ); else if (order) return( strcasecmp( o1, o2 ) ); else return( - (strcasecmp( o1, o2 ) ) ); } static int SortByGroup(FileEntryList *e1, FileEntryList *e2) { char *g1, *g2; char n1[10], n2[10]; g1 = GetGroupName( e1->file->stat_struct.st_gid ); g2 = GetGroupName( e2->file->stat_struct.st_gid ); if( g1 == NULL ) { (void) sprintf( n1, "%d", (int) e1->file->stat_struct.st_uid ); g1 = n1; } if( g2 == NULL ) { (void) sprintf( n2, "%d", (int) e2->file->stat_struct.st_uid ); g2 = n2; } if (do_case) if (order) return( strcmp( g1, g2 ) ); else return( - (strcmp( g1, g2 ) ) ); else if (order) return( strcasecmp( g1, g2 ) ); else return( - (strcasecmp( g1, g2 ) ) ); } void SetKindOfSort(int new_kind_of_sort) { statistic.kind_of_sort = new_kind_of_sort; } static void RemoveFileEntry(int entry_no) { int i, n, l; FileEntry *fe_ptr; max_filename_len = 0; max_linkname_len = 0; n = file_count - 1; for( i=0; i < n; i++ ) { if( i >= entry_no ) file_entry_list[i] = file_entry_list[i+1]; fe_ptr = file_entry_list[i].file; l = strlen( fe_ptr->name ); max_filename_len = MAX( (int)max_filename_len, l ); if( S_ISLNK( fe_ptr->stat_struct.st_mode ) ) { max_linkname_len = MAX( max_filename_len, strlen( &fe_ptr->name[l+1] ) ); } } SetFileMode( file_mode ); /* recalc */ file_count--; /* no realloc */ } static void ChangeFileEntry(void) { int i, n, l; FileEntry *fe_ptr; max_filename_len = 0; max_linkname_len = 0; n = file_count - 1; for( i=0; i < n; i++ ) { fe_ptr = file_entry_list[i].file; if( fe_ptr ) { l = strlen( fe_ptr->name ); max_filename_len = MAX( (int)max_filename_len, l ); if( S_ISLNK( fe_ptr->stat_struct.st_mode ) ) { max_linkname_len = MAX( max_filename_len, strlen( &fe_ptr->name[l+1] ) ); } } } SetFileMode( file_mode ); /* recalc */ } char GetTypeOfFile(struct stat fst) { if ( S_ISLNK(fst.st_mode) ) return '@'; else if ( S_ISSOCK(fst.st_mode) ) return '='; else if ( S_ISCHR(fst.st_mode) ) return '-'; else if ( S_ISBLK(fst.st_mode) ) return '+'; else if ( S_ISFIFO(fst.st_mode) ) return '|'; else if ( S_ISREG(fst.st_mode) ) return ' '; else return '?'; } static void PrintFileEntry(int entry_no, int y, int x, unsigned char hilight, int start_x) { char attributes[11]; char modify_time[13]; char change_time[13]; char access_time[13]; char format[60]; char justify; char *line_ptr; int n, pos_x = 0; FileEntry *fe_ptr; static char *line_buffer = NULL; static int old_cols = -1; char owner[OWNER_NAME_MAX + 1]; char group[GROUP_NAME_MAX + 1]; char *owner_name_ptr; char *group_name_ptr; int ef_window_width; char *sym_link_name = NULL; char type_of_file = ' '; ef_window_width = window_width - 2; /* Effektive Window-Width */ (reverse_sort) ? (justify='+') : (justify='-'); if( old_cols != COLS ) { old_cols = COLS; if( line_buffer ) free( line_buffer ); if( ( line_buffer = (char *) malloc( COLS + PATH_LENGTH ) ) == NULL ) { ERROR_MSG( "Malloc failed*ABORT" ); exit( 1 ); } } fe_ptr = file_entry_list[entry_no].file; if( fe_ptr && S_ISLNK( fe_ptr->stat_struct.st_mode ) ) sym_link_name = &fe_ptr->name[strlen(fe_ptr->name)+1]; else sym_link_name = ""; type_of_file = GetTypeOfFile(fe_ptr->stat_struct); switch( file_mode ) { case MODE_1 : if( fe_ptr ) { (void) GetAttributes( fe_ptr->stat_struct.st_mode, attributes ); (void) CTime( fe_ptr->stat_struct.st_mtime, modify_time ); if( S_ISLNK( fe_ptr->stat_struct.st_mode ) ) { #ifdef HAS_LONGLONG (void) sprintf( format, "%%c%%c%%-%ds %%10s %%3d %%11lld %%12s -> %%-%ds", max_filename_len, max_linkname_len ); (void) sprintf( line_buffer, format, (fe_ptr->tagged) ? TAGGED_SYMBOL : ' ', type_of_file, fe_ptr->name, attributes, fe_ptr->stat_struct.st_nlink, (LONGLONG) fe_ptr->stat_struct.st_size, modify_time, sym_link_name ); #else (void) sprintf( format, "%%c%%c%%-%ds %%10s %%3d %%7d %%12s -> %%-%ds", max_filename_len, max_linkname_len ); (void) sprintf( line_buffer, format, (fe_ptr->tagged) ? TAGGED_SYMBOL : ' ', type_of_file, fe_ptr->name, attributes, fe_ptr->stat_struct.st_nlink, fe_ptr->stat_struct.st_size, modify_time, sym_link_name ); #endif } else { #ifdef HAS_LONGLONG (void) sprintf( format, "%%c%%c%%%c%ds %%10s %%3d %%11lld %%12s", justify, max_filename_len ); (void) sprintf( line_buffer, format, (fe_ptr->tagged) ? TAGGED_SYMBOL : ' ', type_of_file, fe_ptr->name, attributes, fe_ptr->stat_struct.st_nlink, (LONGLONG) fe_ptr->stat_struct.st_size, modify_time ); #else (void) sprintf( format, "%%c%%c%%%c%ds %%10s %%3d %%7d %%12s", justify, max_filename_len ); (void) sprintf( line_buffer, format, (fe_ptr->tagged) ? TAGGED_SYMBOL : ' ', type_of_file, fe_ptr->name, attributes, fe_ptr->stat_struct.st_nlink, fe_ptr->stat_struct.st_size, modify_time ); #endif } } else { /* Empty Entry */ /*-------------*/ (void) sprintf( format, "%%-%ds", max_filename_len + 42 ); (void) sprintf( line_buffer, format, "" ); } if( max_linkname_len ) pos_x = x * (max_filename_len + max_linkname_len + 47); else pos_x = x * (max_filename_len + 43); break; case MODE_2 : if( fe_ptr ) { (void) GetAttributes( fe_ptr->stat_struct.st_mode, attributes ); owner_name_ptr = GetDisplayPasswdName(fe_ptr->stat_struct.st_uid); group_name_ptr = GetDisplayGroupName(fe_ptr->stat_struct.st_gid); if( owner_name_ptr == NULL ) { (void) sprintf( owner, "%d", (int) fe_ptr->stat_struct.st_uid ); owner_name_ptr = owner; } if( group_name_ptr == NULL ) { (void) sprintf( group, "%d", (int) fe_ptr->stat_struct.st_gid ); group_name_ptr = group; } if( S_ISLNK( fe_ptr->stat_struct.st_mode ) ) { #ifdef HAS_LONGLONG (void) sprintf( format, "%%c%%c%%%c%ds %%10lld %%-12s %%-12s -> %%-%ds", justify, max_filename_len, max_linkname_len ); (void) sprintf( line_buffer, format, (fe_ptr->tagged) ? TAGGED_SYMBOL : ' ', type_of_file, fe_ptr->name, (LONGLONG)fe_ptr->stat_struct.st_ino, owner_name_ptr, group_name_ptr, sym_link_name ); #else (void) sprintf( format, "%%c%%c%%%c%ds %%8u %%-12s %%-12s -> %%-%ds", justify, max_filename_len, max_linkname_len ); (void) sprintf( line_buffer, format, (fe_ptr->tagged) ? TAGGED_SYMBOL : ' ', type_of_file, fe_ptr->name, (int)fe_ptr->stat_struct.st_ino, owner_name_ptr, group_name_ptr, sym_link_name ); #endif } else { #ifdef HAS_LONGLONG (void) sprintf( format, "%%c%%c%%%c%ds %%10lld %%-12s %%-12s", justify, max_filename_len ); (void) sprintf( line_buffer, format, (fe_ptr->tagged) ? TAGGED_SYMBOL : ' ', type_of_file, fe_ptr->name, (LONGLONG)fe_ptr->stat_struct.st_ino, owner_name_ptr, group_name_ptr ); #else (void) sprintf( format, "%%c%%c%%%c%ds %%8u %%-12s %%-12s", justify, max_filename_len ); (void) sprintf( line_buffer, format, (fe_ptr->tagged) ? TAGGED_SYMBOL : ' ', type_of_file, fe_ptr->name, (int)fe_ptr->stat_struct.st_ino, owner_name_ptr, group_name_ptr ); #endif } } else { /* Empty-Entry */ /*-------------*/ (void) sprintf( format, "%%-%ds", max_filename_len + 38 ); (void) sprintf( line_buffer, format, "" ); } if( max_linkname_len ) pos_x = x * (max_filename_len + max_linkname_len + 43); else pos_x = x * (max_filename_len + 39); break; case MODE_3 : if( fe_ptr ) { (void) sprintf( format, "%%c%%c%%%c%ds", justify, max_filename_len ); (void) sprintf( line_buffer, format, (fe_ptr->tagged) ? TAGGED_SYMBOL : ' ', type_of_file, fe_ptr->name ); } else { /* Empty-Entry */ /*-------------*/ (void) sprintf( format, "%%-%ds", max_filename_len + 2 ); (void) sprintf( line_buffer, format, "" ); } pos_x = x * (max_filename_len + 3); break; case MODE_4 : if( fe_ptr ) { (void) CTime( fe_ptr->stat_struct.st_ctime, change_time ); (void) CTime( fe_ptr->stat_struct.st_atime, access_time ); if( S_ISLNK( fe_ptr->stat_struct.st_mode ) ) { (void) sprintf( format, "%%c%%c%%%c%ds Chg: %%12s Acc: %%12s -> %%-%ds", justify, max_filename_len, max_linkname_len ); (void) sprintf( line_buffer, format, (fe_ptr->tagged) ? TAGGED_SYMBOL : ' ', type_of_file, fe_ptr->name, change_time, access_time, sym_link_name ); } else { (void) sprintf( format, "%%c%%c%%%c%ds Chg: %%12s Acc: %%12s", justify, max_filename_len ); (void) sprintf( line_buffer, format, (fe_ptr->tagged) ? TAGGED_SYMBOL : ' ', type_of_file, fe_ptr->name, change_time, access_time ); } } else { /* Empty-Entry */ /*-------------*/ (void) sprintf( format, "%%-%ds", max_filename_len + 39 ); (void) sprintf( line_buffer, format, "" ); } if( max_linkname_len ) pos_x = x * (max_filename_len + max_linkname_len + 44); else pos_x = x * (max_filename_len + 40); break; case MODE_5 : if( fe_ptr ) { BuildUserFileEntry(fe_ptr, max_filename_len, max_linkname_len, USERVIEW, 200, line_buffer); } else { /* Empty-Entry */ /*-------------*/ (void) sprintf( format, "%%-%ds", max_userview_len ); (void) sprintf( line_buffer, format, "" ); } pos_x = x * (max_userview_len + 1); break; } /* display line */ /*--------------*/ n = StrVisualLength( line_buffer ); if( n <= ef_window_width ) { /* line fits */ /*-----------*/ hide_left = 0; hide_right = 0; line_ptr = line_buffer; } else { /* ... does not fit; use start_x */ /*-------------------------------*/ if( n > ( start_x + ef_window_width ) ) line_ptr = &line_buffer[start_x]; /* TODO: UTF-8 */ else line_ptr = &line_buffer[n - ef_window_width]; /* TODO: UTF-8 */ hide_left = start_x; hide_right = n - start_x - ef_window_width; line_ptr[ef_window_width] = '\0'; } #ifdef NO_HIGHLIGHT line_ptr[1] = (hilight) ? '>' : ' '; mvwaddstr( file_window, y, pos_x + 1, line_ptr ); #else #ifdef COLOR_SUPPORT if( hilight ) WbkgdSet(file_window, COLOR_PAIR(HIFILE_COLOR)|A_BOLD); else WbkgdSet(file_window, COLOR_PAIR(FILE_COLOR)); mvwaddstr(file_window, y, pos_x + 1, line_ptr ); WbkgdSet(file_window, COLOR_PAIR(FILE_COLOR)|A_BOLD); #else #endif /* COLOR_SUPPORT */ if( hilight ) wattrset( file_window, A_REVERSE ); mvwaddstr( file_window, y, pos_x + 1, line_ptr ); if( hilight ) wattrset( file_window, 0 ); #endif /* NO_HIGHLIGHT */ } void DisplayFileWindow(DirEntry *dir_entry) { GetMaxYX( file_window, &window_height, &window_width ); BuildFileEntryList( dir_entry ); DisplayFiles( dir_entry, dir_entry->start_file, dir_entry->start_file + dir_entry->cursor_pos, 0); } static void DisplayFiles(DirEntry *de_ptr, int start_file_no, int hilight_no, int start_x) { int x, y, p_x, p_y, j; werase( file_window ); if( file_count == 0 ) { mvwaddstr( file_window, 0, 3, (de_ptr->access_denied) ? "Permission Denied!" : "No Files!" ); } j = start_file_no; p_x = -1; p_y = 0; for( x=0; x < max_column; x++) { for( y=0; y < window_height; y++ ) { if( j < (int)file_count ) { if( j == hilight_no ) { p_x = x; p_y = y; } else { PrintFileEntry( j, y, x, FALSE, start_x); } } j++; } } if( p_x >= 0 ) PrintFileEntry( hilight_no, p_y, p_x, TRUE, start_x); } static void fmovedown(int *start_file, int *cursor_pos, int *start_x, DirEntry *dir_entry) { if( *start_file + *cursor_pos + 1 >= (int)file_count ) { /* File nicht vorhanden */ /*----------------------*/ beep(); } else { if( *cursor_pos < max_disp_files - 1 ) { /* DOWN ohne scroll moeglich */ /*---------------------------*/ PrintFileEntry( *start_file + *cursor_pos, *cursor_pos % window_height, *cursor_pos / window_height, FALSE, *start_x ); (*cursor_pos)++; PrintFileEntry( *start_file + *cursor_pos, *cursor_pos % window_height, *cursor_pos / window_height, TRUE , *start_x ); } else { /* Scrollen */ /*----------*/ (*start_file)++; DisplayFiles( dir_entry, *start_file, *start_file + *cursor_pos, *start_x ); } } return; } static void fmoveup(int *start_file, int *cursor_pos, int *start_x, DirEntry *dir_entry) { if( *start_file + *cursor_pos < 1 ) { /* File nicht vorhanden */ /*----------------------*/ beep(); } else { if( *cursor_pos > 0 ) { /* UP ohne scroll moeglich */ /*-------------------------*/ PrintFileEntry( *start_file + *cursor_pos, *cursor_pos % window_height, *cursor_pos / window_height, FALSE, *start_x ); (*cursor_pos)--; PrintFileEntry( *start_file + *cursor_pos, *cursor_pos % window_height, *cursor_pos / window_height, TRUE, *start_x ); } else { /* Scrollen */ /*----------*/ (*start_file)--; DisplayFiles( dir_entry, *start_file, *start_file + *cursor_pos, *start_x ); } } return; } static void fmoveright(int *start_file, int *cursor_pos, int *start_x,DirEntry *dir_entry) { if( x_step == 1 ) { /* Sonderfall: ganzes Filewindow scrollen */ /*----------------------------------------*/ (*start_x)++; PrintFileEntry( *start_file + *cursor_pos, *cursor_pos % window_height, *cursor_pos / window_height, TRUE , *start_x ); if( hide_right < 0 ) (*start_x)--; } else if( *start_file + *cursor_pos >= (int)file_count - 1 ) { /*letzte Position erreicht */ /*-------------------------*/ beep(); } else { if( *start_file + *cursor_pos + x_step >= (int)file_count ) { /* voller Step nicht moeglich; * auf letzten Eintrag positionieren */ my_x_step = file_count - *start_file - *cursor_pos - 1; } else { my_x_step = x_step; } if( *cursor_pos + my_x_step < max_disp_files ) { /* RIGHT ohne scroll moeglich */ /*----------------------------*/ PrintFileEntry( *start_file + *cursor_pos, *cursor_pos % window_height, *cursor_pos / window_height, FALSE, *start_x ); *cursor_pos += my_x_step; PrintFileEntry( *start_file + *cursor_pos, *cursor_pos % window_height, *cursor_pos / window_height, TRUE , *start_x ); } else { /* Scrollen */ /*----------*/ *start_file += x_step; *cursor_pos -= x_step - my_x_step; DisplayFiles( dir_entry, *start_file, *start_file + *cursor_pos, *start_x ); } } return; } static void fmoveleft(int *start_file, int *cursor_pos, int *start_x, DirEntry *dir_entry) { if( x_step == 1 ) { /* Sonderfall: ganzes Filewindow scrollen */ /*----------------------------------------*/ if( *start_x > 0 ) (*start_x)--; PrintFileEntry( *start_file + *cursor_pos, *cursor_pos % window_height, *cursor_pos / window_height, TRUE , *start_x ); } else if( *start_file + *cursor_pos <= 0 ) { /* erste Position erreicht */ /*-------------------------*/ beep(); } else { if( *start_file + *cursor_pos - x_step < 0 ) { /* voller Step nicht moeglich; * auf ersten Eintrag positionieren */ my_x_step = *start_file + *cursor_pos; } else { my_x_step = x_step; } if( *cursor_pos - my_x_step >= 0 ) { /* LEFT ohne scroll moeglich */ /*---------------------------*/ PrintFileEntry( *start_file + *cursor_pos, *cursor_pos % window_height, *cursor_pos / window_height, FALSE, *start_x ); *cursor_pos -= my_x_step; PrintFileEntry( *start_file + *cursor_pos, *cursor_pos % window_height, *cursor_pos / window_height, TRUE, *start_x ); } else { /* Scrollen */ /*----------*/ if( ( *start_file -= x_step ) < 0 ) *start_file = 0; DisplayFiles( dir_entry, *start_file, *start_file + *cursor_pos, *start_x ); } } return; } static void fmovenpage(int *start_file, int *cursor_pos, int *start_x, DirEntry *dir_entry) { if( *start_file + *cursor_pos >= (int)file_count - 1 ) { /*letzte Position erreicht */ /*-------------------------*/ beep(); } else { if( *cursor_pos < max_disp_files - 1 ) { /* Cursor steht noch nicht auf letztem * Eintrag * ==> setzen */ PrintFileEntry( *start_file + *cursor_pos, *cursor_pos % window_height, *cursor_pos / window_height, FALSE, *start_x ); if( *start_file + max_disp_files <= (int)file_count - 1 ) *cursor_pos = max_disp_files - 1; else *cursor_pos = file_count - *start_file - 1; PrintFileEntry( *start_file + *cursor_pos, *cursor_pos % window_height, *cursor_pos / window_height, TRUE, *start_x ); } else { /* Scrollen */ /*----------*/ if( *start_file + *cursor_pos + max_disp_files < (int)file_count ) *start_file += max_disp_files; else *start_file = file_count - max_disp_files; if( *start_file + max_disp_files <= (int)file_count - 1 ) *cursor_pos = max_disp_files - 1; else *cursor_pos = file_count - *start_file - 1; DisplayFiles( dir_entry, *start_file, *start_file + *cursor_pos, *start_x ); } } return; } static void fmoveppage(int *start_file, int *cursor_pos, int *start_x, DirEntry *dir_entry) { if( *start_file + *cursor_pos <= 0 ) { /* erste Position erreicht */ /*-------------------------*/ beep(); } else { if( *cursor_pos > 0 ) { /* Cursor steht noch nicht auf erstem * Eintrag * ==> setzen */ PrintFileEntry( *start_file + *cursor_pos, *cursor_pos % window_height, *cursor_pos / window_height, FALSE, *start_x ); *cursor_pos = 0; PrintFileEntry( *start_file + *cursor_pos, *cursor_pos % window_height, *cursor_pos / window_height, TRUE, *start_x ); } else { /* Scrollen */ /*----------*/ if( *start_file > max_disp_files ) *start_file -= max_disp_files; else *start_file = 0; DisplayFiles( dir_entry, *start_file, *start_file + *cursor_pos, *start_x ); } } return; } int HandleFileWindow(DirEntry *dir_entry) { FileEntry *fe_ptr; FileEntry *new_fe_ptr; DirEntry *de_ptr = NULL; DirEntry *dest_dir_entry; WalkingPackage walking_package; int ch; int tmp2; int unput_char; int list_pos; LONGLONG file_size; int i; int owner_id; int group_id; int start_x = 0; char filepath[PATH_LENGTH +1]; char modus[11]; BOOL path_copy; int term; int mask; static char to_dir[PATH_LENGTH+1]; static char to_path[PATH_LENGTH+1]; static char to_file[PATH_LENGTH+1]; BOOL need_dsp_help; BOOL maybe_change_x_step; char new_name[PATH_LENGTH+1]; char new_login_path[PATH_LENGTH + 1]; int dir_window_width, dir_window_height; unput_char = '\0'; fe_ptr = NULL; /* Cursor-Positionsmerker zuruecksetzen */ /*--------------------------------------*/ need_dsp_help = TRUE; maybe_change_x_step = TRUE; BuildFileEntryList( dir_entry ); if( dir_entry->global_flag || dir_entry->big_window || dir_entry->tagged_flag) { SwitchToBigFileWindow(); GetMaxYX( file_window, &window_height, &window_width ); DisplayDiskStatistic(); } else { GetMaxYX( file_window, &window_height, &window_width ); DisplayDirStatistic( dir_entry ); } DisplayFiles( dir_entry, dir_entry->start_file, dir_entry->start_file + dir_entry->cursor_pos, start_x ); do { if( maybe_change_x_step ) { maybe_change_x_step = FALSE; x_step = (max_column > 1) ? window_height : 1; max_disp_files = window_height * max_column; } if( need_dsp_help ) { need_dsp_help = FALSE; DisplayFileHelp(); } if( unput_char ) { ch = unput_char; unput_char = '\0'; } else { fe_ptr = file_entry_list[dir_entry->start_file + dir_entry->cursor_pos].file; if( dir_entry->global_flag ) DisplayGlobalFileParameter( fe_ptr ); else DisplayFileParameter( fe_ptr ); RefreshWindow( dir_window ); /* needed: ncurses-bug ? */ RefreshWindow( file_window ); doupdate(); ch = (resize_request) ? -1 : Getch(); if( ch == LF ) ch = CR; } #ifdef VI_KEYS ch = ViKey( ch ); #endif /* VI_KEYS */ if(resize_request) { ReCreateWindows(); RereadWindowSize(dir_entry); DisplayMenu(); GetMaxYX(dir_window, &dir_window_height, &dir_window_width); while(statistic.cursor_pos >= dir_window_height) { statistic.cursor_pos--; statistic.disp_begin_pos++; } if(dir_entry->global_flag || dir_entry->big_window || dir_entry->tagged_flag) { /* big window active */ SwitchToBigFileWindow(); DisplayFileWindow(dir_entry); if(dir_entry->global_flag) { DisplayDiskStatistic(); DisplayGlobalFileParameter(fe_ptr); } else { DisplayFileWindow(dir_entry); DisplayDirStatistic(dir_entry); DisplayFileParameter(fe_ptr); } } else { /* small window active */ SwitchToSmallFileWindow(); DisplayTree( dir_window, statistic.disp_begin_pos, statistic.disp_begin_pos + statistic.cursor_pos ); DisplayFileWindow(dir_entry); DisplayDirStatistic(dir_entry); DisplayFileParameter(fe_ptr); } need_dsp_help = TRUE; DisplayAvailBytes(); DisplayFileSpec(); DisplayDiskName(); resize_request = FALSE; } if( file_mode == MODE_1 ) { if( ch == '\t' ) ch = KEY_DOWN; else if( ch == KEY_BTAB ) ch = KEY_UP; } if( x_step == 1 && ( ch == KEY_RIGHT || ch == KEY_LEFT ) ) { /* start_x nicht zuruecksetzen */ /*-----------------------------*/ ; /* do nothing */ } else { /* bei 0 beginnen */ /*----------------*/ if( start_x ) { start_x = 0; PrintFileEntry( dir_entry->start_file + dir_entry->cursor_pos, dir_entry->cursor_pos % window_height, dir_entry->cursor_pos / window_height, TRUE , start_x ); } } if (mode == USER_MODE) { /* FileUserMode returns (possibly remapped) ch, or -1 if it handles ch */ ch = FileUserMode(&(file_entry_list[dir_entry->start_file + dir_entry->cursor_pos]), ch); } switch( ch ) { #ifdef KEY_RESIZE case KEY_RESIZE: resize_request = TRUE; break; #endif case -1: break; case ' ' : /* break; Quick-Key */ case KEY_DOWN : fmovedown(&dir_entry->start_file, &dir_entry->cursor_pos, &start_x, dir_entry); break; case KEY_UP : fmoveup(&dir_entry->start_file, &dir_entry->cursor_pos, &start_x, dir_entry); break; case KEY_RIGHT: fmoveright(&dir_entry->start_file, &dir_entry->cursor_pos, &start_x, dir_entry); break; case KEY_LEFT : fmoveleft(&dir_entry->start_file, &dir_entry->cursor_pos, &start_x, dir_entry); break; case KEY_NPAGE: fmovenpage(&dir_entry->start_file, &dir_entry->cursor_pos, &start_x, dir_entry); break; case KEY_PPAGE: fmoveppage(&dir_entry->start_file, &dir_entry->cursor_pos, &start_x, dir_entry); break; case KEY_END : if( dir_entry->start_file + dir_entry->cursor_pos + 1 >= (int)file_count ) { /* Letzte Position erreicht */ /*--------------------------*/ beep(); } else { if( (int)file_count < max_disp_files ) { dir_entry->start_file = 0; dir_entry->cursor_pos = file_count - 1; } else { dir_entry->start_file = file_count - max_disp_files; dir_entry->cursor_pos = file_count - dir_entry->start_file - 1; } DisplayFiles( dir_entry, dir_entry->start_file, dir_entry->start_file + dir_entry->cursor_pos, start_x ); } break; case KEY_HOME : if( dir_entry->start_file + dir_entry->cursor_pos <= 0 ) { /* erste Position erreicht */ /*-------------------------*/ beep(); } else { dir_entry->start_file = 0; dir_entry->cursor_pos = 0; DisplayFiles( dir_entry, dir_entry->start_file, dir_entry->start_file + dir_entry->cursor_pos, start_x ); } break; case 'A' : case 'a' : fe_ptr = file_entry_list[dir_entry->start_file + dir_entry->cursor_pos].file; need_dsp_help = TRUE; if( !ChangeFileModus( fe_ptr ) ) { PrintFileEntry( dir_entry->start_file + dir_entry->cursor_pos, dir_entry->cursor_pos % window_height, dir_entry->cursor_pos / window_height, TRUE, start_x ); } break; case 'A' & 0x1F : if( (mode != DISK_MODE && mode != USER_MODE) || !IsMatchingTaggedFiles() ) { beep(); } else { need_dsp_help = TRUE; mask = S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; (void) GetAttributes( mask, modus ); if( GetNewFileModus( LINES - 2, 1, modus, "\r\033" ) == CR ) { (void) strcpy( walking_package.function_data.change_modus.new_modus, modus ); WalkTaggedFiles( dir_entry->start_file, dir_entry->cursor_pos, SetFileModus, &walking_package ); DisplayFiles( dir_entry, dir_entry->start_file, dir_entry->start_file + dir_entry->cursor_pos, start_x ); } else { beep(); } } break; case 'O' : case 'o' : fe_ptr = file_entry_list[dir_entry->start_file + dir_entry->cursor_pos].file; need_dsp_help = TRUE; if( !ChangeFileOwner( fe_ptr ) ) { PrintFileEntry( dir_entry->start_file + dir_entry->cursor_pos, dir_entry->cursor_pos % window_height, dir_entry->cursor_pos / window_height, TRUE , start_x ); } break; case 'O' & 0x1F : if(( mode != DISK_MODE && mode != USER_MODE) || !IsMatchingTaggedFiles() ) { beep(); } else { need_dsp_help = TRUE; if( ( owner_id = GetNewOwner( -1 ) ) >= 0 ) { walking_package.function_data.change_owner.new_owner_id = owner_id; WalkTaggedFiles( dir_entry->start_file, dir_entry->cursor_pos, SetFileOwner, &walking_package ); DisplayFiles( dir_entry, dir_entry->start_file, dir_entry->start_file + dir_entry->cursor_pos, start_x ); } } break; case 'G' : case 'g' : fe_ptr = file_entry_list[dir_entry->start_file + dir_entry->cursor_pos].file; need_dsp_help = TRUE; if( !ChangeFileGroup( fe_ptr ) ) { PrintFileEntry( dir_entry->start_file + dir_entry->cursor_pos, dir_entry->cursor_pos % window_height, dir_entry->cursor_pos / window_height, TRUE, start_x ); } break; case 'G' & 0x1F : if(( mode != DISK_MODE && mode != USER_MODE) || !IsMatchingTaggedFiles() ) { beep(); } else { need_dsp_help = TRUE; if( ( group_id = GetNewGroup( -1 ) ) >= 0 ) { walking_package.function_data.change_group.new_group_id = group_id; WalkTaggedFiles( dir_entry->start_file, dir_entry->cursor_pos, SetFileGroup, &walking_package ); DisplayFiles( dir_entry, dir_entry->start_file, dir_entry->start_file + dir_entry->cursor_pos, start_x ); } } break; case 'T' : case 't' : fe_ptr = file_entry_list[dir_entry->start_file + dir_entry->cursor_pos].file; de_ptr = fe_ptr->dir_entry; if( !fe_ptr->tagged ) { fe_ptr->tagged = TRUE; PrintFileEntry( dir_entry->start_file + dir_entry->cursor_pos, dir_entry->cursor_pos % window_height, dir_entry->cursor_pos / window_height, TRUE, start_x ); de_ptr->tagged_files++; de_ptr->tagged_bytes += fe_ptr->stat_struct.st_size; statistic.disk_tagged_files++; statistic.disk_tagged_bytes += fe_ptr->stat_struct.st_size; if( dir_entry->global_flag ) DisplayDiskTagged(); else DisplayDirTagged( de_ptr ); } unput_char = KEY_DOWN; break; case 'U' : case 'u' : fe_ptr = file_entry_list[dir_entry->start_file + dir_entry->cursor_pos].file; de_ptr = fe_ptr->dir_entry; if( fe_ptr->tagged ) { fe_ptr->tagged = FALSE; PrintFileEntry( dir_entry->start_file + dir_entry->cursor_pos, dir_entry->cursor_pos % window_height, dir_entry->cursor_pos / window_height, TRUE, start_x ); de_ptr->tagged_files--; de_ptr->tagged_bytes -= fe_ptr->stat_struct.st_size; statistic.disk_tagged_files--; statistic.disk_tagged_bytes -= fe_ptr->stat_struct.st_size; if( dir_entry->global_flag ) DisplayDiskTagged(); else DisplayDirTagged( de_ptr ); } unput_char = KEY_DOWN; break; case 'F' & 0x1F : list_pos = dir_entry->start_file + dir_entry->cursor_pos; RotateFileMode(); x_step = (max_column > 1) ? window_height : 1; max_disp_files = window_height * max_column; if( dir_entry->cursor_pos >= max_disp_files ) { /* Cursor muss neu positioniert werden */ /*-------------------------------------*/ dir_entry->cursor_pos = max_disp_files - 1; } dir_entry->start_file = list_pos - dir_entry->cursor_pos; DisplayFiles( dir_entry, dir_entry->start_file, dir_entry->start_file + dir_entry->cursor_pos, start_x ); break; case 'T' & 0x1F : for(i=0; i < (int)file_count; i++) { fe_ptr = file_entry_list[i].file; de_ptr = fe_ptr->dir_entry; if( !fe_ptr->tagged ) { file_size = fe_ptr->stat_struct.st_size; fe_ptr->tagged = TRUE; de_ptr->tagged_files++; de_ptr->tagged_bytes += file_size; statistic.disk_tagged_files++; statistic.disk_tagged_bytes += file_size; } } if( dir_entry->global_flag ) DisplayDiskTagged(); else DisplayDirTagged( dir_entry ); DisplayFiles( dir_entry, dir_entry->start_file, dir_entry->start_file + dir_entry->cursor_pos, start_x ); break; case 'U' & 0x1F : for(i=0; i < (int)file_count; i++) { fe_ptr = file_entry_list[i].file; de_ptr = fe_ptr->dir_entry; if( fe_ptr->tagged ) { file_size = fe_ptr->stat_struct.st_size; fe_ptr->tagged = FALSE; de_ptr->tagged_files--; de_ptr->tagged_bytes -= file_size; statistic.disk_tagged_files--; statistic.disk_tagged_bytes -= file_size; } } if( dir_entry->global_flag ) DisplayDiskTagged(); else DisplayDirTagged( dir_entry ); DisplayFiles( dir_entry, dir_entry->start_file, dir_entry->start_file + dir_entry->cursor_pos, start_x ); break; case ';': case 't' | 0x80 : for(i=dir_entry->start_file + dir_entry->cursor_pos; i < (int)file_count; i++) { fe_ptr = file_entry_list[i].file; de_ptr = fe_ptr->dir_entry; if( !fe_ptr->tagged ) { file_size = fe_ptr->stat_struct.st_size; fe_ptr->tagged = TRUE; de_ptr->tagged_files++; de_ptr->tagged_bytes += file_size; statistic.disk_tagged_files++; statistic.disk_tagged_bytes += file_size; } } if( dir_entry->global_flag ) DisplayDiskTagged(); else DisplayDirTagged( dir_entry ); DisplayFiles( dir_entry, dir_entry->start_file, dir_entry->start_file + dir_entry->cursor_pos, start_x ); break; case ':': case 'u' | 0x80 : for(i=dir_entry->start_file + dir_entry->cursor_pos; i < (int)file_count; i++) { fe_ptr = file_entry_list[i].file; de_ptr = fe_ptr->dir_entry; if( fe_ptr->tagged ) { file_size = fe_ptr->stat_struct.st_size; fe_ptr->tagged = FALSE; de_ptr->tagged_files--; de_ptr->tagged_bytes -= file_size; statistic.disk_tagged_files--; statistic.disk_tagged_bytes -= file_size; } } if( dir_entry->global_flag ) DisplayDiskTagged(); else DisplayDirTagged( dir_entry ); DisplayFiles( dir_entry, dir_entry->start_file, dir_entry->start_file + dir_entry->cursor_pos, start_x ); break; case 'V' : case 'v' : fe_ptr = file_entry_list[dir_entry->start_file + dir_entry->cursor_pos].file; de_ptr = fe_ptr->dir_entry; (void) GetRealFileNamePath( fe_ptr, filepath ); (void) View( dir_entry, filepath ); need_dsp_help = TRUE; break; case 'H' : case 'h' : fe_ptr = file_entry_list[dir_entry->start_file + dir_entry->cursor_pos].file; de_ptr = fe_ptr->dir_entry; (void) GetRealFileNamePath( fe_ptr, filepath ); (void) ViewHex( filepath ); need_dsp_help = TRUE; break; case 'E': case 'e' : fe_ptr = file_entry_list[dir_entry->start_file + dir_entry->cursor_pos].file; de_ptr = fe_ptr->dir_entry; (void) GetFileNamePath( fe_ptr, filepath ); (void) Edit( de_ptr, filepath ); break; case 'Y' : case 'y' : case 'C' : case 'c' : fe_ptr = file_entry_list[dir_entry->start_file + dir_entry->cursor_pos].file; de_ptr = fe_ptr->dir_entry; path_copy = FALSE; if( ch == 'y' || ch == 'Y' ) path_copy = TRUE; need_dsp_help = TRUE; if( GetCopyParameter( fe_ptr->name, path_copy, to_file, to_dir ) ) { beep(); break; } if( mode == DISK_MODE || mode == USER_MODE ) { if( (tmp2 = GetDirEntry( statistic.tree, de_ptr, to_dir, &dest_dir_entry, to_path )) == -3) { } else if (tmp2 != 0) { /* beep(); */ break; } if( !CopyFile( &statistic, fe_ptr, TRUE, to_file, dest_dir_entry, to_path, path_copy ) ) { /* File wurde kopiert */ /*--------------------*/ DisplayAvailBytes(); if( dest_dir_entry ) { /* Ziel befindet sich im SUB-Tree */ /*--------------------------------*/ if( dir_entry->global_flag ) DisplayDiskStatistic(); else DisplayDirStatistic( de_ptr ); if( dest_dir_entry == de_ptr ) { /* Ziel ist aktuelles Verzeichnis */ /*--------------------------------*/ BuildFileEntryList( dir_entry ); DisplayFiles( dir_entry, dir_entry->start_file, dir_entry->start_file + dir_entry->cursor_pos, start_x ); } } } } else { /* TAR_FILE_MODE */ /*---------------*/ dest_dir_entry = NULL; if( disk_statistic.tree ) { if( GetDirEntry( disk_statistic.tree, de_ptr, to_dir, &dest_dir_entry, to_path ) ) { beep(); break; } } else { (void) strcpy( to_path, to_dir ); } if( !CopyFile( &disk_statistic, fe_ptr, TRUE, to_file, dest_dir_entry, to_path, path_copy ) ) { /* File wurde kopiert */ /*--------------------*/ DisplayAvailBytes(); } } break; case 'Y' & 0x1F : case 'K' & 0x1F : case 'C' & 0x1F : de_ptr = dir_entry; path_copy = FALSE; if( ch == ('Y' & 0x1F) ) path_copy = TRUE; if( !IsMatchingTaggedFiles() ) { beep(); } else { need_dsp_help = TRUE; if( GetCopyParameter( NULL, path_copy, to_file, to_dir ) ) { beep(); break; } if( mode == DISK_MODE || mode == USER_MODE ) { if( GetDirEntry( statistic.tree, de_ptr, to_dir, &dest_dir_entry, to_path ) ) { beep(); break; } term = InputChoise( "Confirm overwrite existing files (Y/N) ? ", "YN\033" ); if( term == ESC ) { beep(); break; } walking_package.function_data.copy.statistic_ptr = &statistic; walking_package.function_data.copy.dest_dir_entry = dest_dir_entry; walking_package.function_data.copy.to_file = to_file; walking_package.function_data.copy.to_path = to_path; walking_package.function_data.copy.path_copy = path_copy; walking_package.function_data.copy.confirm = (term == 'Y') ? TRUE : FALSE; WalkTaggedFiles( dir_entry->start_file, dir_entry->cursor_pos, CopyTaggedFiles, &walking_package ); DisplayAvailBytes(); DisplayFiles( dir_entry, dir_entry->start_file, dir_entry->start_file + dir_entry->cursor_pos, start_x ); } else { /* TAR_FILE_MODE */ /*---------------*/ dest_dir_entry = NULL; if( disk_statistic.tree ) { if( GetDirEntry( disk_statistic.tree, de_ptr, to_dir, &dest_dir_entry, to_path ) ) { beep(); break; } } else { (void) strcpy( to_path, to_dir ); } term = InputChoise( "Confirm overwrite existing files (Y/N) ? ", "YN\033" ); if( term == ESC ) { beep(); break; } walking_package.function_data.copy.statistic_ptr = &disk_statistic; walking_package.function_data.copy.dest_dir_entry = dest_dir_entry; walking_package.function_data.copy.to_file = to_file; walking_package.function_data.copy.to_path = to_path; walking_package.function_data.copy.path_copy = path_copy; walking_package.function_data.copy.confirm = (term == 'Y') ? TRUE : FALSE; WalkTaggedFiles( dir_entry->start_file, dir_entry->cursor_pos, CopyTaggedFiles, &walking_package ); DisplayAvailBytes(); DisplayFiles( dir_entry, dir_entry->start_file, dir_entry->start_file + dir_entry->cursor_pos, start_x ); } } break; case 'M' : case 'm' : if( mode != DISK_MODE && mode != USER_MODE ) { beep(); break; } fe_ptr = file_entry_list[dir_entry->start_file + dir_entry->cursor_pos].file; de_ptr = fe_ptr->dir_entry; need_dsp_help = TRUE; if( GetMoveParameter( fe_ptr->name, to_file, to_dir ) ) { beep(); break; } if( GetDirEntry( statistic.tree, de_ptr, to_dir, &dest_dir_entry, to_path ) ) { beep(); break; } if( !MoveFile( fe_ptr, TRUE, to_file, dest_dir_entry, to_path, &new_fe_ptr ) ) { /* File wurde bewegt */ /*-------------------*/ DisplayAvailBytes(); if( dir_entry->global_flag ) DisplayDiskStatistic(); else DisplayDirStatistic( de_ptr ); BuildFileEntryList( dir_entry ); if( file_count == 0 ) unput_char = ESC; if( dir_entry->start_file + dir_entry->cursor_pos >= (int)file_count ) { if( --dir_entry->cursor_pos < 0 ) { if( dir_entry->start_file > 0 ) { dir_entry->start_file--; } dir_entry->cursor_pos = 0; } } DisplayFiles( dir_entry, dir_entry->start_file, dir_entry->start_file + dir_entry->cursor_pos, start_x ); maybe_change_x_step = TRUE; } break; case 'N' & 0x1F : if(( mode != DISK_MODE && mode != USER_MODE) || !IsMatchingTaggedFiles() ) { beep(); } else { need_dsp_help = TRUE; if( GetMoveParameter( NULL, to_file, to_dir ) ) { beep(); break; } if( GetDirEntry( statistic.tree, de_ptr, to_dir, &dest_dir_entry, to_path ) ) { beep(); break; } term = InputChoise( "Confirm overwrite existing files (Y/N) ? ", "YN\033" ); if( term == ESC ) { beep(); break; } walking_package.function_data.mv.dest_dir_entry = dest_dir_entry; walking_package.function_data.mv.to_file = to_file; walking_package.function_data.mv.to_path = to_path; walking_package.function_data.mv.confirm = (term == 'Y') ? TRUE : FALSE; WalkTaggedFiles( dir_entry->start_file, dir_entry->cursor_pos, MoveTaggedFiles, &walking_package ); BuildFileEntryList( dir_entry ); if( file_count == 0 ) unput_char = ESC; dir_entry->start_file = 0; dir_entry->cursor_pos = 0; DisplayFiles( dir_entry, dir_entry->start_file, dir_entry->start_file + dir_entry->cursor_pos, start_x ); maybe_change_x_step = TRUE; } break; case 'D' : case 'd' : if( mode != DISK_MODE && mode != USER_MODE ) { beep(); break; } term = InputChoise( "Delete this file (Y/N) ? ", "YN\033" ); need_dsp_help = TRUE; if( term != 'Y' ) break; fe_ptr = file_entry_list[dir_entry->start_file + dir_entry->cursor_pos].file; de_ptr = fe_ptr->dir_entry; if( !DeleteFile( fe_ptr ) ) { /* File wurde geloescht */ /*----------------------*/ if( dir_entry->global_flag ) DisplayDiskStatistic(); else DisplayDirStatistic( de_ptr ); DisplayAvailBytes(); RemoveFileEntry( dir_entry->start_file + dir_entry->cursor_pos ); if( file_count == 0 ) unput_char = ESC; if( dir_entry->start_file + dir_entry->cursor_pos >= (int)file_count ) { if( --dir_entry->cursor_pos < 0 ) { if( dir_entry->start_file > 0 ) { dir_entry->start_file--; } dir_entry->cursor_pos = 0; } } DisplayFiles( dir_entry, dir_entry->start_file, dir_entry->start_file + dir_entry->cursor_pos, start_x ); maybe_change_x_step = TRUE; } break; case 'D' & 0x1F : if(( mode != DISK_MODE && mode != USER_MODE) || !IsMatchingTaggedFiles() ) { beep(); } else { need_dsp_help = TRUE; (void) DeleteTaggedFiles( max_disp_files ); if( file_count == 0 ) unput_char = ESC; dir_entry->start_file = 0; dir_entry->cursor_pos = 0; DisplayAvailBytes(); DisplayFiles( dir_entry, dir_entry->start_file, dir_entry->start_file + dir_entry->cursor_pos, start_x ); maybe_change_x_step = TRUE; } break; case 'R': case 'r': if( mode != DISK_MODE && mode != USER_MODE ) { beep(); break; } fe_ptr = file_entry_list[dir_entry->start_file + dir_entry->cursor_pos].file; de_ptr = fe_ptr->dir_entry; if( !GetRenameParameter( fe_ptr->name, new_name ) ) { if( !RenameFile( fe_ptr, new_name, &new_fe_ptr ) ) { /* Rename OK */ /*-----------*/ /* Maybe structure has changed... */ /*--------------------------------*/ BuildFileEntryList( de_ptr ); DisplayFiles( de_ptr, dir_entry->start_file, dir_entry->start_file + dir_entry->cursor_pos, start_x ); maybe_change_x_step = TRUE; } } need_dsp_help = TRUE; break; case 'R' & 0x1F : if(( mode != DISK_MODE && mode != USER_MODE) || !IsMatchingTaggedFiles() ) { beep(); } else { need_dsp_help = TRUE; if( GetRenameParameter( NULL, new_name ) ) { beep(); break; } walking_package.function_data.rename.new_name = new_name; walking_package.function_data.rename.confirm = FALSE; WalkTaggedFiles( dir_entry->start_file, dir_entry->cursor_pos, RenameTaggedFiles, &walking_package ); BuildFileEntryList( dir_entry ); if( file_count == 0 ) unput_char = ESC; DisplayFiles( dir_entry, dir_entry->start_file, dir_entry->start_file + dir_entry->cursor_pos, start_x ); maybe_change_x_step = TRUE; } break; case 'S': case 's': GetKindOfSort(); dir_entry->start_file = 0; dir_entry->cursor_pos = 0; SortFileEntryList(); DisplayFiles( dir_entry, dir_entry->start_file, dir_entry->start_file + dir_entry->cursor_pos, start_x ); need_dsp_help = TRUE; break; case 'F': case 'f': if(ReadFileSpec() == 0) { dir_entry->start_file = 0; dir_entry->cursor_pos = 0; BuildFileEntryList( dir_entry ); DisplayFileSpec(); DisplayFiles( dir_entry, dir_entry->start_file, dir_entry->start_file + dir_entry->cursor_pos, start_x ); if( dir_entry->global_flag ) DisplayDiskStatistic(); else DisplayDirStatistic( dir_entry ); if( file_count == 0 ) unput_char = ESC; maybe_change_x_step = TRUE; } need_dsp_help = TRUE; break; #ifndef VI_KEYS case 'l': #endif /* VI_KEYS */ case 'L': fe_ptr = file_entry_list[dir_entry->start_file + dir_entry->cursor_pos].file; if( mode == DISK_MODE || mode == USER_MODE ) { (void) GetFileNamePath( fe_ptr, new_login_path ); if( !GetNewLoginPath( new_login_path ) ) { dir_entry->login_flag = TRUE; (void) LoginDisk( new_login_path ); unput_char = LOGIN_ESC; } need_dsp_help = TRUE; } else beep(); break; case LF: case CR: if( dir_entry->big_window ) break; dir_entry->big_window = TRUE; ch = '\0'; SwitchToBigFileWindow(); GetMaxYX( file_window, &window_height, &window_width ); x_step = (max_column > 1) ? window_height : 1; max_disp_files = window_height * max_column; DisplayFiles( dir_entry, dir_entry->start_file, dir_entry->start_file + dir_entry->cursor_pos, start_x ); break; case 'P' : case 'p' : fe_ptr = file_entry_list[dir_entry->start_file + dir_entry->cursor_pos].file; de_ptr = fe_ptr->dir_entry; (void) Pipe( de_ptr, fe_ptr ); need_dsp_help = TRUE; break; case 'P' & 0x1F : de_ptr = dir_entry; if( !IsMatchingTaggedFiles() ) { beep(); } else if( mode != DISK_MODE && mode != USER_MODE ) { MESSAGE( "i am sorry*^P not supported in Archive-mode" ); } else { need_dsp_help = TRUE; if( GetPipeCommand( filepath ) ) { beep(); break; } if( ( walking_package.function_data.pipe_cmd.pipe_file = popen( filepath, "w" ) ) == NULL ) { (void) sprintf( message, "execution of command*%s*failed", filepath ); MESSAGE( message ); break; } WalkTaggedFiles( dir_entry->start_file, dir_entry->cursor_pos, PipeTaggedFiles, &walking_package ); clearok( stdscr, TRUE ); if( pclose( walking_package.function_data.pipe_cmd.pipe_file ) ) { WARNING( "pclose failed" ); } (void) GetAvailBytes( &statistic.disk_space ); DisplayAvailBytes(); DisplayFiles( dir_entry, dir_entry->start_file, dir_entry->start_file + dir_entry->cursor_pos, start_x ); } break; case 'X': case 'x' : fe_ptr = file_entry_list[dir_entry->start_file + dir_entry->cursor_pos].file; de_ptr = fe_ptr->dir_entry; (void) Execute( de_ptr, fe_ptr ); need_dsp_help = TRUE; break; case 'S' & 0x1F : if( !IsMatchingTaggedFiles() ) { beep(); } else if( mode != DISK_MODE && mode != USER_MODE ) { MESSAGE( "Feature not available in archives." ); } else { char *command_line; if( ( command_line = (char *)malloc( COLS + 1 ) ) == NULL ) { ERROR_MSG( "Malloc failed*ABORT" ); exit( 1 ); } need_dsp_help = TRUE; *command_line = '\0'; if( !GetSearchCommandLine( command_line ) ) { refresh(); endwin(); SuspendClock(); walking_package.function_data.execute.command = command_line; SilentTagWalkTaggedFiles( ExecuteCommand, &walking_package ); RefreshWindow( file_window ); HitReturnToContinue(); InitClock(); DisplayFiles( dir_entry, dir_entry->start_file, dir_entry->start_file + dir_entry->cursor_pos, start_x ); } free( command_line ); } break; case 'X' & 0x1F: if( !IsMatchingTaggedFiles() ) { beep(); } else if( mode != DISK_MODE && mode != USER_MODE ) { MESSAGE( "I am sorry*^X not supported in Archive-mode" ); } else { char *command_line; if( ( command_line = (char *)malloc( COLS + 1 ) ) == NULL ) { ERROR_MSG( "Malloc failed*ABORT" ); exit( 1 ); } need_dsp_help = TRUE; *command_line = '\0'; if( !GetCommandLine( command_line ) ) { refresh(); endwin(); walking_package.function_data.execute.command = command_line; SilentWalkTaggedFiles( ExecuteCommand, &walking_package ); HitReturnToContinue(); DisplayFiles( dir_entry, dir_entry->start_file, dir_entry->start_file + dir_entry->cursor_pos, start_x ); } free( command_line ); } break; case 'Q' & 0x1F: need_dsp_help = TRUE; fe_ptr = file_entry_list[dir_entry->start_file + dir_entry->cursor_pos].file; de_ptr = fe_ptr->dir_entry; QuitTo(de_ptr); break; case 'Q': case 'q': need_dsp_help = TRUE; Quit(); break; case 'L' & 0x1F: clearok( stdscr, TRUE ); break; case '\033': break; case LOGIN_ESC : break; case KEY_F(12): ListJump(dir_entry, ""); need_dsp_help = TRUE; break; default: beep(); break; } } while( ch != CR && ch != ESC && ch != LOGIN_ESC ); if( dir_entry->big_window ) SwitchToSmallFileWindow(); if(ch != LOGIN_ESC) { dir_entry->global_flag = FALSE; dir_entry->tagged_flag = FALSE; dir_entry->big_window = FALSE; } return( ch ); } static void WalkTaggedFiles(int start_file, int cursor_pos, int (*fkt) (/* ??? */), WalkingPackage *walking_package ) { FileEntry *fe_ptr; int i; int start_x = 0; int result = 0; BOOL maybe_change_x = FALSE; if( baudrate() >= QUICK_BAUD_RATE ) typeahead( 0 ); /* GetMaxYX( file_window, &window_height, &window_width );*/ max_disp_files = window_height * max_column; for( i=0; i < (int)file_count && result == 0; i++ ) { fe_ptr = file_entry_list[i].file; if( fe_ptr->tagged && fe_ptr->matching ) { if( maybe_change_x == FALSE && i >= start_file && i < start_file + max_disp_files ) { /* Walk ohne scroll moeglich */ /*---------------------------*/ PrintFileEntry( start_file + cursor_pos, cursor_pos % window_height, cursor_pos / window_height, FALSE, start_x ); cursor_pos = i - start_file; PrintFileEntry( start_file + cursor_pos, cursor_pos % window_height, cursor_pos / window_height, TRUE, start_x ); } else { /* Scroll noetig */ /*---------------*/ start_file = MAX( 0, i - max_disp_files + 1 ); cursor_pos = i - start_file; DisplayFiles( fe_ptr->dir_entry, start_file, start_file + cursor_pos, start_x ); maybe_change_x = FALSE; } if( fe_ptr->dir_entry->global_flag ) DisplayGlobalFileParameter( fe_ptr ); else DisplayFileParameter( fe_ptr ); RefreshWindow( file_window ); doupdate(); result = fkt( fe_ptr, walking_package ); if( walking_package->new_fe_ptr != fe_ptr ) { file_entry_list[i].file = walking_package->new_fe_ptr; ChangeFileEntry(); max_disp_files = window_height * max_column; maybe_change_x = TRUE; } } } if( baudrate() >= QUICK_BAUD_RATE ) typeahead( -1 ); } /* ExecuteCommand (*fkt) had its retval zeroed as found. ^S needs that value, so it was unzeroed. forloop below was modified to not care about retval instead? global flag for stop-on-error? does anybody want it? --crb3 12mar04 */ static void SilentWalkTaggedFiles( int (*fkt) (/* ??? */), WalkingPackage *walking_package ) { FileEntry *fe_ptr; int i; int result = 0; for( i=0; i < (int)file_count; i++ ) { fe_ptr = file_entry_list[i].file; if( fe_ptr->tagged && fe_ptr->matching ) { result = fkt( fe_ptr, walking_package ); } } } /* SilentTagWalkTaggedFiles. revision of above function to provide something like XTG's facility, using external grep. - loops for entire filescount. - if called program returns 1 (grep's "no-match" retcode), untags the file. repeated calls can be used to pare down tags, each with a different string, until only the intended target files are tagged. ExecuteCommand must have its retval unzeroed. --crb3 31dec03 */ static void SilentTagWalkTaggedFiles( int (*fkt) (/* ??? */), WalkingPackage *walking_package ) { FileEntry *fe_ptr; int i; int result = 0; for( i=0; i < (int)file_count; i++ ) { fe_ptr = file_entry_list[i].file; if( fe_ptr->tagged && fe_ptr->matching ) { result = fkt( fe_ptr, walking_package ); if( result == 0 ) { fe_ptr->tagged = FALSE; } } } } static BOOL IsMatchingTaggedFiles(void) { FileEntry *fe_ptr; int i; for( i=0; i < (int)file_count; i++) { fe_ptr = file_entry_list[i].file; if( fe_ptr->matching && fe_ptr->tagged ) return( TRUE ); } return( FALSE ); } static int DeleteTaggedFiles(int max_disp_files) { FileEntry *fe_ptr; DirEntry *de_ptr; int i; int start_file; int cursor_pos; BOOL deleted; BOOL confirm; int term; int start_x = 0; int result = 0; term = InputChoise( "Confirm delete each file (Y/N) ? ", "YN\033" ); if( term == ESC ) return( -1 ); if( term == 'Y' ) confirm = TRUE; else confirm = FALSE; if( baudrate() >= QUICK_BAUD_RATE ) typeahead( 0 ); for( i=0; i < (int)file_count && result == 0; ) { deleted = FALSE; fe_ptr = file_entry_list[i].file; de_ptr = fe_ptr->dir_entry; if( fe_ptr->tagged && fe_ptr->matching ) { start_file = MAX( 0, i - max_disp_files + 1 ); cursor_pos = i - start_file; DisplayFiles( de_ptr, start_file, start_file + cursor_pos, start_x ); if( fe_ptr->dir_entry->global_flag ) DisplayGlobalFileParameter( fe_ptr ); else DisplayFileParameter( fe_ptr ); RefreshWindow( file_window ); doupdate(); if( confirm ) term = InputChoise( "Delete this file (Y/N) ? ", "YN\033" ); else term = 'Y'; if( term == ESC ) { if( baudrate() >= QUICK_BAUD_RATE ) typeahead( -1 ); result = -1; break; } if( term == 'Y' ) { if( ( result = DeleteFile( fe_ptr ) ) == 0 ) { /* File wurde geloescht */ /*----------------------*/ deleted = TRUE; if( de_ptr->global_flag ) DisplayDiskStatistic(); else DisplayDirStatistic( de_ptr ); DisplayAvailBytes(); RemoveFileEntry( start_file + cursor_pos ); } } } if( !deleted ) i++; } if( baudrate() >= QUICK_BAUD_RATE ) typeahead( -1 ); return( result ); } static void RereadWindowSize(DirEntry *dir_entry) { SetFileMode(file_mode); x_step = (max_column > 1) ? window_height : 1; max_disp_files = window_height * max_column; if( dir_entry->start_file + dir_entry->cursor_pos < (int)file_count ) { while( dir_entry->cursor_pos >= max_disp_files ) { dir_entry->start_file += x_step; dir_entry->cursor_pos -= x_step; } } return; } static void ListJump( DirEntry * dir_entry, char *str ) { int incremental = (!strcmp(LISTJUMPSEARCH, "1")) ? 1 : 0; /* from ~/.ytree */ /* in file_window press initial char of file to jump to it */ char *newStr = NULL; FileEntry * fe_ptr = NULL; int i=0, j=0, n=0, start_x=0, ic=0, iq=0, tmp2=0; char * jumpmsg = "Press initial of file to jump to... "; ClearHelp(); MvAddStr( LINES - 2, 1, jumpmsg ); PrintOptions ( stdscr, LINES - 2, COLS - 14, "(Escape) cancel" ); ic = tolower(getch()); if( !isprint(ic) ) { beep(); return; } n = strlen(str); if((newStr = malloc(n+2)) == NULL) { ERROR_MSG( "Malloc failed*ABORT" ); exit( 1 ); } strcpy(newStr, str); newStr[n] = ic; newStr[n+1] = '\0'; /* index of current entry in list */ tmp2 = (incremental && n == 0) ? 0 : dir_entry->start_file + dir_entry->cursor_pos; if( tmp2 == file_count - 1 ) { ClearHelp(); MvAddStr( LINES - 2, 1, "Last entry!"); beep(); RefreshWindow( stdscr ); RefreshWindow( file_window ); doupdate(); sleep(1); free(newStr); return; } for( i=tmp2; i < file_count; i++ ) { fe_ptr = file_entry_list[i].file; if(!strncasecmp(newStr, fe_ptr->name, n+1)) break; } if ( i == file_count ) { ClearHelp(); MvAddStr( LINES - 2, 1, "No match!"); beep(); RefreshWindow( stdscr ); RefreshWindow( file_window ); doupdate(); sleep(1); free(newStr); return; } /* position cursor on entry wanted and found */ if( incremental && n == 0 ) { /* first search start on top */ dir_entry->start_file = 0; dir_entry->cursor_pos = 0; DisplayFiles( dir_entry, dir_entry->start_file, dir_entry->start_file + dir_entry->cursor_pos, start_x ); } for ( j=tmp2; j < i; j++ ) fmovedown ( &dir_entry->start_file, &dir_entry->cursor_pos, &start_x, dir_entry ); RefreshWindow( stdscr ); RefreshWindow( file_window ); doupdate(); ListJump( dir_entry, (incremental) ? newStr : "" ); free(newStr); } ytree-1.99pl1/freesp.c000066400000000000000000000176461350711670100146700ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/freesp.c,v 1.25 2012/09/11 16:40:02 werner Exp $ * * Ermittlung der freien Plattenkapazitaet * ***************************************************************************/ #include "ytree.h" #if ( defined( linux ) || defined( sun ) || defined( __NeXT__ ) || defined(hpux) || defined( __DJGPP__ ) || defined ( __GNU__ ) ) && !defined( SVR4 ) #include #else #ifdef WIN32 #include #else #if defined( SVR4 ) || defined( OSF1 ) || defined( sun56 ) || defined( __NetBSD__ ) #include #else #if ( defined( ultrix ) || defined( __OpenBSD__ ) || defined ( __FreeBSD__ ) || defined (__APPLE__) ) #include #include #else #if defined( QNX ) #include #include #else /* z.B. SVR3 */ #include #endif /* QNX */ #endif /* ultrix */ #endif /* SVR4 */ #endif /* WIN32 */ #endif /* sun / linux / __NeXT__ hpux */ #ifdef __GNU__ #include #endif /* Volume-Name und freien Plattenplatz ermitteln */ /*-----------------------------------------------*/ int GetDiskParameter( char *path, char *volume_name, LONGLONG *avail_bytes, LONGLONG *total_disk_space ) { #ifdef WIN32 struct _diskfree_t diskspace; #else #if defined( SVR4 ) || defined( OSF1 ) || defined( __NetBSD__ ) struct statvfs statfs_struct; #else #ifdef ultrix struct fs_data statfs_struct; #else #ifdef QNX long total_blocks, free_blocks; int fd; #else struct statfs statfs_struct; #endif /* QNX */ #endif /* ultrix */ #endif /* SVR4 */ #endif /* WIN32 */ char *p; char *fname; int result; LONGLONG bfree; LONGLONG this_disk_space; #ifdef WIN32 if( ( result = _getdiskfree( 0, &diskspace ) ) == 0 ) #else #ifdef __DJGPP__ if( ( result = statfs( path, &statfs_struct ) ) == 0 ) #else #ifdef QNX fd = open(path, O_RDONLY ); if( ( result = disk_space( fd, &free_blocks, &total_blocks ) ) == 0 ) #else if( ( result = STATFS( path, &statfs_struct, sizeof( statfs_struct ), 0 ) ) == 0 ) #endif /* QNX */ #endif /* __DJGPP__ */ #endif /* WIN32 */ { if( volume_name ) { /* Name ermitteln */ /*----------------*/ if( mode == DISK_MODE || mode == USER_MODE ) { #ifdef linux switch( statfs_struct.f_type ) { case 0xEF51: fname = "EXT2-OLD"; break; case 0xEF53: fname = "EXT2"; break; case 0x137D: fname = "EXT"; break; case 0x9660: fname = "ISOFS"; break; case 0x137F: fname = "MINIX"; break; case 0x138F: fname = "MINIX2"; break; case 0x2468: fname = "MINIX-NEW"; break; case 0x4d44: fname = "DOS"; break; case 0x6969: fname = "NFS"; break; case 0x9fa0: fname = "PROC"; break; case 0x012FD16D: fname = "XIAFS"; break; default: fname = "LINUX"; } #else #ifdef __GNU__ switch( statfs_struct.f_type ) { case FSTYPE_UFS: fname = "UFS"; break; case FSTYPE_NFS: fname = "NFS"; break; case FSTYPE_GFS: fname = "GFS"; break; case FSTYPE_LFS: fname = "LFS"; break; case FSTYPE_SYSV: fname = "SYSV"; break; case FSTYPE_FTP: fname = "FTP"; break; case FSTYPE_TAR: fname = "TAR"; break; case FSTYPE_AR: fname = "AR"; break; case FSTYPE_CPIO: fname = "CPIO"; break; case FSTYPE_MSLOSS: fname = "DOS"; break; case FSTYPE_CPM: fname = "CPM"; break; case FSTYPE_HFS: fname = "HFS"; break; case FSTYPE_DTFS: fname = "DTFS"; break; case FSTYPE_GRFS: fname = "GRFS"; break; case FSTYPE_TERM: fname = "TERM"; break; case FSTYPE_DEV: fname = "DEV"; break; case FSTYPE_PROC: fname = "PROC"; break; case FSTYPE_IFSOCK: fname = "IFSOCK"; break; case FSTYPE_AFS: fname = "AFS"; break; case FSTYPE_DFS: fname = "DFS"; break; case FSTYPE_PROC9: fname = "PROC9"; break; case FSTYPE_SOCKET: fname = "SOCKET"; break; case FSTYPE_MISC: fname = "MISC"; break; case FSTYPE_EXT2FS: fname = "EXT2FS"; break; case FSTYPE_HTTP: fname = "HTTP"; break; case FSTYPE_MEMFS: fname = "MEM"; break; case FSTYPE_ISO9660: fname = "ISO9660"; break; default: fname = "HURD"; } #else #if defined( sun56 ) || defined( sun ) || defined( hpux ) || defined( __NeXT__ ) || defined( ultrix ) || defined ( __FreeBSD__ ) || defined (__APPLE__) fname = "UNIX"; #else #ifdef WIN32 fname = "WIN-NT"; #else #ifdef __DJGPP__ fname = "DJGPP"; #else #ifdef QNX fname = "QNX"; #else #if defined( SVR4 ) || defined( OSF1 ) fname = statfs_struct.f_fstr; #else #if defined(__OpenBSD__) || defined(__NetBSD__) fname = statfs_struct.f_fstypename; #else fname = statfs_struct.f_fname; #endif /* __OpenBSD__ || __NetBSD__ */ #endif /* SVR4 */ #endif /* __DJGPP__ */ #endif /* QNX */ #endif /* WIN32 */ #endif /* sun / hpux / __NeXT__ ultrix */ #endif /* __GNU__ */ #endif /* linux */ (void) strncpy( volume_name, fname, MINIMUM( DISK_NAME_LENGTH, strlen( fname ) ) ); volume_name[ MINIMUM( DISK_NAME_LENGTH, strlen( fname ))] = '\0'; } else { /* TAR/ZOO/ZIP-FILE_MODE */ /*-----------------------*/ if( ( p = strrchr( statistic.login_path, FILE_SEPARATOR_CHAR ) ) == NULL ) p = statistic.login_path; else p++; (void) strncpy( volume_name, p, sizeof( statistic.disk_name ) ); volume_name[sizeof( statistic.disk_name )] = '\0'; } } /* volume_name */ #ifdef WIN32 *avail_bytes = (long) diskspace.bytes_per_sector * (long) diskspace.sectors_per_cluster * (long) diskspace.avail_clusters; this_disk_space = 900000000L; /* for now.. */ #else #if (defined( SVR4 ) || defined( OSF1 )) && !defined( __DGUX__ ) bfree = getuid() ? statfs_struct.f_bavail : statfs_struct.f_bfree; if( bfree < 0L ) bfree = 0L; *avail_bytes = bfree * statfs_struct.f_frsize; this_disk_space = statfs_struct.f_blocks * statfs_struct.f_frsize; #else #if defined( _IBMR2 ) || defined( linux ) || defined( sun ) || defined( __NeXT__ ) || defined( __GNU__ ) bfree = getuid() ? statfs_struct.f_bavail : statfs_struct.f_bfree; if( bfree < 0L ) bfree = 0L; *avail_bytes = bfree * statfs_struct.f_bsize; this_disk_space = statfs_struct.f_blocks * statfs_struct.f_blocks; #else #ifdef SVR3 bfree = statfs_struct.f_bfree; if( bfree < 0L ) bfree = 0L; *avail_bytes = bfree * BLKSIZ; /* SYSV */ this_disk_space = statfs_struct.f_blocks * BLKSIZ; #else #if defined( ultrix ) bfree = statfs_struct.fd_req.bfree; if( bfree < 0L ) bfree = 0L; #else #if defined( QNX ) *avail_bytes = free_blocks * 512; this_disk_space = total_blocks * 512; #else bfree = statfs_struct.f_bfree; if( bfree < 0L ) bfree = 0L; *avail_bytes = bfree * statfs_struct.f_bsize; this_disk_space = statfs_struct.f_blocks * statfs_struct.f_bsize; #endif /* QNX */ #endif /* ultrix */ #endif /* SVR3 */ #endif /* SVR4/!__DGUX__ */ #endif /* _IBMR2/linux/sun/__NeXT__/__GNU__ */ #endif /* WIN32 */ if( total_disk_space ) { *total_disk_space = this_disk_space; } } #ifdef QNX close(fd); #endif return( result ); } int GetAvailBytes(LONGLONG *avail_bytes) { return( GetDiskParameter( statistic.tree->name, NULL, avail_bytes, NULL ) ); } ytree-1.99pl1/global.c000066400000000000000000000013531350711670100146300ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/global.c,v 1.13 2003/08/31 11:11:00 werner Exp $ * * Externe Groessen * ***************************************************************************/ #include "ytree.h" WINDOW *dir_window; WINDOW *small_file_window; WINDOW *big_file_window; WINDOW *file_window; WINDOW *error_window; WINDOW *history_window; WINDOW *matches_window; WINDOW *f2_window; WINDOW *time_window; Statistic statistic; Statistic disk_statistic; int mode; int user_umask; char message[MESSAGE_LENGTH + 1]; BOOL print_time; BOOL resize_request; BOOL bypass_small_window; char number_seperator; char *initial_directory; ytree-1.99pl1/group.c000066400000000000000000000057261350711670100145340ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/group.c,v 1.15 2016/09/04 14:41:12 werner Exp $ * * Handhabung von Gruppen-Nummern / Namen * ***************************************************************************/ #include "ytree.h" #ifdef WIN32 #include "grp.h" #else typedef struct { int gid; char name[GROUP_NAME_MAX + 1]; char display_name[DISPLAY_GROUP_NAME_MAX + 1]; } GroupEntry; extern struct group *getgrent(void); #if !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined( __FreeBSD__ ) && !defined( OSF1 ) && !defined( __APPLE__ ) extern void setgrent(void); #endif static GroupEntry *group_array; static unsigned int group_count; #endif /* WIN32 */ int ReadGroupEntries(void) { #ifndef WIN32 int i; struct group *grp_ptr; for( group_count=0; getgrent(); group_count++ ) ; setgrent(); if( group_array ) { free( group_array ); group_array = NULL; } if( group_count == 0 ) { group_array = NULL; } else { if( ( group_array = (GroupEntry *) calloc( group_count, sizeof( GroupEntry ) ) ) == NULL ) { ERROR_MSG( "Calloc Failed" ); group_array = NULL; group_count = 0; return( 1 ); } } for(i=0; i < (int)group_count; i++) { if( ( grp_ptr = getgrent() ) == NULL ) { ERROR_MSG( "Getgrent Failed" ); if( group_array) free( group_array ); group_array = NULL; group_count = 0; return( 1 ); } group_array[i].gid = grp_ptr->gr_gid; (void)strncpy( group_array[i].name, grp_ptr->gr_name, GROUP_NAME_MAX ); group_array[i].name[GROUP_NAME_MAX] = '\0'; CutName(group_array[i].display_name, grp_ptr->gr_name, DISPLAY_GROUP_NAME_MAX); } #endif /* WIN32 */ return( 0 ); } char *GetGroupName(unsigned int gid) { #ifdef WIN32 struct group *group_ptr; group_ptr = getgrgid( gid ); if( group_ptr ) return( group_ptr->gr_name ); else return( NULL ); #else int i; for( i=0; i < (int)group_count; i++ ) { if( group_array[i].gid == (int)gid ) return( group_array[i].name ); } return( NULL ); #endif /* WIN32 */ } char *GetDisplayGroupName(unsigned int gid) { #ifdef WIN32 struct group *group_ptr; group_ptr = getgrgid( gid ); if( group_ptr ) return( group_ptr->gr_name ); else return( NULL ); #else int i; for( i=0; i < (int)group_count; i++ ) { if( group_array[i].gid == (int)gid ) return( group_array[i].display_name ); } return( NULL ); #endif /* WIN32 */ } int GetGroupId(char *name) { #ifdef WIN32 struct group *group_ptr; group_ptr = getgrnam( name ); if( group_ptr ) return( group_ptr->gr_gid ); else return( -1 ); #else int i; for( i=0; i < (int)group_count; i++ ) { if( !strcmp( name, group_array[i].name ) ) return( (int) group_array[i].gid ); } return( -1 ); #endif /* WIN32 */ } ytree-1.99pl1/hex.c000066400000000000000000000057251350711670100141630ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/hex.c,v 1.15 2003/08/31 11:11:00 werner Exp $ * * View-Hex-Kommando-Bearbeitung * ***************************************************************************/ #include "ytree.h" static int ViewHexFile(char *file_path); static int ViewHexArchiveFile(char *file_path); int ViewHex(char *file_path) { switch( mode ) { case DISK_MODE : case USER_MODE : return( ViewHexFile( file_path ) ); case TAPE_MODE : case RPM_FILE_MODE : case TAR_FILE_MODE : case ZOO_FILE_MODE : case ZIP_FILE_MODE : case LHA_FILE_MODE : case ARC_FILE_MODE : return( ViewHexArchiveFile( file_path ) ); default: beep(); return( -1 ); } } static int ViewHexFile(char *file_path) { char *command_line; int compress_method; int result = -1; if( access( file_path, R_OK ) ) { (void) sprintf( message, "HexView not possible!*\"%s\"*%s", file_path, strerror(errno) ); MESSAGE( message ); ESCAPE; } InternalView(file_path); return(0); if( ( command_line = (char *)malloc( COMMAND_LINE_LENGTH + 1 ) ) == NULL ) { ERROR_MSG( "Malloc failed*ABORT" ); exit( 1 ); } compress_method = GetFileMethod( file_path ); if( compress_method == FREEZE_COMPRESS ) { (void) sprintf( command_line, "%s < '%s' %s | %s | %s", MELT, file_path, ERR_TO_STDOUT, HEXDUMP, PAGER ); } else if( compress_method == COMPRESS_COMPRESS ) { (void) sprintf( command_line, "%s < '%s' %s | %s | %s", UNCOMPRESS, file_path, ERR_TO_STDOUT, HEXDUMP, PAGER ); } else if( compress_method == GZIP_COMPRESS ) { (void) sprintf( command_line, "%s < '%s' %s | %s | %s", GNUUNZIP, file_path, ERR_TO_STDOUT, HEXDUMP, PAGER ); } else { (void) sprintf( command_line, "%s '%s' | %s", HEXDUMP, file_path, PAGER ); } if((result = SilentSystemCall( command_line ))) { (void) sprintf( message, "can't execute*%s", command_line ); MESSAGE( message ); } free( command_line ); FNC_XIT: return( result ); } static int ViewHexArchiveFile(char *file_path) { char *command_line; char *archive; char buffer[80]; int result = -1; if( ( command_line = (char *)malloc( COMMAND_LINE_LENGTH + 1 ) ) == NULL ) { ERROR_MSG( "Malloc failed*ABORT" ); exit( 1 ); } (void) sprintf( buffer, "| %s | %s", HEXDUMP, PAGER ); archive = (mode == TAPE_MODE) ? statistic.tape_name : statistic.login_path; MakeExtractCommandLine( command_line, archive, file_path, buffer ); if((result = SilentSystemCall( command_line ))) { (void) sprintf( message, "can't execute*%s", command_line ); MESSAGE( message ); } free( command_line ); return( result ); } ytree-1.99pl1/history.c000066400000000000000000000253221350711670100150730ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/history.c,v 1.6 2005/09/07 18:50:33 werner Exp $ * * Functionkey F2 History * ***************************************************************************/ #include "ytree.h" #define MAX_HST_FILE_LINES 50 #define MAX(a,b) (((a) > (b)) ? (a):(b)) typedef struct _history { char *hst; struct _history *next; struct _history *prev; } History; static int total_hist = 0; static int cursor_pos = 0; static int disp_begin_pos = 0; static History *Hist = NULL ; void ReadHistory(char *Filename) { FILE *HstFile; char buffer[BUFSIZ]; if ( (HstFile = fopen( Filename, "r" ) ) != NULL) { while( fgets( buffer, sizeof( buffer ), HstFile ) ) { if (strlen(buffer) > 0) { buffer[strlen(buffer) -1] = '\0'; InsHistory(buffer); } } fclose( HstFile ); } return; } void SaveHistory(char *Filename) { FILE *HstFile; int j; History *hst, *last_hst; hst = last_hst = NULL; if((hst = Hist)) { if( (HstFile = fopen( Filename, "w" ) ) != NULL) { for(j = 0 ; hst && j < MAX_HST_FILE_LINES; j++ ) { last_hst = hst; hst = hst->next; } /* write in reverse order */ for(hst=last_hst; hst; hst=hst->prev) { fputs(hst->hst, HstFile); fputs("\n", HstFile); } fclose( HstFile ); } } return; } void InsHistory( char *NewHst) { History *TMP, *TMP2 = NULL; int flag = 0; if (strlen(NewHst)== 0) return; TMP2 = Hist; for ( TMP = Hist; TMP != NULL; TMP = TMP -> next) { if (strcmp(TMP -> hst, NewHst) == 0) { if (TMP2 != TMP) { TMP2 -> next = TMP -> next; TMP -> next = Hist; Hist = TMP; } flag = 1; break; }; TMP2 = TMP; } if (flag == 0) { if ((TMP=(History *) malloc(sizeof(struct _history))) != NULL) { TMP -> next = Hist; TMP -> prev = NULL; if(( TMP -> hst = Strdup(NewHst)) == NULL) { free(TMP); return; } if (Hist != NULL) Hist -> prev = TMP; Hist = TMP; total_hist++; } } return; } void PrintHstEntry(int entry_no, int y, int color, int start_x, int *hide_left, int *hide_right) { int n; History *pp; char buffer[BUFSIZ]; char *line_ptr; int window_width; int window_height; int ef_window_width; GetMaxYX( history_window, &window_height, &window_width ); ef_window_width = window_width - 2; /* Effektive Window-Width */ #ifdef NO_HIGHLIGHT ef_window_width = window_width - 3; /* Effektive Window-Width */ #else ef_window_width = window_width - 2; /* Effektive Window-Width */ #endif *hide_left = *hide_right = 0; for(n=0, pp=Hist; pp && (n < entry_no); pp = pp->next) { n++; } if(pp) { (void) strncpy( buffer, pp->hst, BUFSIZ - 3); buffer[BUFSIZ - 3] = '\0'; n = strlen( buffer ); wmove(history_window,y,1); if(n <= ef_window_width) { /* will completely fit into window */ /*---------------------------------*/ line_ptr = buffer; } else { /* does not completely fit into window; * ==> use start_x */ if(n > (start_x + ef_window_width)) line_ptr = &buffer[start_x]; else line_ptr = &buffer[n - ef_window_width]; *hide_left = start_x; *hide_right = n - start_x - ef_window_width; line_ptr[ef_window_width] ='\0'; } #ifdef NO_HIGHLIGHT strcat(line_ptr, (color == HIHST_COLOR) ? " <" : " "); WAddStr( history_window, line_ptr ); #else #ifdef COLOR_SUPPORT WbkgdSet(history_window, COLOR_PAIR(color)|A_BOLD); #else if(color == HIHST_COLOR) wattrset( history_window, A_REVERSE ); #endif /* COLOR_SUPPORT */ WAddStr( history_window, line_ptr ); #ifdef COLOR_SUPPORT WbkgdSet(history_window, COLOR_PAIR(WINHST_COLOR)| A_BOLD); #else if(color == HIHST_COLOR) wattrset( history_window, 0 ); #endif /* COLOR_SUPPORT */ #endif /* NO_HIGHLIGHT */ } return; } int DisplayHistory() { int i, hilight_no, p_y; int hide_left, hide_right; hilight_no = disp_begin_pos + cursor_pos; p_y = -1; werase( history_window ); for(i=0; i < HISTORY_WINDOW_HEIGHT; i++) { if (disp_begin_pos + i >= total_hist ) break; if (disp_begin_pos + i != hilight_no ) PrintHstEntry(disp_begin_pos + i, i, HST_COLOR, 0, &hide_left, &hide_right); else p_y = i; } if(p_y >= 0) { PrintHstEntry(disp_begin_pos + p_y, p_y, HIHST_COLOR, 0, &hide_left, &hide_right); } return 0; } char *GetHistory() { int ch, tmp; int start_x; char *RetVal = NULL; History *TMP; int hide_left, hide_right; disp_begin_pos = 0; cursor_pos = 0; start_x = 0; /* leaveok(stdscr, TRUE); */ (void) DisplayHistory(); do { RefreshWindow( history_window ); doupdate(); ch = Getch(); if(ch != -1 && ch != KEY_RIGHT && ch != KEY_LEFT) { if(start_x) { start_x = 0; PrintHstEntry( disp_begin_pos + cursor_pos, cursor_pos, HIHST_COLOR, start_x, &hide_left, &hide_right); } } switch( ch ) { case -1: RetVal = NULL; break; case ' ': break; /* Quick-Key */ case KEY_RIGHT: start_x++; PrintHstEntry( disp_begin_pos + cursor_pos, cursor_pos, HIHST_COLOR, start_x, &hide_left, &hide_right); if(hide_right < 0) start_x--; break; case KEY_LEFT: if(start_x > 0) start_x--; PrintHstEntry( disp_begin_pos + cursor_pos, cursor_pos, HIHST_COLOR, start_x, &hide_left, &hide_right); break; case '\t': case KEY_DOWN: if (disp_begin_pos + cursor_pos+1 >= total_hist) { beep(); } else { if( cursor_pos + 1 < HISTORY_WINDOW_HEIGHT ) { PrintHstEntry( disp_begin_pos + cursor_pos, cursor_pos, HST_COLOR, start_x, &hide_left, &hide_right); cursor_pos++; PrintHstEntry( disp_begin_pos + cursor_pos, cursor_pos, HIHST_COLOR, start_x, &hide_left, &hide_right); } else { PrintHstEntry( disp_begin_pos + cursor_pos, cursor_pos, HST_COLOR, start_x, &hide_left, &hide_right); scroll( history_window ); disp_begin_pos++; PrintHstEntry( disp_begin_pos + cursor_pos, cursor_pos, HIHST_COLOR, start_x, &hide_left, &hide_right); } } break; case KEY_BTAB: case KEY_UP : if( disp_begin_pos + cursor_pos - 1 < 0 ) { beep(); } else { if( cursor_pos - 1 >= 0 ) { PrintHstEntry( disp_begin_pos + cursor_pos, cursor_pos, HST_COLOR, start_x, &hide_left, &hide_right); cursor_pos--; PrintHstEntry( disp_begin_pos + cursor_pos, cursor_pos, HIHST_COLOR, start_x, &hide_left, &hide_right); } else { PrintHstEntry( disp_begin_pos + cursor_pos, cursor_pos, HST_COLOR, start_x, &hide_left, &hide_right); wmove( history_window, 0, 0 ); winsertln( history_window ); disp_begin_pos--; PrintHstEntry( disp_begin_pos + cursor_pos, cursor_pos, HIHST_COLOR, start_x, &hide_left, &hide_right); } } break; case KEY_NPAGE: if( disp_begin_pos + cursor_pos >= total_hist - 1 ) { beep(); } else { if( cursor_pos < HISTORY_WINDOW_HEIGHT - 1 ) { PrintHstEntry( disp_begin_pos + cursor_pos, cursor_pos, HST_COLOR, start_x, &hide_left, &hide_right); if( disp_begin_pos + HISTORY_WINDOW_HEIGHT > total_hist - 1 ) cursor_pos = total_hist - disp_begin_pos - 1; else cursor_pos = HISTORY_WINDOW_HEIGHT - 1; PrintHstEntry( disp_begin_pos + cursor_pos, cursor_pos, HIHST_COLOR, start_x, &hide_left, &hide_right); } else { if( disp_begin_pos + cursor_pos + HISTORY_WINDOW_HEIGHT < total_hist ) { disp_begin_pos += HISTORY_WINDOW_HEIGHT; cursor_pos = HISTORY_WINDOW_HEIGHT - 1; } else { disp_begin_pos = total_hist - HISTORY_WINDOW_HEIGHT; if( disp_begin_pos < 0 ) disp_begin_pos = 0; cursor_pos = total_hist - disp_begin_pos - 1; } DisplayHistory(); } } break; case KEY_PPAGE: if( disp_begin_pos + cursor_pos <= 0 ) { beep(); } else { if( cursor_pos > 0 ) { PrintHstEntry( disp_begin_pos + cursor_pos, cursor_pos, HST_COLOR, start_x, &hide_left, &hide_right); cursor_pos = 0; PrintHstEntry( disp_begin_pos + cursor_pos, cursor_pos, HIHST_COLOR, start_x, &hide_left, &hide_right); } else { if( (disp_begin_pos -= HISTORY_WINDOW_HEIGHT) < 0 ) { disp_begin_pos = 0; } cursor_pos = 0; DisplayHistory(); } } break; case KEY_HOME: if( disp_begin_pos == 0 && cursor_pos == 0 ) { beep(); } else { disp_begin_pos = 0; cursor_pos = 0; DisplayHistory(); } break; case KEY_END : disp_begin_pos = MAX(0, total_hist - HISTORY_WINDOW_HEIGHT); cursor_pos = total_hist - disp_begin_pos - 1; DisplayHistory(); break; case LF : case CR : TMP = Hist; for(tmp = 0; (tmp != disp_begin_pos + cursor_pos); tmp++) { TMP = TMP -> next; if (TMP == NULL) break; } if (TMP != NULL) RetVal = TMP -> hst; else RetVal = NULL; break; case ESC: RetVal = NULL; break; default : beep(); break; } /* switch */ } while(ch != CR && ch != ESC && ch != -1); /* leaveok(stdscr, FALSE); */ touchwin(stdscr); return RetVal; } ytree-1.99pl1/init.c000066400000000000000000000133411350711670100143330ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/init.c,v 1.20 2003/08/31 11:11:00 werner Exp $ * * Initialisierungen * ***************************************************************************/ #include "ytree.h" static WINDOW *Subwin(WINDOW *orig, int nlines, int ncols, int begin_y, int begin_x); static WINDOW *Newwin(int nlines, int ncols, int begin_y, int begin_x); #ifdef XCURSES char *XCursesProgramName = "ytree"; #endif int Init(char *configuration_file, char *history_file) { char buffer[PATH_LENGTH + 1]; char *home = NULL; user_umask = umask(0); initscr(); StartColors(); /* even on b/w terminals... */ cbreak(); noecho(); nonl(); raw(); keypad( stdscr, TRUE ); clearok(stdscr, TRUE); leaveok(stdscr,FALSE); curs_set(0); WbkgdSet( stdscr, COLOR_PAIR(WINDIR_COLOR)|A_BOLD); ReCreateWindows(); if( baudrate() >= QUICK_BAUD_RATE ) typeahead( -1 ); file_window = small_file_window; if( ReadGroupEntries() ) { ERROR_MSG( "ReadGroupEntries failed*ABORT" ); exit( 1 ); } if( ReadPasswdEntries() ) { ERROR_MSG( "ReadPasswdEntries failed*ABORT" ); exit( 1 ); } if (configuration_file != NULL) { ReadProfile(configuration_file); } else if( ( home = getenv("HOME") ) ) { sprintf(buffer, "%s%c%s", home, FILE_SEPARATOR_CHAR, PROFILE_FILENAME); ReadProfile(buffer); } if (history_file != NULL) { ReadHistory(history_file); } else if ( home ) { sprintf(buffer, "%s%c%s", home, FILE_SEPARATOR_CHAR, HISTORY_FILENAME); ReadHistory(buffer); } SetFileMode( strtod(FILEMODE, NULL) ); SetKindOfSort( SORT_BY_NAME ); number_seperator = *(NUMBERSEP); bypass_small_window = (BOOL)strtod(NOSMALLWINDOW, NULL ); initial_directory = INITIALDIR; InitClock(); return( 0 ); } void ReCreateWindows() { BOOL is_small; is_small = (file_window == small_file_window) ? TRUE : FALSE; if(dir_window) delwin(dir_window); dir_window = Subwin( stdscr, DIR_WINDOW_HEIGHT, DIR_WINDOW_WIDTH, DIR_WINDOW_Y, DIR_WINDOW_X ); keypad( dir_window, TRUE ); scrollok( dir_window, TRUE ); clearok( dir_window, TRUE); leaveok(dir_window, TRUE); WbkgdSet( dir_window, COLOR_PAIR(WINDIR_COLOR) ); if(small_file_window) delwin(small_file_window); small_file_window = Subwin( stdscr, FILE_WINDOW_1_HEIGHT, FILE_WINDOW_1_WIDTH, FILE_WINDOW_1_Y, FILE_WINDOW_1_X ); if(!small_file_window) beep(); keypad( small_file_window, TRUE ); clearok(small_file_window, TRUE); leaveok(small_file_window, TRUE); WbkgdSet(small_file_window, COLOR_PAIR(WINFILE_COLOR)); if(big_file_window) delwin(big_file_window); big_file_window = Subwin( stdscr, FILE_WINDOW_2_HEIGHT, FILE_WINDOW_2_WIDTH, FILE_WINDOW_2_Y, FILE_WINDOW_2_X ); keypad( big_file_window, TRUE ); clearok(big_file_window, TRUE); leaveok(big_file_window, TRUE); WbkgdSet(big_file_window, COLOR_PAIR(WINFILE_COLOR)); if(error_window) delwin(error_window); error_window = Newwin( ERROR_WINDOW_HEIGHT, ERROR_WINDOW_WIDTH, ERROR_WINDOW_Y, ERROR_WINDOW_X ); WbkgdSet(error_window, COLOR_PAIR(WINERR_COLOR)); clearok(error_window, TRUE); leaveok(error_window, TRUE); #ifdef CLOCK_SUPPORT if(time_window) delwin(time_window); time_window = Subwin( stdscr, TIME_WINDOW_HEIGHT, TIME_WINDOW_WIDTH, TIME_WINDOW_Y, TIME_WINDOW_X ); clearok( time_window, TRUE ); scrollok( time_window, FALSE ); leaveok( time_window, TRUE ); WbkgdSet( time_window, COLOR_PAIR(WINDIR_COLOR|A_BOLD) ); immedok(time_window, TRUE); #endif if(history_window) delwin(history_window); history_window = Newwin( HISTORY_WINDOW_HEIGHT, HISTORY_WINDOW_WIDTH, HISTORY_WINDOW_Y, HISTORY_WINDOW_X ); scrollok(history_window, TRUE); clearok(history_window, TRUE ); leaveok(history_window, TRUE); WbkgdSet(history_window, COLOR_PAIR(WINHST_COLOR)); matches_window = history_window; if(f2_window) delwin(f2_window); f2_window = Newwin( F2_WINDOW_HEIGHT, F2_WINDOW_WIDTH, F2_WINDOW_Y, F2_WINDOW_X ); keypad( f2_window, TRUE ); scrollok( f2_window, FALSE ); clearok( f2_window, TRUE); leaveok( f2_window, TRUE ); WbkgdSet( f2_window, COLOR_PAIR(WINHST_COLOR) ); file_window = (is_small) ? small_file_window : big_file_window; clear(); } static WINDOW *Subwin(WINDOW *orig, int nlines, int ncols, int begin_y, int begin_x) { int x, y, h, w; WINDOW *win; if(nlines > LINES) nlines = LINES; if(ncols > COLS) ncols = COLS; h = MAXIMUM(nlines, 1); w = MAXIMUM(ncols, 1); x = MAXIMUM(begin_x, 0); y = MAXIMUM(begin_y, 0); if(x+w > COLS) x = COLS - w; if(y+h > LINES) y = LINES - h; win = subwin(orig, h, w, y, x); return(win); } static WINDOW *Newwin(int nlines, int ncols, int begin_y, int begin_x) { int x, y, h, w; WINDOW *win; if(nlines > LINES) nlines = LINES; if(ncols > COLS) ncols = COLS; h = MAXIMUM(nlines, 1); w = MAXIMUM(ncols, 1); x = MAXIMUM(begin_x, 0); y = MAXIMUM(begin_y, 0); if(x+w > COLS) x = COLS - w; if(y+h > LINES) y = LINES - h; win = newwin(h, w, y, x); return(win); } ytree-1.99pl1/input.c000066400000000000000000000257031350711670100145340ustar00rootroot00000000000000 #include "ytree.h" #include "tilde.h" #include "xmalloc.h" /*************************************************************************** * InputStr * * Liest eine Zeichenkette an Position (y,x) mit der max. Laenge length * * Vorschlagswert fuer die Eingabe ist s selbst * * Zurueckgegeben wird das Zeichen, mit dem die Eingabe beendet wurde * ***************************************************************************/ char *StrLeft(const char *str, size_t count) { #ifdef WITH_UTF8 mbstate_t state; #endif char *rez, *p, *tmp; size_t len, i; #ifdef WITH_UTF8 memset(&state, 0, sizeof(state)); #endif if (count == 0) return(Strdup("")); len = StrVisualLength(str); if (count >= len) return(Strdup(str)); len = 0; tmp = Strdup(str); p = tmp; for (i = 0; i < count; i++) { #ifdef WITH_UTF8 len += mbrlen(p, 4, &state); #else len++; #endif p = tmp + len; } free(tmp); rez = Strndup(str, len); rez[len] = '\0'; return(rez); } char *StrRight(const char *str, size_t count) { #ifdef WITH_UTF8 mbstate_t state; #endif char *rez, *p, *tmp; size_t byte_len, char_len, tmp_len, i; #ifdef WITH_UTF8 memset(&state, 0, sizeof(state)); #endif if (count == 0) return(Strdup("")); byte_len = strlen(str); char_len = StrVisualLength(str); if (count > char_len) count = char_len; tmp = Strdup(str); p = tmp; i = 0; rez = NULL; while ( (p - tmp) < byte_len ) { if (i == (char_len - count) ) { rez = Strdup(p); } #ifdef WITH_UTF8 tmp_len = mbrlen(p, 4, &state); #else tmp_len = 1; #endif p += tmp_len; i++; } free(tmp); return(rez); } int StrVisualLength(const char *str) { #ifdef WITH_UTF8 mbstate_t state; int len = 0; memset(&state, '\0', sizeof(state)); len = mbsrtowcs(NULL, &str, strlen(str), &state); if(len < 0) { /* Invalid multibyte sequence */ len = strlen(str); } #else return(strlen(str)); #endif } int InputString(char *s, int y, int x, int cursor_pos, int length, char *term) /* Ein- und Ausgabestring */ /* Position auf Bildschirm */ /* max. Laenge */ /* Menge von Terminierungszeichen */ { int p; /* Aktuelle Position */ int c1; /* Gelesenes Zeichen */ int i; /* Laufvariable */ char *pp; BOOL len_flag = FALSE; char path[PATH_LENGTH + 1]; char buf[2], sbuf[20], *ls, *rs; static BOOL insert_flag = TRUE; buf[1] = '\0'; strcpy(sbuf, ""); /* Feld gefuellt ausgeben */ /*------------------------*/ print_time = FALSE; curs_set(1); MvAddStr( y, x, s ); leaveok(stdscr, FALSE); for(i=strlen(s); i < length; i++) addch( '_' ); p = cursor_pos; MvAddStr( y, x, s ); nodelay( stdscr, TRUE ); do { c1 = wgetch(stdscr); if ( c1 != ERR ) { if( c1 >= ' ' && c1 < 0xff && c1 != 127 ) { if ( len_flag == TRUE) beep(); else { buf[0] = (char)c1; strcat(sbuf, buf); } } else { /* Control symbols */ switch( c1 ) { case 'C' & 0x1f : c1 = 27; break; case KEY_LEFT : if( p > 0 ) p--; else beep(); break; case KEY_RIGHT : if( p < StrVisualLength(s) ) p++; else beep(); break; case KEY_UP : nodelay(stdscr, FALSE); pp = GetHistory(); nodelay(stdscr, TRUE); if (pp == NULL) break; if(*pp) { ls = StrLeft(pp, length); strcpy(s, ls); free(ls); p = StrVisualLength(s); MvAddStr( y, x, s ); for(i=p; i < length; i++) addch( '_' ); RefreshWindow( stdscr ); doupdate(); } break; case KEY_HOME : p = 0; break; case KEY_END : p = StrVisualLength( s ); break; case KEY_DC : if( p < StrVisualLength(s) ) { ls = StrLeft(s, p); rs = StrRight(s, StrVisualLength(s) - p - 1); strcpy(s, ls); strcat(s, rs); free(ls); free(rs); MvAddStr( y, x, s ); addch( '_' ); } break; case 0x08 : case 0x7F : case KEY_BACKSPACE : if( p > 0 ) { ls = StrLeft(s, p - 1); rs = StrRight(s, StrVisualLength(s) - p); strcpy(s, ls); strcat(s, rs); free(ls); free(rs); MvAddStr( y, x, s ); addch( '_' ); p--; } else beep(); break; case KEY_DL : for(i=0; i < StrVisualLength(s) - p; i++) addch( '_' ); ls = StrLeft(s, p); strcpy(s, ls); free(ls); break; case KEY_EIC : case KEY_IC : insert_flag ^= TRUE; break; case '\t' : if(( pp = GetMatches(s)) == NULL) { break; } if(*pp) { ls = StrLeft(pp, length); strcpy(s, ls); free(ls); p = StrVisualLength(s); free(pp); MvAddStr( y, x, s ); for(i=p; i < length; i++) addch( '_' ); RefreshWindow( stdscr ); doupdate(); } break; #ifdef KEY_F case KEY_F(2) : #endif case 'F' & 0x1f : if(KeyF2Get( statistic.tree, statistic.disp_begin_pos, statistic.cursor_pos, path)) { /* beep(); */ break; } if(*path) { ls = StrLeft(path, length); strcpy(s, ls); free(ls); p = StrVisualLength(s); MvAddStr( y, x, s ); for(i=p; i < length; i++) addch( '_' ); RefreshWindow( stdscr ); doupdate(); } break; default : if( c1 == LF ) c1 = CR; break; } /* switch */ } /* else control symbols */ } else { if (strlen(sbuf) > 0) { if ( insert_flag ) { /* append symbol */ if ( p >= StrVisualLength(s)) strcat(s, sbuf); else { /* insert symbol at cursor position */ if ( p > 0 ) ls = StrLeft(s, p); else ls = Strdup(""); rs = StrRight(s, StrVisualLength(s) - p); strcpy(s, ls); strcat(s, sbuf); strcat(s, rs); free(ls); free(rs); } } else { /* owerwrite symbol at cursor position */ if ( p > StrVisualLength(s) - 1) strcat(s, sbuf); else { if (p > 0) ls = StrLeft(s, p); else ls = Strdup(""); rs = StrRight(s, StrVisualLength(s) - p - 1); strcpy(s, ls); strcat(s, sbuf); strcat(s, rs); free(ls); free(rs); } } strcpy(sbuf, ""); p++; } if (StrVisualLength(s) >= length) len_flag = TRUE; else len_flag = FALSE; MvAddStr( y, x, s ); wmove(stdscr, y, x + p); } } while( c1 != 27 && c1 != CR ); nodelay( stdscr, FALSE ); p = strlen( s ); move( y, x + p ); for(i=0; i < length - p; i++ ) addch( ' ' ); move( y, x ); leaveok( stdscr, TRUE); curs_set(0); print_time = TRUE; InsHistory( s ); #ifdef READLINE_SUPPORT pp = tilde_expand(s); #else pp = Strdup(s); #endif strncpy( s, pp, length - 1); s[length]='\0'; xfree(pp); return( c1 ); } int InputChoise(char *msg, char *term) { int c; ClearHelp(); curs_set(1); leaveok(stdscr, FALSE); mvprintw( LINES - 2, 1, msg ); RefreshWindow( stdscr ); doupdate(); do { c = Getch(); if(c >= 0) if( islower( c ) ) c = toupper( c ); } while( c != -1 && !strchr( term, c ) ); if(c >= 0) echochar( c ); move( LINES - 2, 1 ); clrtoeol(); leaveok(stdscr, TRUE); curs_set(0); return( c ); } int GetTapeDeviceName( void ) { int result; char path[PATH_LENGTH * 2 +1]; result = -1; ClearHelp(); (void) strcpy( path, statistic.tape_name ); MvAddStr( LINES - 2, 1, "Tape-Device:" ); if( InputString( path, LINES - 2, 14, 0, COLS - 15, "\r\033" ) == CR ) { result = 0; (void) strcpy( statistic.tape_name, path ); } move( LINES - 2, 1 ); clrtoeol(); return( result ); } void HitReturnToContinue(void) { #ifndef XCURSES curs_set(1); vidattr( A_REVERSE ); putp( "[Hit return to continue]" ); vidattr( 0 ); (void) fflush( stdout ); (void) Getch(); #endif /* XCURSES */ curs_set(0); doupdate(); } BOOL KeyPressed() { BOOL pressed = FALSE; #if !defined( linux ) || !defined( TERMCAP ) nodelay( stdscr, TRUE ); if( wgetch( stdscr ) != ERR ) pressed = TRUE; nodelay( stdscr, FALSE ); #endif /* linux/TERMCAP */ return( pressed ); } BOOL EscapeKeyPressed() { BOOL pressed = FALSE; int c; #if !defined( linux ) || !defined( TERMCAP ) nodelay( stdscr, TRUE ); if( ( c = wgetch( stdscr ) ) != ERR ) pressed = TRUE; nodelay( stdscr, FALSE ); #endif /* linux/TERMCAP */ return( ( pressed && c == ESC ) ? TRUE : FALSE ); } #ifdef VI_KEYS int ViKey( int ch ) { switch( ch ) { case VI_KEY_UP: ch = KEY_UP; break; case VI_KEY_DOWN: ch = KEY_DOWN; break; case VI_KEY_RIGHT: ch = KEY_RIGHT; break; case VI_KEY_LEFT: ch = KEY_LEFT; break; case VI_KEY_PPAGE: ch = KEY_PPAGE; break; case VI_KEY_NPAGE: ch = KEY_NPAGE; break; } return(ch); } #endif /* VI_KEYS */ #ifdef _IBMR2 #undef wgetch int AixWgetch( WINDOW *w ) { int c; if( ( c = wgetch( w ) ) == KEY_ENTER ) c = LF; return( c ); } #endif int Getch() { int c; c = getch(); #ifdef KEY_RESIZE if(c == KEY_RESIZE) { resize_request = TRUE; c = -1; } #endif return(c); } ytree-1.99pl1/keyhtab.c000066400000000000000000000223661350711670100150260ustar00rootroot00000000000000#include "ytree.h" #ifdef READLINE_SUPPORT #include "tilde.h" #include #endif #define MAX(a,b) (((a) > (b)) ? (a):(b)) static char **Mtchs = NULL; static int total_matches = 0; static int cursor_pos = 0; static int disp_begin_pos = 1; void PrintMtchEntry(int entry_no, int y, int color, int start_x, int *hide_left, int *hide_right) { int n; char buffer[BUFSIZ]; char *line_ptr; int window_width; int window_height; int ef_window_width; GetMaxYX( matches_window, &window_height, &window_width ); ef_window_width = window_width - 2; /* Effektive Window-Width */ #ifdef NO_HIGHLIGHT ef_window_width = window_width - 3; /* Effektive Window-Width */ #else ef_window_width = window_width - 2; /* Effektive Window-Width */ #endif *hide_left = *hide_right = 0; if(Mtchs[entry_no]) { (void) strncpy( buffer,(char *) Mtchs[entry_no], BUFSIZ - 3); buffer[BUFSIZ - 3] = '\0'; n = strlen( buffer ); wmove(matches_window,y,1); if(n <= ef_window_width) { /* will completely fit into window */ /*---------------------------------*/ line_ptr = buffer; } else { /* does not completely fit into window; * ==> use start_x */ if(n > (start_x + ef_window_width)) line_ptr = &buffer[start_x]; else line_ptr = &buffer[n - ef_window_width]; *hide_left = start_x; *hide_right = n - start_x - ef_window_width; line_ptr[ef_window_width] ='\0'; } #ifdef NO_HIGHLIGHT strcat(line_ptr, (color == HIMTCH_COLOR) ? " <" : " "); WAddStr( matches_window, line_ptr ); #else #ifdef COLOR_SUPPORT WbkgdSet(matches_window, COLOR_PAIR(color)|A_BOLD); #else if(color == HIMTCH_COLOR) wattrset( matches_window, A_REVERSE ); #endif /* COLOR_SUPPORT */ WAddStr( matches_window, line_ptr ); #ifdef COLOR_SUPPORT WbkgdSet(matches_window, COLOR_PAIR(WINMTCH_COLOR)| A_BOLD); #else if(color == HIMTCH_COLOR) wattrset( matches_window, 0 ); #endif /* COLOR_SUPPORT */ #endif /* NO_HIGHLIGHT */ } return; } int DisplayMatches() { int i, hilight_no, p_y; int hide_left, hide_right; hilight_no = disp_begin_pos + cursor_pos; p_y = -1; werase( matches_window ); for(i=0; i < MATCHES_WINDOW_HEIGHT; i++) { if (disp_begin_pos + i >= total_matches ) break; if (disp_begin_pos + i != hilight_no ) PrintMtchEntry(disp_begin_pos + i, i, MTCH_COLOR, 0, &hide_left, &hide_right); else p_y = i; } if(p_y >= 0) { PrintMtchEntry(disp_begin_pos + p_y, p_y, HIMTCH_COLOR, 0, &hide_left, &hide_right); } return 0; } char *GetMatches( char *base) { int ch; int start_x; char *RetVal = NULL; char *TMP; char *tmpval; int hide_left, hide_right; /* tmpval = rl_filename_completion_function(base, 0); if (!strcmp(tmpval,base)) return(tmpval);*/ Mtchs = NULL; #ifdef READLINE_SUPPORT tmpval=tilde_expand(base); if ((Mtchs = rl_completion_matches(tmpval, rl_filename_completion_function)) == NULL) return(NULL); #else return(NULL); #endif if (!(strcmp(tmpval,Mtchs[0])==0)){ TMP=malloc(strlen(Mtchs[0])+1); if (TMP != NULL){ strcpy(TMP, Mtchs[0]); RetVal = TMP; }else{ RetVal = NULL;} free(Mtchs); free(tmpval); return RetVal; } for (total_matches=0; Mtchs[total_matches]; total_matches++); if (total_matches == 1) return(NULL); disp_begin_pos = 1; cursor_pos = 0; start_x = 0; /* leaveok(stdscr, TRUE); */ (void) DisplayMatches(); do { RefreshWindow( matches_window ); doupdate(); ch = Getch(); if(ch != -1 && ch != KEY_RIGHT && ch != KEY_LEFT) { if(start_x) { start_x = 0; PrintMtchEntry( disp_begin_pos + cursor_pos, cursor_pos, HIMTCH_COLOR, start_x, &hide_left, &hide_right); } } switch( ch ) { case -1: RetVal = NULL; break; case ' ': break; /* Quick-Key */ case KEY_RIGHT: start_x++; PrintMtchEntry( disp_begin_pos + cursor_pos, cursor_pos, HIMTCH_COLOR, start_x, &hide_left, &hide_right); if(hide_right < 0) start_x--; break; case KEY_LEFT: if(start_x > 0) start_x--; PrintMtchEntry( disp_begin_pos + cursor_pos, cursor_pos, HIMTCH_COLOR, start_x, &hide_left, &hide_right); break; case '\t': case KEY_DOWN: if (disp_begin_pos + cursor_pos+1 >= total_matches) { beep(); } else { if( cursor_pos + 1 < MATCHES_WINDOW_HEIGHT ) { PrintMtchEntry( disp_begin_pos + cursor_pos, cursor_pos, MTCH_COLOR, start_x, &hide_left, &hide_right); cursor_pos++; PrintMtchEntry( disp_begin_pos + cursor_pos, cursor_pos, HIMTCH_COLOR, start_x, &hide_left, &hide_right); } else { PrintMtchEntry( disp_begin_pos + cursor_pos, cursor_pos, MTCH_COLOR, start_x, &hide_left, &hide_right); scroll( matches_window ); disp_begin_pos++; PrintMtchEntry( disp_begin_pos + cursor_pos, cursor_pos, HIMTCH_COLOR, start_x, &hide_left, &hide_right); } } break; case KEY_BTAB: case KEY_UP : if( disp_begin_pos + cursor_pos - 1 < 1 ) { beep(); } else { if( cursor_pos - 1 >= 0 ) { PrintMtchEntry( disp_begin_pos + cursor_pos, cursor_pos, MTCH_COLOR, start_x, &hide_left, &hide_right); cursor_pos--; PrintMtchEntry( disp_begin_pos + cursor_pos, cursor_pos, HIMTCH_COLOR, start_x, &hide_left, &hide_right); } else { PrintMtchEntry( disp_begin_pos + cursor_pos, cursor_pos, MTCH_COLOR, start_x, &hide_left, &hide_right); wmove( matches_window, 0, 0 ); winsertln( matches_window ); disp_begin_pos--; PrintMtchEntry( disp_begin_pos + cursor_pos, cursor_pos, HIMTCH_COLOR, start_x, &hide_left, &hide_right); } } break; case KEY_NPAGE: if( disp_begin_pos + cursor_pos >= total_matches - 1 ) { beep(); } else { if( cursor_pos < MATCHES_WINDOW_HEIGHT - 1 ) { PrintMtchEntry( disp_begin_pos + cursor_pos, cursor_pos, MTCH_COLOR, start_x, &hide_left, &hide_right); if( disp_begin_pos + MATCHES_WINDOW_HEIGHT > total_matches - 1 ) cursor_pos = total_matches - disp_begin_pos - 1; else cursor_pos = MATCHES_WINDOW_HEIGHT - 1; PrintMtchEntry( disp_begin_pos + cursor_pos, cursor_pos, HIMTCH_COLOR, start_x, &hide_left, &hide_right); } else { if( disp_begin_pos + cursor_pos + MATCHES_WINDOW_HEIGHT < total_matches ) { disp_begin_pos += MATCHES_WINDOW_HEIGHT; cursor_pos = MATCHES_WINDOW_HEIGHT - 1; } else { disp_begin_pos = total_matches - MATCHES_WINDOW_HEIGHT; if( disp_begin_pos < 1 ) disp_begin_pos = 1; cursor_pos = total_matches - disp_begin_pos - 1; } DisplayMatches(); } } break; case KEY_PPAGE: if( disp_begin_pos + cursor_pos <= 1 ) { beep(); } else { if( cursor_pos > 0 ) { PrintMtchEntry( disp_begin_pos + cursor_pos, cursor_pos, MTCH_COLOR, start_x, &hide_left, &hide_right); cursor_pos = 0; PrintMtchEntry( disp_begin_pos + cursor_pos, cursor_pos, HIMTCH_COLOR, start_x, &hide_left, &hide_right); } else { if( (disp_begin_pos -= MATCHES_WINDOW_HEIGHT) < 1 ) { disp_begin_pos = 1; } cursor_pos = 0; DisplayMatches(); } } break; case KEY_HOME: if( disp_begin_pos == 1 && cursor_pos == 0 ) { beep(); } else { disp_begin_pos = 1; cursor_pos = 0; DisplayMatches(); } break; case KEY_END : disp_begin_pos = MAX(1, total_matches - MATCHES_WINDOW_HEIGHT); cursor_pos = total_matches - disp_begin_pos - 1; DisplayMatches(); break; case LF : case CR : TMP=malloc(strlen(Mtchs[ disp_begin_pos + cursor_pos])+1); if (TMP != NULL){ strcpy(TMP, Mtchs[disp_begin_pos + cursor_pos]); RetVal = TMP; }else RetVal = NULL; break; case ESC: RetVal = NULL; break; default : beep(); break; } /* switch */ } while(ch != CR && ch != ESC && ch != -1); /* leaveok(stdscr, FALSE); */ free(Mtchs); free(tmpval); touchwin(stdscr); return RetVal; } ytree-1.99pl1/lha.c000066400000000000000000000110331350711670100141300ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/lha.c,v 1.12 2000/05/20 20:41:11 werner Exp $ * * Funktionen zum Lesen des Dateibaumes aus LHA-Dateien * ***************************************************************************/ #include "ytree.h" static int GetStatFromLHA(char *lha_line, char *name, struct stat *stat); /* Dateibaum aus LHA-Listing lesen */ /*---------------------------------*/ int ReadTreeFromLHA(DirEntry *dir_entry, FILE *f) { char lha_line[LHA_LINE_LENGTH + 1]; char path_name[PATH_LENGTH +1]; struct stat stat; BOOL dir_flag = FALSE; *dir_entry->name = '\0'; while( fgets( lha_line, LHA_LINE_LENGTH, f ) != NULL ) { /* \n loeschen */ /*-------------*/ lha_line[ strlen( lha_line ) - 1 ] = '\0'; if( ( (strlen( lha_line ) > (unsigned) 55 && lha_line[55] == ':' ) || (strlen( lha_line ) > (unsigned) 61 && lha_line[61] == ':' ) ) && lha_line[34] != '*' && strncmp( &lha_line[1], "Total", 5 ) ) { /* gueltiger Eintrag */ /*-------------------*/ if( GetStatFromLHA( lha_line, path_name, &stat ) ) { (void) sprintf( message, "unknown lhainfo*%s", lha_line ); MESSAGE( message ); } else { /* File */ /*------*/ #ifdef DEBUG fprintf( stderr, "FILE: \"%s\"\n", path_name ); #endif (void) InsertArchiveFileEntry( dir_entry, path_name, &stat ); } } } if( dir_flag == FALSE ) { statistic.disk_total_directories++; (void) memset( (char *) &dir_entry->stat_struct, 0, sizeof( struct stat ) ); dir_entry->stat_struct.st_mode = S_IFDIR; } return( MinimizeArchiveTree( dir_entry ) ); } static int GetStatFromLHA(char *lha_line, char *name, struct stat *stat) { char *t, *old; char modus[11]; BOOL dos_mode = FALSE; int i, id; struct tm tm_struct; static char *month[] = { "Jan", "Feb", "Mar", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; (void) memset( stat, 0, sizeof( struct stat ) ); stat->st_nlink = 1; t = Strtok_r( lha_line, " \t", &old ); if( t == NULL ) return( -1 ); /* Attributes */ /*------------*/ if( strlen( t ) == 9 && *t != '[' ) { *modus = '-'; (void) strcpy( &modus[1], t ); stat->st_mode = GetModus( modus ); } else if( *t == '[' ) { stat->st_mode = GetModus( "-rw-r--r--" ); dos_mode = TRUE; } else return( -1 ); t = Strtok_r( NULL, " \t/", &old ); if( t == NULL ) return( -1 ); if( dos_mode ) { stat->st_uid = getuid(); stat->st_gid = getgid(); } else { /* Owner */ /*-------*/ id = atoi( t ); stat->st_uid = (unsigned) id; t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); /* Group */ /*-------*/ id = atoi( t ); stat->st_gid = (unsigned) id; t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); } /* Packed-Size */ /*-------------*/ if( !isdigit( *t ) ) return( -1 ); t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); /* Dateilaenge */ /*-------------*/ if( !isdigit( *t ) ) return( -1 ); stat->st_size = AtoLL( t ); t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); /* Ratio */ /*-------*/ t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); /* CRC */ /*-----*/ t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); if( lha_line[61] == ':' ) { /* ??? */ /*-----*/ t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); } /* M-Datum */ /*---------*/ for( i=0; i < 12; i++ ) { if( !strcmp( t, month[i] ) ) break; } if( i >= 12 ) i = 0; tm_struct.tm_mon = i; t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); tm_struct.tm_mday = atoi( t ); t = Strtok_r( NULL, " \t:", &old ); if( t == NULL ) return( -1 ); tm_struct.tm_hour = atoi( t ); t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); tm_struct.tm_min = atoi( t ); t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); if( lha_line[41] == '-' ) { /* ??? */ tm_struct.tm_year = 70; /* Start UNIX-Time */ } else { tm_struct.tm_year = atoi( t ) - 1900; t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); } tm_struct.tm_sec = 0; tm_struct.tm_isdst = -1; stat->st_atime = 0; stat->st_ctime = 0; stat->st_mtime = Mktime( &tm_struct ); /* Dateiname */ /*-----------*/ (void) strcpy( name, t ); return( 0 ); } ytree-1.99pl1/login.c000066400000000000000000000337711350711670100145110ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/login.c,v 1.23 2014/12/26 09:53:11 werner Exp $ * * Dateibaum lesen * ***************************************************************************/ #include "ytree.h" /* #include */ /* maybe wait.h is available */ static void DeleteTree(DirEntry *tree) { DirEntry *de_ptr, *next_de_ptr; FileEntry *fe_ptr, *next_fe_ptr; for( de_ptr=tree; de_ptr; de_ptr=next_de_ptr) { next_de_ptr = de_ptr->next; for( fe_ptr=de_ptr->file; fe_ptr; fe_ptr=next_fe_ptr) { next_fe_ptr=fe_ptr->next; free( fe_ptr ); } if( de_ptr->sub_tree ) DeleteTree( de_ptr->sub_tree ); free( de_ptr ); } } /* Login Disk liefert * -1 bei Fehler * 0 bei fehlerfreiem lesen eines neuen Baumes * 1 bei Benutzung des Baumes im Speicher */ int LoginDisk(char *path) { struct stat stat_struct; char command_line[COMMAND_LINE_LENGTH + 1]; char cat_file_name[PATH_LENGTH+1]; int file_method = 0; int pid; int p[2]; int depth, l = 0; FILE *f; int status; int result = 0; if( mode == DISK_MODE || mode == USER_MODE) { /* Status retten */ /*---------------*/ (void) memcpy( (char *) &disk_statistic, (char *) &statistic, sizeof( Statistic ) ); } if ( disk_statistic.login_path[0] != 0) { if( !strcmp( disk_statistic.login_path, path ) ) { /* Tree is in memory! Use it! */ /*----------------------------*/ if( statistic.tree != disk_statistic.tree ) DeleteTree( statistic.tree ); if (IsUserActionDefined()) { mode = USER_MODE; } else { mode = DISK_MODE; } (void) memcpy( (char *) &statistic, (char *) &disk_statistic, sizeof( Statistic ) ); (void) SetFileSpec( statistic.file_spec ); return( 1 ); /* Return-Wert fuer "alten Baum" */ } } if( STAT_( path, &stat_struct ) ) { /* Stat failed */ /*-------------*/ (void) sprintf( message, "Can't access*\"%s\"*%s", path, strerror(errno) ); MESSAGE( message ); return( -1 ); } if( mode != DISK_MODE && mode != USER_MODE ) { DeleteTree( statistic.tree ); } (void) memset( &statistic, 0, sizeof( statistic ) ); if( ( statistic.tree = (DirEntry *) malloc( sizeof( DirEntry ) + PATH_LENGTH )) == NULL ) { ERROR_MSG( "Malloc failed*ABORT" ); exit( 1 ); } (void) memset( statistic.tree, 0, sizeof( DirEntry ) + PATH_LENGTH ); (void) strcpy( statistic.path, path ); (void) strcpy( statistic.login_path, path ); (void) strcpy( statistic.file_spec, DEFAULT_FILE_SPEC ); (void) strcpy( statistic.tape_name, DEFAULT_TAPEDEV ); statistic.kind_of_sort = SORT_BY_NAME + SORT_ASC; (void) memcpy( &statistic.tree->stat_struct, &stat_struct, sizeof( stat_struct ) ); if( !S_ISDIR(stat_struct.st_mode ) ) { /* No Directory ==> TAR_FILE/RPM/ZOO/ZIP/LHA/ARC_FILE */ /*----------------------------------------------------*/ file_method = GetFileMethod( statistic.login_path ); l = strlen( statistic.login_path ); switch( file_method ) { case ZOO_COMPRESS: mode = ZOO_FILE_MODE; break; case ARC_COMPRESS: mode = ARC_FILE_MODE; break; case LHA_COMPRESS: mode = LHA_FILE_MODE; break; case ZIP_COMPRESS: mode = ZIP_FILE_MODE; break; case RPM_COMPRESS: mode = RPM_FILE_MODE; break; case RAR_COMPRESS: mode = RAR_FILE_MODE; break; case TAPE_DIR_NO_COMPRESS: case TAPE_DIR_COMPRESS_COMPRESS: case TAPE_DIR_FREEZE_COMPRESS: case TAPE_DIR_GZIP_COMPRESS: case TAPE_DIR_BZIP_COMPRESS: mode = TAPE_MODE; break; default: mode = TAR_FILE_MODE; break; } } else if (IsUserActionDefined()) { mode = USER_MODE; } else { mode = DISK_MODE; } (void) GetDiskParameter( path, statistic.disk_name, &statistic.disk_space, &statistic.disk_capacity ); RefreshWindow( stdscr ); RefreshWindow( dir_window ); DisplayMenu(); doupdate(); if( mode == TAPE_MODE ) { /* zugehoeriges tape-device ermitteln */ /*------------------------------------*/ if( GetTapeDeviceName() ) { return( -1 ); } } if( mode != DISK_MODE && mode != USER_MODE) { (void) strcpy( statistic.tree->name, path ); if( pipe( p ) ) { ERROR_MSG( "pipe failed" ); return( -1 ); } if( file_method == ZOO_COMPRESS ) { /* zoo vom ZOO_FILE */ /*------------------*/ (void) sprintf( command_line, "%s '%s'", ZOOLIST, statistic.login_path ); } else if( file_method == RPM_COMPRESS ) { /* rpm vom RPM_FILE */ /*------------------*/ (void) sprintf( command_line, "%s '%s'", RPMLIST, statistic.login_path ); } else if( file_method == LHA_COMPRESS ) { /* LHA_FILE */ /*----------*/ (void) sprintf( command_line, "%s '%s'", LHALIST, statistic.login_path ); } else if( file_method == ZIP_COMPRESS ) { /* ZIP_FILE */ /*----------*/ (void) sprintf( command_line, "%s '%s'", ZIPLIST, statistic.login_path ); } else if( file_method == ARC_COMPRESS ) { /* ARC_FILE */ /*----------*/ (void) sprintf( command_line, "%s '%s'", ARCLIST, statistic.login_path ); } else if( file_method == RAR_COMPRESS ) { /* RAR_FILE */ /*----------*/ (void) sprintf( command_line, "%s '%s'", RARLIST, statistic.login_path ); } else if( file_method == FREEZE_COMPRESS ) { /* melt < TAR_FILE | gtar tvf - */ /*------------------------------*/ (void) sprintf( command_line, "%s < '%s' %s | %s", MELT, statistic.login_path, ERR_TO_STDOUT, TARLIST ); } else if( file_method == MULTIPLE_FREEZE_COMPRESS ) { (void) strncpy( cat_file_name, statistic.login_path, l - 2 ); (void) strcpy( &cat_file_name[l - 2], "*" ); /* cat TAR_FILE | melt | gtar tvf - */ /*----------------------------------*/ (void) sprintf( command_line, "%s '%s' %s | %s | %s", CAT, cat_file_name, ERR_TO_STDOUT, MELT, TARLIST ); } else if( file_method == COMPRESS_COMPRESS ) { /* uncompress < TAR_FILE | gtar tvf - */ /*------------------------------------*/ (void) sprintf( command_line, "%s < '%s' %s | %s", UNCOMPRESS, statistic.login_path, ERR_TO_STDOUT, TARLIST ); } else if( file_method == MULTIPLE_COMPRESS_COMPRESS ) { (void) strncpy( cat_file_name, statistic.login_path, l - 2 ); (void) strcpy( &cat_file_name[l - 2], "*" ); /* cat TAR_FILE.X* | uncompress | gtar tvf - */ /*-------------------------------------------*/ (void) sprintf( command_line, "%s %s | %s %s | %s", CAT, cat_file_name, UNCOMPRESS, ERR_TO_STDOUT, TARLIST ); } else if( file_method == GZIP_COMPRESS ) { /* gunzip < TAR_FILE | gtar tvf - */ /*--------------------------------*/ (void) sprintf( command_line, "%s < '%s' %s | %s", GNUUNZIP, statistic.login_path, ERR_TO_STDOUT, TARLIST ); } else if( file_method == MULTIPLE_GZIP_COMPRESS ) { (void) strncpy( cat_file_name, statistic.login_path, l - 2 ); (void) strcpy( &cat_file_name[l - 2], "*" ); /* cat TAR_FILE.X* | gunzip | gtar tvf - */ /*---------------------------------------*/ (void) sprintf( command_line, "%s %s | %s %s | %s", CAT, cat_file_name, GNUUNZIP, ERR_TO_STDOUT, TARLIST ); } else if( file_method == BZIP_COMPRESS ) { /* bunzip2 < TAR_FILE | gtar tvf - */ /*---------------------------------*/ (void) sprintf( command_line, "%s < '%s' %s | %s", BUNZIP, statistic.login_path, ERR_TO_STDOUT, TARLIST ); } else if( file_method == NO_COMPRESS ) { /* NO_COMPRESS */ /*-------------*/ /* gtar tvf - < TAR_FILE */ /*-----------------------*/ (void) sprintf( command_line, "%s < '%s'", TARLIST, statistic.login_path ); } else if( file_method == TAPE_DIR_FREEZE_COMPRESS ) { /* melt < TAR_FILE */ /*-----------------*/ (void) sprintf( command_line, "%s < '%s'", MELT, statistic.login_path ); } else if( file_method == TAPE_DIR_COMPRESS_COMPRESS ) { /* uncompress < TAR_FILE */ /*-----------------------*/ (void) sprintf( command_line, "%s < '%s'", UNCOMPRESS, statistic.login_path ); } else if( file_method == TAPE_DIR_GZIP_COMPRESS ) { /* gunzip < TAR_FILE */ /*-------------------*/ (void) sprintf( command_line, "%s < '%s'", GNUUNZIP, statistic.login_path ); } else if( file_method == TAPE_DIR_BZIP_COMPRESS ) { /* bunzip2 < TAR_FILE */ /*--------------------*/ (void) sprintf( command_line, "%s < '%s'", BUNZIP, statistic.login_path ); } else if( file_method == TAPE_DIR_NO_COMPRESS ) { /* cat < TAR_FILE */ /*----------------*/ (void) sprintf( command_line, "%s < '%s'", CAT, statistic.login_path ); } else { (void) sprintf( message, "unknown file_method %d", file_method ); ERROR_MSG( message ); *command_line = '\0'; close( p[0] ); close( p[1] ); return( -1 ); } (void) strcat( command_line, ERR_TO_NULL ); #ifdef DEBUG fprintf( stderr, "system( \"%s\" )\n", command_line ); #endif pid = fork(); if( pid == -1 ) { ERROR_MSG( "can't fork()" ); (void) close( p[0] ); (void) close( p[1] ); return( -1 ); } else if( pid == 0 ) { /* Sohn */ /*------*/ (void) close( p[0] ); (void) close( 1 ); if(dup( p[1] ) == -1) { /* (void) fprintf(stderr, "dup failed\n" ); */ } (void) close( p[1] ); if( result == 0 && SilentSystemCallEx( command_line, FALSE ) ) { result = 1; /* (void) fprintf(stderr, "system(%s)*failed\n", command_line ); */ } exit( result ); } else { /* Vater */ /*-------*/ (void) close( p[1] ); status = 0; if( ( f = fdopen( p[0], "r" ) ) == NULL ) { ERROR_MSG( "fdopen failed" ); return( -1 ); } if( mode == ZOO_FILE_MODE ) { if( ReadTreeFromZOO( statistic.tree, f ) ) { ERROR_MSG( "ReadTreeFromZOO Failed" ); (void) fclose( f ); (void) wait( &status ); return( -1 ); } } else if( mode == RPM_FILE_MODE ) { if( ReadTreeFromRPM( statistic.tree, f ) ) { ERROR_MSG( "ReadTreeFromRPM Failed" ); (void) fclose( f ); (void) wait( &status ); return( -1 ); } } else if( mode == LHA_FILE_MODE ) { if( ReadTreeFromLHA( statistic.tree, f ) ) { ERROR_MSG( "ReadTreeFromLHA Failed" ); (void) fclose( f ); (void) wait( &status ); return( -1 ); } } else if( mode == ZIP_FILE_MODE ) { if( ReadTreeFromZIP( statistic.tree, f ) ) { ERROR_MSG( "ReadTreeFromZIP Failed" ); (void) fclose( f ); (void) wait( &status ); return( -1 ); } } else if( mode == ARC_FILE_MODE ) { if( ReadTreeFromARC( statistic.tree, f ) ) { ERROR_MSG( "ReadTreeFromARC Failed" ); (void) fclose( f ); (void) wait( &status ); return( -1 ); } } else if( mode == RAR_FILE_MODE ) { if( ReadTreeFromRAR( statistic.tree, f ) ) { ERROR_MSG( "ReadTreeFromRAR Failed" ); (void) fclose( f ); (void) wait( &status ); return( -1 ); } } else { if( ReadTreeFromTAR( statistic.tree, f ) ) { ERROR_MSG( "ReadTreeFromTAR Failed" ); (void) fclose( f ); (void) wait( &status ); return( -1 ); } } (void) wait( &status ); if(status) { sprintf( message, "ReadTarFile failed*can't execute*%s", command_line ); MESSAGE( message ); } (void) fclose( f ); } } else { if( *disk_statistic.login_path ) { /* Alten Baum loeschen */ /*---------------------*/ *disk_statistic.login_path = '\0'; DeleteTree( disk_statistic.tree ); } (void) strcpy( statistic.tree->name, path ); statistic.tree->next = statistic.tree->prev = NULL; depth = strtod(TREEDEPTH, NULL); if( ReadTree( statistic.tree, path, depth ) ) { ERROR_MSG( "ReadTree Failed" ); return( -1 ); } (void) memcpy( (char *) &disk_statistic, (char *) &statistic, sizeof( Statistic ) ); } (void) SetFileSpec( statistic.file_spec ); /* SetKindOfSort( statistic.kind_of_sort ); */ return( 0 ); } int GetNewLoginPath(char *path) { int result; char *cptr; char aux[PATH_LENGTH * 2 + 1]= ""; result = -1; ClearHelp(); MvAddStr( LINES - 2, 1, "NEW LOGIN-PATH:" ); strcpy(aux,path); if( mode == LL_FILE_MODE && *path == '<' ) { for( cptr = aux; (*cptr = *(cptr + 1)); cptr++ ) ; if( aux[strlen(aux) - 1] == '>' ) aux[strlen(aux) - 1 ] = '\0'; } if( InputString( aux, LINES - 2, 17, 0, COLS - 24, "\r\033" ) == CR ) { NormPath(aux, path); result = 0; } return( result ); } ytree-1.99pl1/main.c000066400000000000000000000037461350711670100143240ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/main.c,v 1.20 2008/07/24 17:43:04 werner Exp $ * * Hauptmodul * ***************************************************************************/ #include "ytree.h" static char buffer[PATH_LENGTH+1]; static char path[PATH_LENGTH+1]; int main(int argc, char **argv) { char *p; int argi; char *hist; char *conf; #if (!defined(sun) && !defined(__DJGPP__)) setlocale(LC_ALL, ""); #endif hist = NULL; conf = NULL; p = DEFAULT_TREE; for (argi = 1; argi < argc; argi++) { if (*(argv[argi]) != '-') { p = argv[argi]; break; } switch(*(argv[argi]+1)) { case 'p': case 'P': if (*(argv[argi]+2) <= ' ') conf = argv[++argi]; else conf = argv[argi]+2; break; /* case 'e': case 'E': Hex dump (builtin) if(argi == argc) { return(BuiltinHexDump(NULL)); } if (*(argv[argi]+2) <= ' ') hex_file = argv[++argi]; else hex_file = argv[argi]+2; return(BuiltinHexDump(hex_file)); break;*/ case 'h': case 'H': if (*(argv[argi]+2) <= ' ') hist = argv[++argi]; else hist = argv[argi]+2; break; default: printf("Usage: %s [-p profile_file] [-h hist_file] [initial_dir]\n", argv[0]); exit(1); } } if (Init(conf, hist)) exit(1); if( *p != FILE_SEPARATOR_CHAR ) { /* rel. Pfad */ /*-----------*/ (void) Getcwd( buffer, sizeof( buffer ) - 2 ); (void) strcat( buffer, FILE_SEPARATOR_STRING ); (void) strcat( buffer, p ); p = buffer; } /* Normalize path */ NormPath( p, path ); statistic.login_path[0] = '\0'; statistic.path[0] = '0'; if( LoginDisk( path ) == -1 ) { endwin(); #ifdef XCURSES XCursesExit(); #endif exit( 1 ); } while( 1 ) { if( HandleDirWindow(statistic.tree) == 'q' ) Quit(); } } ytree-1.99pl1/match.c000066400000000000000000000066541350711670100144750ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/match.c,v 1.18 2007/04/01 13:33:36 werner Exp $ * * Behandlung reg. Ausdruecke fuer Dateinamen * ***************************************************************************/ #include "ytree.h" #if defined( sun ) || defined( linux ) || defined( __NeXT__ ) || defined( OSF1 ) || defined( __OpenBSD__ ) || defined(__NetBSD__) || defined( __FreeBSD__ ) || defined( __GNU__ ) #define HAS_REGEX #endif #ifdef linux /* To avoid warning about re_comp / re_exec */ /* Maybe this would work on other architectures too */ #define _REGEX_RE_COMP #endif #if defined( hpux ) || defined ( __APPLE__ ) #define HAS_REGCOMP #endif #ifdef HAS_REGEX #ifdef sun #define INIT register char *sp = ""; #define GETC() (*sp++) #define PEEKC() (*sp) #define UNGETC(c) (--sp) #define RETURN(c) return; #define ERROR(c) #include #else #include #endif /* sun */ #else extern char *regcmp(); extern char *regex(); static char *file_spec_cmp = NULL; #endif /* HAS_REGEX */ #if defined( HAS_REGCOMP ) #include static regex_t re; static BOOL re_flag = FALSE; #endif int SetMatchSpec(char *new_spec) { char *result; char *buffer; char *b_ptr; BOOL meta_flag = FALSE; if( ( buffer = (char *)malloc( strlen( new_spec ) * 2 + 4 ) ) == NULL ) { ERROR_MSG( "Malloc failed*ABORT" ); exit( 1 ); } b_ptr = buffer; *b_ptr++ = '^'; for(; *new_spec; new_spec++) { if( meta_flag ) { *b_ptr++ = *new_spec; meta_flag = FALSE; } else if( *new_spec == '\\' ) meta_flag = TRUE; else if( *new_spec == '?' ) *b_ptr++ = '.'; else if( *new_spec == '.' ) { *b_ptr++ = '\\'; *b_ptr++ = '.'; } else if( *new_spec == '*' ) { *b_ptr++ = '.'; *b_ptr++ = '*'; } else *b_ptr++ = *new_spec; } *b_ptr++ = '$'; *b_ptr = '\0'; #if defined ( HAS_REGEX ) if( ( result = (char *) re_comp( buffer ) ) ) { free( buffer ); return( 1 ); } #else #if defined( HAS_REGCOMP ) if(re_flag) { regfree(&re); re_flag = FALSE; } if( regcomp(&re, buffer, REG_NOSUB) ) { free( buffer ); return( 1 ); } free( buffer ); re_flag = TRUE; #else #if (!(defined(WIN32) || defined(__DJGPP__))) if( ( result = regcmp( buffer, (char *) 0 ) ) == NULL ) { free( buffer ); return( 1 ); } if( file_spec_cmp ) free( file_spec_cmp ); free( buffer ); file_spec_cmp = result; #else /* WIN32 */ /* z.Z. nicht unterstuetzt */ free( buffer ); result = 0; #endif /* WIN32 */ #endif /* HAS_REGCOMP */ #endif /* HAS_REGEX */ return( 0 ); } BOOL Match(char *file_name) { #if defined ( HAS_REGEX ) if( re_exec( file_name ) ) return( TRUE ); else return( FALSE ); #else #if defined( HAS_REGCOMP ) if(re_flag == FALSE) return( TRUE ); if( ( regexec(&re, file_name, (size_t) 0, NULL, 0 ) ) == 0 ) { return( TRUE ); } else { return( FALSE ); } #else #if (!(defined(WIN32) || defined(__DJGPP__))) char match_part[PATH_LENGTH + 1]; if( !file_spec_cmp ) return( TRUE ); if( regex( file_spec_cmp, file_name, match_part ) == NULL ) return( FALSE ); return( TRUE ); #else /* WIN32 */ /* z.Z. nicht unterstuetzt */ return( TRUE ); #endif /* WIN32 */ #endif /* HAS_REGCOMP */ #endif /* HAS_REGEX */ } ytree-1.99pl1/mkdir.c000066400000000000000000000141721350711670100145010ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/mkdir.c,v 1.17 2005/01/22 16:32:29 werner Exp $ * * Erstellen von Verzeichnissen * ***************************************************************************/ #include "ytree.h" int MakeDirectory(DirEntry *father_dir_entry) { char dir_name[PATH_LENGTH * 2 +1]; int result = -1; if( mode != DISK_MODE && mode != USER_MODE ) { beep(); return( result ); } ClearHelp(); MvAddStr( LINES - 2, 1, "Make Subdirectory: " ); *dir_name = '\0'; if( InputString( dir_name, LINES - 2, 20, 0, COLS - 20 - 1, "\r\033" ) == CR ) { result = MakeDirEntry( father_dir_entry, dir_name ); } move( LINES - 2, 1 ); clrtoeol(); return( result ); } int MakeDirEntry(DirEntry *father_dir_entry, char *dir_name ) { DirEntry *den_ptr, *des_ptr; char buffer[PATH_LENGTH+1]; struct stat stat_struct; int result = -1; if( mode != DISK_MODE && mode != USER_MODE ) { beep(); return( result ); } (void) GetPath( father_dir_entry, buffer ); (void) strcat( buffer, FILE_SEPARATOR_STRING ); (void) strcat( buffer, dir_name ); if( ( result = mkdir( buffer, (S_IREAD | S_IWRITE | S_IEXEC | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH) & ~user_umask ) ) ) { (void) sprintf( message, "Can't create Directory*\"%s\"*%s", buffer, strerror(errno) ); MESSAGE( message ); } else { /* Directory erstellt * ==> einklinken im Baum */ if( ( den_ptr = (DirEntry *) malloc( sizeof( DirEntry ) + strlen( dir_name ) ) ) == NULL ) { ERROR_MSG( "Malloc Failed*ABORT" ); exit( 1 ); } den_ptr->file = NULL; den_ptr->next = NULL; den_ptr->prev = NULL; den_ptr->sub_tree = NULL; den_ptr->total_bytes = 0L; den_ptr->matching_bytes = 0L; den_ptr->tagged_bytes = 0L; den_ptr->total_files = 0; den_ptr->matching_files = 0; den_ptr->tagged_files = 0; den_ptr->access_denied = FALSE; den_ptr->cursor_pos = 0; den_ptr->start_file = 0; den_ptr->global_flag = FALSE; den_ptr->login_flag = FALSE; den_ptr->big_window = FALSE; den_ptr->up_tree = father_dir_entry; den_ptr->not_scanned = FALSE; statistic.disk_total_directories++; (void) strcpy( den_ptr->name, dir_name ); if( STAT_( buffer, &stat_struct ) ) { ERROR_MSG( "Stat Failed*ABORT" ); exit( 1 ); } (void) memcpy( &den_ptr->stat_struct, &stat_struct, sizeof( stat_struct ) ); /* Sortieren durch direktes Einfuegen */ /*------------------------------------*/ for( des_ptr = father_dir_entry->sub_tree; des_ptr; des_ptr = des_ptr->next ) { if( strcmp( des_ptr->name, den_ptr->name ) > 0 ) { /* des-Element ist groesser */ /*--------------------------*/ den_ptr->next = des_ptr; den_ptr->prev = des_ptr->prev; if( des_ptr->prev) des_ptr->prev->next = den_ptr; else father_dir_entry->sub_tree = den_ptr; des_ptr->prev = den_ptr; break; } if( des_ptr->next == NULL ) { /* Ende der Liste erreicht; ==> einfuegen */ /*----------------------------------------*/ den_ptr->prev = des_ptr; den_ptr->next = des_ptr->next; des_ptr->next = den_ptr; break; } } if( father_dir_entry->sub_tree == NULL ) { /* Erstes Element */ /*----------------*/ father_dir_entry->sub_tree = den_ptr; den_ptr->prev = NULL; den_ptr->next = NULL; } (void) GetAvailBytes( &statistic.disk_space ); result = 0; } return( result ); } int MakePath( DirEntry *tree, char *dir_path, DirEntry **dest_dir_entry ) { DirEntry *de_ptr, *sde_ptr; char path[PATH_LENGTH+1]; char *cptr; char *token, *old; int n; int result = -1; NormPath( dir_path, path ); *dest_dir_entry = NULL; n = strlen( tree->name ); if( !strcmp(tree->name, FILE_SEPARATOR_STRING) || ( !strncmp( tree->name, path, n ) && ( path[n] == FILE_SEPARATOR_CHAR || path[n] == '\0' ) ) ) { /* Pfad befindet sich im (Sub)-Tree */ /*----------------------------------*/ de_ptr = tree; token = Strtok_r( &path[n], FILE_SEPARATOR_STRING, &old ); while( token ) { for( sde_ptr = de_ptr->sub_tree; sde_ptr; sde_ptr = sde_ptr->next ) { if( !strcmp( sde_ptr->name, token ) ) { /* Subtree gefunden */ /*------------------*/ de_ptr = sde_ptr; break; } } if( sde_ptr == NULL ) { /* Folgeverzeichnis nicht vorhanden */ /*----------------------------------*/ #ifdef DEBUG fprintf( stderr, "MakeDirEntry: \"%s\"\n", token ); #endif /* DEBUG */ if( MakeDirEntry( de_ptr, token ) ) { return( result ); } continue; } token = Strtok_r( NULL, FILE_SEPARATOR_STRING, &old ); } *dest_dir_entry = de_ptr; result = 0; } else { /* Zielverzeichnis ist nicht im Subtree */ /*--------------------------------------*/ (void) strcat( path, FILE_SEPARATOR_STRING ); for( cptr = strchr( path, FILE_SEPARATOR_CHAR ); cptr; cptr = strchr( cptr + 1, FILE_SEPARATOR_CHAR ) ) { if( cptr == path ) continue; if( cptr[-1] == FILE_SEPARATOR_CHAR ) continue; if( cptr[-1] == '.' && (cptr == path+1 || cptr[-2] == FILE_SEPARATOR_CHAR ) ) continue; *cptr = '\0'; #ifdef DEBUG fprintf( stderr, "MakePath: \"%s\"\n", path ); #endif /* DEBUG */ if( mkdir( path, S_IREAD | S_IWRITE | S_IEXEC | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH ) ) { /* ging nicht... */ /*---------------*/ *cptr = FILE_SEPARATOR_CHAR; if( errno == EEXIST ) continue; /* OK, weitermachen */ break; } *cptr = FILE_SEPARATOR_CHAR; } result = 0; } return( result ); } ytree-1.99pl1/mktime.c000066400000000000000000000073541350711670100146650ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/mktime.c,v 1.8 1997/08/13 12:24:58 werner Rel $ * * David MacKenzie, Michael Haertel * Replacement for mktime * ***************************************************************************/ #include "ytree.h" /* free mktime function Copyright 1988, 1989 by David MacKenzie and Michael Haertel Unlimited distribution permitted provided this copyright notice is retained and any functional modifications are prominently identified. */ /* Note: This version of mktime is ignorant of the tzfile; it does not return correct results during the few hours around when daylight savings time goes in to or out of effect. It also does not allow or adjust for invalid values in any of the fields, contrary to the ANSI C specification. */ static time_t mkgmtime (struct tm *tm); /* Return the equivalent in seconds past 12:00:00 a.m. Jan 1, 1970 GMT of the local time and date in the exploded time structure `tm', and set `tm->tm_yday', `tm->tm_wday', and `tm->tm_isdst'. Return -1 if any of the other fields in `tm' has an invalid value. */ time_t Mktime (struct tm *tm) { struct tm save_tm; /* Copy of contents of `*tm'. */ struct tm *ltm; /* Local time. */ time_t then; /* The time to return. */ then = mkgmtime (tm); if (then == -1) return -1; /* In case `tm' points to the static area used by localtime, save its contents and restore them later. */ save_tm = *tm; /* Correct for the timezone and any daylight savings time. If a change to or from daylight savings time occurs between when it is the time in `tm' locally and when it is that time in Greenwich, the change to or from dst is ignored, but that is a rare case. */ then += then - mkgmtime (localtime (&then)); ltm = localtime (&then); save_tm.tm_yday = ltm->tm_yday; save_tm.tm_wday = ltm->tm_wday; save_tm.tm_isdst = ltm->tm_isdst; *tm = save_tm; return then; } /* Nonzero if `y' is a leap year, else zero. */ #define leap(y) (((y) % 4 == 0 && (y) % 100 != 0) || (y) % 400 == 0) /* Number of leap years from 1970 to `y' (not including `y' itself). */ #define nleap(y) (((y) - 1969) / 4 - ((y) - 1901) / 100 + ((y) - 1601) / 400) /* Number of days in each month of the year. */ static char monlens[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; /* Return the equivalent in seconds past 12:00:00 a.m. Jan 1, 1970 GMT of the Greenwich Mean time and date in the exploded time structure `tm', and set `tm->tm_yday', `tm->tm_wday', and `tm->tm_isdst'. Return -1 if any of the other fields in `tm' has an invalid value. */ static time_t mkgmtime (struct tm *tm) { int years, months, days, hours, minutes, seconds; years = tm->tm_year + 1900; /* year - 1900 -> year */ months = tm->tm_mon; /* 0..11 */ days = tm->tm_mday - 1; /* 1..31 -> 0..30 */ hours = tm->tm_hour; /* 0..23 */ minutes = tm->tm_min; /* 0..59 */ seconds = tm->tm_sec; /* 0..61 in ANSI C. */ if (years < 1970 || months < 0 || months > 11 || days < 0 || days > monlens[months] + (months == 1 && leap (years)) - 1 || hours < 0 || hours > 23 || minutes < 0 || minutes > 59 || seconds < 0 || seconds > 61) return -1; /* Set `days' to the number of days into the year. */ if (months > 1 && leap (years)) ++days; while (months-- > 0) days += monlens[months]; tm->tm_yday = days; /* Now set `days' to the number of days since Jan 1, 1970. */ days += 365 * (years - 1970) + nleap (years); tm->tm_wday = (days + 4) % 7; /* Jan 1, 1970 was Thursday. */ tm->tm_isdst = 0; return 86400 * days + 3600 * hours + 60 * minutes + seconds; } ytree-1.99pl1/move.c000066400000000000000000000142271350711670100143420ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/move.c,v 1.16 2011/01/09 12:28:01 werner Exp $ * * Beschreibung : Bewegen von Dateien * ***************************************************************************/ #include "ytree.h" static int Move(char *to_path, char *from_path); int MoveFile(FileEntry *fe_ptr, unsigned char confirm, char *to_file, DirEntry *dest_dir_entry, char *to_dir_path, FileEntry **new_fe_ptr ) { DirEntry *de_ptr; LONGLONG file_size; char from_path[PATH_LENGTH+1]; char to_path[PATH_LENGTH+1]; FileEntry *dest_file_entry; FileEntry *fen_ptr; struct stat stat_struct; int term; int result; result = -1; *new_fe_ptr = NULL; de_ptr = fe_ptr->dir_entry; (void) GetPath( de_ptr, from_path ); (void) strcat( from_path, FILE_SEPARATOR_STRING ); (void) strcat( from_path, fe_ptr->name ); (void) strcpy( to_path, to_dir_path ); (void) strcat( to_path, FILE_SEPARATOR_STRING ); (void) strcat( to_path, to_file ); if( !strcmp( to_path, from_path ) ) { MESSAGE( "Can't move file into itself" ); ESCAPE; } if( access( from_path, W_OK ) ) { (void) sprintf( message, "Unmoveable file*\"%s\"*%s", from_path, strerror(errno) ); MESSAGE( message ); ESCAPE; } if( dest_dir_entry ) { /* Ziel befindet sich im Sub-Tree */ /*--------------------------------*/ (void) GetFileEntry( dest_dir_entry, to_file, &dest_file_entry ); if( dest_file_entry ) { /* Datei existiert */ /*-----------------*/ if( confirm ) { term = InputChoise( "file exist; overwrite (Y/N) ? ", "YN\033" ); if( term != 'Y' ) { result = (term == 'N' ) ? 0 : -1; /* Abort on escape */ ESCAPE; } } (void) DeleteFile( dest_file_entry ); } } else { /* access benutzen */ /*-----------------*/ if( !access( to_path, F_OK ) ) { /* Datei existiert */ /*-----------------*/ if( confirm ) { term = InputChoise( "file exist; overwrite (Y/N) ? ", "YN\033" ); if( term != 'Y' ) { result = (term == 'N' ) ? 0 : -1; /* Abort on escape */ ESCAPE; } } if( unlink( to_path ) ) { (void) sprintf( message, "Can't unlink*\"%s\"*%s", to_path, strerror(errno) ); MESSAGE( message ); ESCAPE; } } } if( !Move( to_path, from_path ) ) { /* File wurde bewegt */ /*-------------------*/ /* Original aus Baum austragen */ /*-----------------------------*/ (void) RemoveFile( fe_ptr ); if( dest_dir_entry ) { if( STAT_( to_path, &stat_struct ) ) { ERROR_MSG( "Stat Failed*ABORT" ); exit( 1 ); } file_size = stat_struct.st_size; dest_dir_entry->total_bytes += file_size; dest_dir_entry->total_files++; statistic.disk_total_bytes += file_size; statistic.disk_total_files++; dest_dir_entry->matching_bytes += file_size; dest_dir_entry->matching_files++; statistic.disk_matching_bytes += file_size; statistic.disk_matching_files++; /* File eintragen */ /*----------------*/ if( ( fen_ptr = (FileEntry *) malloc( sizeof( FileEntry ) + strlen( to_file ) ) ) == NULL ) { ERROR_MSG( "Malloc Failed*ABORT" ); exit( 1 ); } (void) strcpy( fen_ptr->name, to_file ); (void) memcpy( &fen_ptr->stat_struct, &stat_struct, sizeof( stat_struct ) ); fen_ptr->dir_entry = dest_dir_entry; fen_ptr->tagged = FALSE; fen_ptr->matching = Match( fen_ptr->name ); fen_ptr->next = dest_dir_entry->file; fen_ptr->prev = NULL; if( dest_dir_entry->file ) dest_dir_entry->file->prev = fen_ptr; dest_dir_entry->file = fen_ptr; *new_fe_ptr = fen_ptr; } (void) GetAvailBytes( &statistic.disk_space ); result = 0; } FNC_XIT: move( LINES - 3, 1 ); clrtoeol(); move( LINES - 2, 1 ); clrtoeol(); move( LINES - 1, 1 ); clrtoeol(); return( result ); } int GetMoveParameter(char *from_file, char *to_file, char *to_dir) { char buffer[PATH_LENGTH * 2 +1]; if( from_file == NULL ) { from_file = "TAGGED FILES"; (void) strcpy( to_file, "*" ); } else { (void) strcpy( to_file, from_file ); } (void) sprintf( buffer, "MOVE %s", from_file ); ClearHelp(); MvAddStr( LINES - 3, 1, buffer ); MvAddStr( LINES - 2, 1, "AS " ); if( InputString( to_file, LINES - 2, 6, 0, COLS - 6, "\r\033" ) == CR ) { MvAddStr( LINES - 1, 1, "TO " ); if( InputString( to_dir, LINES - 1, 6, 0, COLS - 6, "\r\033" ) == CR ) return( 0 ); } ClearHelp(); return( -1 ); } static int Move(char *to_path, char *from_path) { if( !strcmp( to_path, from_path ) ) { MESSAGE( "Can't move file into itself" ); return( -1 ); } if( link( from_path, to_path ) ) { (void) sprintf( message, "Can't link \"%s\"*to \"%s\"*%s", from_path, to_path, strerror(errno) ); MESSAGE( message ); return( -1 ); } if( unlink( from_path ) ) { (void) sprintf( message, "Can't unlink*\"%s\"*%s", from_path, strerror(errno) ); MESSAGE( message ); return( -1 ); } return( 0 ); } int MoveTaggedFiles(FileEntry *fe_ptr, WalkingPackage *walking_package) { int result = -1; char new_name[PATH_LENGTH+1]; if( BuildFilename( fe_ptr->name, walking_package->function_data.mv.to_file, new_name ) == 0 ) { if( *new_name == '\0' ) { MESSAGE( "Can't move file to*empty name" ); } else { result = MoveFile( fe_ptr, walking_package->function_data.mv.confirm, new_name, walking_package->function_data.mv.dest_dir_entry, walking_package->function_data.mv.to_path, &walking_package->new_fe_ptr ); } } return( result ); } ytree-1.99pl1/passwd.c000066400000000000000000000057561350711670100147040ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/passwd.c,v 1.15 2016/09/04 14:41:12 werner Exp $ * * Handhabung von User-Nummern / Namen * ***************************************************************************/ #include "ytree.h" #ifdef WIN32 #include #else typedef struct { int uid; char name[OWNER_NAME_MAX + 1]; char display_name[DISPLAY_OWNER_NAME_MAX + 1]; } PasswdEntry; extern struct passwd *getpwent(void); #if !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined( __FreeBSD__ ) && !defined( OSF1 ) && !defined( __APPLE__ ) extern void setpwent(void); #endif static PasswdEntry *passwd_array; static unsigned int passwd_count; #endif /* WIN32 */ int ReadPasswdEntries(void) { #ifndef WIN32 int i; struct passwd *pwd_ptr; for( passwd_count=0; getpwent(); passwd_count++ ) ; setpwent(); if( passwd_array ) { free( passwd_array ); passwd_array = NULL; } if( passwd_count == 0 ) { passwd_array = NULL; } else { if( ( passwd_array = (PasswdEntry *) calloc( passwd_count, sizeof( PasswdEntry ) ) ) == NULL ) { ERROR_MSG( "Calloc Failed" ); passwd_array = NULL; passwd_count = 0; return( 1 ); } } for(i=0; i < (int)passwd_count; i++) { if( ( pwd_ptr = getpwent() ) == NULL ) { ERROR_MSG( "Getpwent Failed" ); if( passwd_array) free( passwd_array ); passwd_array = NULL; passwd_count = 0; return( 1 ); } passwd_array[i].uid = pwd_ptr->pw_uid; (void) strncpy( passwd_array[i].name, pwd_ptr->pw_name, OWNER_NAME_MAX ); passwd_array[i].name[OWNER_NAME_MAX] = '\0'; CutName(passwd_array[i].display_name, pwd_ptr->pw_name, DISPLAY_OWNER_NAME_MAX); } #endif /* WIN32 */ return( 0 ); } char *GetPasswdName(unsigned int uid) { #ifdef WIN32 struct passwd *pwd_ptr; pwd_ptr = getpwuid( uid ); if( pwd_ptr ) return( pwd_ptr->pw_name ); else return( NULL ); #else int i; for( i=0; i < (int)passwd_count; i++ ) { if( passwd_array[i].uid == (int)uid ) return( passwd_array[i].name ); } return( NULL ); #endif /* WIN32 */ } char *GetDisplayPasswdName(unsigned int uid) { #ifdef WIN32 struct passwd *pwd_ptr; pwd_ptr = getpwuid( uid ); if( pwd_ptr ) return( pwd_ptr->pw_name ); else return( NULL ); #else int i; for( i=0; i < (int)passwd_count; i++ ) { if( passwd_array[i].uid == (int)uid ) return( passwd_array[i].display_name ); } return( NULL ); #endif /* WIN32 */ } int GetPasswdUid(char *name) { #ifdef WIN32 struct passwd *pwd_ptr; pwd_ptr = getpwnam( name ); if( pwd_ptr ) return( pwd_ptr->pw_uid ); else return( -1 ); #else int i; for( i=0; i < (int)passwd_count; i++ ) { if( !strcmp( name, passwd_array[i].name ) ) return( (int) passwd_array[i].uid ); } return( -1 ); #endif /* WIN32 */ } ytree-1.99pl1/patchlev.h000066400000000000000000000005561350711670100152070ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/patchlev.h,v 1.53 2016/09/04 17:15:34 werner Exp $ * * Patchlevel-Definitionen * ***************************************************************************/ #define VERSION "1.99" #define PATCHLEVEL 1 #define VERSIONDATE "Sep 04 2016" ytree-1.99pl1/pipe.c000066400000000000000000000061501350711670100143250ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/pipe.c,v 1.15 2004/03/21 14:13:11 werner Exp $ * * Umlenken von Datei-Inhalten zu einem Kommando * ***************************************************************************/ #include "ytree.h" extern int chdir(const char *); int Pipe(DirEntry *dir_entry, FileEntry *file_entry) { static char input_buffer[COMMAND_LINE_LENGTH + 1] = "| "; char file_name_path[PATH_LENGTH+1]; char file_name_p_aux[PATH_LENGTH+1]; char *command_line; char *archive; char cwd[PATH_LENGTH+1]; char path[PATH_LENGTH+1]; int result; result = -1; if( ( command_line = (char *)malloc( COMMAND_LINE_LENGTH + 1 ) ) == NULL ) { ERROR_MSG( "Malloc failed*ABORT" ); exit( 1 ); } (void) GetRealFileNamePath( file_entry, file_name_path ); (void) StrCp( file_name_p_aux, file_name_path); ClearHelp(); MvAddStr( LINES - 2, 1, "Pipe-Command:" ); if( GetPipeCommand( &input_buffer[2] ) == 0 ) { move( LINES - 2, 1 ); clrtoeol(); if( Getcwd( cwd, PATH_LENGTH ) == NULL ) { WARNING( "Getcwd failed*\".\"assumed" ); (void) strcpy( cwd, "." ); } (void) GetPath( dir_entry, path ); if( mode == DISK_MODE || mode == USER_MODE ) { /* Kommandozeile zusammenbasteln */ /*-------------------------------*/ (void) sprintf( command_line, "%s %s %s", CAT, file_name_p_aux, input_buffer ); } else { /* TAR/ZOO/ZIP_FILE_MODE */ /*-----------------------*/ archive = (mode == TAPE_MODE) ? statistic.tape_name : statistic.login_path; MakeExtractCommandLine( command_line, archive, file_name_p_aux, input_buffer ); } refresh(); result = QuerySystemCall( command_line ); } else { move( LINES - 2, 1 ); clrtoeol(); } free( command_line ); return( result ); } int GetPipeCommand(char *pipe_command) { int result; result = -1; ClearHelp(); MvAddStr( LINES - 2, 1, "Pipe-Command: " ); if( InputString( pipe_command, LINES - 2, 15, 0, COLS - 16, "\r\033" ) == CR ) { result = 0; } move( LINES - 2, 1 ); clrtoeol(); return( result ); } int PipeTaggedFiles(FileEntry *fe_ptr, WalkingPackage *walking_package) { int i, n; char from_path[PATH_LENGTH+1]; char buffer[2048]; walking_package->new_fe_ptr = fe_ptr; /* unchanged */ (void) GetRealFileNamePath( fe_ptr, from_path ); if( ( i = open( from_path, O_RDONLY ) ) == -1 ) { (void) sprintf( message, "Can't open file*\"%s\"*%s", from_path, strerror(errno) ); MESSAGE( message ); return( -1 ); } while( ( n = read( i, buffer, sizeof( buffer ) ) ) > 0 ) { if( fwrite( buffer, n, 1, walking_package->function_data.pipe_cmd.pipe_file ) != 1 ) { (void) sprintf( message, "Write-Error!*%s", strerror(errno) ); MESSAGE( message ); (void) close( i ); return( -1 ); } } (void) close( i ); return( 0 ); } ytree-1.99pl1/print.c000066400000000000000000000021551350711670100145250ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/print.c,v 1.3 2005/01/22 16:32:29 werner Exp $ * * Enhanced Curses Functions * ***************************************************************************/ #include "ytree.h" int MvAddStr(int y, int x, char *str) { #ifdef WITH_UTF8 mvaddstr(y, x, str); #else for(;*str != '\0';str++) mvaddch(y, x++, PRINT(*str)); #endif return 0; } int MvWAddStr(WINDOW *win, int y, int x, char *str) { #ifdef WITH_UTF8 mvwaddstr(win, y, x, str); #else for(;*str != '\0';str++) mvwaddch(win, y, x++, PRINT(*str)); #endif return 0; } int WAddStr(WINDOW *win, char *str) { #ifdef WITH_UTF8 waddstr(win, str); #else for(;*str != '\0';str++) waddch(win, PRINT(*str)); #endif return 0; } int AddStr(char *str) { #ifdef WITH_UTF8 addstr(str); #else for(;*str != '\0';str++) addch( PRINT(*str)); #endif return 0; } int WAttrAddStr(WINDOW *win, int attr, char *str) { int rc; wattrset( win, attr ); rc = WAddStr(win, str); wattrset( win, 0 ); return(rc); } ytree-1.99pl1/profile.c000066400000000000000000000277311350711670100150400ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/profile.c,v 1.10 2014/12/26 09:53:11 werner Exp $ * * Profile support * ***************************************************************************/ #include "ytree.h" #define NO_SECTION 0 #define GLOBAL_SECTION 1 #define VIEWER_SECTION 2 #define MENU_SECTION 3 #define FILEMAP_SECTION 4 #define FILECMD_SECTION 5 #define DIRMAP_SECTION 6 #define DIRCMD_SECTION 7 typedef struct { char *name; char *def; char *envvar; char *value; } Profile; typedef struct _viewer { char *ext; char *cmd; struct _viewer *next; } Viewer; typedef struct _dirmenu { int chkey; int chremap; char *cmd; struct _dirmenu *next; } Dirmenu; typedef struct _filemenu { int chkey; int chremap; char *cmd; struct _filemenu *next; } Filemenu; static Viewer viewer; static Dirmenu dirmenu; static Filemenu filemenu; /* MUSS sortiert sein! */ static Profile profile[] = { { "ARCEXPAND", DEFAULT_ARCEXPAND, NULL, NULL }, { "ARCLIST", DEFAULT_ARCLIST, NULL, NULL }, { "BUNZIP", DEFAULT_BUNZIP, NULL, NULL }, { "CAT", DEFAULT_CAT, NULL, NULL }, { "DIR1", DEFAULT_DIR1, NULL, NULL }, { "DIR2", DEFAULT_DIR2, NULL, NULL }, { "EDITOR", DEFAULT_EDITOR, "EDITOR", NULL }, { "FILE1", DEFAULT_FILE1, NULL, NULL }, { "FILE2", DEFAULT_FILE2, NULL, NULL }, { "FILEMODE", DEFAULT_FILEMODE, NULL, NULL }, { "GNUUNZIP", DEFAULT_GNUUNZIP, NULL, NULL }, { "HEXDUMP", DEFAULT_HEXDUMP, NULL, NULL }, { "HEXEDITOFFSET", DEFAULT_HEXEDITOFFSET, NULL, NULL }, { "INITIALDIR", DEFAULT_INITIALDIR, NULL, NULL }, { "LHAEXPAND", DEFAULT_LHAEXPAND, NULL, NULL }, { "LHALIST", DEFAULT_LHALIST, NULL, NULL }, { "LISTJUMPSEARCH", DEFAULT_LISTJUMPSEARCH,NULL, NULL }, { "MANROFF", DEFAULT_MANROFF, NULL, NULL }, { "MELT", DEFAULT_MELT, NULL, NULL }, { "NOSMALLWINDOW", DEFAULT_NOSMALLWINDOW, NULL, NULL }, { "NUMBERSEP", DEFAULT_NUMBERSEP, NULL, NULL }, { "PAGER", DEFAULT_PAGER, "PAGER", NULL }, { "RAREXPAND", DEFAULT_RAREXPAND, NULL, NULL }, { "RARLIST", DEFAULT_RARLIST, NULL, NULL }, { "RPMEXPAND", DEFAULT_RPMEXPAND, NULL, NULL }, { "RPMLIST", DEFAULT_RPMLIST, NULL, NULL }, { "SEARCHCOMMAND", DEFAULT_SEARCHCOMMAND, NULL, NULL }, { "TAPEDEV", DEFAULT_TAPEDEV, "TAPE", NULL }, { "TAREXPAND", DEFAULT_TAREXPAND, NULL, NULL }, { "TARLIST", DEFAULT_TARLIST, NULL, NULL }, { "TREEDEPTH", DEFAULT_TREEDEPTH, NULL, NULL }, { "UNCOMPRESS", DEFAULT_UNCOMPRESS, NULL, NULL }, { "USERVIEW", "", NULL, NULL }, { "ZIPEXPAND", DEFAULT_ZIPEXPAND, NULL, NULL }, { "ZIPLIST", DEFAULT_ZIPLIST, NULL, NULL }, { "ZOOEXPAND", DEFAULT_ZOOEXPAND, NULL, NULL }, { "ZOOLIST", DEFAULT_ZOOLIST, NULL, NULL } }; #define PROFILE_ENTRIES (sizeof(profile) / sizeof(profile[0])) static int Compare(const void *s1, const void *s2); static int ChCode(const char *s); int ReadProfile( char *filename ) { int l, result = -1; char buffer[1024], *n, *old; unsigned char *name, *value, *cptr; int section; Profile *p, key; Viewer *v, *new_v; Filemenu *m, *new_m; Dirmenu *d, *new_d; FILE *f; section = NO_SECTION; v = &viewer; m = &filemenu; d = &dirmenu; v->next = NULL; m->next = NULL; d->next = NULL; if( ( f = fopen( filename, "r" ) ) == NULL ) { ESCAPE; } while( fgets( buffer, sizeof( buffer ), f ) ) { if(*buffer == '#') continue; l = strlen( buffer ); if( l > 2 ) { buffer[l-1] = '\0'; /* trim whitspace */ for( name = buffer; isspace(*name); name++ ) ; for(cptr=name; !isspace(*cptr) && *cptr != '='; cptr++ ) ; if(*cptr != '=') *cptr = '\0'; if(*name == '[') { /* section */ if( !strcmp(name, "[GLOBAL]") ) section = GLOBAL_SECTION; else if( !strcmp(name, "[VIEWER]") ) section = VIEWER_SECTION; else if( !strcmp(name, "[MENU]") ) section = MENU_SECTION; else if( !strcmp(name, "[FILEMAP]") ) section = FILEMAP_SECTION; else if( !strcmp(name, "[FILECMD]") ) section = FILECMD_SECTION; else if( !strcmp(name, "[DIRMAP]") ) section = DIRMAP_SECTION; else if( !strcmp(name, "[DIRCMD]") ) section = DIRCMD_SECTION; else section = NO_SECTION; continue; } if( section == GLOBAL_SECTION ) { value = strchr( buffer, '=' ); if( *name && value ) { *value++ = '\0'; key.name = name; if(( p = bsearch(&key, profile, PROFILE_ENTRIES, sizeof(*p), Compare))) { p->value = Strdup( value ); } } } else if( section == MENU_SECTION ) { value = strchr( buffer, '=' ); if( *name && value ) { *value++ = '\0'; if (!strcmp(name, "DIR1") || !strcmp(name, "DIR2") || !strcmp(name, "FILE1") || !strcmp(name, "FILE2") ) { key.name = name; if(( p = bsearch(&key, profile, PROFILE_ENTRIES, sizeof(*p), Compare))) { /* Space pad menu strings to length COLS, ignoring '(' and ')' characters */ l = 0; for (cptr = value; *cptr; ++cptr) { if (*cptr != '(' && *cptr != ')') { ++l; } } while (l++ < COLS - 1) *cptr++ = ' '; *cptr = '\0'; p->value = Strdup( value ); } } } } else if(section == FILEMAP_SECTION ) { value = strchr( buffer, '=' ); if( *name && value ) { *value++ = '\0'; /* trim whitespace */ while(*value && isspace(*value)) value++; n = Strtok_r(name, ",", &old); /* maybe comma-separated list, eg.: k,K=x */ while(n) { /* Check for existing entry from FILECMD_SECTION */ for(new_m = filemenu.next; new_m != NULL; new_m = new_m->next) { if (new_m->chkey == ChCode( n )) { new_m->chremap = ChCode( value ); if (new_m->chremap == 0) new_m->chremap = -1; /* Don't beep if user cmd defined */ break; } } if( new_m == NULL && ( new_m = malloc( sizeof(*new_m) ) ) ) { new_m->chkey = ChCode( n ); new_m->chremap = ChCode( value ); new_m->cmd = NULL; new_m->next = NULL; m->next = new_m; m = new_m; } n = Strtok_r(NULL, ",", &old); } } } else if(section == FILECMD_SECTION ) { value = strchr( buffer, '=' ); if( *name && value ) { *value++ = '\0'; /* trim whitespace */ while(*value && isspace(*value)) value++; /* may not be comma-separated list */ /* Check for existing entry from FILEMAP_SECTION */ for (new_m = filemenu.next; new_m != NULL; new_m = new_m->next) { if (new_m->chkey == ChCode( name )) { new_m->cmd = Strdup( value ); if (new_m->chremap == 0) new_m->chremap = -1; /* Don't beep if user cmd defined */ break; } } if( new_m == NULL && ( new_m = malloc( sizeof(*new_m) ) ) ) { new_m->chkey = ChCode( name ); new_m->chremap = new_m->chkey; new_m->cmd = Strdup( value ); new_m->next = NULL; m->next = new_m; m = new_m; } } } else if(section == DIRMAP_SECTION ) { value = strchr( buffer, '=' ); if( *name && value ) { *value++ = '\0'; /* trim whitespace */ while(*value && isspace(*value)) value++; n = Strtok_r(name, ",", &old); /* maybe comma-separated list, eg.: k,K=x */ while(n) { /* Check for existing entry from DIRCMD_SECTION */ for(new_d = dirmenu.next; new_d != NULL; new_d = new_d->next) { if (new_d->chkey == ChCode( n )) { new_d->chremap = ChCode( value ); if (new_d->chremap == 0) new_d->chremap = -1; /* Don't beep if user cmd defined */ break; } } if( new_d == NULL && ( new_d = malloc( sizeof(*new_d) ) ) ) { new_d->chkey = ChCode( n ); new_d->chremap = ChCode( value ); new_d->cmd = NULL; new_d->next = NULL; d->next = new_d; d = new_d; } n = Strtok_r(NULL, ",", &old); } } } else if(section == DIRCMD_SECTION ) { value = strchr( buffer, '=' ); if( *name && value ) { *value++ = '\0'; /* trim whitespace */ while(*value && isspace(*value)) value++; /* may not be comma-separated list */ /* Check for existing entry from DIRMAP_SECTION */ for(new_d = dirmenu.next; new_d != NULL; new_d = new_d->next) { if (new_d->chkey == ChCode( name )) { new_d->cmd = Strdup( value ); if (new_d->chremap == 0) new_d->chremap = -1; /* Don't beep if user cmd defined */ break; } } if ( new_d == NULL && ( new_d = malloc( sizeof(*new_d) ) ) ) { new_d->chkey = ChCode( name ); new_d->chremap = new_d->chkey; new_d->cmd = Strdup( value ); new_d->next = NULL; d->next = new_d; d = new_d; } } } else if ( section == VIEWER_SECTION ) { value = strchr( buffer, '=' ); if( *name && value ) { *value++ = '\0'; n = Strtok_r(name, ",", &old); /* maybe comma-separated list, eg.: .jpeg,.gif=xv */ while(n) { if(( new_v = malloc( sizeof(*new_v) ) ) ) { new_v->ext = Strdup( n ); new_v->cmd = Strdup( value ); new_v->next = NULL; if(new_v->ext == NULL || new_v->cmd == NULL) { /* ignore entry */ if(new_v->ext) free(new_v->ext); if(new_v->cmd) free(new_v->cmd); free(new_v); } else { v->next = new_v; v = new_v; } } n = Strtok_r(NULL, ",", &old); } } } } } result = 0; FNC_XIT: if( f ) fclose( f ); return( result ); } char *GetProfileValue( char *name ) { Profile *p, key; char *cptr; key.name = name; p = bsearch(&key, profile, PROFILE_ENTRIES, sizeof(*p), Compare); if(!p) return( "" ); if( p->value ) return( p->value ); if( p->envvar && (cptr = getenv( p->envvar ) ) ) return( cptr ); return( p->def ); } static int ChCode(const char *s) { if (*s == '^' && *(s+1) != '^') return((int)((*(s+1)) & 0x1F)); else return((int)(*s)); } static int Compare(const void *s1, const void *s2) { return( strcmp( ((Profile *)s1)->name, ((Profile *)s2)->name ) ); } char *GetUserFileAction(int chkey, int *pchremap) { Filemenu *m; for(m=filemenu.next; m; m=m->next) { if(chkey == m->chkey) { if (pchremap) *pchremap = m->chremap; return(m->cmd); } } if (pchremap) *pchremap = chkey; return(NULL); } char *GetUserDirAction(int chkey, int *pchremap) { Dirmenu *d; for(d=dirmenu.next; d; d=d->next) { if(chkey == d->chkey) { if (pchremap) *pchremap = d->chremap; return(d->cmd); } } if (pchremap) *pchremap = chkey; return(NULL); } BOOL IsUserActionDefined(void) { return((BOOL)(dirmenu.next != NULL || filemenu.next != NULL)); } char *GetExtViewer(char *filename) { Viewer *v; int l, x; l = strlen(filename); for(v=viewer.next; v; v=v->next) { x = strlen(v->ext); if(l > x) { if(!strcmp(&filename[l - x], v->ext)) { return(v->cmd); } } } return(NULL); } ytree-1.99pl1/quit.c000066400000000000000000000077401350711670100143600ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/quit.c,v 1.13 2003/03/16 13:13:29 werner Exp $ * * Verlassen von ytree * * ***************************************************************************/ #include "ytree.h" /* quit-to-directory (xtree: alt-Q)(ytree: shift-Q, ^Q) this uses the Ztree method. for this to work, a ytree is called via a function in ~/.bashrc instead of directly. that function generates a pid-unique file containing a "cd cwd" line before calling ytree, and sources-in the pid-unique file afterward, thus jumping to the directory specified. if ytree rewrites that file to the quit-to dir, the eventual command-prompt will be in that chosen dir. thus, a Quit exit jumps to the dir it's already in. a QuitTo exit jumps to the dir_entry-specified dir. QuitTo: - get parent's pid - get owning uid's homedir - compose shell stub name - test: - exists? - regular file? - non-zero length? - write dir_entry to it, thus replacing the starting-cwd line - chain to Quit if user elects not to quit, no harm done: - rewrite that file to starting-cwd if it passes those checks again (avoiding race opening vuln) - return to main program loop a user can have a bunch of ytrees open, but they'll be run one-per- shell (i.e. each xterm singletasking) unless the user's ASKING for trouble, so a given shell-pid will be unique for the xterm that owns it, even though they're all clustered in the user's homedir. changes: - ytree.h add prototype for QuitTo - filewin.c add call to QuitTo, for Q and ^Q - dirwin.c add call to QuitTo, for Q and ^Q (q still falls to main) i've mapped this to ^Q for now on my home machine, but it's probably best to use just SHIFT-Q for this, following the trend of mapping XtreeGold Alt-commands to SHIFT-commands in ytree/xtc. that leaves ytree usable in serial terminals with soft (XOFF/XON) line control protocol. in .bashrc: # # "yt" is part of getting ytree to quit to the target directory rather # than the starting one (Alt-Q rather than Q, in XTG terms). # the pid-numbered chdir "bat" will get rewritten to the selected # dir if ytree is Quit or ^Quit rather than quit, if ytree-1.75b # (or later version, assuming Werner incorporates my changes) is used. # This method is based on Kim Henkel's alt-Q batfile method for ZtreeWin. # --crb3 14jan00/12mar03 # function yt { echo cd $PWD >~/.ytree-$$.chdir /usr/bin/ytree $1 $2 $3 $4 $5 source ~/.ytree-$$.chdir rm ~/.ytree-$$.chdir } */ #define MAXPATH (PATH_LENGTH+1) static int QuitFileCheck(char *fname); void QuitTo(DirEntry * dir_entry) { int parpid; FILE *qfile; char nbuf[MAXPATH],qfilename[MAXPATH]; struct passwd *pwp; GetPath(dir_entry,nbuf); parpid=getppid(); pwp=getpwuid(getuid()); sprintf(qfilename,"%s/.ytree-%d.chdir",pwp->pw_dir,parpid); if(!QuitFileCheck(qfilename)){ if( (qfile=fopen(qfilename,"w"))!=NULL) { fprintf(qfile,"cd %s\n",nbuf); fclose(qfile); } } Quit(); /* never come back from a successful quit */ if(!QuitFileCheck(qfilename)){ if( (qfile=fopen(qfilename,"w"))!=NULL) { fprintf(qfile,"cd %s\n",Getcwd(NULL,0)); fclose(qfile); } } } /* * QuitFileCheck. * quick safety-check of the shell stub we want to write to. * if any of these tests fail, somebody's trying to use us for a * security breach. */ static int QuitFileCheck(char *fname) { struct stat fstat; if(stat(fname,&fstat)) return(1); if(!S_ISREG(fstat.st_mode)) return(1); if(!fstat.st_size) return(2); if(fstat.st_uid != getuid()) return(3); return(0); } void Quit(void) { int term; char path[PATH_LENGTH + 1]; char *p; term = InputChoise( "quit ytree (Y/N) ?", "YNQq\r\033" ); if( term == 'Y' || term == 'Q' || term == 'q' ) { if (( p = getenv("HOME") )) { sprintf(path, "%s%c%s", p, FILE_SEPARATOR_CHAR, HISTORY_FILENAME); SaveHistory(path); } endwin(); #ifdef XCURSES XCursesExit(); #endif exit( 0 ); } } ytree-1.99pl1/rar.c000066400000000000000000000065341350711670100141620ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/rar.c,v 1.3 2000/06/10 13:15:41 werner Exp $ * * Funktionen zum Lesen des Dateibaumes aus RAR-Dateien * ***************************************************************************/ #include "ytree.h" static int GetStatFromRAR(char *rar_line, char *name, struct stat *stat); /* Dateibaum aus RAR-Listing lesen */ /*---------------------------------*/ int ReadTreeFromRAR(DirEntry *dir_entry, FILE *f) { char rar_line[RAR_LINE_LENGTH + 1]; char path_name[PATH_LENGTH +1]; struct stat stat; BOOL dir_flag = FALSE; *dir_entry->name = '\0'; while( fgets( rar_line, RAR_LINE_LENGTH, f ) != NULL ) { /* \n loeschen */ /*-------------*/ rar_line[ strlen( rar_line ) - 1 ] = '\0'; if( strlen( rar_line ) > (unsigned) 48 && rar_line[48] == ':' ) { /* gueltiger Eintrag */ /*-------------------*/ if( GetStatFromRAR( rar_line, path_name, &stat ) ) { (void) sprintf( message, "unknown rarinfo*%s", rar_line ); MESSAGE( message ); } else { /* File */ /*------*/ #ifdef DEBUG fprintf( stderr, "FILE: \"%s\"\n", path_name ); #endif (void) InsertArchiveFileEntry( dir_entry, path_name, &stat ); } } } if( dir_flag == FALSE ) { statistic.disk_total_directories++; (void) memset( (char *) &dir_entry->stat_struct, 0, sizeof( struct stat ) ); dir_entry->stat_struct.st_mode = S_IFDIR; } return( MinimizeArchiveTree( dir_entry ) ); } static int GetStatFromRAR(char *rar_line, char *name, struct stat *stat) { char *t, *old; int id; struct tm tm_struct; (void) memset( stat, 0, sizeof( struct stat ) ); stat->st_nlink = 1; t = Strtok_r( rar_line, " \t", &old ); if( t == NULL ) return( -1 ); /* Dateiname */ /*-----------*/ (void) strcpy( name, t ); t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); /* Dateilaenge */ /*-------------*/ if( !isdigit( *t ) ) return( -1 ); stat->st_size = AtoLL( t ); t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); /* Packed */ /*--------*/ t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); /* Ratio */ /*-------*/ t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); /* M-Datum */ /*---------*/ if(strlen(t) == 8) { t[2] = t[5] = '\0'; tm_struct.tm_mday = atoi( &t[0] ); tm_struct.tm_mon = atoi( &t[3] ); tm_struct.tm_year = atoi( &t[6] ); if(tm_struct.tm_year < 70) tm_struct.tm_year += 100; } t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); /* M-time */ /*--------*/ if(strlen(t) == 5) { t[2] = '\0'; tm_struct.tm_hour = atoi( &t[0] ); tm_struct.tm_min = atoi( &t[2] ); } tm_struct.tm_sec = 0; tm_struct.tm_isdst = -1; stat->st_atime = 0; stat->st_ctime = 0; stat->st_mtime = Mktime( &tm_struct ); t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); /* Attributes */ /*------------*/ stat->st_mode = S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; /* Owner */ /*-------*/ id = getuid(); if( id == -1 ) id = atoi( t ); stat->st_uid = (unsigned) id; /* Group */ /*-------*/ id = getgid(); stat->st_gid = (unsigned) id; return( 0 ); } ytree-1.99pl1/readtree.c000066400000000000000000000166061350711670100151720ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/readtree.c,v 1.13 2000/07/13 18:26:06 werner Exp $ * * Funktionen zum Lesen des Dateibaumes * ***************************************************************************/ #include "ytree.h" static void UnReadSubTree(DirEntry *dir_entry); /* Dateibaum lesen: path = "Root"-Pfad * dir_entry wird von der Funktion gefuellt */ int ReadTree(DirEntry *dir_entry, char *path, int depth) { DIR *dir; struct stat stat_struct; struct dirent *dirent; char new_path[PATH_LENGTH + 1]; DirEntry first_dir_entry; DirEntry *des_ptr; DirEntry *den_ptr; FileEntry first_file_entry; FileEntry *fes_ptr; FileEntry *fen_ptr; int file_count; /* dir_entry initialisieren */ /*--------------------------*/ dir_entry->file = NULL; /* dir_entry->next = NULL; dir_entry->prev = NULL; */ dir_entry->sub_tree = NULL; dir_entry->total_bytes = 0L; dir_entry->matching_bytes = 0L; dir_entry->tagged_bytes = 0L; dir_entry->total_files = 0; dir_entry->matching_files = 0; dir_entry->tagged_files = 0; dir_entry->access_denied = FALSE; dir_entry->start_file = 0; dir_entry->cursor_pos = 0; dir_entry->global_flag = FALSE; dir_entry->login_flag = FALSE; dir_entry->big_window = FALSE; dir_entry->not_scanned = FALSE; if( S_ISBLK( dir_entry->stat_struct.st_mode ) ) return( 0 ); /* Block-Device */ if( depth < 0 ) { if( dir_entry->up_tree ) { dir_entry->up_tree->not_scanned = TRUE; return( 1 ); } } statistic.disk_total_directories++; if( ( dir = opendir( path ) ) == NULL ) { dir_entry->access_denied = TRUE; return( 1 ); } first_dir_entry.prev = NULL; first_dir_entry.next = NULL; *first_dir_entry.name = '\0'; first_file_entry.next = NULL; fes_ptr = &first_file_entry; file_count = 0; while( ( dirent = readdir( dir ) ) != NULL ) { if( !strcmp( dirent->d_name, "." ) || !strcmp( dirent->d_name, ".." ) ) continue; if( EscapeKeyPressed() ) { Quit(); /* Abfrage ob ytree verlassen werden soll */ } if( ( file_count++ % 100 ) == 0 ) { DisplayDiskStatistic(); doupdate(); } (void) strcpy( new_path, path ); if( strcmp( new_path, FILE_SEPARATOR_STRING ) ) (void) strcat( new_path, FILE_SEPARATOR_STRING ); (void) strcat( new_path, dirent->d_name ); if( STAT_( new_path, &stat_struct ) ) { if( errno == EACCES ) continue; (void) sprintf( message, "Stat failed on*%s*IGNORED", new_path ); ERROR_MSG( message ); continue; } if( S_ISDIR( stat_struct.st_mode ) ) { /* Directory-Entry */ /*-----------------*/ if( ( den_ptr = (DirEntry *) malloc( sizeof( DirEntry ) + strlen( dirent->d_name ) ) ) == NULL ) { ERROR_MSG( "Malloc Failed*ABORT" ); exit( 1 ); } den_ptr->up_tree = dir_entry; (void) strcpy( den_ptr->name, dirent->d_name ); (void) memcpy( &den_ptr->stat_struct, &stat_struct, sizeof( stat_struct ) ); den_ptr->prev = den_ptr->next = NULL; (void) ReadTree( den_ptr, new_path, depth - 1); /* Sortieren durch direktes Einfuegen */ /*------------------------------------*/ for( des_ptr = &first_dir_entry; des_ptr; des_ptr = des_ptr->next ) { if( strcmp( des_ptr->name, den_ptr->name ) > 0 ) { /* des-Element ist groesser */ /*--------------------------*/ den_ptr->next = des_ptr; den_ptr->prev = des_ptr->prev; des_ptr->prev->next = den_ptr; des_ptr->prev = den_ptr; break; } if( des_ptr->next == NULL ) { /* Ende der Liste erreicht; ==> einfuegen */ /*----------------------------------------*/ den_ptr->prev = des_ptr; den_ptr->next = des_ptr->next; des_ptr->next = den_ptr; break; } } } else { /* File-Entry */ /*------------*/ int n; char link_path[PATH_LENGTH + 1]; /* Test, ob Eintrag Symbolischer Link ist */ /*----------------------------------------*/ n = 0; *link_path = '\0'; if( S_ISLNK( stat_struct.st_mode ) ) { /* Ja, symbolischer Name wird an "echten" Namen angehaengt */ /*---------------------------------------------------------*/ if( ( n = readlink( new_path, link_path, sizeof( link_path ) ) ) == -1 ) { (void) strcpy( link_path, "unknown" ); n = strlen( link_path ); } link_path[n] = '\0'; if( ( fen_ptr = (FileEntry *) malloc( sizeof( FileEntry ) + strlen( dirent->d_name ) + n + 1 ) ) == NULL ) { ERROR_MSG( "Malloc Failed*ABORT" ); exit( 1 ); } (void) strcpy( fen_ptr->name, dirent->d_name ); (void) strcpy( &fen_ptr->name[strlen(fen_ptr->name) + 1], link_path ); } else { if( ( fen_ptr = (FileEntry *) malloc( sizeof( FileEntry ) + strlen( dirent->d_name ) ) ) == NULL ) { ERROR_MSG( "Malloc Failed*ABORT" ); exit( 1 ); } (void) strcpy( fen_ptr->name, dirent->d_name ); } fen_ptr->next = NULL; fen_ptr->prev = NULL; fen_ptr->tagged = FALSE; (void) memcpy( &fen_ptr->stat_struct, &stat_struct, sizeof( stat_struct ) ); fen_ptr->dir_entry = dir_entry; fes_ptr->next = fen_ptr; fen_ptr->prev = fes_ptr; fes_ptr = fen_ptr; dir_entry->total_files++; dir_entry->total_bytes += stat_struct.st_size; statistic.disk_total_files++; statistic.disk_total_bytes += stat_struct.st_size; } } (void) closedir( dir ); if( first_file_entry.next ) first_file_entry.next->prev = NULL; if( first_dir_entry.next ) first_dir_entry.next->prev = NULL; dir_entry->file = first_file_entry.next; dir_entry->sub_tree = first_dir_entry.next; DisplayDiskStatistic(); doupdate(); return( 0 ); } void UnReadTree(DirEntry *dir_entry) { FileEntry *fe_ptr, *next_fe_ptr; if( dir_entry == statistic.tree ) { MESSAGE( "Can't delete ROOT" ); } else { for( fe_ptr=dir_entry->file; fe_ptr; fe_ptr=next_fe_ptr ) { next_fe_ptr = fe_ptr->next; RemoveFile( fe_ptr ); } if( dir_entry->sub_tree ) { UnReadSubTree( dir_entry->sub_tree ); } statistic.disk_total_directories--; (void) GetAvailBytes( &statistic.disk_space ); DisplayDiskStatistic(); doupdate(); } } static void UnReadSubTree(DirEntry *dir_entry) { DirEntry *de_ptr, *next_de_ptr; FileEntry *fe_ptr, *next_fe_ptr; for( de_ptr = dir_entry; de_ptr; de_ptr = next_de_ptr ) { next_de_ptr = de_ptr->next; for( fe_ptr=de_ptr->file; fe_ptr; fe_ptr=next_fe_ptr ) { next_fe_ptr = fe_ptr->next; RemoveFile( fe_ptr ); } if( de_ptr->sub_tree ) { UnReadSubTree( de_ptr->sub_tree ); } if( !de_ptr->up_tree->not_scanned ) statistic.disk_total_directories--; if( de_ptr->prev ) de_ptr->prev->next = de_ptr->next; else de_ptr->up_tree->sub_tree = de_ptr->next; if( de_ptr->next ) de_ptr->next->prev = de_ptr->prev; free( de_ptr ); } } ytree-1.99pl1/rename.c000066400000000000000000000170531350711670100146430ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/rename.c,v 1.14 2014/12/26 09:53:11 werner Exp $ * * Umbenennen von Dateien/Verzeichnissen * ***************************************************************************/ #include "ytree.h" static int RenameDirEntry(char *to_path, char *from_path); static int RenameFileEntry(char *to_path, char *from_path); int RenameDirectory(DirEntry *de_ptr, char *new_name) { DirEntry *den_ptr; DirEntry *sde_ptr; DirEntry *ude_ptr; FileEntry *fe_ptr; char from_path[PATH_LENGTH+1]; char to_path[PATH_LENGTH+1]; struct stat stat_struct; int result; char *cptr; result = -1; (void) GetPath( de_ptr, from_path ); (void) strcpy( to_path, from_path ); cptr = strrchr( to_path, '/' ); if( !cptr ) { (void) sprintf( message, "Invalid Path!*\"%s\"", to_path ); WARNING( message ); ESCAPE; } if( cptr == to_path ) { MESSAGE( "Can't rename ROOT" ); ESCAPE; } (void) strcpy( cptr + 1, new_name ); if( access( from_path, W_OK ) ) { (void) sprintf( message, "Rename not possible!*\"%s\"*%s", from_path, strerror(errno) ); MESSAGE( message ); ESCAPE; } if( !RenameDirEntry( to_path, from_path ) ) { /* Rename erfolgreich */ /*--------------------*/ if( STAT_( to_path, &stat_struct ) ) { ERROR_MSG( "Stat Failed*ABORT" ); exit( 1 ); } if( ( den_ptr = (DirEntry *) malloc( sizeof( DirEntry ) + strlen( new_name ) ) ) == NULL ) { ERROR_MSG( "Malloc Failed*ABORT" ); exit( 1 ); } (void) memcpy( den_ptr, de_ptr, sizeof( DirEntry ) ); (void) strcpy( den_ptr->name, new_name ); (void) memcpy( &den_ptr->stat_struct, &stat_struct, sizeof( stat_struct ) ); /* Struktur einklinken */ /*---------------------*/ if( den_ptr->prev ) den_ptr->prev->next = den_ptr; if( den_ptr->next ) den_ptr->next->prev = den_ptr; /* Subtree */ /*---------*/ for( sde_ptr=den_ptr->sub_tree; sde_ptr; sde_ptr = sde_ptr->next ) sde_ptr->up_tree = den_ptr; /* Files */ /*-------*/ for( fe_ptr=den_ptr->file; fe_ptr; fe_ptr=fe_ptr->next ) fe_ptr->dir_entry = den_ptr; /* Uptree */ /*--------*/ for( ude_ptr=den_ptr->up_tree; ude_ptr; ude_ptr = ude_ptr->next ) if( ude_ptr->sub_tree == de_ptr ) ude_ptr->sub_tree = den_ptr; /* Alte Struktur freigeben */ /*-------------------------*/ free( de_ptr ); /* Achtung: de_ptr ist ab jetzt ungueltig !!! */ /*--------------------------------------------*/ result = 0; } FNC_XIT: move( LINES - 2, 1 ); clrtoeol(); return( result ); } int RenameFile(FileEntry *fe_ptr, char *new_name, FileEntry **new_fe_ptr ) { DirEntry *de_ptr; FileEntry *fen_ptr; char from_path[PATH_LENGTH+1]; char to_path[PATH_LENGTH+1]; struct stat stat_struct; int result; result = -1; *new_fe_ptr = fe_ptr; de_ptr = fe_ptr->dir_entry; (void) GetFileNamePath( fe_ptr, from_path ); (void) GetPath( de_ptr, to_path ); (void) strcat( to_path, FILE_SEPARATOR_STRING ); (void) strcat( to_path, new_name ); if( access( from_path, W_OK ) ) { (void) sprintf( message, "Rename not possible!*\"%s\"*%s", from_path, strerror(errno) ); MESSAGE( message ); ESCAPE; } if( !RenameFileEntry( to_path, from_path ) ) { /* Rename erfolgreich */ /*--------------------*/ if( STAT_( to_path, &stat_struct ) ) { ERROR_MSG( "Stat Failed*ABORT" ); exit( 1 ); } if( ( fen_ptr = (FileEntry *) malloc( sizeof( FileEntry ) + strlen( new_name ) ) ) == NULL ) { ERROR_MSG( "Malloc Failed*ABORT" ); exit( 1 ); } (void) memcpy( fen_ptr, fe_ptr, sizeof( FileEntry ) ); (void) strcpy( fen_ptr->name, new_name ); (void) memcpy( &fen_ptr->stat_struct, &stat_struct, sizeof( stat_struct ) ); /* Struktur einklinken */ /*---------------------*/ if( fen_ptr->prev ) fen_ptr->prev->next = fen_ptr; if( fen_ptr->next ) fen_ptr->next->prev = fen_ptr; if( fen_ptr->dir_entry->file == fe_ptr ) fen_ptr->dir_entry->file = fen_ptr; /* Alte Struktur freigeben */ /*-------------------------*/ free( fe_ptr ); /* Achtung: fe_ptr ist ab jetzt ungueltig !!! */ /*--------------------------------------------*/ result = 0; *new_fe_ptr = fen_ptr; } FNC_XIT: move( LINES - 2, 1 ); clrtoeol(); return( result ); } int GetRenameParameter(char *old_name, char *new_name) { int l; if( mode != DISK_MODE && mode != USER_MODE ) { beep(); return( -1 ); } ClearHelp(); if( old_name == NULL ) { MvAddStr( LINES - 2, 1, "RENAME TAGGED FILES TO:" ); l = 25; } else { MvAddStr( LINES - 2, 1, "RENAME TO:" ); l = 13; } (void) strcpy( new_name, (old_name) ? old_name : "*" ); if( InputString(new_name, LINES - 2, l, 0, COLS - l - 1, "\r\033" ) != CR) return( -1 ); if(!strlen(new_name)) return( -1 ); if(!strcmp(old_name, new_name)) { MESSAGE("Can't rename: New name same as old name."); return( -1 ); } if(strrchr(new_name, FILE_SEPARATOR_CHAR) != NULL) { MESSAGE("Invalid new name:*No slashes when renaming!"); return( -1 ); } return( 0 ); } static int RenameDirEntry(char *to_path, char *from_path) { struct stat fdstat; if( !strcmp( to_path, from_path ) ) { MESSAGE( "Can't rename directory:*New Name == Old Name" ); return( 0 ); } if( stat( to_path, &fdstat ) == 0 ) { MESSAGE( "Can't rename directory:*Destination object already exist!" ); return( -1 ); } #ifdef HAVE_RENAME if( rename( from_path, to_path ) ) { (void) sprintf( message, "Can't rename \"%s\"*to \"%s\"*%s", from_path, to_path, strerror(errno) ); MESSAGE( message ); return( -1 ); } #else if( link( from_path, to_path ) ) { (void) sprintf( message, "Can't link \"%s\"*to \"%s\"*%s", from_path, to_path, strerror(errno) ); MESSAGE( message ); return( -1 ); } if( unlink( from_path ) ) { (void) sprintf( message, "Can't unlink*\"%s\"*%s", from_path, strerror(errno) ); MESSAGE( message ); return( -1 ); } #endif return( 0 ); } static int RenameFileEntry(char *to_path, char *from_path) { if( !strcmp( to_path, from_path ) ) { MESSAGE( "Can't rename!*New Name == Old Name" ); return( -1 ); } if( link( from_path, to_path ) ) { (void) sprintf( message, "Can't link \"%s\"*to \"%s\"*%s", from_path, to_path, strerror(errno) ); MESSAGE( message ); return( -1 ); } if( unlink( from_path ) ) { (void) sprintf( message, "Can't unlink*\"%s\"*%s", from_path, strerror(errno) ); MESSAGE( message ); return( -1 ); } return( 0 ); } int RenameTaggedFiles(FileEntry *fe_ptr, WalkingPackage *walking_package) { int result = -1; char new_name[PATH_LENGTH+1]; if( BuildFilename( fe_ptr->name, walking_package->function_data.rename.new_name, new_name ) == 0 ) { if( *new_name == '\0' ) { MESSAGE( "Can't rename file to*empty name" ); } else { result = RenameFile( fe_ptr, new_name, &walking_package->new_fe_ptr ); } } return( result ); } ytree-1.99pl1/rmdir.c000066400000000000000000000067241350711670100145140ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/rmdir.c,v 1.11 2001/06/15 16:36:36 werner Exp $ * * Loeschen von Verzeichnissen * ***************************************************************************/ #include "ytree.h" static int DeleteSubTree(DirEntry *dir_entry); static int DeleteSingleDirectory(DirEntry *dir_entry); int DeleteDirectory(DirEntry *dir_entry) { char buffer[PATH_LENGTH+1]; int result = -1; if( mode != DISK_MODE && mode != USER_MODE ) { beep(); return( result ); } ClearHelp(); if( dir_entry == statistic.tree ) { MESSAGE( "Can't delete ROOT" ); } else if( dir_entry->file || dir_entry->sub_tree ) { if( InputChoise( "Directory not empty, PRUNE ? (Y/N) ? ", "YN\033" ) == 'Y' ) { if( dir_entry->sub_tree ) { if( ScanSubTree( dir_entry ) ) { ESCAPE; } if( DeleteSubTree( dir_entry->sub_tree ) ) { ESCAPE; } } if( DeleteSingleDirectory( dir_entry ) ) { ESCAPE; } result = 0; ESCAPE; } } else if( InputChoise( "Delete this directory (Y/N) ? ", "YN\033" ) == 'Y' ) { (void) GetPath( dir_entry, buffer ); if( access( buffer, W_OK ) ) { (void) sprintf( message, "Can't delete directory*\"%s\"*%s", buffer, strerror(errno) ); MESSAGE( message ); } else if( rmdir( buffer ) ) { (void) sprintf( message, "Can't delete directory*\"%s\"*%s", buffer, strerror(errno) ); MESSAGE( message ); } else { /* Directory geloescht * ==> aus Baum loeschen */ statistic.disk_total_directories--; if( dir_entry->prev ) dir_entry->prev->next = dir_entry->next; else dir_entry->up_tree->sub_tree = dir_entry->next; if( dir_entry->next ) dir_entry->next->prev = dir_entry->prev; free( dir_entry ); (void) GetAvailBytes( &statistic.disk_space ); result = 0; } } FNC_XIT: return( result ); } static int DeleteSubTree( DirEntry *dir_entry ) { int result = -1; DirEntry *de_ptr, *next_de_ptr; for( de_ptr = dir_entry; de_ptr; de_ptr = next_de_ptr ) { next_de_ptr = de_ptr->next; if( de_ptr->sub_tree ) { if( DeleteSubTree( de_ptr->sub_tree ) ) { ESCAPE; } } if( DeleteSingleDirectory( de_ptr ) ) { ESCAPE; } } result = 0; FNC_XIT: return( result ); } static int DeleteSingleDirectory( DirEntry *dir_entry ) { int result = -1; char buffer[PATH_LENGTH+1]; FileEntry *fe_ptr, *next_fe_ptr; (void) GetPath( dir_entry, buffer ); if( access( buffer, W_OK ) ) { (void) sprintf( message, "Can't delete directory*\"%s\"*%s", buffer, strerror(errno) ); MESSAGE( message ); ESCAPE; } for( fe_ptr = dir_entry->file; fe_ptr; fe_ptr=next_fe_ptr ) { next_fe_ptr = fe_ptr->next; if( DeleteFile( fe_ptr ) ) { ESCAPE; } } if( rmdir( buffer ) ) { (void) sprintf( message, "Can't delete directory*\"%s\"*%s", buffer, strerror(errno) ); MESSAGE( message ); ESCAPE; } if( !dir_entry->up_tree->not_scanned ) statistic.disk_total_directories--; if( dir_entry->prev ) dir_entry->prev->next = dir_entry->next; else dir_entry->up_tree->sub_tree = dir_entry->next; if( dir_entry->next ) dir_entry->next->prev = dir_entry->prev; free( dir_entry ); result = 0; FNC_XIT: return( result ); } ytree-1.99pl1/rpm.c000066400000000000000000000066121350711670100141710ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/rpm.c,v 1.3 2000/05/20 20:41:11 werner Exp $ * * Read RPM-Files * Currently no extraction supported * ***************************************************************************/ #include "ytree.h" static int GetStatFromRPM(char *rpm_line, char *name, struct stat *stat); /* Dateibaum aus RPM-Listing lesen */ /*---------------------------------*/ int ReadTreeFromRPM(DirEntry *dir_entry, FILE *f) { char rpm_line[RPM_LINE_LENGTH + 1]; char path_name[PATH_LENGTH +1]; struct stat stat; BOOL dir_flag = FALSE; *dir_entry->name = '\0'; while( fgets( rpm_line, RPM_LINE_LENGTH, f ) != NULL ) { /* \n loeschen */ /*-------------*/ rpm_line[ strlen( rpm_line ) - 1 ] = '\0'; if( GetStatFromRPM( rpm_line, path_name, &stat ) ) { (void) sprintf( message, "unknown rpminfo*%s", rpm_line ); MESSAGE( message ); } else { if( (path_name[strlen( path_name ) - 1] == FILE_SEPARATOR_CHAR) || !strcmp( path_name, "." ) || S_ISDIR(stat.st_mode) ) { /* Directory */ /*-----------*/ #ifdef DEBUG fprintf( stderr, "DIR: %s\n", path_name ); #endif if( strcmp( path_name, "./" ) ) { /* "./" wird ignoriert */ /*---------------------*/ (void) TryInsertArchiveDirEntry( dir_entry, path_name, &stat ); DisplayDiskStatistic(); doupdate(); } } else { /* File */ /*------*/ #ifdef DEBUG fprintf( stderr, "FILE: \"%s\"\n", path_name ); #endif (void) InsertArchiveFileEntry( dir_entry, path_name, &stat ); } } } if( dir_flag == FALSE ) { statistic.disk_total_directories++; (void) memset( (char *) &dir_entry->stat_struct, 0, sizeof( struct stat ) ); dir_entry->stat_struct.st_mode = S_IFDIR; } return( MinimizeArchiveTree( dir_entry ) ); } static int GetStatFromRPM(char *rpm_line, char *name, struct stat *stat) { char *t, *old; int id; (void) memset( stat, 0, sizeof( struct stat ) ); stat->st_nlink = 1; t = Strtok_r( rpm_line, " \t", &old ); if( t == NULL ) return( -1 ); /* Dateiname */ /*-----------*/ (void) strcpy( name, t ); t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); /* Dateilaenge */ /*-------------*/ if( !isdigit( *t ) ) return( -1 ); stat->st_size = AtoLL( t ); t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); /* M-Datum */ /*---------*/ stat->st_atime = 0; stat->st_ctime = 0; stat->st_mtime = atoi( t ); t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); /* M5 */ if(strlen(t) > 20) { t = Strtok_r( NULL, " \t/", &old ); if( t == NULL ) return( -1 ); } /* Attribute */ /*-----------*/ stat->st_mode = strtoul(t, NULL, 8); t = Strtok_r( NULL, " \t/", &old ); if( t == NULL ) return( -1 ); /* Owner */ /*-------*/ id = GetPasswdUid( t ); if( id == -1 ) id = atoi( t ); stat->st_uid = (unsigned) id; t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); /* Group */ /*-------*/ id = GetGroupId( t ); if( id == -1 ) id = atoi( t ); stat->st_gid = (unsigned) id; if( S_ISLNK( stat->st_mode ) ) { /* Symbolischer Link */ /*-------------------*/ t = "symlink"; (void) strcpy( &name[ strlen( name ) + 1 ], t ); } return( 0 ); } ytree-1.99pl1/sort.c000066400000000000000000000043061350711670100143600ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/sort.c,v 1.11 2001/04/16 13:34:26 werner Exp $ * * Umschalten des Sortierkriteriums * ***************************************************************************/ #include "ytree.h" void GetKindOfSort(void) { int c; int s; int order; order = SORT_ASC; s=0; ClearHelp(); PrintOptions( stdscr, LINES - 2, 1, "Sort by (A)ccTime (C)hgTime (E)xtension (G)roup (M)odTime (O)rder: [ascending]" ); PrintOptions( stdscr, LINES - 1, 2, " (N)ame o(W)ner (S)ize" ); RefreshWindow( stdscr ); doupdate(); do { c = Getch(); if(c == -1 || c == ESC) return; c = toupper(c); if (c == 'Q') return; switch( c ) { case 'N': s = SORT_BY_NAME; break; case 'E': s = SORT_BY_EXTENSION; break; case 'M': s = SORT_BY_MOD_TIME; break; case 'A': s = SORT_BY_ACC_TIME; break; case 'C': s = SORT_BY_CHG_TIME; break; case 'G': s = SORT_BY_GROUP; break; case 'W': s = SORT_BY_OWNER; break; case 'S': s = SORT_BY_SIZE; break; case 'O': if (order == SORT_ASC) { PrintOptions( stdscr, LINES - 2, 58, "[descending]" ); order = SORT_DSC; } else { PrintOptions( stdscr, LINES - 2, 58, "[ascending] " ); order = SORT_ASC; } RefreshWindow( stdscr ); doupdate(); break; default : beep(); RefreshWindow( stdscr ); doupdate(); break; } } while( ! strchr("ACEGMNWS", c)); SetKindOfSort(s + order); } ytree-1.99pl1/stat.c000066400000000000000000000151111350711670100143400ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/stat.c,v 1.19 2016/09/04 14:41:12 werner Exp $ * * Statistik-Modul * ***************************************************************************/ #include "ytree.h" static void PrettyPrintNumber(int y, int x, LONGLONG number); void DisplayDiskStatistic(void) { const char *fmt= "[%-17s]"; char buff[20]; *buff = '\0'; sprintf( buff, fmt, statistic.file_spec); PrintMenuOptions( stdscr, 2, COLS - 18, buff, MENU_COLOR, HIMENUS_COLOR); PrettyPrintNumber( 5, COLS - 17, statistic.disk_space / (LONGLONG)1024 ); PrintOptions( stdscr, 7, COLS - 24, "[DISK Statistics ]" ); PrettyPrintNumber( 9, COLS - 17, statistic.disk_total_files ); PrettyPrintNumber( 10, COLS - 17, statistic.disk_total_bytes ); PrettyPrintNumber( 12, COLS - 17, statistic.disk_matching_files ); PrettyPrintNumber( 13, COLS - 17, statistic.disk_matching_bytes ); PrettyPrintNumber( 15, COLS - 17, statistic.disk_tagged_files ); PrettyPrintNumber( 16, COLS - 17, statistic.disk_tagged_bytes ); PrintOptions( stdscr, 17, COLS - 24, "[Current Directory ]"); DisplayDiskName(); return; } void DisplayAvailBytes(void) { PrettyPrintNumber( 5, COLS - 17, statistic.disk_space / (LONGLONG)1024 ); RefreshWindow( stdscr ); } void DisplayFileSpec(void) { mvwprintw( stdscr, 2, COLS - 18, "%-17s", statistic.file_spec ); RefreshWindow( stdscr ); } void DisplayDiskName(void) { const char *fmt= "[%-17s]"; char buff[20]; sprintf( buff, fmt, statistic.disk_name); PrintMenuOptions( stdscr, 4, COLS - 18, buff, MENU_COLOR, HIMENUS_COLOR); RefreshWindow( stdscr ); } void DisplayDirStatistic(DirEntry *dir_entry) { char format[10]; char buffer[PATH_LENGTH + 1]; char auxbuff[PATH_LENGTH + 1]; *auxbuff = *buffer = '\0'; (void) sprintf( format, "%%-%ds", COLS - 10 ); (void) GetPath( dir_entry, statistic.path ); if (dir_entry -> not_scanned) strcat(statistic.path,"*"); sprintf(auxbuff, format, FormFilename( buffer, statistic.path, COLS - 10 )); wmove( stdscr, 0, 6); wclrtoeol( stdscr); Print( stdscr, 0, 6, auxbuff, HIMENUS_COLOR); PrintOptions( stdscr, 7, COLS - 24, "[DIR Statistics ]" ); PrettyPrintNumber( 9, COLS - 17, dir_entry->total_files ); PrettyPrintNumber( 10, COLS - 17, dir_entry->total_bytes ); PrettyPrintNumber( 12, COLS - 17, dir_entry->matching_files ); PrettyPrintNumber( 13, COLS - 17, dir_entry->matching_bytes ); PrettyPrintNumber( 15, COLS - 17, dir_entry->tagged_files ); PrettyPrintNumber( 16, COLS - 17, dir_entry->tagged_bytes ); PrintOptions( stdscr, 17, COLS - 24, "[Current File ]" ); RefreshWindow( stdscr ); return; } void DisplayDirTagged(DirEntry *dir_entry) { PrettyPrintNumber( 15, COLS - 17, dir_entry->tagged_files ); PrettyPrintNumber( 16, COLS - 17, dir_entry->tagged_bytes ); RefreshWindow( stdscr ); } void DisplayDiskTagged(void) { PrettyPrintNumber( 15, COLS - 17, statistic.disk_tagged_files ); PrettyPrintNumber( 16, COLS - 17, statistic.disk_tagged_bytes ); RefreshWindow( stdscr ); } void DisplayDirParameter(DirEntry *dir_entry) { char *p, *f; char format[10]; char buffer[PATH_LENGTH + 1]; char auxbuff[PATH_LENGTH + 1]; p = strrchr( dir_entry->name, FILE_SEPARATOR_CHAR ); if( p == NULL ) f = dir_entry->name; else f = p + 1; (void) sprintf( format, "%%-%ds", COLS - 10 ); (void) GetPath( dir_entry, statistic.path ); if (dir_entry -> not_scanned) strcat(statistic.path,"*"); sprintf(auxbuff, format, FormFilename(buffer,statistic.path, COLS-10)); wmove( stdscr, 0, 6); wclrtoeol( stdscr); Print( stdscr, 0, 6, auxbuff, HIMENUS_COLOR); *auxbuff = '\0'; sprintf(auxbuff, "[%-20s]", CutFilename(buffer, f, 20)); PrintMenuOptions( stdscr, 18, COLS - 22, auxbuff, MENU_COLOR, HIMENUS_COLOR); PrettyPrintNumber( 19, COLS - 17, (LONGLONG) dir_entry->total_bytes ); RefreshWindow( stdscr ); } void DisplayGlobalFileParameter(FileEntry *file_entry) { char buffer1[PATH_LENGTH+1]; char buffer2[PATH_LENGTH+1]; char format[10]; (void) sprintf( format, "[%%-%ds]", COLS - 10 ); (void) GetPath( file_entry->dir_entry, buffer1 ); FormFilename( buffer2, buffer1, COLS - 10 ); sprintf(buffer1, format, buffer2); wmove( stdscr, 0, 6); wclrtoeol( stdscr); PrintMenuOptions( stdscr, 0, 6, buffer1, GLOBAL_COLOR, HIGLOBAL_COLOR); CutFilename( buffer1, file_entry->name, 20 ); sprintf( buffer2, "[%-20s]", buffer1 ); PrintMenuOptions( stdscr, 18, COLS - 22, buffer2, GLOBAL_COLOR, HIGLOBAL_COLOR); PrettyPrintNumber( 19, COLS - 17, (LONGLONG) file_entry->stat_struct.st_size ); RefreshWindow( stdscr ); } void DisplayFileParameter(FileEntry *file_entry) { char buffer[21*6]; char auxbuff[23*6]; sprintf( auxbuff, "[%-20s]", CutFilename( buffer, file_entry->name, 20 ) ); PrintMenuOptions( stdscr, 18, COLS - 22, auxbuff, MENU_COLOR, HIMENUS_COLOR); PrettyPrintNumber( 19, COLS - 17, (LONGLONG)file_entry->stat_struct.st_size ); RefreshWindow( stdscr ); } void PrettyPrintNumber(int y, int x, LONGLONG number) { char buffer[20]; long terra, giga, mega, kilo, one; *buffer = 0; terra = (long) ( number / (LONGLONG) 1000000000000 ); giga = (long) ( ( number % (LONGLONG) 1000000000000 ) / (LONGLONG) 1000000000 ); mega = (long) ( ( number % (LONGLONG) 1000000000 ) / (LONGLONG) 1000000 ); kilo = (long) ( ( number % (LONGLONG) 1000000 ) / (LONGLONG) 1000 ); one = (long) ( number % (LONGLONG) 1000 ); if( terra ){ /* "123123123123123" */ sprintf( buffer, "[%3ld%3ld%03ld%03ld%03ld]", terra, giga, mega, kilo, one ); PrintMenuOptions( stdscr, y, x, buffer, MENU_COLOR, HIMENUS_COLOR); } if( giga ){ /* "123,123,123,123" */ sprintf( buffer, "[%3ld%c%03ld%c%03ld%c%03ld]", giga, number_seperator, mega, number_seperator, kilo, number_seperator, one ); PrintMenuOptions( stdscr, y, x, buffer, MENU_COLOR, HIMENUS_COLOR); } else if( mega ) { /* " 123,123,123" */ sprintf( buffer, "[ %3ld%c%03ld%c%03ld]", mega, number_seperator, kilo, number_seperator, one ); PrintMenuOptions( stdscr, y, x, buffer, MENU_COLOR, HIMENUS_COLOR); } else if( kilo ) { /* " 123,123" */ sprintf( buffer, "[ %3ld%c%03ld]", kilo, number_seperator, one); PrintMenuOptions( stdscr, y, x, buffer, MENU_COLOR, HIMENUS_COLOR); } else { /* " 123" */ sprintf( buffer, "[ %3ld]", one); PrintMenuOptions( stdscr, y, x, buffer, MENU_COLOR, HIMENUS_COLOR); } return; } ytree-1.99pl1/system.c000066400000000000000000000033221350711670100147120ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/system.c,v 1.12 2008/07/26 14:29:30 werner Exp $ * * System Call * ***************************************************************************/ #include "ytree.h" int SystemCall(char *command_line) { int result; #ifndef XCURSES endwin(); #endif result = SilentSystemCall( command_line ); (void) GetAvailBytes( &statistic.disk_space ); refresh(); return( result ); } int QuerySystemCall(char *command_line) { int result; #ifndef XCURSES endwin(); #endif result = SilentSystemCall( command_line ); HitReturnToContinue(); (void) GetAvailBytes( &statistic.disk_space ); refresh(); return( result ); } extern struct itimerval value, ovalue; int SilentSystemCall(char *command_line) { return(SilentSystemCallEx(command_line, TRUE)); } int SilentSystemCallEx(char *command_line, BOOL enable_clock) { int result; #ifdef XCURSES char *xterm=NULL; #endif /* Hier ist die einzige Stelle, in der Kommandos aufgerufen werden! */ #if defined( __NeXT__ ) nl(); #endif /* linux */ SuspendClock(); #ifdef XCURSES if( ( xterm = malloc( strlen( command_line ) + 10 ) ) == NULL ) { ERROR_MSG( "Malloc Failed*ABORT" ); exit( 1 ); } sprintf(xterm, "xterm -e %s &", command_line); result = system( xterm ); free(xterm); #else result = system( command_line ); #endif #ifndef XCURSES leaveok(stdscr, TRUE); curs_set(0); #if defined( __NeXT__ ) cbreak(); nonl(); noecho(); clearok( stdscr, TRUE ); #endif /* linux */ #endif /* XCURSES */ if(enable_clock) InitClock(); (void) GetAvailBytes( &statistic.disk_space ); return( result ); } ytree-1.99pl1/tar.c000066400000000000000000000111701350711670100141540ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/tar.c,v 1.11 2000/05/20 20:41:11 werner Exp $ * * Funktionen zum Lesen des Dateibaumes aus TAR-Dateien * ***************************************************************************/ #include "ytree.h" static int GetStatFromTAR(char *tar_line, char *name, struct stat *stat); /* Dateibaum aus TAR-Listing lesen */ /*---------------------------------*/ int ReadTreeFromTAR(DirEntry *dir_entry, FILE *f) { char tar_line[TAR_LINE_LENGTH + 1]; char path_name[PATH_LENGTH +1]; struct stat stat; BOOL dir_flag = FALSE; *dir_entry->name = '\0'; while( fgets( tar_line, TAR_LINE_LENGTH, f ) != NULL ) { /* \n loeschen */ /*-------------*/ tar_line[ strlen( tar_line ) - 1 ] = '\0'; if( GetStatFromTAR( tar_line, path_name, &stat ) ) { (void) sprintf( message, "unknown tarinfo*%s", tar_line ); MESSAGE( message ); } else { if( (path_name[strlen( path_name ) - 1] == FILE_SEPARATOR_CHAR) || !strcmp( path_name, "." ) || *tar_line == 'd' ) { /* Directory */ /*-----------*/ #ifdef DEBUG fprintf( stderr, "DIR: %s\n", path_name ); #endif if( strcmp( path_name, "./" ) ) { /* "./" wird ignoriert */ /*---------------------*/ (void) TryInsertArchiveDirEntry( dir_entry, path_name, &stat ); DisplayDiskStatistic(); doupdate(); } } else { /* File */ /*------*/ #ifdef DEBUG fprintf( stderr, "FILE: \"%s\"\n", path_name ); #endif (void) InsertArchiveFileEntry( dir_entry, path_name, &stat ); } } } if( dir_flag == FALSE ) { statistic.disk_total_directories++; (void) memset( (char *) &dir_entry->stat_struct, 0, sizeof( struct stat ) ); dir_entry->stat_struct.st_mode = S_IFDIR; } return( MinimizeArchiveTree( dir_entry ) ); } static int GetStatFromTAR(char *tar_line, char *name, struct stat *stat) { char *t, *old; int i, id; struct tm tm_struct; static char *month[] = { "Jan", "Feb", "Mar", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; (void) memset( stat, 0, sizeof( struct stat ) ); stat->st_nlink = 1; t = Strtok_r( tar_line, " \t", &old ); if( t == NULL ) return( -1 ); /* Attribute */ /*-----------*/ if( strlen( t ) != 10 ) return( -1 ); stat->st_mode = GetModus( t ); t = Strtok_r( NULL, " \t/", &old ); if( t == NULL ) return( -1 ); /* Owner */ /*-------*/ id = GetPasswdUid( t ); if( id == -1 ) id = atoi( t ); stat->st_uid = (unsigned) id; t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); /* Group */ /*-------*/ id = GetGroupId( t ); if( id == -1 ) id = atoi( t ); stat->st_gid = (unsigned) id; t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); /* Dateilaenge */ /*-------------*/ if( !isdigit( *t ) ) return( -1 ); stat->st_size = AtoLL( t ); t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); /* M-Datum */ /*---------*/ for( i=0; i < 12; i++ ) { if( !strcmp( t, month[i] ) ) break; } if( i >= 12 ) { t[4] = t[7] = '\0'; tm_struct.tm_year = atoi(t) - 1900; tm_struct.tm_mon = atoi(&t[5]) - 1; tm_struct.tm_mday = atoi(&t[8]); t = Strtok_r( NULL, " \t:", &old ); if( t == NULL ) return( -1 ); tm_struct.tm_hour = atoi( t ); t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); tm_struct.tm_min = atoi( t ); t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); goto XDATE; } tm_struct.tm_mon = i; t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); tm_struct.tm_mday = atoi( t ); t = Strtok_r( NULL, " \t:", &old ); if( t == NULL ) return( -1 ); tm_struct.tm_hour = atoi( t ); t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); tm_struct.tm_min = atoi( t ); t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); tm_struct.tm_year = atoi( t ) - 1900; t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); XDATE: tm_struct.tm_sec = 0; tm_struct.tm_isdst = -1; stat->st_atime = 0; stat->st_ctime = 0; stat->st_mtime = Mktime( &tm_struct ); /* Dateiname */ /*-----------*/ (void) strcpy( name, t ); if( S_ISLNK( stat->st_mode ) ) { /* Symbolischer Link */ /*-------------------*/ t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); (void) strcpy( &name[ strlen( name ) + 1 ], t ); } return( 0 ); } ytree-1.99pl1/termcap.c000066400000000000000000000103351350711670100150230ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/termcap.c,v 1.9 1997/08/13 12:24:58 werner Rel $ * * Termcap Term-I/O * ***************************************************************************/ #include "ytree.h" #ifdef TERMCAP #ifdef __NeXT__ char tcdummy[256], tcbuf[1024]; char *tcdptr = tcdummy; #else # define tcbuf NULL # define tcdummy NULL #endif /* __NeXT__ */ #undef wgetch #undef initscr #undef endwin typedef struct { int key_code; char *termcap_name; char *key_sequence; } SpecialKey; static SpecialKey special_key[] = { { KEY_BTAB, "kB", NULL }, { KEY_DOWN, "kd", NULL }, { KEY_UP, "ku", NULL }, { KEY_LEFT, "kl", NULL }, { KEY_RIGHT, "kr", NULL }, { KEY_END, "kH", NULL }, { KEY_HOME, "kh", NULL }, { KEY_NPAGE, "kN", NULL }, { KEY_PPAGE, "kP", NULL }, { KEY_DC, "kD", NULL }, { KEY_BACKSPACE, "kb", NULL }, { KEY_EIC, "kM", NULL }, { KEY_IC, "kI", NULL }, { KEY_DL, "kL", NULL }, { -1, NULL, NULL } }; static int TermcapMultiByte( WINDOW *win, int ch ); static void SigAlarm( int signo ); static jmp_buf env_alarm; static char *reverse; static char *normal; void TermcapVidattr( int attr ) { if( normal && reverse ) { if( attr == 0 ) putp( normal ); else { if( attr & A_REVERSE ) putp( reverse ); } } } int TermcapWgetch( WINDOW *win ) { int ch; SpecialKey *sk_ptr; BOOL one_matched = FALSE; int i; ch = wgetch( stdscr ); for( i=0, sk_ptr = special_key; sk_ptr->key_code > 0; sk_ptr = &special_key[++i] ) { /* Ein-Byte Codes ausblenden */ /*---------------------------*/ if( sk_ptr->key_sequence && *(sk_ptr->key_sequence) == ch ) { /* Erstes Zeichen matched */ /*------------------------*/ if( sk_ptr->key_sequence[1] == '\0' ) { /* 1 Byte-Code */ /*-------------*/ ch = sk_ptr->key_code; break; } one_matched = TRUE; } } if( one_matched ) { /* Multi-Byte Code */ /*-----------------*/ ch = TermcapMultiByte( win, ch ); } return( ch ); } static int TermcapMultiByte( WINDOW *win, int ch ) { SpecialKey *sk_ptr; char buffer[80]; BOOL found; int i, j; memset( buffer, 0, sizeof( buffer ) ); *buffer = ch; if( signal( SIGALRM, SigAlarm ) == SIG_ERR ) { ERROR_MSG( "signal SIGALRM failed*ABORT" ); exit( 1 ); } if( setjmp( env_alarm ) ) { return( ch ); } alarm( 1 ); for( j=1, found = FALSE; !found && j < sizeof( buffer ); j++ ) { buffer[j] = wgetch( win ); for( i=0, sk_ptr = special_key; sk_ptr->key_code > 0; sk_ptr = &special_key[++i] ) { if( sk_ptr->key_sequence && !strcmp( sk_ptr->key_sequence, buffer ) ) { ch = sk_ptr->key_code; found = TRUE; break; } } } alarm( 0 ); return( ch ); } static void SigAlarm( int signo ) { longjmp( env_alarm, 1 ); } void TermcapInitscr() { int i; initscr(); tgetent( tcbuf, getenv( "TERM" ) ); for( i=0; special_key[i].key_code > 0; i++ ) { #ifdef __NeXT__ tcdptr = tcdummy; special_key[i].key_sequence = Strdup(tgetstr( special_key[i].termcap_name, &tcdptr )); #else special_key[i].key_sequence = tgetstr( special_key[i].termcap_name, NULL ); #endif } #ifdef __NeXT__ reverse = Strdup(tgetstr( "so", &tcdptr )); normal = Strdup(tgetstr( "se", &tcdptr )); #else reverse = tgetstr( "so", tcdummy ); normal = tgetstr( "se", tcdummy ); #endif } void TermcapEndwin() { nl(); endwin(); putchar( '\n' ); } #endif /* TERMCAP */ ytree-1.99pl1/tilde.c000066400000000000000000000222751350711670100144770ustar00rootroot00000000000000/* tilde.c -- Tilde expansion code (~/foo := $HOME/foo). */ /* Copyright (C) 1988,1989 Free Software Foundation, Inc. This file is part of GNU Readline, a library for reading lines of text with interactive input and history editing. Readline is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. Readline is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Readline; see the file COPYING. If not, write to the Free Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ #ifdef READLINE_SUPPORT #include "ytree.h" #include "tilde.h" #include "xmalloc.h" /*#include */ /*#if !defined (HAVE_GETPW_DECLS) extern struct passwd *getpwuid(uid_t); extern struct passwd *getpwnam(const char *); #endif */ /* !HAVE_GETPW_DECLS */ #if !defined (savestring) # ifndef strcpy extern char *strcpy (); # endif #define savestring(x) strcpy ((char *)xmalloc (1 + strlen (x)), (x)) #endif /* !savestring */ #if !defined (NULL) # if defined (__STDC__) # define NULL ((void *) 0) # else # define NULL 0x0 # endif /* !__STDC__ */ #endif /* !NULL */ /* If being compiled as part of bash, these will be satisfied from variables.o. If being compiled as part of readline, they will be satisfied from shell.o. */ extern char *sh_get_home_dir(void); extern char *sh_get_env_value(const char *); /* The default value of tilde_additional_prefixes. This is set to whitespace preceding a tilde so that simple programs which do not perform any word separation get desired behaviour. */ static const char *default_prefixes[] = { " ~", "\t~", (const char *)NULL }; /* The default value of tilde_additional_suffixes. This is set to whitespace or newline so that simple programs which do not perform any word separation get desired behaviour. */ static const char *default_suffixes[] = { " ", "\n", (const char *)NULL }; /* When non-null, this is a NULL terminated array of strings which are duplicates for a tilde prefix. Bash uses this to expand `=~' and `:~'. */ char **tilde_additional_prefixes = (char **)default_prefixes; /* When non-null, this is a NULL terminated array of strings which match the end of a username, instead of just "/". Bash sets this to `:' and `=~'. */ char **tilde_additional_suffixes = (char **)default_suffixes; /* Find the start of a tilde expansion in STRING, and return the index of the tilde which starts the expansion. Place the length of the text which identified this tilde starter in LEN, excluding the tilde itself. */ static int tilde_find_prefix (string, len) const char *string; int *len; { register int i, j, string_len; register char **prefixes; prefixes = tilde_additional_prefixes; string_len = strlen (string); *len = 0; if (*string == '\0' || *string == '~') return (0); if (prefixes) { for (i = 0; i < string_len; i++) { for (j = 0; prefixes[j]; j++) { if (strncmp (string + i, prefixes[j], strlen (prefixes[j])) == 0) { *len = strlen (prefixes[j]) - 1; return (i + *len); } } } } return (string_len); } /* Find the end of a tilde expansion in STRING, and return the index of the character which ends the tilde definition. */ static int tilde_find_suffix (string) const char *string; { register int i, j, string_len; register char **suffixes; suffixes = tilde_additional_suffixes; string_len = strlen (string); for (i = 0; i < string_len; i++) { #if defined (__MSDOS__) if (string[i] == '/' || string[i] == '\\' /* || !string[i] */) #else if (string[i] == '/' /* || !string[i] */) #endif break; for (j = 0; suffixes && suffixes[j]; j++) { if (strncmp (string + i, suffixes[j], strlen (suffixes[j])) == 0) return (i); } } return (i); } /* Take FNAME and return the tilde prefix we want expanded. If LENP is non-null, the index of the end of the prefix into FNAME is returned in the location it points to. */ static char * isolate_tilde_prefix (fname, lenp) const char *fname; int *lenp; { char *ret; int i; ret = (char *)xmalloc (strlen (fname)); #if defined (__MSDOS__) for (i = 1; fname[i] && fname[i] != '/' && fname[i] != '\\'; i++) #else for (i = 1; fname[i] && fname[i] != '/'; i++) #endif ret[i - 1] = fname[i]; ret[i - 1] = '\0'; if (lenp) *lenp = i; return ret; } /* Return a string that is PREFIX concatenated with SUFFIX starting at SUFFIND. */ static char * glue_prefix_and_suffix (prefix, suffix, suffind) char *prefix; const char *suffix; int suffind; { char *ret; int plen, slen; plen = (prefix && *prefix) ? strlen (prefix) : 0; slen = strlen (suffix + suffind); ret = (char *)xmalloc (plen + slen + 1); if (plen) strcpy (ret, prefix); strcpy (ret + plen, suffix + suffind); return ret; } /* Do the work of tilde expansion on FILENAME. FILENAME starts with a tilde. If there is no expansion, call tilde_expansion_failure_hook. This always returns a newly-allocated string, never static storage. */ char * tilde_expand_word (filename) const char *filename; { char *dirname, *expansion, *username; int user_len; struct passwd *user_entry; if (filename == 0) return ((char *)NULL); if (*filename != '~') return (savestring (filename)); /* A leading `~/' or a bare `~' is *always* translated to the value of $HOME or the home directory of the current user, regardless of any preexpansion hook. */ if (filename[1] == '\0' || filename[1] == '/') { /* Prefix $HOME to the rest of the string. */ expansion = sh_get_env_value("HOME"); /* If there is no HOME variable, look up the directory in the password database. */ if (expansion == 0) expansion = sh_get_home_dir(); return (glue_prefix_and_suffix (expansion, filename, 1)); } username = isolate_tilde_prefix(filename, &user_len); /* Look in the password database. */ dirname = (char *)NULL; user_entry = getpwnam (username); if (user_entry == 0) { free (username); /* Return a copy of what we were passed. */ dirname = savestring(filename); } else { free (username); dirname = glue_prefix_and_suffix(user_entry->pw_dir, filename, user_len); } endpwent(); return (dirname); } /* Return a new string which is the result of tilde expanding STRING. */ char * tilde_expand (string) const char *string; { char *result; int result_size, result_index; result_index = result_size = 0; if ((result = strchr (string, '~'))) result = (char *)xmalloc (result_size = (strlen (string) + 16)); else result = (char *)xmalloc (result_size = (strlen (string) + 1)); /* Scan through STRING expanding tildes as we come to them. */ while (1) { register int start, end; char *tilde_word, *expansion; int len; /* Make START point to the tilde which starts the expansion. */ start = tilde_find_prefix (string, &len); /* Copy the skipped text into the result. */ if ((result_index + start + 1) > result_size) result = (char *)xrealloc (result, 1 + (result_size += (start + 20))); strncpy (result + result_index, string, start); result_index += start; /* Advance STRING to the starting tilde. */ string += start; /* Make END be the index of one after the last character of the username. */ end = tilde_find_suffix (string); /* If both START and END are zero, we are all done. */ if (!start && !end) break; /* Expand the entire tilde word, and copy it into RESULT. */ tilde_word = (char *)xmalloc (1 + end); strncpy (tilde_word, string, end); tilde_word[end] = '\0'; string += end; expansion = tilde_expand_word (tilde_word); free (tilde_word); len = strlen (expansion); #ifdef __CYGWIN__ /* Fix for Cygwin to prevent ~user/xxx from expanding to //xxx when $HOME for `user' is /. On cygwin, // denotes a network drive. */ if (len > 1 || *expansion != '/' || *string != '/') #endif { if ((result_index + len + 1) > result_size) result = (char *)xrealloc (result, 1 + (result_size += (len + 20))); strcpy (result + result_index, expansion); result_index += len; } free (expansion); } result[result_index] = '\0'; return (result); } #ifdef TEST #include main (argc, argv) int argc; char **argv; { char *result, line[512]; int done = 0; while (!done) { printf ("~expand: "); fflush (stdout); if (!gets (line)) strcpy (line, "done"); if ((strcmp (line, "done") == 0) || (strcmp (line, "quit") == 0) || (strcmp (line, "exit") == 0)) { done = 1; break; } result = tilde_expand (line); printf (" --> %s\n", result); free (result); } exit (0); } #endif #endif /* READLINE_SUPPORT */ ytree-1.99pl1/tilde.h000066400000000000000000000047771350711670100145130ustar00rootroot00000000000000/* tilde.h: Externally available variables and function in libtilde.a. */ /* Copyright (C) 1992 Free Software Foundation, Inc. This file contains the Readline Library (the Library), a set of routines for providing Emacs style line input to programs that ask for it. The Library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. The Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. The GNU General Public License is often shipped with GNU software, and is generally kept in a file called COPYING or LICENSE. If you do not have a copy of the license, write to the Free Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ #if !defined (_TILDE_H_) # define _TILDE_H_ typedef char *tilde_hook_func_t(char *); /* If non-null, this contains the address of a function that the application wants called before trying the standard tilde expansions. The function is called with the text sans tilde, and returns a malloc()'ed string which is the expansion, or a NULL pointer if the expansion fails. */ extern tilde_hook_func_t *tilde_expansion_preexpansion_hook; /* If non-null, this contains the address of a function to call if the standard meaning for expanding a tilde fails. The function is called with the text (sans tilde, as in "foo"), and returns a malloc()'ed string which is the expansion, or a NULL pointer if there is no expansion. */ extern tilde_hook_func_t *tilde_expansion_failure_hook; /* When non-null, this is a NULL terminated array of strings which are duplicates for a tilde prefix. Bash uses this to expand `=~' and `:~'. */ extern char **tilde_additional_prefixes; /* When non-null, this is a NULL terminated array of strings which match the end of a username, instead of just "/". Bash sets this to `:' and `=~'. */ extern char **tilde_additional_suffixes; /* Return a new string which is the result of tilde expanding STRING. */ extern char *tilde_expand(const char *); /* Do the work of tilde expansion on FILENAME. FILENAME starts with a tilde. If there is no expansion, call tilde_expansion_failure_hook. */ extern char *tilde_expand_word(const char *); #endif /* _TILDE_H_ */ ytree-1.99pl1/usermode.c000066400000000000000000000043101350711670100152070ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/usermode.c,v 1.3 2003/08/31 11:11:00 werner Exp $ * * Funktionen zur Handhabung des FILE-Windows * ***************************************************************************/ #include "ytree.h" #define MAX( a, b ) ( ( (a) > (b) ) ? (a) : (b) ) int DirUserMode(DirEntry *dir_entry, int ch) { int chremap; char *command_line, *aux; char filepath[PATH_LENGTH +1]; GetPath( dir_entry, filepath ); command_line = NULL; while (( aux = GetUserDirAction(ch, &chremap)) != NULL) { if( command_line == NULL && ( command_line = malloc( COMMAND_LINE_LENGTH + 1 ) ) == NULL ) { ERROR_MSG( "Malloc failed*ABORT" ); exit( 1 ); } if (strstr(aux,"%s") != NULL) { (void) sprintf( command_line, aux, filepath ); } else { (void) sprintf( command_line, "%s%c%s", aux, ' ', filepath ); } if(SilentSystemCall( command_line )) { (void) sprintf( message, "can't execute*%s", command_line ); MESSAGE( message ); } if (chremap == ch || chremap == 0) break; else ch = chremap; } if (command_line != NULL) free( command_line ); return(ch); } int FileUserMode(FileEntryList *file_entry_list, int ch) { int chremap; char filepath[PATH_LENGTH +1]; char *command_line, *aux; GetRealFileNamePath( file_entry_list->file, filepath ); command_line = NULL; while (( aux = GetUserFileAction(ch, &chremap)) != NULL) { if( command_line == NULL && ( command_line = malloc( COMMAND_LINE_LENGTH + 1 ) ) == NULL ) { ERROR_MSG( "Malloc failed*ABORT" ); exit( 1 ); } if (strstr(aux,"%s") != NULL) { (void) sprintf( command_line, aux, filepath ); } else { (void) sprintf( command_line, "%s%c%s", aux, ' ', filepath ); } if(SilentSystemCall( command_line )) { (void) sprintf( message, "can't execute*%s", command_line ); MESSAGE( message ); } if (chremap == ch || chremap == 0) break; else ch = chremap; } if (command_line != NULL) free( command_line ); return(chremap); } ytree-1.99pl1/util.c000066400000000000000000000611641350711670100143530ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/util.c,v 1.37 2016/09/04 17:15:34 werner Exp $ * * Diverse Hilfsfunktionen * ***************************************************************************/ #include "ytree.h" #include "xmalloc.h" typedef struct { char *extension; int method; } Extension2Method; static Extension2Method file_extensions[] = FILE_EXTENSIONS; static char *GNU_getcwd(void); char *GetPath(DirEntry *dir_entry, char *buffer) { DirEntry *de_ptr; char help_buffer[PATH_LENGTH + 1]; *buffer = '\0'; for( de_ptr = dir_entry; de_ptr; de_ptr = de_ptr->up_tree ) { *help_buffer = '\0'; if( de_ptr->up_tree ) (void) strcat( help_buffer, FILE_SEPARATOR_STRING ); if( strcmp( de_ptr->name, FILE_SEPARATOR_STRING ) ) (void) strcat( help_buffer, de_ptr->name ); (void) strcat( help_buffer, buffer ); (void) strcpy( buffer, help_buffer ); } /* if( *buffer == '\0' ) (void) strcpy( buffer, FILE_SEPARATOR_STRING ); */ return( buffer ); } char *GetFileNamePath(FileEntry *file_entry, char *buffer) { (void) GetPath( file_entry->dir_entry, buffer ); if( *buffer && strcmp( buffer, FILE_SEPARATOR_STRING ) ) (void) strcat( buffer, FILE_SEPARATOR_STRING ); return( strcat( buffer, file_entry->name ) ); } char *GetRealFileNamePath(FileEntry *file_entry, char *buffer) { char *sym_name; if( mode == DISK_MODE || mode == USER_MODE ) return( GetFileNamePath( file_entry, buffer ) ); if( S_ISLNK( file_entry->stat_struct.st_mode ) ) { sym_name = &file_entry->name[ strlen( file_entry->name ) + 1 ]; if( *sym_name == FILE_SEPARATOR_CHAR ) return( strcpy( buffer, sym_name ) ); } (void) GetPath( file_entry->dir_entry, buffer ); if( *buffer && strcmp( buffer, FILE_SEPARATOR_STRING ) ) (void) strcat( buffer, FILE_SEPARATOR_STRING ); if( S_ISLNK( file_entry->stat_struct.st_mode ) ) return( strcat( buffer, &file_entry->name[ strlen( file_entry->name ) + 1 ] ) ); else return( strcat( buffer, file_entry->name ) ); } int GetDirEntry(DirEntry *tree, DirEntry *current_dir_entry, char *dir_path, DirEntry **dir_entry, char *to_path ) { char dest_path[PATH_LENGTH+1]; char current_path[PATH_LENGTH+1]; char help_path[PATH_LENGTH+1]; char *token, *old; DirEntry *de_ptr, *sde_ptr; int n; *dir_entry = NULL; *to_path = '\0'; strcpy(to_path, dir_path); if( Getcwd( current_path, sizeof( current_path ) - 2 ) == NULL ) { (void) sprintf( message, "Getcwd failed*%s", strerror(errno) ); ERROR_MSG( message ); return( -1 ); } if( *dir_path != FILE_SEPARATOR_CHAR ) { if( chdir( GetPath( current_dir_entry, help_path ) ) ) { ERROR_MSG( "Chdir Failed" ); return( -1 ); } } if( chdir( dir_path ) ) { #ifdef DEBUG (void) sprintf( message, "Invalid Path!*\"%s\"", dir_path ); MESSAGE( message ); #endif return( -3 ); } if( *dir_path != FILE_SEPARATOR_CHAR ) { (void) Getcwd( dest_path, sizeof( dest_path ) - 2 ); (void) strcpy( to_path, dest_path ); } else { strcpy(dest_path, dir_path); } if( chdir( current_path ) ) { ERROR_MSG( "Chdir failed; Can't resume" ); return( -1 ); } n = strlen( tree->name ); if( !strcmp(tree->name, FILE_SEPARATOR_STRING) || (!strncmp( tree->name, dest_path, n ) && ( dest_path[n] == FILE_SEPARATOR_CHAR || dest_path[n] == '\0' ) ) ) { /* Pfad befindet sich im (Sub)-Tree */ /*----------------------------------*/ de_ptr = tree; token = Strtok_r( &dest_path[n], FILE_SEPARATOR_STRING, &old ); while( token ) { for( sde_ptr = de_ptr->sub_tree; sde_ptr; sde_ptr = sde_ptr->next ) { if( !strcmp( sde_ptr->name, token ) ) { /* Subtree gefunden */ /*------------------*/ de_ptr = sde_ptr; break; } } if( sde_ptr == NULL ) { #ifdef DEBUG (void) sprintf( message, "Can't find directory; token=%s", token ); ERROR_MSG( message ); #endif return( -3 ); } token = Strtok_r( NULL, FILE_SEPARATOR_STRING, &old ); } *dir_entry = de_ptr; } return( 0 ); } int GetFileEntry(DirEntry *de_ptr, char *file_name, FileEntry **file_entry) { FileEntry *fe_ptr; *file_entry = NULL; for( fe_ptr = de_ptr->file; fe_ptr; fe_ptr = fe_ptr->next ) { if( !strcmp( fe_ptr->name, file_name ) ) { /* Eintrag gefunden */ /*------------------*/ *file_entry = fe_ptr; break; } } return( 0 ); } char *GetAttributes(unsigned short modus, char *buffer) { char *save_buffer = buffer; if( S_ISREG( modus ) ) *buffer++ = '-'; else if( S_ISDIR( modus ) ) *buffer++ = 'd'; else if( S_ISCHR( modus ) ) *buffer++ = 'c'; else if( S_ISBLK( modus ) ) *buffer++ = 'b'; else if( S_ISFIFO( modus ) ) *buffer++ = 'p'; else if( S_ISLNK( modus ) ) *buffer++ = 'l'; else if( S_ISSOCK( modus ) ) *buffer++ = 's'; /* ??? */ else *buffer++ = '?'; /* unknown */ if( modus & S_IRUSR ) *buffer++ = 'r'; else *buffer++ = '-'; if( modus & S_IWUSR ) *buffer++ = 'w'; else *buffer++ = '-'; if( modus & S_IXUSR ) *buffer++ = 'x'; else *buffer++ = '-'; if( modus & S_ISUID ) *(buffer - 1) = 's'; if( modus & S_IRGRP ) *buffer++ = 'r'; else *buffer++ = '-'; if( modus & S_IWGRP ) *buffer++ = 'w'; else *buffer++ = '-'; if( modus & S_IXGRP ) *buffer++ = 'x'; else *buffer++ = '-'; if( modus & S_ISGID ) *(buffer - 1) = 's'; if( modus & S_IROTH ) *buffer++ = 'r'; else *buffer++ = '-'; if( modus & S_IWOTH ) *buffer++ = 'w'; else *buffer++ = '-'; if( modus & S_IXOTH ) *buffer++ = 'x'; else *buffer++ = '-'; *buffer = '\0'; return( save_buffer ); } char *CTime(time_t f_time, char *buffer) { char *cptr; time_t now; if( (now = time( NULL )) == -1 ) { ERROR_MSG( "time() failed" ); exit( 1 ); } cptr = ctime( &f_time ); (void) strncpy( buffer, cptr+4, 12 ); buffer[12] = '\0'; if( (now - f_time) > 31536000L ) { /* Differenz groesser als 1 Jahr */ /*-------------------------------*/ (void) strncpy( &buffer[7], cptr + 19, 5 ); } return( buffer ); } void PrintSpecialString(WINDOW *win, int y, int x, char *str, int color) { int ch; if(x < 0 || y < 0) { /* screen too small */ return; } wmove( win, y, x); for( ; *str; str++ ) { if ( (!iscntrl(*str)) || (!isspace(*str)) || (*str==' ') ) switch( *str ) { case '1': ch = ACS_ULCORNER; break; case '2': ch = ACS_URCORNER; break; case '3': ch = ACS_LLCORNER; break; case '4': ch = ACS_LRCORNER; break; case '5': ch = ACS_TTEE; break; case '6': ch = ACS_LTEE; break; case '7': ch = ACS_RTEE; break; case '8': ch = ACS_BTEE; break; case '9': ch = ACS_LARROW; break; case '|': ch = ACS_VLINE; break; case '-': ch = ACS_HLINE; break; default: ch = PRINT(*str); } else ch = ACS_BLOCK; #ifdef COLOR_SUPPORT wattrset( win, COLOR_PAIR(color) | A_BOLD ); #endif /* COLOR_SUPPORT */ waddch( win, ch ); #ifdef COLOR_SUPPORT wattrset( win, 0 ); #endif /* COLOR_SUPPORT */ } } void Print(WINDOW *win, int y, int x, char *str, int color) { int ch; if(x < 0 || y < 0) { /* screen too small */ return; } wmove(win, y, x); for( ; *str; str++ ) { ch = PRINT((int) *str); #ifdef COLOR_SUPPORT wattrset( win, COLOR_PAIR(color) | A_BOLD); #endif /* COLOR_SUPPORT */ waddch(win, ch ); #ifdef COLOR_SUPPORT wattrset( win, 0); #endif /* COLOR_SUPPORT */ } } void PrintOptions(WINDOW *win, int y, int x, char *str) { int ch; int color, hi_color, lo_color; if(x < 0 || y < 0) { /* screen too small */ return; } #ifdef COLOR_SUPPORT lo_color = MENU_COLOR; hi_color = HIMENUS_COLOR; #else lo_color = A_NORMAL; hi_color = A_BOLD; #endif color = lo_color; for( ; *str; str++ ) { ch = (int) *str; switch( *str ) { case '(': color = hi_color; continue; case ')': color = lo_color; continue; #ifdef COLOR_SUPPORT case ']': color = lo_color; continue; case '[': color = hi_color; continue; #else case ']': case '[': /* ignore */ continue; #endif case '1': ch = ACS_ULCORNER; break; case '2': ch = ACS_URCORNER; break; case '3': ch = ACS_LLCORNER; break; case '4': ch = ACS_LRCORNER; break; case '5': ch = ACS_TTEE; break; case '6': ch = ACS_LTEE; break; case '7': ch = ACS_RTEE; break; case '8': ch = ACS_BTEE; break; case '9': ch = ACS_LARROW; break; case '|': ch = ACS_VLINE; break; case '-': ch = ACS_HLINE; break; default: ch = PRINT(*str); } #ifdef COLOR_SUPPORT wattrset( win, COLOR_PAIR(color) | A_BOLD); #else wattrset( win, color); #endif mvwaddch( win, y, x++, ch ); wattrset( win, 0 ); } } void PrintMenuOptions(WINDOW *win,int y, int x, char *str, int ncolor, int hcolor) { int ch; int color, hi_color, lo_color; char *sbuf, buf[2]; sbuf = (char *)malloc(strlen(str)+1); sbuf[0] = '\0'; buf[1] = '\0'; if(x < 0 || y < 0) { /* screen too small */ return; } #ifdef COLOR_SUPPORT lo_color = MENU_COLOR; hi_color = HIMENUS_COLOR; #else lo_color = A_NORMAL; hi_color = A_REVERSE; #endif color = lo_color; wmove(win, y, x); for( ; *str; str++ ) { ch = (int) *str; switch( ch ) { case '(': color = hi_color; #ifdef COLOR_SUPPORT WAttrAddStr( win, COLOR_PAIR(color) | A_BOLD, sbuf); #else WAttrAddStr( win, color, sbuf); #endif strcpy(sbuf, ""); continue; case ')': color = lo_color; #ifdef COLOR_SUPPORT WAttrAddStr( win, COLOR_PAIR(color) | A_BOLD, sbuf); #else WAttrAddStr( win, color, sbuf); #endif strcpy(sbuf, ""); continue; #ifdef COLOR_SUPPORT case ']': color = lo_color; WAttrAddStr( win, COLOR_PAIR(color) | A_BOLD, sbuf); strcpy(sbuf, ""); continue; case '[': color = hi_color; WAttrAddStr( win, COLOR_PAIR(color) | A_BOLD, sbuf); strcpy(sbuf, ""); continue; #else case ']': case '[': /* ignore */ continue; #endif default : buf[0] = PRINT(*str); strcat(sbuf, buf); } } #ifdef COLOR_SUPPORT WAttrAddStr( win, COLOR_PAIR(color) | A_BOLD, sbuf); #else WAttrAddStr( win, color, sbuf); #endif free(sbuf); } /***************************************************************************** * FormFilename * *****************************************************************************/ char *FormFilename(char *dest, char *src, unsigned int max_len) { int i; int begin; unsigned int l; l = strlen(src); begin = 0; if( l <= max_len ) return( strcpy( dest, src ) ); else { for(i=0; i < (int) max_len - 4; i++) if( src[l - i] == FILE_SEPARATOR_CHAR || src[l - i] == '\\' ) begin = l - i; (void) strcpy( dest, "/..." ); return( strcat(dest, &src[begin] ) ); } } /***************************************************************************** * CutFilename * *****************************************************************************/ char *CutFilename(char *dest, char *src, unsigned int max_len) { unsigned int l; char *tmp; l = StrVisualLength(src); if( l <= max_len ) return( strcpy( dest, src ) ); else { tmp = StrLeft(src, max_len - 3); sprintf(dest, "%s...", tmp); free(tmp); return( dest ); } } /***************************************************************************** * CutPathname * *****************************************************************************/ char *CutPathname(char *dest, char *src, unsigned int max_len) { unsigned int l; l = strlen(src); if( l <= max_len ) return( strcpy( dest, src ) ); else { (void) strcpy( dest, "..." ); (void) strncat( dest, &src[l - max_len + 3], max_len - 3 ); return( dest ); } } /***************************************************************************** * Fnsplit * *****************************************************************************/ /* Aufsplitten des Dateinamens in die einzelnen Komponenten */ void Fnsplit(char *path, char *dir, char *name) { int i; char *name_begin; char *trunc_name; while( *path == ' ' || *path == '\t' ) path++; while( strchr(path, FILE_SEPARATOR_CHAR ) || strchr(path, '\\') ) *(dir++) = *(path++); *dir = '\0'; name_begin = path; trunc_name = name; for(i=0; i < PATH_LENGTH && *path; i++ ) *(name++) = *(path++); *name = '\0'; if( i == PATH_LENGTH && *path ) { (void) sprintf( message, "filename too long:*%s*truncating to*%s", name_begin, trunc_name ); WARNING( message ); } } int BuildFilename( char *in_filename, char *pattern, char *out_filename ) { char *cptr; int result = 0; for( ; *pattern; pattern++ ) { if( *pattern == '*' ) { cptr = in_filename; for( ; (*out_filename = *cptr); out_filename++, cptr++ ); } else { *out_filename++ = *pattern; } } *out_filename = '\0'; return( result ); } int GetFileMethod( char *filename ) { int i, k, l; l = strlen( filename ); for( i=0; i < (int)(sizeof( file_extensions ) / sizeof( file_extensions[0] )); i++ ) { k = strlen( file_extensions[i].extension ); if( l >= k && !strcmp( &filename[l-k], file_extensions[i].extension ) ) return( file_extensions[i].method ); } return( NO_COMPRESS ); } #ifdef __NeXT__ char *getcwd(char *dest, int len) { static char buffer[MAXNAMLEN]; DIR *dirp; struct direct *dp; long inode; char *cp = buffer + MAXNAMLEN - 1; *cp = 0; do { dirp = opendir("."); for (dp=readdir(dirp); dp; dp=readdir(dirp)) { if(dp->d_namlen && !strcmp(dp->d_name,".")) { break; } } if (inode == dp->d_ino) break; inode = dp->d_ino; (void) closedir(dirp); dirp = opendir(".."); for (dp=readdir(dirp); dp && (dp->d_ino != inode); dp=readdir(dirp)); cp -= dp->d_namlen; (void) strncpy(cp,dp->d_name,dp->d_namlen); *--cp = FILE_SEPARATOR_CHAR; (void) closedir(dirp); } while(!chdir("..")); (void) chdir(cp+2); (void) strncpy(dest,cp+2,len); } #endif void NormPath( char *in_path, char *out_path ) { char *s, *d; char *old, *opath; int level; char *in_path_dup; level = 0; opath = out_path; if( ( in_path_dup = malloc( strlen( in_path ) + 1 ) ) == NULL ) { ERROR_MSG( "Malloc Failed*ABORT" ); exit( 1 ); } if( *in_path == FILE_SEPARATOR_CHAR ) { s = in_path + 1; *opath++ = FILE_SEPARATOR_CHAR; } else { s = in_path; } for( d=in_path_dup; *s; d++ ) { *d = *s++; while( *d == FILE_SEPARATOR_CHAR && *s == FILE_SEPARATOR_CHAR ) s++; } *d = '\0'; d = opath; s = Strtok_r( in_path_dup, FILE_SEPARATOR_STRING, &old ); while( s ) { if( strcmp( s, "." ) ) { /* skip "." */ if( !strcmp( s, ".." ) ) { /* optimize ".." */ if( level > 0 ) { if( level == 1 ) { d = out_path; } else { for( d -= 2; *d != FILE_SEPARATOR_CHAR; d-- ) ; d++; } } else { /* level <= 0 */ *d++ = '.'; *d++ = '.'; *d++ = FILE_SEPARATOR_CHAR; } level--; } else { /* add component */ strcpy( d, s ); d += strlen( s ); *d++ = FILE_SEPARATOR_CHAR; level++; } } s = Strtok_r( NULL, FILE_SEPARATOR_STRING, &old ); } if( level != 0 ) d--; *d = '\0'; if( *out_path == '\0' ) strcpy(out_path, "." ); free( in_path_dup ); } /* reentrantes strtok */ char *Strtok_r( char *str, char *delim, char **old ) { char *result; int l, m; if( str == NULL ) str = *old; if( str == NULL ) return( NULL ); l = strlen( str ); if( ( result = strtok( str, delim ) ) != NULL ) { m = strlen( result ); if( (m + 1) >= l) *old = NULL; else *old = result + m + 1; } else *old = NULL; return( result ); } void GetMaxYX(WINDOW *win, int *height, int *width) { if( win == dir_window ) { *height = MAXIMUM(DIR_WINDOW_HEIGHT, 1); *width = MAXIMUM(DIR_WINDOW_WIDTH, 1); } else if( win == small_file_window ) { *height = MAXIMUM(FILE_WINDOW_1_HEIGHT, 1); *width = MAXIMUM(FILE_WINDOW_1_WIDTH, 1); } else if( win == big_file_window ) { *height = MAXIMUM(FILE_WINDOW_2_HEIGHT, 1); *width = MAXIMUM(FILE_WINDOW_2_WIDTH, 1); } else if( win == f2_window ) { *height = MAXIMUM(F2_WINDOW_HEIGHT - 1, 1); /* fake for separator line */ *width = MAXIMUM(F2_WINDOW_WIDTH, 1); } else if( win == history_window ) { *height = MAXIMUM(HISTORY_WINDOW_HEIGHT, 1); *width = MAXIMUM(HISTORY_WINDOW_WIDTH, 1); } else { ERROR_MSG( "Unknown Window-ID*ABORT" ); exit( 1 ); } } int Strrcmp(char *s1, char* s2)/*compares in reverse order 2 strings*/ { int aux; int l1 = strlen(s1); int l2 = strlen(s2); for (aux = 0; aux <= l2; aux++) { if ((l1 - aux) < 0) return(-1); if (s1[l1 - aux] > s2[l2 - aux]) return(1); else if (s1[l1 - aux] < s2[l2 - aux]) return(-1); } return(0); } /* NeXT does not define strdup */ char *Strdup(const char *s) { char *cp = NULL; if (s) { cp = malloc(strlen(s)+1); if (cp) { strcpy(cp,s); } } return(cp); } /* Solaris does not define this */ char *Strndup(const char *s, int len) { char *cp = NULL; int l; if (s) { l = MINIMUM(strlen(s), len); cp = malloc(l+1); if (cp) { memcpy(cp, s, l); cp[l] = '\0'; } } return(cp); } char *GetExtension(char *filename) { char *cptr; cptr = strrchr(filename, '.'); return( (cptr) ? cptr + 1 : "" ); } void StrCp(char *dest, const char *src) { static char esc_chars[] ="#*|&;()<> \t\n\r\"!$?'`~"; while(*src) { if(strchr(esc_chars, *src)) *dest++ = '\\'; *dest++ = *src++; } *dest = '\0'; } int BuildUserFileEntry(FileEntry *fe_ptr, int max_filename_len, int max_linkname_len, char *template, int linelen, char *line) { char attributes[11]; char modify_time[13]; char change_time[13]; char access_time[13]; char format1[60]; char format2[60]; int i, n; char owner[OWNER_NAME_MAX + 1]; char group[GROUP_NAME_MAX + 1]; char *owner_name_ptr; char *group_name_ptr; char *sym_link_name = NULL; char *sptr, *dptr; char tag; char buffer[4096]; /* enough??? */ if( fe_ptr && S_ISLNK( fe_ptr->stat_struct.st_mode ) ) sym_link_name = &fe_ptr->name[strlen(fe_ptr->name)+1]; else sym_link_name = ""; tag = (fe_ptr->tagged) ? TAGGED_SYMBOL : ' '; (void) GetAttributes( fe_ptr->stat_struct.st_mode, attributes); (void) CTime( fe_ptr->stat_struct.st_mtime, modify_time ); (void) CTime( fe_ptr->stat_struct.st_ctime, change_time ); (void) CTime( fe_ptr->stat_struct.st_atime, access_time ); owner_name_ptr = GetPasswdName(fe_ptr->stat_struct.st_uid); group_name_ptr = GetGroupName(fe_ptr->stat_struct.st_gid); if( owner_name_ptr == NULL ) { (void) sprintf( owner, "%d", (int) fe_ptr->stat_struct.st_uid ); owner_name_ptr = owner; } if( group_name_ptr == NULL ) { (void) sprintf( group, "%d", (int) fe_ptr->stat_struct.st_gid ); group_name_ptr = group; } sprintf(format1, "%%-%ds", max_filename_len); sprintf(format2, "%%-%ds", max_linkname_len); for(sptr=template, dptr=buffer, i=0; *sptr; ) { if(*sptr == '%') { sptr++; if(!strncmp(sptr, TAGSYMBOL_VIEWNAME, 3)) { *dptr = tag; n=1; } else if(!strncmp(sptr, FILENAME_VIEWNAME, 3)) { n = sprintf(dptr, format1, fe_ptr->name); } else if(!strncmp(sptr, ATTRIBUTE_VIEWNAME, 3)) { n = sprintf(dptr, "%10s", attributes); } else if(!strncmp(sptr, LINKCOUNT_VIEWNAME, 3)) { n = sprintf(dptr, "%3d", (int)fe_ptr->stat_struct.st_nlink); } else if(!strncmp(sptr, FILESIZE_VIEWNAME, 3)) { #ifdef HAS_LONGLONG n = sprintf(dptr, "%7lld", (LONGLONG) fe_ptr->stat_struct.st_size); #else n = sprintf(dptr, "%7d", fe_ptr->stat_struct.st_size); #endif } else if(!strncmp(sptr, MODTIME_VIEWNAME, 3)) { n = sprintf(dptr, "%12s", modify_time); } else if(!strncmp(sptr, SYMLINK_VIEWNAME, 3)) { n = sprintf(dptr, format2, sym_link_name); } else if(!strncmp(sptr, UID_VIEWNAME, 3)) { n = sprintf(dptr, "%-8s", owner_name_ptr); } else if(!strncmp(sptr, GID_VIEWNAME, 3)) { n = sprintf(dptr, "%-8s", group_name_ptr); } else if(!strncmp(sptr, INODE_VIEWNAME, 3)) { #ifdef HAS_LONGLONG n = sprintf(dptr, "%7lld", (LONGLONG)fe_ptr->stat_struct.st_ino); #else n = sprintf(dptr, "%7ld", (int)fe_ptr->stat_struct.st_ino); #endif } else if(!strncmp(sptr, ACCTIME_VIEWNAME, 3)) { n = sprintf(dptr, "%12s", access_time); } else if(!strncmp(sptr, CHGTIME_VIEWNAME, 3)) { n = sprintf(dptr, "%12s", change_time); } else { n = -1; } if(n == -1) { *dptr++ = '%'; } else { dptr += n; if(*sptr) sptr++; if(*sptr) sptr++; if(*sptr) sptr++; } } else { *dptr++ = *sptr++; } } *dptr = '\0'; strncpy(line, buffer, linelen); line[linelen - 1] = '\0'; return(0); } int GetUserFileEntryLength( int max_filename_len, int max_linkname_len, char *template) { int len, n; char *sptr; for(len=0, sptr=template; *sptr; ) { if(*sptr == '%') { sptr++; if(!strncmp(sptr, TAGSYMBOL_VIEWNAME, 3)) { n=1; } else if(!strncmp(sptr, FILENAME_VIEWNAME, 3)) { n = max_filename_len; } else if(!strncmp(sptr, ATTRIBUTE_VIEWNAME, 3)) { n = 10; } else if(!strncmp(sptr, LINKCOUNT_VIEWNAME, 3)) { n = 3; } else if(!strncmp(sptr, FILESIZE_VIEWNAME, 3)) { n = 7; } else if(!strncmp(sptr, MODTIME_VIEWNAME, 3)) { n = 12; } else if(!strncmp(sptr, SYMLINK_VIEWNAME, 3)) { n = max_linkname_len; } else if(!strncmp(sptr, UID_VIEWNAME, 3)) { n = 8; } else if(!strncmp(sptr, GID_VIEWNAME, 3)) { n = 8; } else if(!strncmp(sptr, INODE_VIEWNAME, 3)) { n = 7; } else if(!strncmp(sptr, ACCTIME_VIEWNAME, 3)) { n = 12; } else if(!strncmp(sptr, CHGTIME_VIEWNAME, 3)) { n = 12; } else { n = -1; } if(n == -1) { len++; sptr++; } else { len += n; if(*sptr) sptr++; if(*sptr) sptr++; if(*sptr) sptr++; } } else { sptr++; len++; } } return(len); } LONGLONG AtoLL(char *cptr) { LONGLONG ll; #ifdef HAS_LONGLONG sscanf(cptr, "%lld", &ll); #else #ifdef __QNX__ sscanf(cptr, "%ld", &ll); #else sscanf(ll, "%ld", cptr); #endif #endif return(ll); } #ifndef HAVE_STRERROR const char *StrError(int errnum) { #if !defined(__FreeBSD__) && !(defined(__GLIBC__) && __GLIBC__ >= 2) extern char *sys_errlist[]; extern int sys_nerr; #endif if (errnum > 0 && errnum <= sys_nerr) return(sys_errlist[errnum]); return ("Unknown system error"); } #endif /* HAVE_STRERROR */ /***************************************************************************** * Getcwd * *****************************************************************************/ char *Getcwd(char *buffer, unsigned int size) { if(size == 0) return(GNU_getcwd()); return(getcwd(buffer, size)); } static char *GNU_getcwd() { unsigned int size = 100; while (1) { char *buffer = (char *) xmalloc (size); if (getcwd (buffer, size) == buffer) return buffer; free (buffer); if (errno != ERANGE) return 0; size *= 2; } } /***************************************************************************** * CutName * *****************************************************************************/ char *CutName(char *dest, char *src, unsigned int max_len) { unsigned int l; l = strlen(src); if( l <= max_len ) return( strcpy( dest, src ) ); else { (void) strncpy( dest, src, max_len - 3 ); return strcpy( &dest[max_len - 3], "..." ); } } ytree-1.99pl1/view.c000066400000000000000000000517531350711670100143530ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/view.c,v 1.26 2014/12/26 09:53:11 werner Exp $ * * View-Kommando-Bearbeitung * ***************************************************************************/ #include "ytree.h" #include #include "xmalloc.h" typedef struct MODIF { long pos; unsigned char old_char; unsigned char new_char; struct MODIF *next; } CHANGES; static CHANGES *changes; static int cursor_pos_x; static int cursor_pos_y; static long current_line; static int fd, fd2; static struct stat fdstat; static int WLINES, WCOLS, BYTES; static WINDOW *VIEW, *BORDER; BOOL inhex=TRUE; BOOL inedit=FALSE; BOOL hexoffset=TRUE; #define CURSOR_CALC_X (10+((cursor_pos_x<(BYTES))? 2:3)+(cursor_pos_x)+(cursor_pos_x/2)) #define CURSOR_POS_X ((inhex)? CURSOR_CALC_X:(WCOLS-BYTES+cursor_pos_x)) #define C_POSX (((cursor_pos_x%2)!=1)? cursor_pos_x:(cursor_pos_x-1)) #define CURSOR_POSX ((inhex)? (C_POSX/2):cursor_pos_x) #define CANTX(x) ((inhex)? (x*2):x) #define THECOLOR ((inedit)? COLOR_PAIR(STATS_COLOR):COLOR_PAIR(DIR_COLOR)) static int ViewFile(DirEntry * dir_entry, char *file_path); static int ViewArchiveFile(char *file_path); int View(DirEntry * dir_entry, char *file_path) { switch( mode ) { case DISK_MODE : case USER_MODE : return( ViewFile(dir_entry, file_path ) ); case TAPE_MODE: case RAR_FILE_MODE: case RPM_FILE_MODE: case TAR_FILE_MODE : case ZOO_FILE_MODE : case ZIP_FILE_MODE : case LHA_FILE_MODE : case ARC_FILE_MODE : return( ViewArchiveFile( file_path ) ); default: beep(); return( -1 ); } } static int ViewFile(DirEntry * dir_entry, char *file_path) { char *command_line, *aux; int compress_method; int result = -1; int l; char *file_p_aux; BOOL notice_mapped = FALSE; char cwd[PATH_LENGTH+1]; char path[PATH_LENGTH+1]; command_line = file_p_aux = NULL; if( ( file_p_aux = (char *) malloc( COMMAND_LINE_LENGTH + 1 ) ) == NULL ) { ERROR_MSG( "Malloc failed*ABORT" ); exit( 1 ); } StrCp(file_p_aux, file_path); if( access( file_path, R_OK ) ) { (void) sprintf( message, "View not possible!*\"%s\"*%s", file_path, strerror(errno) ); MESSAGE( message ); ESCAPE; } if( ( command_line = malloc( COMMAND_LINE_LENGTH + 1 ) ) == NULL ) { ERROR_MSG( "Malloc failed*ABORT" ); exit( 1 ); } if (( aux = GetExtViewer(file_path))!= NULL) { if (strstr(aux,"%s") != NULL) { (void) sprintf(command_line, aux, file_p_aux); } else (void) sprintf(command_line, "%s %s", aux, file_p_aux); } else { compress_method = GetFileMethod( file_path ); l = strlen( file_path ); if( compress_method == FREEZE_COMPRESS ) { (void) sprintf( command_line, "%s < %s %s | %s", MELT, file_p_aux, ERR_TO_STDOUT, PAGER ); } else if( compress_method == COMPRESS_COMPRESS ) { (void) sprintf( command_line, "%s < %s %s | %s", UNCOMPRESS, file_p_aux, ERR_TO_STDOUT, PAGER ); } else if( compress_method == GZIP_COMPRESS ) { (void) sprintf( command_line, "%s < %s %s | %s", GNUUNZIP, file_p_aux, ERR_TO_STDOUT, PAGER ); } else if( compress_method == BZIP_COMPRESS ) { (void) sprintf( command_line, "%s < %s %s | %s", BUNZIP, file_p_aux, ERR_TO_STDOUT, PAGER ); } else { (void) sprintf( command_line, "%s %s", PAGER, file_p_aux ); } } /* --crb3 01oct02: replicating what I did to dit, eliminate the problem with jstar-chained-thru-less writing new files to the ytree starting cwd. new code grabbed from execute.c. */ if (mode == DISK_MODE) { if (Getcwd(cwd, PATH_LENGTH) == NULL) { WARNING("Getcwd failed*\".\"assumed"); (void) strcpy(cwd, "."); } if (chdir(GetPath(dir_entry, path))) { (void) sprintf(message, "Can't change directory to*\"%s\"", path); MESSAGE(message); }else{ result = SystemCall(command_line); } if( chdir(cwd) ) { (void) sprintf(message, "Can't change directory to*\"%s\"", cwd); MESSAGE(message); } }else{ result = SystemCall(command_line); } /* if((result = SilentSystemCall( command_line ))) ..did systemcall just above */ if(result) { (void) sprintf( message, "can't execute*%s", command_line ); MESSAGE( message ); } if( notice_mapped ) { UnmapNoticeWindow(); } FNC_XIT: if(file_p_aux) free(file_p_aux); if(command_line) free(command_line); return( result ); } static int ViewArchiveFile(char *file_path) { char *command_line, *aux; char buffer[100]; char *archive; int l; int result = -1; if( ( command_line = malloc( COMMAND_LINE_LENGTH + 1 ) ) == NULL ) { ERROR_MSG( "Malloc failed*ABORT" ); exit( 1 ); } l = strlen( file_path ); if (( aux = GetExtViewer(file_path)) != NULL) { if (strstr(aux,"%s") != NULL) { (void) sprintf( buffer, "| %s", PAGER ); } else { (void) sprintf( buffer, "| %s", aux ); /* maybe pipe-able */ } } else { (void) sprintf( buffer, "| %s", PAGER ); } archive = (mode == TAPE_MODE) ? statistic.tape_name : statistic.login_path; MakeExtractCommandLine( command_line, archive, file_path, buffer ); if((result = SystemCall( command_line ))) { (void) sprintf( message, "can't execute*%s", command_line ); MESSAGE( message ); } free( command_line ); return( result ); } char *strn2print(char *dest, char *src, int c) { dest[c]='\0'; for( ;c >= 0;c--) dest[c] = (isprint(src[c]) ? src[c] : '.'); return dest; } void printhexline(WINDOW *win, char *line, char *buf, int r, long offset) { char *aux; int i; aux = (char *) xmalloc(WCOLS ); if (r==0) { wclrtoeol(win); return; } if(hexoffset) { sprintf(line, "%010X ", (int)offset); } else { sprintf(line, "%010d ", (int)offset); } for (i = 1; i <= r; i++ ) { if ((i == (BYTES / 2) ) || (i == BYTES )) sprintf(aux, "%02hhX ", buf[i-1]); else sprintf(aux, "%02hhX ", buf[i-1]); strcat(line, aux); } for (i = r+1; i <= BYTES; i++) { buf[i-1]= ' '; if ((i == (BYTES / 2) ) || (i == BYTES )) sprintf(aux, " "); else sprintf(aux, " "); strcat(line, aux); } /* strcat(line, " ");*/ line[strlen(line)] = ' '; for (i=0; i< WCOLS-BYTES; i++) waddch(win, line[i]| THECOLOR); for( i=0; i< BYTES; i++) isprint(buf[i]) ? waddch(win, buf[i] | THECOLOR) : waddch(win, ACS_BLOCK | COLOR_PAIR(HIDIR_COLOR)); free(aux); return; } void update_line(WINDOW *win, long line) { int r; unsigned char *buf; char *line_string; char mensaje[50]; line_string = (char *) xmalloc(WCOLS); memset(line_string, ' ', WCOLS); line_string[0] = '\0'; buf = (char *) xmalloc(BYTES); memset(buf, ' ', BYTES); if (lseek(fd, (line - 1) * BYTES, SEEK_SET)== -1 ) { sprintf(mensaje, "Error %ld ", line); perror(mensaje); fflush(stdout); return; } r = read(fd, buf, BYTES); printhexline(win, line_string, buf, r, (line - 1) * (BYTES)); xfree(line_string); xfree(buf); } void scroll_down(WINDOW *win) { scrollok(win,TRUE); wscrl(win,1); scrollok(win,FALSE); wmove(win, WLINES - 1 , 0); update_line(win, current_line + WLINES - 1); wnoutrefresh(win); doupdate(); } void scroll_up(WINDOW *win) { scrollok(win,TRUE); wscrl(win,-1); scrollok(win,FALSE); wmove(win, 0, 0); update_line(win, current_line ); wnoutrefresh(win); doupdate(); } void update_all_lines(WINDOW *win, char l) { long i; for (i = current_line; i <= current_line + l; i++) { wmove(win, i - current_line, 0); update_line(win, i); } wnoutrefresh(win); doupdate(); } void Change2Edit(char *file_path) { int i; char *str; str = (char *)xmalloc(COLS); for(i = WLINES + 4; i < LINES; i++) { wmove(stdscr,i , 0); wclrtoeol(stdscr); } doupdate(); Print( stdscr, 0, 0, "File: ", MENU_COLOR ); Print( stdscr, 0, 6, CutPathname(str,file_path,WCOLS-5), HIMENUS_COLOR ); PrintOptions( stdscr, LINES - 3, 0, "(Edit file in hexadecimal mode)"); PrintOptions( stdscr, LINES - 2, 0, "(Q)uit (^L) redraw () change edit mode"); PrintOptions( stdscr, LINES - 1, 0, "(NEXT)-(RIGHT)/(PREV)-(LEFT) page (HOME)-(END) of line (DOWN)-(UP) line"); free(str); return; } void Change2View(char *file_path) { int i; char *str; str = (char *)xmalloc(COLS); for(i = WLINES + 4; i < LINES; i++) { wmove(stdscr,i , 0); wclrtoeol(stdscr); } doupdate(); Print( stdscr, 0, 0, "File: ", MENU_COLOR ); Print( stdscr, 0, 6, CutPathname(str,file_path,WCOLS-5), HIMENUS_COLOR ); PrintOptions( stdscr, LINES - 3, 0, "View file in hexadecimal mode"); PrintOptions( stdscr, LINES - 2, 0, "(Q)uit (^L) redraw (E)dit hex"); PrintOptions( stdscr, LINES - 1, 0, "(NEXT)-(RIGHT)/(PREV)-(LEFT) page (HOME)-(END) of line (DOWN)-(UP) line"); free(str); return; } void SetupViewWindow(char *file_path) { int i; char *str; str = (char *)xmalloc(COLS); WLINES= LINES - 6; WCOLS= COLS - 2; if (BORDER) delwin(BORDER); BORDER=newwin(WLINES + 2, WCOLS + 2, 1, 0); if (VIEW) delwin(VIEW); VIEW=newwin(WLINES, WCOLS, 2, 1); keypad(VIEW,TRUE); scrollok(VIEW,FALSE); clearok(VIEW,TRUE); leaveok(VIEW,FALSE); /* werase(VIEW);*/ WbkgdSet(VIEW,COLOR_PAIR(WINDIR_COLOR)); wclear(VIEW); for( i = 0; i < WLINES - 1; i++) { wmove(VIEW,i,0); wclrtoeol(VIEW); } WbkgdSet(BORDER,COLOR_PAIR(WINDIR_COLOR)|A_BOLD); box(BORDER,0,0); RefreshWindow(BORDER); RefreshWindow(VIEW); Change2View(file_path); BYTES = (WCOLS - 13) / 4; free(str); return; } unsigned char hexval(unsigned char v) { if (v >= 'a' && v <= 'f') v = v - 'a' + 10; else if (v >= '0' && v <= '9') v = v - '0'; return v; } void change_char(int ch) { CHANGES *cambio=NULL; char pp=0; char mensaje[50]; cambio = malloc(sizeof(struct MODIF)); cambio -> pos = ( (cursor_pos_y + current_line - 1) * BYTES) + CURSOR_POSX; if (lseek(fd, cambio -> pos, SEEK_SET)== -1 ) { sprintf(mensaje,"Error %s ", strerror(errno)); perror(mensaje); fflush(stdout); free(cambio); return; } if ((read(fd, &cambio -> old_char,1)==1)) if (lseek(fd, cambio -> pos, SEEK_SET)!= -1 ) { if (inhex) { switch( ch){ case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': if ((cursor_pos_x%2)==1) pp = (cambio -> old_char & 0xF0) | (hexval(ch)); else pp = (cambio -> old_char & 0x0F) | (hexval(ch) << 4); touchwin(VIEW); break; default: beep(); touchwin(VIEW); free(cambio); return; break; } }else{ pp = ch; } if (write(fd, &pp, 1)!= 1) { sprintf(mensaje,"Error al grabar el cambio %s ", strerror(errno)); perror(mensaje); fflush(stdout); free(cambio); return; } cambio -> new_char = pp; cambio -> next = changes; changes = cambio; }else{ sprintf(mensaje,"Error al posicionar %s ", strerror(errno)); perror(mensaje); fflush(stdout); free(cambio); return; } else{ sprintf(mensaje,"Error al pre-leer %s ", strerror(errno)); perror(mensaje); fflush(stdout); free(cambio); return; } return; } void move_right(WINDOW *win) { fstat(fd,&fdstat); cursor_pos_x++; if (fdstat.st_size > ((cursor_pos_y+current_line-1) * BYTES + CURSOR_POSX )){ cursor_pos_x--; if ( cursor_pos_x < CANTX(BYTES) - 1 ) { cursor_pos_x += 1; wmove( win, cursor_pos_y, CURSOR_POS_X); }else { if (fdstat.st_size >= ((current_line+cursor_pos_y) * BYTES) ){ if (cursor_pos_y < WLINES-1 ) { cursor_pos_y++; cursor_pos_x = 0; wmove( win, cursor_pos_y, CURSOR_POS_X); } else { current_line++; scroll_down(win); cursor_pos_x = 0; wmove( win, cursor_pos_y, CURSOR_POS_X); } } else beep(); } }else{ cursor_pos_x--; beep(); } return; } void hex_edit(char *file_path) { int ch; long cursor_byte; char mensaje[50]; BOOL QUIT=FALSE; cursor_pos_x = cursor_pos_y = 0; cursor_byte = 0; fd2 = fd; fd=open(file_path,O_RDWR); if (fd == -1){ sprintf(mensaje,"Error %s ", strerror(errno)); ERROR_MSG(mensaje); touchwin(VIEW); fd = fd2; return; } inedit=TRUE; update_all_lines(VIEW,WLINES-1); leaveok( VIEW, FALSE); curs_set( 1); wmove( VIEW, cursor_pos_y, CURSOR_POS_X); wnoutrefresh(VIEW); while (!QUIT) { doupdate(); ch = (resize_request) ? -1 : Getch(); #ifdef VI_KEYS ch = ViKey(ch); #endif if (resize_request) { SetupViewWindow(file_path); Change2Edit(file_path); /* current_line = oldpos/BYTES;*/ update_all_lines(VIEW,WLINES-1); wmove( VIEW, cursor_pos_y, CURSOR_POS_X); wnoutrefresh(VIEW); doupdate(); } switch(ch){ case ESC: QUIT=TRUE; break; case KEY_DOWN: /*ScrollDown();*/ fstat(fd,&fdstat); if (fdstat.st_size > ((cursor_pos_y + current_line - 1) * BYTES + CURSOR_POSX)) { if (fdstat.st_size > ((cursor_pos_y + current_line - 1 + 1) * BYTES + CURSOR_POSX)) { if (cursor_pos_y < WLINES-1){ wmove( VIEW, ++cursor_pos_y, CURSOR_POS_X); wnoutrefresh(VIEW); } else { ++current_line; scroll_down(VIEW); wmove( VIEW, cursor_pos_y, CURSOR_POS_X); wnoutrefresh(VIEW); } } else { /* special case: last line */ if (fdstat.st_size > ((cursor_pos_y + current_line - 1 + 1) * BYTES)) { for(cursor_pos_x = 0; (CURSOR_POSX + 1) < (fdstat.st_size % BYTES); cursor_pos_x++); if (cursor_pos_y < WLINES-1){ wmove( VIEW, ++cursor_pos_y, CURSOR_POS_X); wnoutrefresh(VIEW); } else { ++current_line; scroll_down(VIEW); wmove( VIEW, cursor_pos_y, CURSOR_POS_X); wnoutrefresh(VIEW); } } } } else { beep(); } break; case KEY_UP: /*ScroollUp();*/ if (cursor_pos_y > 0) { wmove( VIEW, --cursor_pos_y, CURSOR_POS_X); wnoutrefresh(VIEW); } else if (current_line > 1) { current_line--; scroll_up(VIEW); wmove( VIEW, cursor_pos_y, CURSOR_POS_X); wnoutrefresh(VIEW); } else beep(); break; case KEY_LEFT: /* move 1 char left */ if ( cursor_pos_x > 0 ) { cursor_pos_x-=1; wmove( VIEW, cursor_pos_y, CURSOR_POS_X); } else if (cursor_pos_y > 0 ) { /*cursor_pos_x=ultimo_caracter;*/ cursor_pos_x=CANTX(BYTES) - 1; wmove( VIEW, --cursor_pos_y,CURSOR_POS_X); } else if (current_line > 1) { current_line--; scroll_up(VIEW); cursor_pos_x=CANTX(BYTES) - 1; wmove( VIEW, cursor_pos_y, CURSOR_POS_X); } else beep(); wnoutrefresh(VIEW); break; case KEY_PPAGE: /*ScrollPageDown();*/ if (current_line > WLINES) current_line -= WLINES; else if (current_line > 1) current_line = 1; else beep(); /* oldpos = current_line * BYTES;*/ update_all_lines(VIEW,WLINES); wmove( VIEW, cursor_pos_y, CURSOR_POS_X); wnoutrefresh(VIEW); break; case KEY_RIGHT: move_right(VIEW); wnoutrefresh(VIEW); break; case KEY_NPAGE: /*ScroollPageUp();*/ fstat(fd,&fdstat); if (fdstat.st_size > ((current_line - 1 + WLINES + cursor_pos_y) * BYTES) + CURSOR_POSX ) { current_line += WLINES; } else { int n; n = fdstat.st_size / BYTES; /* numer of full lines */ if(fdstat.st_size % BYTES) { n++; /* plus 1 not fully used line */ } if(current_line != n) { current_line = n; cursor_pos_y = 0; for(cursor_pos_x = 0; (CURSOR_POSX + 1) < (fdstat.st_size % BYTES); cursor_pos_x++); } else { beep(); } } /* oldpos = current_line * BYTES;*/ update_all_lines(VIEW,WLINES); wmove( VIEW, cursor_pos_y, CURSOR_POS_X); wnoutrefresh(VIEW); break; case KEY_HOME: if (CURSOR_POSX > 0) { cursor_pos_x = 0; wmove( VIEW, cursor_pos_y, CURSOR_POS_X); } else beep(); wnoutrefresh(VIEW); break; case KEY_END: fstat(fd,&fdstat); if ( ((cursor_pos_y + current_line) * BYTES) > fdstat.st_size ) { cursor_pos_x = CANTX(fdstat.st_size % BYTES) - 1; } else { cursor_pos_x = CANTX(BYTES)-1; } wmove( VIEW, cursor_pos_y, CURSOR_POS_X); wnoutrefresh(VIEW); break; case '\t' : /* move cursor to the the other part of the window*/ if (inhex){ inhex=FALSE; cursor_pos_x=cursor_pos_x/2; }else{ inhex=TRUE; cursor_pos_x=cursor_pos_x*2; } wmove( VIEW, cursor_pos_y, CURSOR_POS_X); wnoutrefresh(VIEW); break; case 'L' & 0x1f: clearok(stdscr,TRUE); RefreshWindow(stdscr); break; case 'q': case 'Q': if (inhex) { QUIT=TRUE; break; } default: change_char(ch); wmove(VIEW, cursor_pos_y, 0); update_line(VIEW, current_line+cursor_pos_y); move_right(VIEW); wmove(VIEW, cursor_pos_y, CURSOR_POS_X); wnoutrefresh(VIEW); break; } } curs_set( 0); close(fd); fd=fd2; inedit=FALSE; return; } int InternalView(char *file_path) { long oldpos; int ch; BOOL QUIT=FALSE; hexoffset = (!strcmp(HEXEDITOFFSET, "HEX")) ? TRUE : FALSE; if (stat(file_path, &fdstat)!=0) return -1; if (!(S_ISREG(fdstat.st_mode)) || S_ISBLK(fdstat.st_mode)) return -1; fd=open(file_path,O_RDONLY); if (fd == -1) return -1; SetupViewWindow(file_path); current_line = 1; oldpos = 1; update_all_lines(VIEW,WLINES-1); while (!QUIT) { ch = (resize_request) ? -1 : Getch(); #ifdef VI_KEYS ch = ViKey(ch); #endif if (resize_request) { SetupViewWindow(file_path); current_line = oldpos/BYTES; update_all_lines(VIEW,WLINES-1); } switch(ch){ case ESC: case 'q': case 'Q': QUIT=TRUE; break; case 'e': case 'E': Change2Edit(file_path); hex_edit(file_path); update_all_lines(VIEW,WLINES-1); Change2View(file_path); break; case KEY_DOWN: /*ScrollDown();*/ fstat(fd,&fdstat); if (fdstat.st_size > (current_line * BYTES) ) { current_line++; oldpos = current_line * BYTES; scroll_down(VIEW); } else beep(); break; case KEY_UP: /*ScroollUp();*/ if (current_line > 1) { current_line--; oldpos = current_line * BYTES; scroll_up(VIEW); } else beep(); break; case KEY_LEFT: case KEY_PPAGE: /*ScrollPageDown();*/ if (current_line > WLINES) current_line -= WLINES; else if (current_line > 1) current_line = 1; else beep(); oldpos = current_line * BYTES; update_all_lines(VIEW,WLINES); break; case KEY_RIGHT: case KEY_NPAGE: /*ScroollPageUp();*/ fstat(fd,&fdstat); if (fdstat.st_size > ((current_line - 1 + WLINES) * BYTES) ) { current_line += WLINES; } else { int n; n = fdstat.st_size / BYTES; /* numer of full lines */ if(fdstat.st_size % BYTES) { n++; /* plus 1 not fully used line */ } if(current_line != n) { current_line = n; } else { beep(); } } oldpos = current_line * BYTES; update_all_lines(VIEW,WLINES); break; case KEY_HOME: /*ScrollHome();*/ if (current_line > 1) { current_line = 1; oldpos = current_line * BYTES; update_all_lines(VIEW,WLINES-1); }else beep(); break; case KEY_END: /*ScrollEnd();*/ fstat(fd,&fdstat); if (fdstat.st_size >= BYTES * 2) current_line = (fdstat.st_size - BYTES) / BYTES; else beep(); oldpos = current_line * BYTES; update_all_lines(VIEW,WLINES); break; case 'L' & 0x1f: clearok(stdscr,TRUE); RefreshWindow(stdscr); break; default: break; } } Print( stdscr, 0, 0, "Path: ", MENU_COLOR ); delwin(VIEW); delwin(BORDER); touchwin(stdscr); wnoutrefresh(stdscr); close(fd); return 0; } ytree-1.99pl1/xmalloc.c000066400000000000000000000040601350711670100150250ustar00rootroot00000000000000/* xmalloc.c -- safe versions of malloc and realloc */ /* Copyright (C) 1991 Free Software Foundation, Inc. This file is part of GNU Readline, a library for reading lines of text with interactive input and history editing. Readline is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. Readline is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Readline; see the file COPYING. If not, write to the Free Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ #include "ytree.h" #define READLINE_LIBRARY #include "xmalloc.h" /* **************************************************************** */ /* */ /* Memory Allocation and Deallocation. */ /* */ /* **************************************************************** */ static void memory_error_and_abort (char *fname) { ERROR_MSG("malloc() Failed*Abort"); /* fprintf (stderr, "%s: out of virtual memory\n", fname); */ exit (2); } /* Return a pointer to free()able block of memory large enough to hold BYTES number of bytes. If the memory cannot be allocated, print an error message and abort. */ PTR_T xmalloc (size_t bytes) { PTR_T temp; temp = malloc (bytes); if (temp == 0) memory_error_and_abort ("xmalloc"); return (temp); } PTR_T xrealloc (PTR_T pointer, size_t bytes) { PTR_T temp; temp = pointer ? realloc (pointer, bytes) : malloc (bytes); if (temp == 0) memory_error_and_abort ("xrealloc"); return (temp); } /* Use this as the function to call when adding unwind protects so we don't need to know what free() returns. */ void xfree (PTR_T string) { if (string) free (string); } ytree-1.99pl1/xmalloc.h000066400000000000000000000024551350711670100150400ustar00rootroot00000000000000/* xmalloc.h -- memory allocation that aborts on errors. */ /* Copyright (C) 1999 Free Software Foundation, Inc. This file is part of the GNU Readline Library, a library for reading lines of text with interactive input and history editing. The GNU Readline Library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. The GNU Readline Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. The GNU General Public License is often shipped with GNU software, and is generally kept in a file called COPYING or LICENSE. If you do not have a copy of the license, write to the Free Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ #if !defined (_XMALLOC_H_) #define _XMALLOC_H_ #ifndef PTR_T #ifdef __STDC__ # define PTR_T void * #else # define PTR_T char * #endif #endif /* !PTR_T */ extern PTR_T xmalloc(size_t bytes); extern PTR_T xrealloc(PTR_T, size_t bytes); extern void xfree(PTR_T); #endif /* _XMALLOC_H_ */ ytree-1.99pl1/ytree-1.99pl1.lsm000066400000000000000000000013251350711670100161030ustar00rootroot00000000000000Begin4 Title: ytree-1.99pl1 Version: 1.99 Entered-date: 2016-09-04 Description: Ytree is a nifty filemanager similar to xtree. With some helper-applications (zip/zoo/tar/rpm etc.) you can also browse archive files. Viewers for "special" files are configurable (*.wav, *.gif etc.). Even the commands/menus are now user configurable. For a screenshot visit http://www.han.de/~werner/ytree.html Keywords: file manager, browser, xtree Author: werner@frolix.han.de (Werner Bregulla) Maintained-by: werner@frolix.han.de (Werner Bregulla) Primary-site: sunsite.unc.edu /pub/Linux/utils/file/managers ytree-1.99pl1.tar.gz ytree-1.99pl1.lsm Alternate-site: http://www.han.de/~werner/ytree.html Copying-policy: GPL End ytree-1.99pl1/ytree.1000066400000000000000000000175041350711670100144430ustar00rootroot00000000000000.\" extracted from ytree.doc 26 November 1996 by cmt2doc.pl .TH YTREE 1L "21 March 2004" " " "LOCAL COMMANDS" .PD .8v .SH NAME .nf ytree \- File Manager \- .fi .SH SYNOPSYS ytree [\fIarchiv file\fR|\fIdirectory\fR] .SH DESCRIPTION If there is no command line argument, the current directory will be used. Following commands are available: 1.) DIR-Modus: .TP \fB\-Attribute\fR Change direcory permissions (like chmod) .TP \fB\-Delete\fR Delete selected directory .TP \fB\-Filespec\fR Set file specification (reg. expression) e.g. *.[ch] for all *.c and *.h \- Files .TP \fB\-Group\fR Change directory group ownership .TP \fB\-Log\fR Restart ytree with new root directory/archiv file .TP \fB\-Makedir\fR Create new directory .TP \fB\-Owner\fR Change user ownership of selected directory .TP \fB\-Rename\fR Rename selected directory .TP \fB\-Showall\fR Show all files in all directories .TP \fB\-Tag\fR Tag all files in selected directory .TP \fB\-Untag\fR Untag all files in selected directory .TP \fB\-eXecute\fR Execute a shell commando .TP \fB\-^Filemode\fR Change viewmodus for files: .nf .RS \fB\- filenames only\fR \fB\- name, attributes, links, size,\fR \fB modification time, symb. link\fR \fB\- name, attribute, inode, owner, group, symb. link\fR \fB\- change status-, access time, symb. link\fR .fi .RE .TP \fB\-Return\fR Switch to file modus .TP \fB\-^Quit\fR QuitTo: If you exit ytree with ^Q, the last selected directory becomes your current working directory. This feature only works if you start ytree with this bash-function (copy this to your ~/.bashrc): .nf .RS function yt { echo cd $PWD >~/.ytree-$$.chdir /usr/bin/ytree $1 $2 $3 $4 $5 source ~/.ytree-$$.chdir rm ~/.ytree-$$.chdir } .fi .RE .TP .PP 2.) FILE-Modus .TP \fB\-Attribute\fR Change file permissions (like chmod) .TP \fB\-^Attribute\fR Change permissions of all tagged files. \fB?\fR stands for: do not change attribute .TP \fB\-Copy\fR Copy file .TP \fB\-^K Copy\fR Copy all tagged files .TP \fB\-Delete\fR Delete selected file .TP \fB\-^Delete\fR Delete all tagged files .TP \fB\-Edit\fR Edit selected file with EDITOR (see ~/.ytree) or \- if not defined \- vi .TP \fB\-Filespec\fR Set file specification (reg. expression) e.g. *.[ch] for all *.c and *.h \- Files .TP \fB\-Group\fR Change group ownership of selected file .TP \fB\-^Group\fR Change group ownership of all tagged files .TP \fB\-Hex\fR View selected file with HEXDUMP (see ~/.ytree), or \- if not defined \- hd / od \-h .TP \fB\-Log\fR Restart ytree with new root directory/archive file .TP \fB\-Move\fR move selected file .TP \fB\-^N Move\fR Move all tagged files .TP \fB\-Owner\fR Change user ownership of selected file .TP \fB\-^Owner\fR Change user owndership of all tagged files .TP \fB\-Pipe\fR Pipe content of file to a command .TP \fB\-^Pipe\fR Pipe content of all tagged files to a command .TP \fB\-Rename\fR Rename selected file .TP \fB\-^Rename\fR Rename all tagged files .TP \fB\-untag ^Search\fR Untag files by using an external program (e.g. grep) .TP \fB\-Sort\fR Sort filelist by .nf .RS \fB\- access time\fR \fB\- change time\fR \fB\- extension\fR \fB\- group\fR \fB\- modification time\fR \fB\- name\fR \fB\- owner\fR \fB\- size\fR .fi .RE .TP \fB\-Tag\fR Tag selected file .TP \fB\-^Tag\fR Tag all currently shown files .TP \fB\-Untag\fR Untag selected file .TP \fB\-^Untag\fR Untag all currently shown files .TP \fB\-View\fR View file with the pager defined in ~/.ytree or - if not defined - with pg \-cen .TP \fB\-eXecute\fR Execute a shell commando .TP \fB\-e^Xecute\fR Execute shell commando for all tagged files. The string {} is replaced by the current filename .TP \fB\-pathcopY\fR Copy selected file inclusive path .TP \fB\-pathcop^Y\fR Copy all tagged files inclusive path .TP \fB\-^Filemode\fR Switch view-modus for files: .nf .RS \fB\- filenames only\fR \fB\- name, attribute, links, size, modification time,\fR \fB symb. link\fR \fB\- name, attribute, inode, owner, group, symb. link\fR \fB\- changestatus-, access time, symb. link\fR .fi .RE .TP \fB\-^L\fR Refresh Screen .TP \fB\-Space\fR Suppress screen-output while working .TP \fB\-Return\fR Switch to expand modus .PP 3.) ARCHIV-DIR-Modus .TP \fB\-Filespec\fR Set file specification (reg. expression) e.g. *.[ch] for all *.c and *.h \- Files .TP \fB\-Log\fR Restart ytree with new root directory/archive file .TP \fB\-Showall\fR Show all files in all directories .TP \fB\-Tag\fR Tag all files in selected directory .TP \fB\-Untag\fR Untag all files in selected directory .TP \fB\-eXecute\fR Execute a shell commando .TP \fB\-^Filemode\fR Change viewmodus for files: .nf .RS \fB\- filenames only\fR \fB\- name, attribute, links, size, modification time\fR \fB\- name, attribute, owner, group\fR .fi .RE .TP \fB\-^L\fR Refresh Screen .PP 4.) ARCHIV-FILE-Modus: .TP \fB\-Copy\fR Copy selected file .TP \fB\-^K Copy\fR Copy all tagged files .TP \fB\-Filespec\fR Set file specification (reg. expression) e.g. *.[ch] for all *.c and *.h \- Files .TP \fB\-Hex\fR View selected file with HEXDUMP (see ~/.ytree), or \- if not defined \- hd / od \-h .TP \fB\-Pipe\fR Pipe content of all tagged to a command .TP \fB\-Sort\fR Sort file list by .nf .RS \fB\- access time\fR \fB\- change time\fR \fB\- extension\fR \fB\- group\fR \fB\- modification time\fR \fB\- name\fR \fB\- owner\fR \fB\- size\fR .fi .RE .TP \fB\-Tag\fR Tag selected file .TP \fB\-^Tag\fR Tag all files in selected directory .TP \fB\-Untag\fR Untag all files in selected directory .TP \fB\-View\fR View file with the pager defined in ~/.ytree or - if not defined - with pg \-cen .TP \fB\-eXecute\fR Execute a shell commando .TP \fB\-^Filemode\fR Switch view-modus for files: .nf .RS \fB\- filenames only\fR \fB\- name, attribute, links, size\fR .fi .RE .TP \fB\-^L\fR Refresh Screen .TP \fB\-Return\fR Switch to Expand-Modus .PP ytree switches to archive-modus automatically either by choosing an archive file with the \fILog\fR commando or by calling ytree from the command line with an archive file given as a command line argument. ytree recognize the filename extensions ".F", ".Z", ".z" and ".gz" and calls the appropriate uncompressor MELT (default=melt), UNCOMPRESS (default=uncompress) and GNUUNZIP (default=gunzip \-c). You may change these settings in ~/.ytree. ytree supports following archive types and requires: .nf .RS .sp 1 \fB TAR-Files: gtar (tested with GNU-TAR 1.12)\fR \fB ARC-Files: arc (tested with arc 5.12 02/05/86)\fR \fB LHA-Files: xlharc (tested with xlharc V1.02 1989)\fR \fB ZIP-Files: unzip (tested with unzip v5.0 08/92)\fR \fB " " zipinfo (tested with zipinfo v1.0 08/92)\fR \fB ZOO-Files: zoo (tested with zoo v2.10)\fR \fB RAR-Files: unrar (tested with unrar v2.01\fR \fB RPM-Files: rpm2cpio (tested with RedHat V6.1)\fR \fB " " rpm (tested with RedHat V6.1)\fR .fi .RE Archive files will be recognized by filename extension (e.g zoo, zip). TAR-Files may have following extensions: .nf .RS .sp 1 \fB ".F", ".TFR", ".Faa", (freeze)\fR \fB ".Z", ".TZ", ".TZR", ".Xaa", (compress)\fR \fB ".z", ".gz", ".tzr", ".tz", ".xaa", ".tgz", ".TGZ",\fR \fB ".taz", ".TAZ", ".tpz" und ".TPZ" (gzip)\fR .fi .RE The View commando is customizeable in the [VIEWER] section of ~/.ytree: Example: .nf \fB [VIEWER] \fB .jpg,.gif,.bmp,.tif,.ppm,.xpm=xv \fB .1,.2,.3,.4,.5,.6,.7,.8,.n=nroff -man | less \fB .ps=ghostview \fB .mid,.MID=playmidi -e \fB .wav,.WAV=splay \fB .au=auplay \fB .avi,.mpg,.mov=xanim \fB .htm,.html=lynx \fB .pdf,.PDF=acroread \fB .mp3=mpg123 .fi .PP A command-line history is supported: Use cursor up/down. Use "F2" on the command-line to select directories. .SH FILES $HOME/.ytree ytree configuration file .SH BUGS To avoid problems with escape sequences on RS/6000 machines (telnet/rlogin) please set the environment variable ESCDELAY: .nf .sp 1 ESCDELAY=1000 export ESCDELAY .fi .SH AUTOR W. Bregulla (werner@frolix.han.de) ytree-1.99pl1/ytree.1.KOI8-R000066400000000000000000000217451350711670100153550ustar00rootroot00000000000000.\" extracted from ytree.doc 26 November 1996 by cmt2doc.pl .TH YTREE 1L "21 March 2004" " " "LOCAL COMMANDS" .PD .8v .SH éíñ .nf ytree \- íÅÎÅÄÖÅÒ ÆÁÊÌÏ× .fi .SH ïâúïò ytree [\fIÆÁÊÌ ÁÒÈÉ×Á\fR|\fIËÁÔÁÌÏÇ\fR] .SH ïðéóáîéå åÓÌÉ × ËÏÍÁÎÄÎÏÊ ÓÔÒÏËÅ ÎÅ ÚÁÄÁÎ ÁÒÇÕÍÅÎÔ, ÔÏ ÂÕÄÅÔ ÉÓÐÏÌØÚÏ×ÁÎ ÔÅËÕÝÉÊ ËÁÔÁÌÏÇ. äÏÓÔÕÐÎÙ ÓÌÅÄÕÀÝÉÅ ËÏÍÁÎÄÙ: 1.) òÅÖÉÍ DIR: .TP \fB\-Attribute\fR éÚÍÅÎÅÎÉÔØ ÐÒÁ×Á ÄÏÓÔÕÐÁ Ë ËÁÔÁÌÏÇÕ (ËÁË chmod) .TP \fB\-Delete\fR õÄÁÌÉÔØ ×ÙÂÒÁÎÎÙÊ ËÁÔÁÌÏÇÁ .TP \fB\-Filespec\fR õÓÔÁÎÏ×ÉÔØ ÍÁÓËÕ ÆÁÊÌÏ× (ÒÅÇÕÌÑÒÎÏÅ ×ÙÒÁÖÅÎÉÅ) ÎÁÐÒÉÍÅÒ *.[ch] ÄÌÑ ×ÓÅÈ ÆÁÊÌÏ× *.c É *.h .TP \fB\-Group\fR éÚÍÅÎÉÔØ ÇÒÕÐÐÕ ×ÌÁÄÅÌØÃÁ .TP \fB\-Log\fR ðÅÒÅÚÁÐÕÓÔÉÔØ ytree Ó ÎÏ×ÙÍ ËÏÒÎÅ×ÙÍ ËÁÔÁÌÏÇÏÍ ÉÌÉ ÁÒÈÉ×ÎÙÍ ÆÁÊÌÏÍ .TP \fB\-Makedir\fR óÏÚÄÁÔØ ÎÏ×ÙÊ ËÁÔÁÌÏÇ .TP \fB\-Owner\fR éÚÍÅÎÉÔØ ×ÌÁÄÅÌØÃÁ ×ÙÂÒÁÎÎÏÇÏ ËÁÔÁÌÏÇÁ .TP \fB\-Rename\fR ðÅÒÅÉÍÅÎÏ×ÁÔØ ×ÙÂÒÁÎÎÙÊ ËÁÔÁÌÏÇ .TP \fB\-Showall\fR ðÏËÁÚÁÔØ ×ÓÅ ÆÁÊÌÙ ×Ï ×ÓÅÈ ËÁÔÁÌÏÇÁÈ .TP \fB\-Tag\fR ïÔÍÅÔÉÔØ ×ÓÅ ÆÁÊÌÙ × ×ÙÂÒÁÎÎÏÍ ËÁÔÁÌÏÇÅ .TP \fB\-Untag\fR óÎÑÔØ ÏÔÍÅÔËÕ ÓÏ ×ÓÅÈ ÆÁÊÌÏ× × ×ÙÂÒÁÎÎÏÍ ËÁÔÁÌÏÇÅ .TP \fB\-eXecute\fR ÷ÙÐÏÌÎÉÔØ ËÏÍÁÎÄÕ shell .TP \fB\-^Filemode\fR éÚÍÅÎÉÔØ ÒÅÖÉÍ ÐÒÏÓÍÏÔÒÁ ÆÁÊÌÏ×: .nf .RS \fB\- ÔÏÌØËÏ ÉÍÅÎÁ ÆÁÊÌÏ×\fR \fB\- ÉÍÑ, ÁÔÒÉÂÕÔ, ÓÓÙÌËÉ, ÒÁÚÍÅÒ,\fR \fB ×ÒÅÍÑ ÐÏÓÌÅÄÎÅÇÏ ÉÚÍÅÎÅÎÉÑ, ÓÉÍ×ÏÌØÎÁÑ ÓÓÙÌËÁ\fR \fB\- ÉÍÑ, ÁÔÒÉÂÕÔ, inode, ×ÌÁÄÅÌÅÃ, ÇÒÕÐÐÁ, ÓÉÍ×ÏÌØÎÁÑ ÓÓÙÌËÁ\fR \fB\- ÓÏÓÔÏÑÎÉÅ ÉÚÍÅÎÅÎÉÑ-, ×ÒÅÍÑ ÐÏÓÌÅÄÎÅÇÏ ÄÏÓÔÕÐÁ, ÓÉÍ×ÏÌØÎÁÑ ÓÓÙÌËÁ\fR .fi .RE .TP \fB\-Return\fR ðÅÒÅÊÔÉ × ÒÅÖÉÍ ÆÁÊÌÏ× FILE .TP \fB\-^Quit\fR ÷ÙÈÏÄ: åÓÌÉ ×Ù ×ÙÈÏÄÉÔÅ ÉÚ ytree Ó ÐÏÍÏÝØÀ ËÏÍÁÎÄÙ ^Q, ÔÏ ÐÏÓÌÅÄÎÉÊ ×ÙÂÒÁÎÎÙÊ ËÁÔÁÌÏÇ ÓÔÁÎÏ×ÉÔÓÑ ×ÁÛÉÍ ÔÅËÕÝÉÍ ÒÁÂÏÞÉÍ ËÁÔÁÌÏÇÏÍ. üÔÁ ÏÓÏÂÅÎÎÏÓÔØ ÒÁÂÏÔÁÅÔ ÔÏÌØËÏ ÅÓÌÉ ×Ù ÚÁÐÕÓÔÉÌÉ ytree Ó ÐÏÍÏÝØÀ ÓÐÅÃÉÁÌØÎÏÊ bash-ÆÕÎËÃÉÉ (ÓËÏÐÉÒÕÊÔÅ × ×ÁÛ ~/.bashrc ÓÌÅÄÕÀÝÉÅ ÓÔÒÏËÉ): .nf .RS function yt { echo cd $PWD >~/.ytree-$$.chdir /usr/bin/ytree $1 $2 $3 $4 $5 source ~/.ytree-$$.chdir rm ~/.ytree-$$.chdir } .fi .RE .TP .PP 2.) òÅÖÉÍ FILE .TP \fB\-Attribute\fR éÚÍÅÎÉÔØ ÐÒÁ×Á ÄÏÓÔÕÐÁ Ë ÆÁÊÌÕ (ËÁË chmod) .TP \fB\-^Attribute\fR éÚÍÅÎÉÔØ ÐÒÁ×Á ÄÏÓÔÕÐÁ ×ÓÅÈ ÏÔÍÅÞÅÎÎÙÈ ÆÁÊÌÏ×. \fB?\fR ÏÚÎÁÞÁÅÔ: ÎÅ ÉÚÍÅÎÉÔØ ÁÔÒÉÂÕÔ .TP \fB\-Copy\fR ëÏÐÉÒÏ×ÁÔØ ÆÁÊÌ .TP \fB\-^K Copy\fR ëÏÐÉÒÏ×ÁÔØ ×ÓÅ ÏÔÍÅÞÅÎÎÙÅ ÆÁÊÌÙ .TP \fB\-Delete\fR õÄÁÌÉÔØ ×ÙÂÒÁÎÎÙÊ ÆÁÊÌ .TP \fB\-^Delete\fR õÄÁÌÉÔØ ×ÓÅ ×ÙÂÒÁÎÎÙÅ ÆÁÊÌÙ .TP \fB\-Edit\fR éÚÍÅÎÉÔØ ×ÙÂÒÁÎÎÙÊ ÆÁÊÌ Ó ÐÏÍÏÝØÀ ÒÅÄÁËÔÏÒÁ, ÏÐÉÓÁÎÎÏÇÏ × ÐÅÒÅÍÅÎÎÏÊ EDITOR (ÓÍ. ~/.ytree) ÉÌÉ \- ÅÓÌÉ ÐÅÒÅÍÅÎÎÁÑ ÎÅ ÏÐÒÅÄÅÌÅÎÁ \- vi .TP \fB\-Filespec\fR õÓÔÁÎÏ×ÉÔØ ÍÁÓËÕ ÆÁÊÌÏ× (ÒÅÇÕÌÑÒÎÏÅ ×ÙÒÁÖÅÎÉÅ) ÎÁÐÒÉÍÅÒ *.[ch] ÄÌÑ ×ÓÅÈ ÆÁÊÌÏ× *.c É *.h .TP \fB\-Group\fR éÚÍÅÎÉÔØ ÇÒÕÐÐÕ ×ÌÁÄÅÌØÃÁ ×ÙÂÒÁÎÎÏÇÏ ÆÁÊÌÁ .TP \fB\-^Group\fR éÚÍÅÎÉÔØ ÇÒÕÐÐÕ ×ÌÁÄÅÌØÃÁ ×ÓÅÈ ÏÔÍÅÞÅÎÎÙÈ ÆÁÊÌÏ× .TP \fB\-Hex\fR ðÒÏÓÍÏÔÒÅÔØ ×ÙÂÒÁÎÎÙÊ ÆÁÊÌ Ó ÐÏÍÏÝØÀ ÐÒÏÇÒÁÍÍÙ, ÕËÁÚÁÎÎÏÊ × ÐÅÒÅÍÅÎÎÏÊ HEXDUMP (ÓÍ. ~/.ytree), ÉÌÉ \- ÅÓÌÉ ÐÅÒÅÍÅÎÎÁÑ ÎÅ ÏÐÒÅÄÅÌÅÎÁ \- hd / od \-h .TP \fB\-Log\fR ðÅÒÅÚÁÐÕÓÔÉÔØ ytree Ó ÎÏ×ÙÍ ËÏÒÎÅ×ÙÍ ËÁÔÁÌÏÇÏÍ ÉÌÉ ÁÒÈÉ×ÎÙÍ ÆÁÊÌÏÍ .TP \fB\-Move\fR ðÅÒÅÍÅÓÔÉÔØ ×ÙÂÒÁÎÎÙÊ ÆÁÊÌ .TP \fB\-^N Move\fR ðÅÒÅÍÅÓÔÉÔØ ×ÓÅ ÏÔÍÅÞÅÎÎÙÅ ÆÁÊÌÙ .TP \fB\-Owner\fR éÚÍÅÎÉÔØ ×ÌÁÄÅÌØÃÁ ×ÙÂÒÁÎÎÏÇÏ ÆÁÊÌÁ .TP \fB\-^Owner\fR éÚÍÅÎÉÔØ ×ÌÁÄÅÌØÃÁ ×ÓÅÈ ÏÔÍÅÞÅÎÎÙÈ ÆÁÊÌÏ× .TP \fB\-Pipe\fR ïÔÐÒÁ×ÉÔØ ÓÏÄÅÒÖÉÍÏÅ ÆÁÊÌÁ ÎÁ ÓÔÁÎÄÁÒÔÎÙÊ ××ÏÄ ×ÎÅÛÎÅÊ ËÏÍÁÎÄÙ .TP \fB\-^Pipe\fR ïÔÐÒÁ×ÉÔØ ÓÏÄÅÒÖÉÍÏÅ ×ÓÅÈ ÏÔÍÅÞÅÎÎÙÈ ÆÁÊÌÏ× ÎÁ ÓÔÁÎÄÁÒÔÎÙÊ ××ÏÄ ×ÎÅÛÎÅÊ ËÏÍÁÎÄÙ .TP \fB\-Rename\fR ðÅÒÅÉÍÅÎÏ×ÁÔØ ×ÙÂÒÁÎÎÙÊ ÆÁÊÌ .TP \fB\-^Rename\fR ðÅÒÅÉÍÅÎÏ×ÁÔØ ×ÓÅ ÏÔÍÅÞÅÎÎÙÅ ÆÁÊÌÙ .TP \fB\-untag ^Search\fR óÎÑÔØ ÐÏÍÅÔËÕ Ó ÐÏÍÏÝØÀ ×ÎÅÛÎÅÊ ÐÒÏÇÒÁÍÍÙ (ÎÁÐÒÉÍÅÒ grep) .TP \fB\-Sort\fR ïÔÓÏÒÔÉÒÏ×ÁÔØ ÓÐÉÓÏË ÆÁÊÌÏ× ÐÏ .nf .RS \fB\- ×ÒÅÍÅÎÉ ÄÏÓÔÕÐÁ\fR \fB\- ×ÒÅÍÅÎÉ ÉÚÍÅÎÅÎÉÑ\fR \fB\- ÒÁÓÛÉÒÅÎÉÀ\fR \fB\- ÇÒÕÐÐÅ\fR \fB\- ×ÒÅÍÅÎÉ ÉÚÍÅÎÅÎÉÑ\fR \fB\- ÉÍÅÎÉ\fR \fB\- ×ÌÁÄÅÌØÃÕ\fR \fB\- ÒÁÚÍÅÒÕ\fR .fi .RE .TP \fB\-Tag\fR ïÔÍÅÔÉÔØ ×ÙÂÒÁÎÎÙÊ ÆÁÊÌ .TP \fB\-^Tag\fR ïÔÍÅÔÉÔØ ×ÓÅ ÆÁÊÌÙ, ËÏÔÏÒÙÅ ÐÏËÁÚÙ×ÁÀÔÓÑ × ÄÁÎÎÙÊ ÍÏÍÅÎÔ .TP \fB\-Untag\fR óÎÑÔØ ÏÔÍÅÔËÕ Ó ×ÙÂÒÁÎÎÏÇÏ ÆÁÊÌÁ .TP \fB\-^Untag\fR óÎÑÔØ ÏÔÍÅÔËÕ ÓÏ ×ÓÅÈ ÆÁÊÌÏ×, ËÏÔÏÒÙÅ ÐÏËÁÚÙ×ÁÀÔÓÑ × ÄÁÎÎÙÊ ÍÏÍÅÎÔ .TP \fB\-View\fR ðÒÏÓÍÏÔÒÅÔØ ÆÁÊÌ Ó ÐÏÍÏÝØÀ ÐÒÏÇÒÁÍÍÙ, ÚÁÄÁÎÎÏÊ × ÐÅÒÅÍÅÎÎÏÊ PAGER (ÓÍ. ~/.ytree) ÉÌÉ \- ÅÓÌÉ ÐÅÒÅÍÅÎÎÁÑ ÎÅ ÏÐÒÅÄÅÌÅÎÁ \- pg \-cen .TP \fB\-eXecute\fR ÷ÙÐÏÌÎÉÔØ ËÏÍÁÎÄÕ shell .TP \fB\-e^Xecute\fR ÷ÙÐÏÌÎÉÔØ ËÏÍÁÎÄÕ shell ÄÌÑ ×ÓÅÈ ÏÔÍÅÞÅÎÎÙÈ ÆÁÊÌÏ×. óÔÒÏËÁ {} ÚÁÍÅÎÑÅÔÓÑ ÔÅËÕÝÉÍ ÉÍÅÎÅÍ ÆÁÊÌÁ .TP \fB\-pathcopY\fR ëÏÐÉÒÏ×ÁÔØ ×ÙÂÒÁÎÎÙÊ ÆÁÊÌ, ×ËÌÀÞÁÑ ÐÕÔØ .TP \fB\-pathcop^Y\fR ëÏÐÉÒÏ×ÁÔØ ×ÓÅ ÏÔÍÅÞÅÎÎÙÅ ÆÁÊÌÙ, ×ËÌÀÞÁÑ ÐÕÔØ .TP \fB\-^Filemode\fR ðÅÒÅËÌÀÞÉÔØ ÒÅÖÉÍ ÐÒÏÓÍÏÔÒÁ ÓÐÉÓËÁ ÆÁÊÌÏ×: .nf .RS \fB\- ÔÏÌØËÏ ÉÍÅÎÁ ÆÁÊÌÏ×\fR \fB\- ÉÍÑ, ÁÔÒÉÂÕÔ, ÓÓÙÌËÉ, ÒÁÚÍÅÒ, ×ÒÅÍÑ ÐÏÓÌÅÄÎÅÇÏ ÉÚÍÅÎÅÎÉÑ,\fR \fB ÓÉÍ×ÏÌØÎÁÑ ÓÓÙÌËÁ\fR \fB\- ÉÍÑ, ÁÔÒÉÂÕÔ, inode, ×ÌÁÄÅÌÅÃ, ÇÒÕÐÐÁ, ÓÉÍ×ÏÌØÎÁÑ ÓÓÙÌËÁ\fR \fB\- ÓÔÁÔÕÓ ÉÚÍÅÎÅÎÉÑ-, ×ÒÅÍÑ ÐÏÓÌÅÄÎÅÇÏ ÄÏÓÔÕÐÁ, ÓÉÍ×ÏÌØÎÁÑ ÓÓÙÌËÁ\fR .fi .RE .TP \fB\-^L\fR ïÂÎÏ×ÉÔØ ÜËÒÁÎ .TP \fB\-Space\fR ðÏÄÁ×ÌÑÔØ ×Ù×ÏÄ ÎÁ ÜËÒÁÎ ×Ï ×ÒÅÍÑ ÒÁÂÏÔÙ .TP \fB\-Return\fR ðÅÒÅËÌÀÞÉÔØÓÑ × ÒÁÓÛÉÒÅÎÎÙÊ ÒÅÖÉÍ .PP 3.) òÅÖÉÍ ARCHIV-DIR .TP \fB\-Filespec\fR õÓÔÁÎÏ×ÉÔØ ÍÁÓËÕ ÆÁÊÌÏ× (ÒÅÇÕÌÑÒÎÏÅ ×ÙÒÁÖÅÎÉÅ) ÎÁÐÒÉÍÅÒ *.[ch] ÄÌÑ ×ÓÅÈ ÆÁÊÌÏ× *.c É *.h .TP \fB\-Log\fR ðÅÒÅÚÁÐÕÓÔÉÔØ ytree Ó ÎÏ×ÙÍ ËÏÒÎÅ×ÙÍ ËÁÔÁÌÏÇÏÍ ÉÌÉ ÁÒÈÉ×ÎÙÍ ÆÁÊÌÏÍ .TP \fB\-Showall\fR ðÏËÁÚÁÔØ ×ÓÅ ÆÁÊÌÙ ×Ï ×ÓÅÈ ËÁÔÁÌÏÇÁÈ .TP \fB\-Tag\fR ïÔÍÅÔÉÔØ ÆÁÊÌÙ × ×ÙÂÒÁÎÎÏÍ ËÁÔÁÌÏÇÅ .TP \fB\-Untag\fR óÎÑÔØ ÏÔÍÅÔËÕ ÓÏ ×ÓÅÈ ÆÁÊÌÏ× × ×ÙÂÒÁÎÎÏÍ ËÁÔÁÌÏÇÅ .TP \fB\-eXecute\fR ÷ÙÐÏÌÎÉÔØ ËÏÍÁÎÄÕ shell .TP \fB\-^Filemode\fR ðÅÒÅËÌÀÞÉÔØ ÒÅÖÉÍ ÐÒÏÓÍÏÔÒÁ ÓÐÉÓËÁ ÆÁÊÌÏ×: .nf .RS \fB\- ÔÏÌØËÏ ÉÍÅÎÁ ÆÁÊÌÏ×\fR \fB\- ÉÍÑ, ÁÔÒÉÂÕÔ, ÓÓÙÌËÉ, ÒÁÚÍÅÒ, ×ÒÅÍÑ ÐÏÓÌÅÄÎÅÇÏ ÉÚÍÅÎÅÎÉÑ\fR \fB\- ÉÍÑ, ÁÔÒÉÂÕÔ, ×ÌÁÄÅÌÅÃ, ÇÒÕÐÐÁ\fR .fi .RE .TP \fB\-^L\fR ïÂÎÏ×ÉÔØ ÜËÒÁÎ .PP 4.) òÅÖÉÍ ARCHIV-FILE .TP \fB\-Copy\fR ëÏÐÉÒÏ×ÁÔØ ×ÙÂÒÁÎÎÙÊ ÆÁÊÌ .TP \fB\-^K Copy\fR ëÏÐÉÒÏ×ÁÔØ ×ÓÅ ÏÔÍÅÞÅÎÎÙÅ ÆÁÊÌÙ .TP \fB\-Filespec\fR õÓÔÁÎÏ×ÉÔØ ÍÁÓËÕ ÆÁÊÌÏ× (ÒÅÇÕÌÑÒÎÏÅ ×ÙÒÁÖÅÎÉÅ) ÎÁÐÒÉÍÅÒ *.[ch] ÄÌÑ ×ÓÅÈ ÆÁÊÌÏ× *.c É *.h .TP \fB\-Hex\fR ðÒÏÓÍÏÔÒÅÔØ ×ÙÂÒÁÎÎÙÊ ÆÁÊÌ Ó ÐÏÍÏÝØÀ ÐÒÏÇÒÁÍÍÙ, ÕËÁÚÁÎÎÏÊ × ÐÅÒÅÍÅÎÎÏÊ HEXDUMP (ÓÍ. ~/.ytree), ÉÌÉ \- ÅÓÌÉ ÐÅÒÅÍÅÎÎÁÑ ÎÅ ÏÐÒÅÄÅÌÅÎÁ \- hd / od \-h .TP \fB\-Pipe\fR ïÔÐÒÁ×ÉÔØ ÓÏÄÅÒÖÉÍÏÅ ÆÁÊÌÁ ÎÁ ÓÔÁÎÄÁÒÔÎÙÊ ××ÏÄ ×ÎÅÛÎÅÊ ËÏÍÁÎÄÙ .TP \fB\-Sort\fR ïÔÓÏÒÔÉÒÏ×ÁÔØ ÓÐÉÓÏË ÆÁÊÌÏ× ÐÏ .nf .RS \fB\- ×ÒÅÍÅÎÉ ÄÏÓÔÕÐÁ\fR \fB\- ×ÒÅÍÅÎÉ ÉÚÍÅÎÅÎÉÑ\fR \fB\- ÒÁÓÛÉÒÅÎÉÀ\fR \fB\- ÇÒÕÐÐÅ\fR \fB\- ×ÒÅÍÅÎÉ ÉÚÍÅÎÅÎÉÑ\fR \fB\- ÉÍÅÎÉ\fR \fB\- ×ÌÁÄÅÌØÃÕ\fR \fB\- ÒÁÚÍÅÒÕ\fR .fi .RE .TP \fB\-Tag\fR ïÔÍÅÔÉÔØ ×ÙÂÒÁÎÎÙÊ ÆÁÊÌ .TP \fB\-^Tag\fR ïÔÍÅÔÉÔØ ×ÓÅ ÆÁÊÌÙ × ×ÙÂÒÁÎÎÏÍ ËÁÔÁÌÏÇÅ .TP \fB\-Untag\fR óÎÑÔØ ÏÔÍÅÔËÕ ÓÏ ×ÓÅÈ ÆÁÊÌÏ× × ×ÙÂÒÁÎÎÏÍ ËÁÔÁÌÏÇÅ .TP \fB\-View\fR ðÒÏÓÍÏÔÒÅÔØ ÆÁÊÌ Ó ÐÏÍÏÝØÀ ÐÒÏÇÒÁÍÍÙ, ÚÁÄÁÎÎÏÊ × ÐÅÒÅÍÅÎÎÏÊ PAGER (ÓÍ. ~/.ytree) ÉÌÉ \- ÅÓÌÉ ÐÅÒÅÍÅÎÎÁÑ ÎÅ ÏÐÒÅÄÅÌÅÎÁ \- pg \-cen .TP \fB\-eXecute\fR ÷ÙÐÏÌÎÉÔØ ËÏÍÁÎÄÕ shell .TP \fB\-^Filemode\fR ðÅÒÅËÌÀÞÉÔØ ÒÅÖÉÍ ÐÒÏÓÍÏÔÒÁ ÆÁÊÌÏ×: .nf .RS \fB\- ÔÏÌØËÏ ÉÍÅÎÁ ÆÁÊÌÏ×\fR \fB\- ÉÍÑ, ÁÔÒÉÂÕÔ, ÓÓÙÌËÉ, ÒÁÚÍÅÒ\fR .fi .RE .TP \fB\-^L\fR ïÂÎÏ×ÉÔØ ÜËÒÁÎ .TP \fB\-Return\fR ðÅÒÅÊÔÉ × ÒÁÓÛÉÒÅÎÎÙÊ ÒÅÖÉÍ .PP ytree ÐÅÒÅËÌÀÞÁÅÔÓÑ × ÒÅÖÉÍ ÒÁÂÏÔÙ Ó ÁÒÈÉ×ÁÍÉ Á×ÔÏÍÁÔÉÞÅÓËÉ ÅÓÌÉ ×ÙÂÒÁÎ ÆÁÊÌ ÁÒÈÉ×Á ÞÅÒÅÚ ËÏÍÁÎÄÕ \fILog\fR ÉÌÉ ÐÒÉ ×ÙÚÏ×Å ytree ÉÚ ËÏÍÁÎÄÎÏÊ ÓÔÒÏËÉ, ËÏÇÄÁ × ËÁÞÅÓÔ×Å ÁÒÇÍÅÎÔÁ ÚÁÄÁÎ ÆÁÊÌ ÁÒÈÉ×Á. ytree ÒÁÓÐÏÚÎÁ£Ô ÒÁÓÛÉÒÅÎÉÑ ÁÊÌÏ× ".F", ".Z", ".z" É ".gz" É ×ÙÚÙ×ÁÅÔ ÓÏÏÔ×ÅÔÓÔ×ÕÀÝÕÀ ÐÒÏÇÒÁÍÍÕ-ÄÅËÏÍÐÒÅÓÓÏÒ, ÚÁÄÁÎÎÕÀ × ÐÅÒÅÍÅÎÎÙÈ MELT (ÐÏ ÕÍÏÌÞÁÎÉÀ=melt), UNCOMPRESS (ÐÏ ÕÍÏÌÞÁÎÉÀ=uncompress) É GNUUNZIP (ÐÏ ÕÍÏÌÞÁÎÉÀ=gunzip \-c). ÷Ù ÍÏÖÅÔÅ ÉÚÍÅÎÉÔØ ÚÎÁÞÅÎÉÅ ÜÔÉÈ ÐÅÒÅÍÅÎÎÙÈ × ÆÁÊÌÅ ~/.ytree. ytree ÐÏÄÄÅÒÖÉ×ÁÅÔ ÓÌÅÄÕÀÝÉÅ ×ÉÄÙ ÁÒÈÉ×Ï× É ÔÒÅÂÕÅÔ: .nf .RS .sp 1 \fB TAR-ÆÁÊÌÙ: gtar (ÔÅÓÔÉÒÏ×ÁÎÏ Ó GNU-TAR 1.12)\fR \fB ARC-ÆÁÊÌÙ: arc (ÔÅÓÔÉÒÏ×ÁÎÏ Ó arc 5.12 02/05/86)\fR \fB LHA-ÆÁÊÌÙ: xlharc (ÔÅÓÔÉÒÏ×ÁÎÏ Ó xlharc V1.02 1989)\fR \fB ZIP-ÆÁÊÌÙ: unzip (ÔÅÓÔÉÒÏ×ÁÎÏ Ó unzip v5.0 08/92)\fR \fB " " zipinfo (ÔÅÓÔÉÒÏ×ÁÎÏ Ó zipinfo v1.0 08/92)\fR \fB ZOO-ÆÁÊÌÙ: zoo (ÔÅÓÔÉÒÏ×ÁÎÏ Ó zoo v2.10)\fR \fB RAR-ÆÁÊÌÙ: unrar (ÔÅÓÔÉÒÏ×ÁÎÏ Ó unrar v2.01\fR \fB RPM-ÆÁÊÌÙ: rpm2cpio (ÔÅÓÔÉÒÏ×ÁÎÏ Ó RedHat V6.1)\fR \fB " " rpm (ÔÅÓÔÉÒÏ×ÁÎÏ Ó RedHat V6.1)\fR .fi .RE æÁÊÌÙ ÁÒÈÉ×Ï× ÒÁÓÐÏÚÎÁÀÔÓÑ ÐÏ ÒÁÓÛÉÒÅÎÉÑÍ ÉͣΠÆÁÊÌÏ× (ÎÁÐÒÉÍÅÒ zoo, zip). TAR-ÆÁÊÌÙ ÍÏÇÕÔ ÉÍÅÔØ ÓÌÅÄÕÀÝÉÅ ÒÁÓÛÉÒÅÎÉÑ: .nf .RS .sp 1 \fB ".F", ".TFR", ".Faa", (freeze)\fR \fB ".Z", ".TZ", ".TZR", ".Xaa", (compress)\fR \fB ".z", ".gz", ".tzr", ".tz", ".xaa", ".tgz", ".TGZ",\fR \fB ".taz", ".TAZ", ".tpz" und ".TPZ" (gzip)\fR .fi .RE ëÏÍÁÎÄÁ View ÎÁÓÔÒÁÉ×ÁÅÔÓÑ × ÓÅËÃÉÉ [VIEWER] ÆÁÊÌÁ ~/.ytree: ðÒÉÍÅÒ: .nf \fB [VIEWER] \fB .jpg,.gif,.bmp,.tif,.ppm,.xpm=xv \fB .1,.2,.3,.4,.5,.6,.7,.8,.n=nroff -man | less \fB .ps=ghostview \fB .mid,.MID=playmidi -e \fB .wav,.WAV=splay \fB .au=auplay \fB .avi,.mpg,.mov=xanim \fB .htm,.html=lynx \fB .pdf,.PDF=acroread \fB .mp3=mpg123 .fi .PP ðÏÄÄÅÒÖÉ×ÁÅÔÓÑ ÉÓÔÏÒÉÑ ËÏÍÁÎÄ: éÓÐÏÌØÚÕÊÔÅ ÓÔÒÅÌËÉ ËÕÒÓÏÒÁ ××ÅÒÈ/×ÎÉÚ. éÓÐÏÌØÚÕÊÔÅ "F2" × ÓÔÒÏËÅ ËÏÍÁÎÄÙ, ÞÔÏÂÙ ×ÙÂÒÁÔØ ËÁÔÁÌÏÇ. .SH æáêìù $HOME/.ytree ÆÁÊÌ Ó ÎÁÓÔÒÏÊËÁÍÉ ytree .SH âáçé þÔÏÂÙ ÉÚÂÅÖÁÔØ ÐÒÏÂÌÅÍ Ó ESC ÐÏÓÌÅÄÏ×ÁÔÅÌØÎÏÓÔÑÍÉ ÎÁ ÍÁÛÉÎÁÈ RS/6000 (telnet/rlogin) ÐÏÖÁÌÕÊÓÔÁ ÕÓÔÁÎÏ×ÉÔÅ ÐÅÒÅÍÅÎÎÕÀ ÏËÒÕÖÅÎÉÑ ESCDELAY: .nf .sp 1 ESCDELAY=1000 export ESCDELAY .fi .SH á÷ôïò W. Bregulla (werner@frolix.han.de) .SH ðåòå÷ïä ðÅÒÅ×£Ì Ó ÁÎÇÌÉÊÓËÏÇÏ ÷ÉËÔÏÒ ÷ÉÓÌÏÂÏËÏ× 2005 ytree-1.99pl1/ytree.1.UTF-8000066400000000000000000000327521350711670100152470ustar00rootroot00000000000000.\" extracted from ytree.doc 26 November 1996 by cmt2doc.pl .TH YTREE 1L "21 March 2004" " " "LOCAL COMMANDS" .PD .8v .SH ИМЯ .nf ytree \- Менеджер файлов .fi .SH ОБЗОР ytree [\fIфайл архива\fR|\fIкаталог\fR] .SH ОПИСÐÐИЕ ЕÑли в командной Ñтроке не задан аргумент, то будет иÑпользован текущий каталог. ДоÑтупны Ñледующие команды: 1.) Режим DIR: .TP \fB\-Attribute\fR Измененить права доÑтупа к каталогу (как chmod) .TP \fB\-Delete\fR Удалить выбранный каталога .TP \fB\-Filespec\fR УÑтановить маÑку файлов (регулÑрное выражение) например *.[ch] Ð´Ð»Ñ Ð²Ñех файлов *.c и *.h .TP \fB\-Group\fR Изменить группу владельца .TP \fB\-Log\fR ПерезапуÑтить ytree Ñ Ð½Ð¾Ð²Ñ‹Ð¼ корневым каталогом или архивным файлом .TP \fB\-Makedir\fR Создать новый каталог .TP \fB\-Owner\fR Изменить владельца выбранного каталога .TP \fB\-Rename\fR Переименовать выбранный каталог .TP \fB\-Showall\fR Показать вÑе файлы во вÑех каталогах .TP \fB\-Tag\fR Отметить вÑе файлы в выбранном каталоге .TP \fB\-Untag\fR СнÑть отметку Ñо вÑех файлов в выбранном каталоге .TP \fB\-eXecute\fR Выполнить команду shell .TP \fB\-^Filemode\fR Изменить режим проÑмотра файлов: .nf .RS \fB\- только имена файлов\fR \fB\- имÑ, атрибут, ÑÑылки, размер,\fR \fB Ð²Ñ€ÐµÐ¼Ñ Ð¿Ð¾Ñледнего изменениÑ, ÑÐ¸Ð¼Ð²Ð¾Ð»ÑŒÐ½Ð°Ñ ÑÑылка\fR \fB\- имÑ, атрибут, inode, владелец, группа, ÑÐ¸Ð¼Ð²Ð¾Ð»ÑŒÐ½Ð°Ñ ÑÑылка\fR \fB\- ÑоÑтоÑние изменениÑ-, Ð²Ñ€ÐµÐ¼Ñ Ð¿Ð¾Ñледнего доÑтупа, ÑÐ¸Ð¼Ð²Ð¾Ð»ÑŒÐ½Ð°Ñ ÑÑылка\fR .fi .RE .TP \fB\-Return\fR Перейти в режим файлов FILE .TP \fB\-^Quit\fR Выход: ЕÑли вы выходите из ytree Ñ Ð¿Ð¾Ð¼Ð¾Ñ‰ÑŒÑŽ команды ^Q, то поÑледний выбранный каталог ÑтановитÑÑ Ð²Ð°ÑˆÐ¸Ð¼ текущим рабочим каталогом. Эта оÑобенноÑть работает только еÑли вы запуÑтили ytree Ñ Ð¿Ð¾Ð¼Ð¾Ñ‰ÑŒÑŽ Ñпециальной bash-функции (Ñкопируйте в ваш ~/.bashrc Ñледующие Ñтроки): .nf .RS function yt { echo cd $PWD >~/.ytree-$$.chdir /usr/bin/ytree $1 $2 $3 $4 $5 source ~/.ytree-$$.chdir rm ~/.ytree-$$.chdir } .fi .RE .TP .PP 2.) Режим FILE .TP \fB\-Attribute\fR Изменить права доÑтупа к файлу (как chmod) .TP \fB\-^Attribute\fR Изменить права доÑтупа вÑех отмеченных файлов. \fB?\fR означает: не изменить атрибут .TP \fB\-Copy\fR Копировать файл .TP \fB\-^K Copy\fR Копировать вÑе отмеченные файлы .TP \fB\-Delete\fR Удалить выбранный файл .TP \fB\-^Delete\fR Удалить вÑе выбранные файлы .TP \fB\-Edit\fR Изменить выбранный файл Ñ Ð¿Ð¾Ð¼Ð¾Ñ‰ÑŒÑŽ редактора, опиÑанного в переменной EDITOR (Ñм. ~/.ytree) или \- еÑли Ð¿ÐµÑ€ÐµÐ¼ÐµÐ½Ð½Ð°Ñ Ð½Ðµ определена \- vi .TP \fB\-Filespec\fR УÑтановить маÑку файлов (регулÑрное выражение) например *.[ch] Ð´Ð»Ñ Ð²Ñех файлов *.c и *.h .TP \fB\-Group\fR Изменить группу владельца выбранного файла .TP \fB\-^Group\fR Изменить группу владельца вÑех отмеченных файлов .TP \fB\-Hex\fR ПроÑмотреть выбранный файл Ñ Ð¿Ð¾Ð¼Ð¾Ñ‰ÑŒÑŽ программы, указанной в переменной HEXDUMP (Ñм. ~/.ytree), или \- еÑли Ð¿ÐµÑ€ÐµÐ¼ÐµÐ½Ð½Ð°Ñ Ð½Ðµ определена \- hd / od \-h .TP \fB\-Log\fR ПерезапуÑтить ytree Ñ Ð½Ð¾Ð²Ñ‹Ð¼ корневым каталогом или архивным файлом .TP \fB\-Move\fR ПеремеÑтить выбранный файл .TP \fB\-^N Move\fR ПеремеÑтить вÑе отмеченные файлы .TP \fB\-Owner\fR Изменить владельца выбранного файла .TP \fB\-^Owner\fR Изменить владельца вÑех отмеченных файлов .TP \fB\-Pipe\fR Отправить Ñодержимое файла на Ñтандартный ввод внешней команды .TP \fB\-^Pipe\fR Отправить Ñодержимое вÑех отмеченных файлов на Ñтандартный ввод внешней команды .TP \fB\-Rename\fR Переименовать выбранный файл .TP \fB\-^Rename\fR Переименовать вÑе отмеченные файлы .TP \fB\-untag ^Search\fR СнÑть пометку Ñ Ð¿Ð¾Ð¼Ð¾Ñ‰ÑŒÑŽ внешней программы (например grep) .TP \fB\-Sort\fR ОтÑортировать ÑпиÑок файлов по .nf .RS \fB\- времени доÑтупа\fR \fB\- времени изменениÑ\fR \fB\- раÑширению\fR \fB\- группе\fR \fB\- времени изменениÑ\fR \fB\- имени\fR \fB\- владельцу\fR \fB\- размеру\fR .fi .RE .TP \fB\-Tag\fR Отметить выбранный файл .TP \fB\-^Tag\fR Отметить вÑе файлы, которые показываютÑÑ Ð² данный момент .TP \fB\-Untag\fR СнÑть отметку Ñ Ð²Ñ‹Ð±Ñ€Ð°Ð½Ð½Ð¾Ð³Ð¾ файла .TP \fB\-^Untag\fR СнÑть отметку Ñо вÑех файлов, которые показываютÑÑ Ð² данный момент .TP \fB\-View\fR ПроÑмотреть файл Ñ Ð¿Ð¾Ð¼Ð¾Ñ‰ÑŒÑŽ программы, заданной в переменной PAGER (Ñм. ~/.ytree) или \- еÑли Ð¿ÐµÑ€ÐµÐ¼ÐµÐ½Ð½Ð°Ñ Ð½Ðµ определена \- pg \-cen .TP \fB\-eXecute\fR Выполнить команду shell .TP \fB\-e^Xecute\fR Выполнить команду shell Ð´Ð»Ñ Ð²Ñех отмеченных файлов. Строка {} заменÑетÑÑ Ñ‚ÐµÐºÑƒÑ‰Ð¸Ð¼ именем файла .TP \fB\-pathcopY\fR Копировать выбранный файл, Ð²ÐºÐ»ÑŽÑ‡Ð°Ñ Ð¿ÑƒÑ‚ÑŒ .TP \fB\-pathcop^Y\fR Копировать вÑе отмеченные файлы, Ð²ÐºÐ»ÑŽÑ‡Ð°Ñ Ð¿ÑƒÑ‚ÑŒ .TP \fB\-^Filemode\fR Переключить режим проÑмотра ÑпиÑка файлов: .nf .RS \fB\- только имена файлов\fR \fB\- имÑ, атрибут, ÑÑылки, размер, Ð²Ñ€ÐµÐ¼Ñ Ð¿Ð¾Ñледнего изменениÑ,\fR \fB ÑÐ¸Ð¼Ð²Ð¾Ð»ÑŒÐ½Ð°Ñ ÑÑылка\fR \fB\- имÑ, атрибут, inode, владелец, группа, ÑÐ¸Ð¼Ð²Ð¾Ð»ÑŒÐ½Ð°Ñ ÑÑылка\fR \fB\- ÑÑ‚Ð°Ñ‚ÑƒÑ Ð¸Ð·Ð¼ÐµÐ½ÐµÐ½Ð¸Ñ-, Ð²Ñ€ÐµÐ¼Ñ Ð¿Ð¾Ñледнего доÑтупа, ÑÐ¸Ð¼Ð²Ð¾Ð»ÑŒÐ½Ð°Ñ ÑÑылка\fR .fi .RE .TP \fB\-^L\fR Обновить Ñкран .TP \fB\-Space\fR ПодавлÑть вывод на Ñкран во Ð²Ñ€ÐµÐ¼Ñ Ñ€Ð°Ð±Ð¾Ñ‚Ñ‹ .TP \fB\-Return\fR ПереключитьÑÑ Ð² раÑширенный режим .PP 3.) Режим ARCHIV-DIR .TP \fB\-Filespec\fR УÑтановить маÑку файлов (регулÑрное выражение) например *.[ch] Ð´Ð»Ñ Ð²Ñех файлов *.c и *.h .TP \fB\-Log\fR ПерезапуÑтить ytree Ñ Ð½Ð¾Ð²Ñ‹Ð¼ корневым каталогом или архивным файлом .TP \fB\-Showall\fR Показать вÑе файлы во вÑех каталогах .TP \fB\-Tag\fR Отметить файлы в выбранном каталоге .TP \fB\-Untag\fR СнÑть отметку Ñо вÑех файлов в выбранном каталоге .TP \fB\-eXecute\fR Выполнить команду shell .TP \fB\-^Filemode\fR Переключить режим проÑмотра ÑпиÑка файлов: .nf .RS \fB\- только имена файлов\fR \fB\- имÑ, атрибут, ÑÑылки, размер, Ð²Ñ€ÐµÐ¼Ñ Ð¿Ð¾Ñледнего изменениÑ\fR \fB\- имÑ, атрибут, владелец, группа\fR .fi .RE .TP \fB\-^L\fR Обновить Ñкран .PP 4.) Режим ARCHIV-FILE .TP \fB\-Copy\fR Копировать выбранный файл .TP \fB\-^K Copy\fR Копировать вÑе отмеченные файлы .TP \fB\-Filespec\fR УÑтановить маÑку файлов (регулÑрное выражение) например *.[ch] Ð´Ð»Ñ Ð²Ñех файлов *.c и *.h .TP \fB\-Hex\fR ПроÑмотреть выбранный файл Ñ Ð¿Ð¾Ð¼Ð¾Ñ‰ÑŒÑŽ программы, указанной в переменной HEXDUMP (Ñм. ~/.ytree), или \- еÑли Ð¿ÐµÑ€ÐµÐ¼ÐµÐ½Ð½Ð°Ñ Ð½Ðµ определена \- hd / od \-h .TP \fB\-Pipe\fR Отправить Ñодержимое файла на Ñтандартный ввод внешней команды .TP \fB\-Sort\fR ОтÑортировать ÑпиÑок файлов по .nf .RS \fB\- времени доÑтупа\fR \fB\- времени изменениÑ\fR \fB\- раÑширению\fR \fB\- группе\fR \fB\- времени изменениÑ\fR \fB\- имени\fR \fB\- владельцу\fR \fB\- размеру\fR .fi .RE .TP \fB\-Tag\fR Отметить выбранный файл .TP \fB\-^Tag\fR Отметить вÑе файлы в выбранном каталоге .TP \fB\-Untag\fR СнÑть отметку Ñо вÑех файлов в выбранном каталоге .TP \fB\-View\fR ПроÑмотреть файл Ñ Ð¿Ð¾Ð¼Ð¾Ñ‰ÑŒÑŽ программы, заданной в переменной PAGER (Ñм. ~/.ytree) или \- еÑли Ð¿ÐµÑ€ÐµÐ¼ÐµÐ½Ð½Ð°Ñ Ð½Ðµ определена \- pg \-cen .TP \fB\-eXecute\fR Выполнить команду shell .TP \fB\-^Filemode\fR Переключить режим проÑмотра файлов: .nf .RS \fB\- только имена файлов\fR \fB\- имÑ, атрибут, ÑÑылки, размер\fR .fi .RE .TP \fB\-^L\fR Обновить Ñкран .TP \fB\-Return\fR Перейти в раÑширенный режим .PP ytree переключаетÑÑ Ð² режим работы Ñ Ð°Ñ€Ñ…Ð¸Ð²Ð°Ð¼Ð¸ автоматичеÑки еÑли выбран файл архива через команду \fILog\fR или при вызове ytree из командной Ñтроки, когда в качеÑтве аргмента задан файл архива. ytree раÑпознаёт раÑÑˆÐ¸Ñ€ÐµÐ½Ð¸Ñ Ð°Ð¹Ð»Ð¾Ð² ".F", ".Z", ".z" и ".gz" и вызывает ÑоответÑтвующую программу-декомпреÑÑор, заданную в переменных MELT (по умолчанию=melt), UNCOMPRESS (по умолчанию=uncompress) и GNUUNZIP (по умолчанию=gunzip \-c). Ð’Ñ‹ можете изменить значение Ñтих переменных в файле ~/.ytree. ytree поддерживает Ñледующие виды архивов и требует: .nf .RS .sp 1 \fB TAR-файлы: gtar (теÑтировано Ñ GNU-TAR 1.12)\fR \fB ARC-файлы: arc (теÑтировано Ñ arc 5.12 02/05/86)\fR \fB LHA-файлы: xlharc (теÑтировано Ñ xlharc V1.02 1989)\fR \fB ZIP-файлы: unzip (теÑтировано Ñ unzip v5.0 08/92)\fR \fB " " zipinfo (теÑтировано Ñ zipinfo v1.0 08/92)\fR \fB ZOO-файлы: zoo (теÑтировано Ñ zoo v2.10)\fR \fB RAR-файлы: unrar (теÑтировано Ñ unrar v2.01\fR \fB RPM-файлы: rpm2cpio (теÑтировано Ñ RedHat V6.1)\fR \fB " " rpm (теÑтировано Ñ RedHat V6.1)\fR .fi .RE Файлы архивов раÑпознаютÑÑ Ð¿Ð¾ раÑширениÑм имён файлов (например zoo, zip). TAR-файлы могут иметь Ñледующие раÑширениÑ: .nf .RS .sp 1 \fB ".F", ".TFR", ".Faa", (freeze)\fR \fB ".Z", ".TZ", ".TZR", ".Xaa", (compress)\fR \fB ".z", ".gz", ".tzr", ".tz", ".xaa", ".tgz", ".TGZ",\fR \fB ".taz", ".TAZ", ".tpz" und ".TPZ" (gzip)\fR .fi .RE Команда View наÑтраиваетÑÑ Ð² Ñекции [VIEWER] файла ~/.ytree: Пример: .nf \fB [VIEWER] \fB .jpg,.gif,.bmp,.tif,.ppm,.xpm=xv \fB .1,.2,.3,.4,.5,.6,.7,.8,.n=nroff -man | less \fB .ps=ghostview \fB .mid,.MID=playmidi -e \fB .wav,.WAV=splay \fB .au=auplay \fB .avi,.mpg,.mov=xanim \fB .htm,.html=lynx \fB .pdf,.PDF=acroread \fB .mp3=mpg123 .fi .PP ПоддерживаетÑÑ Ð¸ÑÑ‚Ð¾Ñ€Ð¸Ñ ÐºÐ¾Ð¼Ð°Ð½Ð´: ИÑпользуйте Ñтрелки курÑора вверх/вниз. ИÑпользуйте "F2" в Ñтроке команды, чтобы выбрать каталог. .SH ФÐЙЛЫ $HOME/.ytree файл Ñ Ð½Ð°Ñтройками ytree .SH БÐГИ Чтобы избежать проблем Ñ ESC поÑледовательноÑÑ‚Ñми на машинах RS/6000 (telnet/rlogin) пожалуйÑта уÑтановите переменную Ð¾ÐºÑ€ÑƒÐ¶ÐµÐ½Ð¸Ñ ESCDELAY: .nf .sp 1 ESCDELAY=1000 export ESCDELAY .fi .SH ÐВТОР W. Bregulla (werner@frolix.han.de) .SH ПЕРЕВОД Перевёл Ñ Ð°Ð½Ð³Ð»Ð¸Ð¹Ñкого Виктор ВиÑлобоков 2005 ytree-1.99pl1/ytree.1.es000066400000000000000000000206541350711670100150510ustar00rootroot00000000000000.\" extracted from ytree.doc 26 November 1996 by cmt2doc.pl .TH YTREE 1 "19 de Febrero 1999" " " "PROGRAMAS" .PD .8v .SH NOMBRE .nf ytree \- Administrador de archivos \- .fi .SH SINOPSIS ytree [\fInómbre de archivo \f | \fIdirectorio\fR] .SH DESCRIPCION Si no hay argumentos de línea de comandos, será usado el directorio actual. Son provistos de los siguientes comandos 1.) Ventana de DRIECTORIOS: .TP \fB\-Attribute\fR Cambiar permisos de directorio (como chmod) .TP \fB\-Delete\fR Borrar el directorio seleccionado .TP \fB\-Filespec\fR Configurar máscara (exp. regulares) e.g. *.[ch] para todos los ficheros *.c y *.h \- .TP \fB\-Group\fR Cambiar el grupo dueño del directorio .TP \fB\-Log\fR Reiniciar ytree con un nuevo directorio/archivo raiz .TP \fB\-Makedir\fR Crear un nuevo directorio .TP \fB\-Owner\fR Cambiar el usuario dueño del directorio/fichero seleccionado .TP \fB\-Rename\fR Renombrar el directorio o fichero seleccionado .TP \fB\-Showall\fR Mostrar todos los ficheros de todos los directorios cargados en memoria .TP \fB\-Tag\fR Marcar todos los ficheros en el directorio seleccionado .TP \fB\-Untag\fR Desmarcar todos los ficheros del directorio seleccionado .TP \fB\-eXecute\fR Ejecutar un shell con un comando .TP \fB\-^Filemode\fR Cambiar el modo de vista: .nf .RS \fB\- Solamente nómbres\fR \fB\- Nómbre, atributos, links, tamaño,\fR \fB fecha de modificación, link simbólico\fR \fB\- nómbre, atributos, inode, dueño, grupo, link simbólico\fR \fB\- change status-, fecha de acceso, link simbólico\fR .fi .RE .TP \fB\-Return\fR Cambiar a la siguiente ventana .PP 2.) Ventana de FICHEROS .TP \fB\-Attribute\fR Cambiar los permisos del fichero (como chmod) .TP \fB\-^Attribute\fR Cambiar los permisos de todos los ficheros marcados. \fB?\fR significa: no cambiar el atributo .TP \fB\-Copy\fR Copiar el fichero .TP \fB\-^K Copy\fR Copiar todos los ficheros marcados .TP \fB\-Delete\fR Borrar el fichero seleccionado .TP \fB\-^Delete\fR Borrar todos los ficheros seleccionados .TP \fB\-Edit\fR Editar el fichero con $EDITOR (ver ~/.ytree) o \- si no esta ninguno definido \- vi .TP \fB\-Filespec\fR Configurar mascara (expresiones regulares) e.g. *.[ch] para todos los *.c y *.h \- Files .TP \fB\-Group\fR Cambiar el grupo del fichero seleccionado .TP \fB\-^Group\fR Cambiar el grupo de todos los ficheros marcados .TP \fB\-Hex\fR Ver el fichero seleccionado con HEXDUMP (ver ~/.ytree), o \- si no esta definido \- hd / od \-h .TP \fB\-Log\fR Reiniciar ytree con un nuevo directorio/archivo como raiz .TP \fB\-Move\fR mover el fichero seleccionado .TP \fB\-^N Move\fR Mover todos los ficheros marcados .TP \fB\-Owner\fR Cambiar el usuario dueño del fichero seleccionado .TP \fB\-^Owner\fR Cambiar el usuario dueño de todos los ficheros marcados .TP \fB\-Pipe\fR Enviar el contenido del archivo a traves de un comando .TP \fB\-^Pipe\fR Enviar el contenido de todos los ficheros a traves de un comando .TP \fB\-Rename\fR Renombrar el fichero marcado .TP \fB\-^Rename\fR Renombrar todos los ficheros marcados .TP \fB\-Sort\fR Ordenar la lista de ficheros por .nf .RS \fB\- Fecha de acceso\fR \fB\- Fecha de cambio\fR \fB\- Extensión\fR \fB\- Grupo\fR \fB\- Fecha de modificación\fR \fB\- Nómbre\fR \fB\- Dueño\fR \fB\- Tamaño\fR .fi .RE .TP \fB\-Tag\fR Marcar el fichero seleccionado .TP \fB\-^Tag\fR Marcar todos los ficheros mostrados .TP \fB\-Untag\fR Desmarcar el fichero seleccionado .TP \fB\-^Untag\fR Desmarcar todos los ficheros mostrados .TP \fB\-View\fR Ver el fichero con el paginador definido en ~/.ytree o - si no esta definido - con pg \-cen .TP \fB\-eXecute\fR Ejecutar un shell con un comando .TP \fB\-e^Xecute\fR Ejecutar un shell con un comando para todos los ficheros marcados. El texto {} es reemplazado por el fichero actual .TP \fB\-pathcopY\fR Copiar el fichero selecionado con el camino .TP \fB\-pathcop^Y\fR Copiar todos los ficheros marcados con el camino .TP \fB\-^Filemode\fR Cambiar el modo de vista para los ficheros: .nf .RS \fB\- solamente nómbres\fR \fB\- nómbre, atributos, links, tamaño, fecha de modificación,\fR \fB link simbólico\fR \fB\- nómbre, atributos, inode, dueño, grupo, link simbólico\fR \fB\- changestatus-, fecha de acceso, link simbólico\fR .fi .RE .TP \fB\-^L\fR Redibujar la terminal .TP \fB\-Space\fR Suprimir la salida por terminal mientras esta trabajando .TP \fB\-Return\fR Cambiar a la ventana expandida .PP 3.) Ventana de directorios .TP \fB\-Filespec\fR Configurar máscara(expresiones regulares) e.g. *.[ch] para todos ficheros los *.c y *.h \- .TP \fB\-Log\fR Reiniciar ytree con un nuevo directorio/archivo como raiz .TP \fB\-Showall\fR Mostrar todos los ficheros de todos los directorios .TP \fB\-Tag\fR Marcar todos los ficheros en el directorio seleccionado .TP \fB\-Untag\fR Desmarcar todos los ficheros en el directorio seleccionado .TP \fB\-eXecute\fR Ejecutar un shell con un comando .TP \fB\-^Filemode\fR Cambiar el modo de vista para los ficheros: .nf .RS \fB\- Solamente nómbres de ficheros\fR \fB\- nómbres, atributos, links, tamaño, fecha de modificación\fR \fB\- nómbre, atributos, dueño, grupo\fR .fi .RE .TP \fB\-^L\fR Redibujar la terminal .PP 4.) Ventana de Archivos: .TP \fB\-Copy\fR Copiar el fichero seleccionado .TP \fB\-^K Copy\fR Copiar todos los ficheros marcados .TP \fB\-Filespec\fR Configurar la mascara (expresiones regulares) e.g. *.[ch] para todos los ficheros *.c y *.h \- .TP \fB\-Hex\fR Ver el fichero seleccionado con HEXDUMP (ver ~/.ytree), o \- si no esta definido \- hd / od \-h .TP \fB\-Pipe\fR Pipe content of all tagged to a command Enviar el contenido de todos los ficheros marcados a traves de un comando .TP \fB\-Sort\fR Ordenar la lista de ficheros por .nf .RS \fB\- Fecha de acceso\fR \fB\- Fecha de cambio\fR \fB\- Extensión\fR \fB\- Grupo\fR \fB\- Fecha de modificación\fR \fB\- Nómbre\fR \fB\- Dueño\fR \fB\- Tamaño\fR .fi .RE .TP \fB\-Tag\fR Marcar el fichero seleccionado .TP \fB\-^Tag\fR Marcar todos los ficheros en el directorio seleccionado .TP \fB\-Untag\fR Desmarcar todos los ficheros del directorio seleccionado .TP \fB\-View\fR Ver el fichero con el paginador definido en ~/.ytree o - si no esta definido - con pg \-cen .TP \fB\-eXecute\fR Ejecutar un shell con un comando .TP \fB\-^Filemode\fR Cambiar el modo de vista para los ficheros: .nf .RS \fB\- solamente nómbres\fR \fB\- nómbres, atributos, links, tamaño\fR .fi .RE .TP \fB\-^L\fR Redibujar la terminal .TP \fB\-Return\fR Cambiar a ventana expandida .PP ytree cambia a ventana de archivo automáticamentes simplemente por seleccionar un fichero con el commando \fILog\fR o por ejecutar ytree desde la línea de comandos con un fichero como argumento. ytree reconoce la extensión del fichero ".F", ".Z", ".z" y ".gz" y ejecuta el descompresor apropiado MELT (por defecto=melt), UNCOMPRESS (por defecto=uncompress) y GNUUNZIP (por defecto=gunzip \-c). Usted puede cambiar estas configuraciones en ~/.ytree. ytree reconoce los siguientes tipos de archivos y requiere: .nf .RS .sp 1 \fB archivos TAR: gtar (revisado con GNU-TAR 1.11.2)\fR \fB archivos ARC: arc (revisado con arc 5.12 02/05/86)\fR \fB archivos LHA: xlharc (revisado con xlharc V1.02 1989)\fR \fB archivos ZIP: unzip (revisado con unzip v5.0 08/92)\fR \fB " " : zipinfo (revisado con zipinfo v1.0 08/92)\fR \fB archivos ZOO: zoo (revisado con zoo v2.10)\fR .fi .RE Los archivos son reconocidos por la extension del nombre(e.g zoo, zip). Los archivos TAR pueden tener las siguientes extensiones: .nf .RS .sp 1 \fB ".F", ".TFR", ".Faa", (freeze)\fR \fB ".Z", ".TZ", ".TZR", ".Xaa", (compress)\fR \fB ".z", ".gz", ".tzr", ".tz", ".xaa", ".tgz", ".TGZ",\fR \fB ".taz", ".TAZ", ".tpz" und ".TPZ" (gzip)\fR .fi .RE El comando VER es configurable en la seccion [VIEWER] de ~/.ytree: Example: .nf \fB [VIEWER] \fB .jpg,.gif,.bmp,.tif,.ppm,.xpm=xv \fB .1,.2,.3,.4,.5,.6,.7,.8,.n=nroff -man | less \fB .ps=ghostview \fB .mid,.MID=playmidi -e \fB .wav,.WAV=splay \fB .au=auplay \fB .avi,.mpg,.mov=xanim \fB .htm,.html=lynx \fB .pdf,.PDF=acroread \fB .mp3=mpg123 .fi .PP Un historial de lineas es soportado: Use las teclas up/down. Use "F2" en la línea de comando para seleccionar directorios. .SH FICHEROS $HOME/.ytree fichero de configuracion del ytree .SH ERRORES Para evitar problemas con las sequencias de escape en máquinas RS/6000 (telnet/rlogin) configure la variable de entorno ESCDELAY: .nf .sp 1 ESCDELAY=1000 export ESCDELAY .fi .SH AUTOR W. Bregulla (werner@frolix.han.de) .SH Traduccion del manual Carlos Barros (cbf@debian.org) ytree-1.99pl1/ytree.conf000066400000000000000000000115521350711670100152250ustar00rootroot00000000000000############################################### # Ytree Defaults # Modify this file and copy it to the hidden # file called .ytree placed in your home directory. # You may also invoke it explicitly with the # "-p command line argument. ############################################### # [GLOBAL] TREEDEPTH=2 FILEMODE=2 NUMBERSEP=. NOSMALLWINDOW=0 #LISTJUMP search: 0== standard (one key); 1==incremental LISTJUMPSEARCH=0 # SEARCHCOMMAND=grep {} # Configure if the internal HEX-Viewer/Editor should display # Adress-Offsets in hex (HEX) or decimal (DECIMAL) HEXEDITOFFSET=HEX # Make ytree start in file window mode, in a specified directory # The "root" directory for ytree is specified on the command # line; INITIALDIR must be a directory under this root directory. # The form may be ".", "/full/path/userhome/test/alpha/beta", # "./alpha/beta", "~/test/alpha/beta", or "beta" # INITIALDIR=./alpha/beta # You can create a custom view by defining the variable USERVIEW # %tag: Tag-Symbol # %fnm: Filename # %atr: Attributes # %lct: Link-Count # %fsz: File-Size # %mot: Modification Time # %lnm: Symbolik Link-Name # %uid: User-ID # %gid: Group-ID # %ino: Inode # %act: Access Time # %sct: Status Change Time # USERVIEW=%tag%fnm %atr %lct %fsz %mot # ARCEXPAND=arc p # ARCLIST=arc v # CAT=cat # EDITOR=vim # GUNZIP=gunzip -c HEXDUMP=builtin # LHAEXPAND=lharc p # LHALIST=lharc v # MANROFF=nroff -man # MELT=melt # PAGER=less -cen # TAPEDEV=/dev/rmt0 # TAREXPAND=tar xOPf - # TARLIST=tar tar tvf - # UNCOMPRESS=gunzip # ZIPEXPAND=unzip -c # ZIPLIST=zipinfo -l # ZOOEXPAND=zoo xp # ZOOLIST=zoo vm # RAREXPAND=unrar p -c- -INUL # RARLIST=unrar l # RPMEXPAND=builtin # RPMLIST=rpm -q --dump -l -p # ############################# # Bracketed [] sections may appear in any order after the # initial global configuration section. ############################# [VIEWER] .jpg,.gif,.bmp,.tif,.ppm,.xpm=xv - .1,.2,.3,.4,.5,.6,.7,.8,.n=nroff -man - | less .ps=ghostview .mid=timidity -id .wav=splay .au=auplay .avi,.mpg,.mov=xanim .htm,.html=lynx .pdf,.PDF=acroread .mp3=mpg123 ###################################### # The values DIR1, DIR2, FILE1, and FILE2 in the [MENU] section redefine the text # presented in menu lines 1 and 2 of the DIR and FILE windows, respectively. The # mapping of the keyboard is not changed here, just the text presented to the user. ###################################### # [MENU] # DIR1=DIR-CUST (A)ttribute (B)->a (D)elete (F)ilespec (G)roup (k)-du (K)-dirpath (L)og (Q)uit # DIR2=COMMANDS (M)akedir (O)wner (P)ath/owner (R)ename (S)howall (T)ag (U)ntag e(X)ecute (^F) dirmode # FILE1=FILE-CUST (A)ttribute (C)opy (D)elete (E)dit (F)ilespec (G)cc (H)ex (I)->v (L)ogin (M)ove (Q)uit # FILE2=COMMANDS (O)wner (P)ipe (R)ename (S)ort (T)ag (U)ntag (V)iew (W)c e(X)ecute pathcop(Y) (^F)ilemode ###################################### # The [DIRMAP] and [FILEMAP] sections allow keyboard keys to be remapped or unmapped # in directory mode and file mode, respectively. The comma-separated list of keys to # the left of the "=" is remapped to perform the action specified by the character to # the right of the "=". If no character is specified, the keys are unmapped (do nothing). ###################################### # [DIRMAP] # or in dir window mode is remapped to key action (Attribute) # B,b=a #

or

in dir window mode is remapped to key action (Owner) # P,p=o # [FILEMAP] # in file window mode is remapped to key action (View) # i,I=v # in file window mode is remapped to # G=g # ytree default assignment of to "group" is removed # g= ###################################### # The [DIRCMD] and [FILECMD] sections allow new command actions to be defined # in directory mode and file mode, respectively. The command to the right of # the "=" is executed when the key to the right of the "=" is pressed. If the # key is mapped (either by the default ytree key assignments or by a [DIRMAP] # or [FILEMAP] entry,) this mapping is followed after the command is executed. # Thus to change FILE mode "g" from "group" to "gcc" requires both a FILECMD # assignment "g=gcc -O -c" and a FILEMAP assignment "g=" (to remove the default # action "group" from the "g" key.) # # If [command] contains the characters "%s", the selected is # substituted for "%s". Otherwise, the selected is appended to [command]. ###################################### # [DIRCMD] # in dir window mode does "du | less" # k=du %s | less # in dir window mode does "echo | less" # K=echo %s | less #

in dir window mode does "echo | less" # p=echo %s | less # [FILECMD] # in file window mode does "gcc -O -c " # g=gcc -O -c # in file window mode does "wc | less" # w=wc %s | less ytree-1.99pl1/ytree.h000066400000000000000000001007771350711670100145370ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/ytree.h,v 1.47 2016/09/04 14:41:12 werner Exp $ * * Header-Datei fuer YTREE * ***************************************************************************/ #define _LARGEFILE64_SOURCE 1 #define _FILE_OFFSET_BITS 64 #include #include #include #if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__) #include #endif #ifdef XCURSES #include #define HAVE_CURSES 1 #endif #ifdef _IBMR2 #define NLS #endif /* _IBMR2 */ #ifdef ultrix #ifndef HAVE_CURSES #include #endif #else #ifdef __FreeBSD__ #ifndef HAVE_CURSES #include #endif #else #ifndef HAVE_CURSES #include #endif #endif /* __FreeBSD__ */ #endif /* ultrix */ #include #include #include #include #if defined(linux) || defined(__GNU__) #include #include #include /* needed vor RedHed5 (thanks to Robert Spier) */ #endif #if __STDC__ || defined( _IBMR2 ) #include #endif /* __STDC__ || _IBMR2 */ #ifdef __NeXT__ extern char *getcwd(); #include #define dirent direct #else #include #include #endif /* __NeXT__ */ #include #include #include #ifndef __QNX__ #include #endif #include #include #include #include #if defined( TERMCAP ) && !defined( __NeXT__ ) #include #endif #ifdef WITH_UTF8 #include #endif #ifdef __OpenBSD__ #define STATFS(a, b, c, d ) statfs( a, b ) #define LONGLONG long long #define HAS_LONGLONG 1 #else #ifdef __NetBSD__ #define STATFS(a, b, c, d ) statvfs( a, b ) #define LONGLONG long long #define HAS_LONGLONG 1 #define typeahead( file ) #define vidattr( attr ) #define putp( str ) tputs( str, 1, putchar ) #else #ifdef __APPLE__ #define STATFS(a, b, c, d ) statfs( a, b ) #define LONGLONG long long #define HAS_LONGLONG 1 #else #ifdef __FreeBSD__ #define STATFS(a, b, c, d ) statfs( a, b ) #define LONGLONG long long #define HAS_LONGLONG 1 #else #ifdef OSF1 #define STATFS(a, b, c, d ) statvfs( a, b ) #define echochar( ch ) { addch( ch ); refresh(); } #define LONGLONG unsigned long #else #ifdef SVR4 #define STATFS(a, b, c, d ) statvfs( a, b ) #define LONGLONG unsigned long #else #ifdef SVR3 #define LONGLONG unsigned long #define STATFS(a, b, c, d ) statfs( a, b, c, d ) #define LONGLONG unsigned long #else #ifdef _IBMR2 #define STATFS(a, b, c, d ) statfs( a, b ) #define LONGLONG long long #define HAS_LONGLONG 1 #else #if defined(linux) #define STATFS(a, b, c, d ) statfs( a, b ) #define LONGLONG long long #define HAS_LONGLONG 1 #else #if defined(__GNU__) #define STATFS(a, b, c, d ) statfs( a, b ) #define LONGLONG long long #define HAS_LONGLONG 1 #else #ifdef hpux #define STATFS(a, b, c, d ) statfs( a, b ) #define echochar( ch ) { addch( ch ); refresh(); } #define LONGLONG long long #define HAS_LONGLONG 1 #else #ifdef ultrix #define STATFS(a, b, c, d ) statfs( a, b ) #define echochar( ch ) { addch( ch ); refresh(); } #define LONGLONG unsigned long #else #ifdef __QNX__ #define STATFS(a, b, c, d ) statfs( a, b ) #define LONGLONG unsigned long #else #define STATFS(a, b, c, d ) statfs( a, b, c, d ) #define LONGLONG long long #define HAS_LONGLONG 1 #endif /* __QNX__ */ #endif /* ultrix */ #endif /* hpux */ #endif /* __GNU__ */ #endif /* linux */ #endif /* _IBMR2 */ #endif /* SVR4 */ #endif /* SVR3 */ #endif /* OSF1 */ #endif /* __APPLE__ */ #endif /* __FreeBSD__ */ #endif /* __NetBSD__ */ #endif /* __OpenBSD__ */ /* Some handy macros... */ #define MINIMUM( a, b ) ( ( (a) < (b) ) ? (a) : (b) ) #define MAXIMUM( a, b ) ( ( (a) > (b) ) ? (a) : (b) ) #ifdef WIN32 #define S_IREAD S_IRUSR #define S_IWRITE S_IWUSR #define S_IEXEC S_IXUSR #define popen _popen #define pclose _pclose #define sys_errlist _sys_errlist #endif /* WIN32 */ #ifdef __NeXT__ #define S_IRUSR S_IREAD #define S_IWUSR S_IWRITE #define S_IXUSR S_IEXEC #define S_IRGRP (S_IREAD >> 3) #define S_IWGRP (S_IWRITE >> 3) #define S_IXGRP (S_IEXEC >> 3) #define S_IROTH (S_IREAD >> 6) #define S_IWOTH (S_IWRITE >> 6) #define S_IXOTH (S_IEXEC >> 6) #define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH) #define S_IRWXG (S_IRGRP|S_IWGRP|S_IXGRP) #define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR) #endif /* __NeXT__ */ #if defined(linux) || defined (__GNU__) #define HAVE_RENAME #endif /* linux || __GNU__ */ #ifdef WIN32 /* Diese Funktionen koennen direkt umgesetzt werden */ /*--------------------------------------------------*/ #define echochar( ch ) { addch( ch ); refresh(); } #define putp( str ) puts( str ) /* ... hier ist ein wenig mehr Arbeit noetig ... */ /*-----------------------------------------------*/ #define vidattr( attr ) /* ... und hier gibt's keine entsprechende Funktion. */ /*---------------------------------------------------*/ #define typeahead( file ) #endif /* WIN32 */ #ifdef __DJGPP__ /* DJGPP GNU DOS Compiler */ /*--------------------------------------------------*/ #define putp( str ) puts( str ) #define vidattr( attr ) #define typeahead( file ) #endif /* __DJGPP__*/ #ifdef TERMCAP #define KEY_BTAB 5000 #define KEY_DOWN 5001 #define KEY_UP 5002 #define KEY_LEFT 5003 #define KEY_RIGHT 5004 #define KEY_END 5005 #define KEY_HOME 5006 #define KEY_NPAGE 5007 #define KEY_PPAGE 5008 #define KEY_DC 5009 #define KEY_BACKSPACE 5010 #define KEY_EIC 5011 #define KEY_IC 5012 #define KEY_DL 5013 #define NO_HIGHLIGHT #define A_REVERSE 1 #define A_BLINK 2 #define BELL 0x07 /* Diese Funktionen koennen direkt umgesetzt werden */ /*--------------------------------------------------*/ #undef cbreak #define cbreak() raw() #define beep() putchar( BELL ) #define echochar( ch ) { addch( ch ); refresh(); } #define putp( str ) tputs( str, 1, putchar ) #define wnoutrefresh( win ) wrefresh( win ) /* ... hier ist ein wenig mehr Arbeit noetig ... */ /*-----------------------------------------------*/ #define wgetch( win ) TermcapWgetch( win ) #define vidattr( attr ) TermcapVidattr( attr ) #define initscr() TermcapInitscr() #define endwin() TermcapEndwin() /* ... und hier gibt's keine entsprechende Funktion. */ /*---------------------------------------------------*/ #define doupdate() #define wattrset( win, attr ) #define typeahead( file ) #define keypad( win, flag ) #endif /* TERMCAP */ #ifndef KEY_BTAB #define KEY_BTAB 0x1d #endif #ifndef KEY_END #define KEY_END KEY_EOL #endif #if defined(_IBMR2) && !defined(_AIX41) #define echochar( c ) { addch( c ); refresh(); } #define wgetch( w ) AixWgetch( w ) #endif #if defined( S_IFLNK ) && !defined( isc386 ) #define STAT_(a, b) lstat(a, b) #else #define STAT_(a, b) stat(a, b) #define readlink( a, b, c ) (-1) #endif /* S_IFLNK */ #ifndef S_ISREG #define S_ISREG( mode ) (((mode) & S_IFMT) == S_IFREG) #endif /* S_ISREG */ #ifndef S_ISDIR #define S_ISDIR( mode ) (((mode) & S_IFMT) == S_IFDIR) #endif /* S_ISDIR */ #ifndef S_ISCHR #define S_ISCHR( mode ) (((mode) & S_IFMT) == S_IFCHR) #endif /* S_ISCHR */ #ifndef S_ISBLK #define S_ISBLK( mode ) (((mode) & S_IFMT) == S_IFBLK) #endif /* S_ISBLK */ #ifndef S_ISFIFO #define S_ISFIFO( mode ) (((mode) & S_IFMT) == S_IFIFO) #endif /* S_ISFIFO */ #ifndef S_ISLNK #ifdef S_IFLNK #define S_ISLNK( mode ) (((mode) & S_IFMT) == S_IFLNK) #else #define S_ISLNK( mode ) FALSE #endif /* S_IFLNK */ #endif /* S_ISLNK */ #ifndef S_ISSOCK #ifdef S_IFSOCK #define S_ISSOCK( mode ) (((mode) & S_IFMT) == S_IFSOCK) #else #define S_ISSOCK( mode ) FALSE #endif /* S_IFSOCK */ #endif /* S_ISSOCK */ #define VI_KEY_UP 'k' #define VI_KEY_DOWN 'j' #define VI_KEY_RIGHT 'l' #define VI_KEY_LEFT 'h' #define VI_KEY_NPAGE ( 'D' & 0x1F ) #define VI_KEY_PPAGE ( 'U' & 0x1F ) #define OWNER_NAME_MAX 64 #define GROUP_NAME_MAX 64 #define DISPLAY_OWNER_NAME_MAX 12 #define DISPLAY_GROUP_NAME_MAX 12 /* Sonderzeichen fuer Liniengrafik */ /*---------------------------------*/ #ifndef ACS_ULCORNER #define ACS_ULCORNER '+' #endif #ifndef ACS_URCORNER #define ACS_URCORNER '+' #endif #ifndef ACS_LLCORNER #define ACS_LLCORNER '+' #endif #ifndef ACS_LRCORNER #define ACS_LRCORNER '+' #endif #ifndef ACS_VLINE #define ACS_VLINE '|' #endif #ifndef ACS_HLINE #define ACS_HLINE '-' #endif #ifndef ACS_RTEE #define ACS_RTEE '+' #endif #ifndef ACS_LTEE #define ACS_LTEE '+' #endif #ifndef ACS_BTEE #define ACS_BTEE '+' #endif #ifndef ACS_TTEE #define ACS_TTEE '+' #endif #ifndef ACS_BLOCK #define ACS_BLOCK '?' #endif #ifndef ACS_LARROW #define ACS_LARROW '<' #endif /* Color Definitionen */ #define DIR_COLOR 1 #define FILE_COLOR 2 #define STATS_COLOR 3 #define BORDERS_COLOR 4 #define MENU_COLOR 5 #define WINDIR_COLOR 6 #define WINFILE_COLOR 7 #define WINSTATS_COLOR 8 #define WINERR_COLOR 9 #define HIDIR_COLOR 10 #define HIFILE_COLOR 11 #define HISTATS_COLOR 12 #define HIMENUS_COLOR 13 #define WINHST_COLOR 14 #define HST_COLOR 15 #define HIHST_COLOR 16 #define WINMTCH_COLOR 14 #define MTCH_COLOR 15 #define HIMTCH_COLOR 16 #define GLOBAL_COLOR 17 #define HIGLOBAL_COLOR 18 #define PROFILE_FILENAME ".ytree" #define HISTORY_FILENAME ".ytree-hst" /* User-Defines */ /*--------------*/ #include "config.h" /* Auswahl der benutzten UNIX-Kommandos */ /*--------------------------------------*/ #define CAT GetProfileValue( "CAT" ) #define HEXDUMP GetProfileValue( "HEXDUMP" ) #define EDITOR GetProfileValue( "EDITOR" ) #define PAGER GetProfileValue( "PAGER" ) #define MELT GetProfileValue( "MELT" ) #define UNCOMPRESS GetProfileValue( "UNCOMPRESS" ) #define GNUUNZIP GetProfileValue( "GNUUNZIP" ) #define BUNZIP GetProfileValue( "BUNZIP" ) #define MANROFF GetProfileValue( "MANROFF" ) #define TARLIST GetProfileValue( "TARLIST" ) #define TAREXPAND GetProfileValue( "TAREXPAND" ) #define RPMLIST GetProfileValue( "RPMLIST" ) #define RPMEXPAND GetProfileValue( "RPMEXPAND" ) #define ZOOLIST GetProfileValue( "ZOOLIST" ) #define ZOOEXPAND GetProfileValue( "ZOOEXPAND" ) #define ZIPLIST GetProfileValue( "ZIPLIST" ) #define ZIPEXPAND GetProfileValue( "ZIPEXPAND" ) #define LHALIST GetProfileValue( "LHALIST" ) #define LHAEXPAND GetProfileValue( "LHAEXPAND" ) #define ARCLIST GetProfileValue( "ARCLIST" ) #define ARCEXPAND GetProfileValue( "ARCEXPAND" ) #define TREEDEPTH GetProfileValue( "TREEDEPTH" ) #define USERVIEW GetProfileValue( "USERVIEW" ) #define RARLIST GetProfileValue( "RARLIST" ) #define RAREXPAND GetProfileValue( "RAREXPAND" ) #define FILEMODE GetProfileValue( "FILEMODE" ) #define NUMBERSEP GetProfileValue( "NUMBERSEP" ) #define NOSMALLWINDOW GetProfileValue( "NOSMALLWINDOW" ) #define INITIALDIR GetProfileValue( "INITIALDIR" ) #define DIR1 GetProfileValue( "DIR1" ) #define DIR2 GetProfileValue( "DIR2" ) #define FILE1 GetProfileValue( "FILE1" ) #define FILE2 GetProfileValue( "FILE2" ) #define SEARCHCOMMAND GetProfileValue( "SEARCHCOMMAND" ) #define HEXEDITOFFSET GetProfileValue( "HEXEDITOFFSET" ) #define LISTJUMPSEARCH GetProfileValue( "LISTJUMPSEARCH" ) #define DEFAULT_TREE "." #define ERROR_MSG( msg ) Error( msg, __FILE__, __LINE__ ) #define WARNING( msg ) Warning( msg ) #define MESSAGE( msg ) Message( msg ) #define NOTICE( msg ) Notice( msg ) #define TAGGED_SYMBOL '*' #define MAX_MODES 11 #define DISK_MODE 0 #define LL_FILE_MODE 1 #define TAR_FILE_MODE 2 #define ZOO_FILE_MODE 3 #define ZIP_FILE_MODE 4 #define LHA_FILE_MODE 5 #define ARC_FILE_MODE 6 #define RPM_FILE_MODE 7 #define RAR_FILE_MODE 8 #define TAPE_MODE 9 #define USER_MODE 10 #define NO_COMPRESS 0 #define FREEZE_COMPRESS 1 #define MULTIPLE_FREEZE_COMPRESS 2 #define COMPRESS_COMPRESS 3 #define MULTIPLE_COMPRESS_COMPRESS 4 #define GZIP_COMPRESS 5 #define BZIP_COMPRESS 6 #define MULTIPLE_GZIP_COMPRESS 7 #define ZOO_COMPRESS 8 #define LHA_COMPRESS 9 #define ARC_COMPRESS 10 #define ZIP_COMPRESS 11 #define RPM_COMPRESS 12 #define TAPE_DIR_NO_COMPRESS 13 #define TAPE_DIR_FREEZE_COMPRESS 14 #define TAPE_DIR_COMPRESS_COMPRESS 15 #define TAPE_DIR_GZIP_COMPRESS 16 #define TAPE_DIR_BZIP_COMPRESS 17 #define RAR_COMPRESS 18 #define FILE_EXTENSIONS { \ { ".TAP", TAPE_DIR_NO_COMPRESS }, \ { ".tap", TAPE_DIR_NO_COMPRESS }, \ { ".TAP.F", TAPE_DIR_FREEZE_COMPRESS }, \ { ".tap.F", TAPE_DIR_FREEZE_COMPRESS }, \ { ".TAP.Z", TAPE_DIR_COMPRESS_COMPRESS }, \ { ".tap.Z", TAPE_DIR_COMPRESS_COMPRESS }, \ { ".TAP.z", TAPE_DIR_GZIP_COMPRESS }, \ { ".tap.z", TAPE_DIR_GZIP_COMPRESS }, \ { ".tap.gz", TAPE_DIR_GZIP_COMPRESS }, \ { ".tap.bz2", TAPE_DIR_BZIP_COMPRESS }, \ { ".TAP.BZ2", TAPE_DIR_BZIP_COMPRESS }, \ { ".F", FREEZE_COMPRESS }, \ { ".TFR", FREEZE_COMPRESS }, \ { ".Faa", MULTIPLE_FREEZE_COMPRESS }, \ { ".Z", COMPRESS_COMPRESS }, \ { ".TZ", COMPRESS_COMPRESS }, \ { ".TZR", COMPRESS_COMPRESS }, \ { ".Xaa", MULTIPLE_COMPRESS_COMPRESS }, \ { ".bz2", BZIP_COMPRESS }, \ { ".z", GZIP_COMPRESS }, \ { ".gz", GZIP_COMPRESS }, \ { ".tz", GZIP_COMPRESS }, \ { ".tzr", GZIP_COMPRESS }, \ { ".tgz", GZIP_COMPRESS }, \ { ".TGZ", GZIP_COMPRESS }, \ { ".taz", GZIP_COMPRESS }, \ { ".TAZ", GZIP_COMPRESS }, \ { ".tpz", GZIP_COMPRESS }, \ { ".TPZ", GZIP_COMPRESS }, \ { ".xaa", MULTIPLE_GZIP_COMPRESS }, \ { ".zoo", ZOO_COMPRESS }, \ { ".ZOO", ZOO_COMPRESS }, \ { ".lzh", LHA_COMPRESS }, \ { ".LZH", LHA_COMPRESS }, \ { ".arc", ARC_COMPRESS }, \ { ".ARC", ARC_COMPRESS }, \ { ".rar", RAR_COMPRESS }, \ { ".RAR", RAR_COMPRESS }, \ { ".jar", ZIP_COMPRESS }, \ { ".zip", ZIP_COMPRESS }, \ { ".ZIP", ZIP_COMPRESS }, \ { ".JAR", ZIP_COMPRESS }, \ { ".rpm", RPM_COMPRESS }, \ { ".RPM", RPM_COMPRESS }, \ { ".spm", RPM_COMPRESS }, \ { ".SPM", RPM_COMPRESS } \ } #define SORT_BY_NAME 1 #define SORT_BY_MOD_TIME 2 #define SORT_BY_CHG_TIME 3 #define SORT_BY_ACC_TIME 4 #define SORT_BY_SIZE 5 #define SORT_BY_OWNER 6 #define SORT_BY_GROUP 7 #define SORT_BY_EXTENSION 8 #define SORT_ASC 10 #define SORT_DSC 20 #define SORT_CASE 40 #define SORT_ICASE 80 #define DEFAULT_FILE_SPEC "*" #define TAGSYMBOL_VIEWNAME "tag" #define FILENAME_VIEWNAME "fnm" #define ATTRIBUTE_VIEWNAME "atr" #define LINKCOUNT_VIEWNAME "lct" #define FILESIZE_VIEWNAME "fsz" #define MODTIME_VIEWNAME "mot" #define SYMLINK_VIEWNAME "lnm" #define UID_VIEWNAME "uid" #define GID_VIEWNAME "gid" #define INODE_VIEWNAME "ino" #define ACCTIME_VIEWNAME "act" #define CHGTIME_VIEWNAME "sct" #define BLKSIZ 512 /* Blockgroesse fuer SVR3 */ #define CLOCK_INTERVAL 1 #define FILE_SEPARATOR_CHAR '/' #define FILE_SEPARATOR_STRING "/" #define ERR_TO_NULL " 2> /dev/null" #define ERR_TO_STDOUT " 2>&1 " #define BOOL unsigned char #define LF 10 #define ESC 27 #define LOGIN_ESC '.' #ifdef sgi #define SGI_CR 0x157 /* Irix 3.2.2 special ? */ #endif #define CR 13 #define DIR_WINDOW_X 1 #define DIR_WINDOW_Y 2 #define DIR_WINDOW_WIDTH (COLS - 26) #define DIR_WINDOW_HEIGHT ((LINES * 8 / 14)-1) #define F2_WINDOW_X DIR_WINDOW_X #define F2_WINDOW_Y DIR_WINDOW_Y #define F2_WINDOW_WIDTH DIR_WINDOW_WIDTH #define F2_WINDOW_HEIGHT (DIR_WINDOW_HEIGHT + 1) #define FILE_WINDOW_1_X 1 #define FILE_WINDOW_1_Y DIR_WINDOW_HEIGHT + 3 #define FILE_WINDOW_1_WIDTH (COLS - 26) #define FILE_WINDOW_1_HEIGHT (LINES - DIR_WINDOW_HEIGHT - 7 ) #define FILE_WINDOW_2_X 1 #define FILE_WINDOW_2_Y 2 #define FILE_WINDOW_2_WIDTH (COLS - 26) #define FILE_WINDOW_2_HEIGHT (LINES - 6) #define ERROR_WINDOW_WIDTH 40 #define ERROR_WINDOW_HEIGHT 10 #define ERROR_WINDOW_X ((COLS - ERROR_WINDOW_WIDTH) >> 1) #define ERROR_WINDOW_Y ((LINES - ERROR_WINDOW_HEIGHT) >> 1) #define HISTORY_WINDOW_X 1 #define HISTORY_WINDOW_Y 2 #define HISTORY_WINDOW_WIDTH (COLS - 26) #define HISTORY_WINDOW_HEIGHT (LINES - 6) #define MATCHES_WINDOW_X 1 #define MATCHES_WINDOW_Y 2 #define MATCHES_WINDOW_WIDTH (COLS - 26) #define MATCHES_WINDOW_HEIGHT (LINES - 6) #define TIME_WINDOW_X ((COLS > 20) ? (COLS - 20) : 1) #define TIME_WINDOW_Y 1 #define TIME_WINDOW_WIDTH ((COLS > 15) ? 15 : COLS) #define TIME_WINDOW_HEIGHT 1 #define PATH_LENGTH 1024 #define FILE_SPEC_LENGTH (12 + 1) #define DISK_NAME_LENGTH (12 + 1) #define LL_LINE_LENGTH 512 #define TAR_LINE_LENGTH 512 #define RPM_LINE_LENGTH 512 #define ZOO_LINE_LENGTH 512 #define ZIP_LINE_LENGTH 512 #define LHA_LINE_LENGTH 512 #define ARC_LINE_LENGTH 512 #define RAR_LINE_LENGTH 512 #define MESSAGE_LENGTH (PATH_LENGTH + 80 + 1) #define COMMAND_LINE_LENGTH 4096 #define MODE_1 0 #define MODE_2 1 #define MODE_3 2 #define MODE_4 3 #define MODE_5 4 #ifdef __NeXT__ #include #define QUICK_BAUD_RATE B9600 #else #define QUICK_BAUD_RATE 9600 #endif /* __NeXT__ */ #define ESCAPE goto FNC_XIT #define PRINT(ch) (iscntrl(ch) && (((unsigned char)(ch)) < ' ')) ? (ACS_BLOCK) : ((unsigned char)(ch)) /* #define PRINT(ch) (ch) */ #ifdef COLOR_SUPPORT extern void StartColors(void); extern void WbkgdSet(WINDOW *w, chtype c); #else #define StartColors() ; #define WbkgdSet(a, b) ; #endif /* COLOR_SUPPORT */ typedef struct _file_entry { struct _file_entry *next; struct _file_entry *prev; struct _dir_entry *dir_entry; struct stat stat_struct; BOOL tagged; BOOL matching; char name[1]; /*char symlink_name[]; */ /* Folgt direkt dem Namen, falls */ /* Eintrag == symbolischer Link */ } FileEntry; typedef struct _dir_entry { struct _file_entry *file; struct _dir_entry *next; struct _dir_entry *prev; struct _dir_entry *sub_tree; struct _dir_entry *up_tree; LONGLONG total_bytes; LONGLONG matching_bytes; LONGLONG tagged_bytes; unsigned int total_files; unsigned int matching_files; unsigned int tagged_files; int cursor_pos; int start_file; struct stat stat_struct; BOOL access_denied; BOOL global_flag; BOOL tagged_flag; BOOL only_tagged; BOOL not_scanned; BOOL big_window; BOOL login_flag; char name[1]; } DirEntry; typedef struct { unsigned long indent; DirEntry *dir_entry; unsigned short level; } DirEntryList; typedef struct { FileEntry *file; } FileEntryList; typedef struct { DirEntry *tree; LONGLONG disk_space; LONGLONG disk_capacity; LONGLONG disk_total_files; LONGLONG disk_total_bytes; LONGLONG disk_matching_files; LONGLONG disk_matching_bytes; LONGLONG disk_tagged_files; LONGLONG disk_tagged_bytes; unsigned int disk_total_directories; int disp_begin_pos; int cursor_pos; int kind_of_sort; char login_path[PATH_LENGTH + 1]; char path[PATH_LENGTH + 1]; char tape_name[PATH_LENGTH + 1]; char file_spec[FILE_SPEC_LENGTH + 1]; char disk_name[DISK_NAME_LENGTH + 1]; } Statistic; typedef union { struct { char new_modus[11]; } change_modus; struct { unsigned new_owner_id; } change_owner; struct { unsigned new_group_id; } change_group; struct { char *command; } execute; struct { Statistic *statistic_ptr; DirEntry *dest_dir_entry; char *to_file; char *to_path; BOOL path_copy; BOOL confirm; } copy; struct { char *new_name; BOOL confirm; } rename; struct { DirEntry *dest_dir_entry; char *to_file; char *to_path; BOOL confirm; } mv; struct { FILE *pipe_file; } pipe_cmd; struct { FILE *zipfile; int method; } compress_cmd; } FunctionData; typedef struct { FileEntry *new_fe_ptr; FunctionData function_data; } WalkingPackage; /* strerror() is POSIX, and all modern operating systems provide it. */ #define HAVE_STRERROR 1 #ifndef HAVE_STRERROR extern const char *StrError(int); #endif /* HAVE_STRERROR */ extern WINDOW *dir_window; extern WINDOW *small_file_window; extern WINDOW *big_file_window; extern WINDOW *file_window; extern WINDOW *error_window; extern WINDOW *history_window; extern WINDOW *matches_window; extern WINDOW *f2_window; extern WINDOW *time_window; extern Statistic statistic; extern Statistic disk_statistic; extern int mode; extern int user_umask; extern char message[]; extern BOOL print_time; extern BOOL resize_request; extern char number_seperator; extern BOOL bypass_small_window; extern char *initial_directory; extern char builtin_hexdump_cmd[]; #if defined(ultrix) extern char *getenv(char *); #else extern char *getenv(const char *); #endif extern int ytree(int argc, char *argv[]); extern void DisplayMenu(void); extern void DisplayDiskStatistic(void); extern void DisplayDirStatistic(DirEntry *dir_entry); extern void DisplayDirParameter(DirEntry *dir_entry); extern void DisplayDirTagged(DirEntry *dir_entry); extern void DisplayDiskTagged(void); extern void DisplayDiskName(void); extern void DisplayFileParameter(FileEntry *file_entry); extern void DisplayGlobalFileParameter(FileEntry *file_entry); extern void RefreshWindow(WINDOW *win); extern int ReadTree(DirEntry *dir_entry, char *path, int depth); extern void UnReadTree(DirEntry *dir_entry); extern int ReadTreeFromTAR(DirEntry *dir_entry, FILE *f); extern int ReadTreeFromRPM(DirEntry *dir_entry, FILE *f); extern int ReadTreeFromZOO(DirEntry *dir_entry, FILE *f); extern int ReadTreeFromZIP(DirEntry *dir_entry, FILE *f); extern int ReadTreeFromLHA(DirEntry *dir_entry, FILE *f); extern int ReadTreeFromARC(DirEntry *dir_entry, FILE *f); extern int ReadTreeFromRAR(DirEntry *dir_entry, FILE *f); extern int GetDiskParameter(char *path, char *volume_name, LONGLONG *avail_bytes, LONGLONG *capacity ); extern int HandleDirWindow(DirEntry *start_dir_entry); extern void DisplayFileWindow(DirEntry *dir_entry); extern int Init(char *configuration_file, char *history_file); extern char *GetPath(DirEntry *dir_entry, char *buffer); extern BOOL Match(char *file_name); extern int SetMatchSpec(char *new_spec); extern int SetFileSpec(char *file_spec); extern void SetMatchingParam(DirEntry *dir_entry); extern void Error(char *msg, char *module, int line); extern void Warning(char *msg); extern void Notice(char *msg); extern void UnmapNoticeWindow(void); extern void SetFileMode(int new_file_mode); extern int HandleFileWindow(DirEntry *dir_entry); extern char *GetAttributes(unsigned short modus, char *buffer); extern void SwitchToSmallFileWindow(void); extern void SwitchToBigFileWindow(void); extern int ReadGroupEntries(void); extern char *GetGroupName(unsigned int gid); extern char *GetDisplayGroupName(unsigned int gid); extern int GetGroupId(char *name); extern int ReadPasswdEntries(void); extern char *GetPasswdName(unsigned int uid); extern char *GetDisplayPasswdName(unsigned int uid); extern int GetPasswdUid(char *name); extern char *GetFileNamePath(FileEntry *file_entry, char *buffer); extern char *GetRealFileNamePath(FileEntry *file_entry, char *buffer); extern int SystemCall(char *command_line); extern int QuerySystemCall(char *command_line); extern int SilentSystemCall(char *command_line); extern int SilentSystemCallEx(char *command_line, BOOL enable_clock); extern int View(DirEntry * dir_entry, char *file_path); extern int ViewHex(char *file_path); extern int InternalView(char *file_path); extern int Edit(DirEntry * dir_entry, char *file_path); extern void DisplayAvailBytes(void); extern void DisplayFileSpec(void); extern void QuitTo(DirEntry * dir_entry); extern void Quit(void); extern int ReadFileSpec(void); extern int InputString(char *s, int y, int x, int cursor_pos, int length, char *term); extern void RotateFileMode(void); extern int Execute(DirEntry *dir_entry, FileEntry *file_entry); extern int Pipe(DirEntry *dir_entry, FileEntry *file_entry); extern int PipeTaggedFiles(FileEntry *fe_ptr, WalkingPackage *walking_package); extern int GetPipeCommand(char *pipe_command); extern void GetKindOfSort(void); extern void SetKindOfSort(int new_kind_of_sort); extern int ChangeFileModus(FileEntry *fe_ptr); extern int ChangeDirModus(DirEntry *de_ptr); extern int GetNewFileModus(int y, int x, char *modus, char *term); extern int GetModus(char *modus); extern int SetFileModus(FileEntry *fe_ptr, WalkingPackage *walking_package); extern int CopyTaggedFiles(FileEntry *fe_ptr, WalkingPackage *walking_package); extern int CopyFile(Statistic *statistic_ptr, FileEntry *fe_ptr, unsigned char confirm, char *to_file, DirEntry *dest_dir_entry, char *to_dir_path, BOOL path_copy); extern int MoveTaggedFiles(FileEntry *fe_ptr, WalkingPackage *walking_package); extern int MoveFile(FileEntry *fe_ptr, unsigned char confirm, char *to_file, DirEntry *dest_dir_entry, char *to_dir_path, FileEntry **new_fe_ptr); extern int InputChoise(char *msg, char *term); extern void Message(char *msg); extern int GetDirEntry(DirEntry *tree, DirEntry *current_dir_entry, char *dir_path, DirEntry **dir_entry, char *to_path); extern int GetFileEntry(DirEntry *de_ptr, char *file_name, FileEntry **file_entry); extern int GetCopyParameter(char *from_file, BOOL path_copy, char *to_file, char *to_dir); extern int GetMoveParameter(char *from_file, char *to_file, char *to_dir); extern int ChangeFileOwner(FileEntry *fe_ptr); extern int GetNewOwner(int st_uid); extern int SetFileOwner(FileEntry *fe_ptr, WalkingPackage *walking_package); extern int ChangeDirOwner(DirEntry *de_ptr); extern int ChangeFileGroup(FileEntry *fe_ptr); extern int GetNewGroup(int st_gid); extern int SetFileGroup(FileEntry *fe_ptr, WalkingPackage *walking_package); extern int ChangeDirGroup(DirEntry *de_ptr); extern void DisplayDirHelp(void); extern void DisplayFileHelp(void); extern void ClearHelp(void); extern int GetAvailBytes(LONGLONG *avail_bytes); extern int DeleteDirectory(DirEntry *dir_entry); extern int ExecuteCommand(FileEntry *fe_ptr, WalkingPackage *walking_package); extern int GetCommandLine(char *command_line); extern int GetSearchCommandLine(char *command_line); extern int DeleteFile(FileEntry *fe_ptr); extern int RemoveFile(FileEntry *fe_ptr); extern int RenameDirectory(DirEntry *de_ptr, char *new_name); extern int RenameFile(FileEntry *fe_ptr, char *new_name, FileEntry **new_fe_ptr); extern int RenameTaggedFiles(FileEntry *fe_ptr, WalkingPackage *walking_package); extern int GetRenameParameter(char *old_name, char *new_name); extern char *CTime(time_t f_time, char *buffer); extern int LoginDisk(char *path); extern int GetNewLoginPath(char *path); extern void PrintSpecialString(WINDOW *win, int y, int x, char *str, int color); extern void Print(WINDOW *, int, int, char *, int); extern void PrintOptions(WINDOW *,int, int, char *); extern void PrintMenuOptions(WINDOW *,int, int, char *, int, int); extern char *FormFilename(char *dest, char *src, unsigned int max_len); extern char *CutFilename(char *dest, char *src, unsigned int max_len); extern char *CutPathname(char *dest, char *src, unsigned int max_len); extern void Fnsplit(char *path, char *dir, char *name); extern void MakeExtractCommandLine(char *command_line, char *path, char *file, char *cmd); extern int MakeDirectory(DirEntry *father_dir_entry); extern time_t Mktime(struct tm *tm); extern int TryInsertArchiveDirEntry(DirEntry *tree, char *dir, struct stat *stat); extern int InsertArchiveFileEntry(DirEntry *tree, char *path, struct stat *stat); extern int MinimizeArchiveTree(DirEntry *tree); extern void HitReturnToContinue(void); extern int TermcapWgetch(WINDOW *win); extern void TermcapVidattr(int attr ); extern void TermcapInitscr(void); extern void TermcapEndwin(void); extern int BuildFilename( char *in_filename, char *pattern, char *out_filename); extern int ViKey( int ch ); extern int GetFileMethod( char *filename ); extern int AixWgetch( WINDOW *w ); extern BOOL KeyPressed(void); extern BOOL EscapeKeyPressed(void); extern int GetTapeDeviceName(void); extern int MakePath( DirEntry *tree, char *dir_path, DirEntry **dest_dir_entry ); extern int MakeDirEntry( DirEntry *father_dir_entry, char *dir_name ); extern void NormPath( char *in_path, char *out_path ); extern char *Strtok_r( char *str, char *delim, char **old ); extern int ReadProfile( char *filename ); extern char *GetProfileValue( char *key ); extern int ScanSubTree( DirEntry *dir_entry ); extern void GetMaxYX(WINDOW *win, int *height, int *width); extern char *GetHistory(void); extern void InsHistory(char *new_hist); extern void ReadHistory(char *filename); extern void SaveHistory(char *filename); extern char *GetMatches(char *); extern int KeyF2Get(DirEntry *start_dir_entry, int disp_begin_pos, int cursor_pos, char *path); extern void Switch2F2Window(void); extern void MapF2Window(void); extern void UnmapF2Window(void); extern void ReadExtFile(char *); extern char *GetExtCmd(char *); extern int MvAddStr(int y, int x, char *str); extern int MvWAddStr(WINDOW *win, int y, int x, char *str); extern int WAddStr(WINDOW *win, char *str); extern int AddStr(char *str); extern void ClockHandler(int); extern int Strrcmp(char *s1, char* s2); extern char *Strdup(const char *s); extern char *GetExtViewer(char *filename); extern void InitClock(void); extern void SuspendClock(void); extern char *GetExtension(char *filename); extern void StrCp(char *dest, const char *src); extern int BuildUserFileEntry(FileEntry *fe_ptr, int max_filename_len, int max_linkname_len, char *template, int linelen, char *line); extern int GetUserFileEntryLength(int max_filename_len, int max_linkname_len, char *template); extern LONGLONG AtoLL(char* cptr); extern void DisplayTree(WINDOW *win, int start_entry_no, int hilight_no); extern void ReCreateWindows(void); extern int Getch(void); extern int DirUserMode(DirEntry *dir_entry, int ch); extern int FileUserMode(FileEntryList *file_entry_list, int ch); extern char *GetUserFileAction(int chkey, int *pchremap); extern char *GetUserDirAction(int chkey, int *pchremap); extern BOOL IsUserActionDefined(void); extern char *Getcwd(char *buffer, unsigned int len); extern int RefreshDirWindow(); extern char *StrLeft(const char *str, size_t count); extern int StrVisualLength(const char *str); extern int WAttrAddStr(WINDOW *win, int attr, char *str); extern char *Strndup(const char *s, int len); extern char *CutName(char *dest, char *src, unsigned int max_len); ytree-1.99pl1/ytree.spec000066400000000000000000000017461350711670100152360ustar00rootroot00000000000000Summary: A filemanager similar to XTree Name: ytree Version: 1.98 Release: 1 Source: http://www.han.de/~werner/ytree-1.98.tar.gz Copyright: GPL Group: System Environment/Shells BuildRoot: %{_tmppath}/root-%{name}-%{version} BuildRequires: ncurses-devel >= 5.4 BuildRequires: readline >= 4.3 %description A console based file manager in the tradition of Xtree. %prep %setup %build make RPM_OPT_FLAGS="$RPM_OPT_FLAGS" DESTDIR="%{_prefix}" %install mkdir -p $RPM_BUILD_ROOT/usr/bin mkdir -p $RPM_BUILD_ROOT/usr/share/man/man1 install -m644 -o root -g root ytree.1 $RPM_BUILD_ROOT/usr/share/man/man1/ytree.1 install -m755 -o root -g bin -s ytree $RPM_BUILD_ROOT/usr/bin %clean rm -rf $RPM_BUILD_ROOT %post %files %doc CHANGES COPYING README THANKS ytree.conf /usr/share/man/man1/ytree.1.gz /usr/bin/ytree %changelog * Sun Dec 19 2004 Victor Vislobokov 1.82-1rhfc3.vv - Fedora Core 3 adaptation * Fri Dec 31 2004 Werner Bregulla 1.83 - update to 1.83 ytree-1.99pl1/zip.c000066400000000000000000000101211350711670100141630ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/zip.c,v 1.11 2000/05/20 20:41:11 werner Exp $ * * Funktionen zum Lesen des Dateibaumes aus ZIP-Dateien * ***************************************************************************/ #include "ytree.h" static int GetStatFromZIP(char *zip_line, char *name, struct stat *stat); /* Dateibaum aus ZIP-Listing lesen */ /*---------------------------------*/ int ReadTreeFromZIP(DirEntry *dir_entry, FILE *f) { char zip_line[ZIP_LINE_LENGTH + 1]; char path_name[PATH_LENGTH +1]; struct stat stat; BOOL dir_flag = FALSE; *dir_entry->name = '\0'; while( fgets( zip_line, ZIP_LINE_LENGTH, f ) != NULL ) { /* \n loeschen */ /*-------------*/ zip_line[ strlen( zip_line ) - 1 ] = '\0'; if( strlen( zip_line ) > (unsigned) 58 && (zip_line[56] == ':' || (zip_line[57] != 'd' && zip_line[58] == ':'))) { /* gueltiger Eintrag */ /*-------------------*/ if( GetStatFromZIP( zip_line, path_name, &stat ) ) { (void) sprintf( message, "unknown zipinfo*%s", zip_line ); MESSAGE( message ); } else { /* File */ /*------*/ #ifdef DEBUG fprintf( stderr, "FILE: \"%s\"\n", path_name ); #endif (void) InsertArchiveFileEntry( dir_entry, path_name, &stat ); } } } if( dir_flag == FALSE ) { statistic.disk_total_directories++; (void) memset( (char *) &dir_entry->stat_struct, 0, sizeof( struct stat ) ); dir_entry->stat_struct.st_mode = S_IFDIR; } return( MinimizeArchiveTree( dir_entry ) ); } static int GetStatFromZIP(char *zip_line, char *name, struct stat *stat) { char *t, *old; int i, id; struct tm tm_struct; static char *month[] = { "Jan", "Feb", "Mar", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; (void) memset( stat, 0, sizeof( struct stat ) ); stat->st_nlink = 1; t = Strtok_r( zip_line, " \t", &old ); if( t == NULL ) return( -1 ); /* Attributes */ /*------------*/ if( strlen( t ) == 10 ) { stat->st_mode = GetModus( t ); } else { /* DOS-Zip-File ? */ /*----------------*/ stat->st_mode = GetModus( "-rw-rw-rw-" ); } t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); /* Version */ /*---------*/ t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); /* BS */ /*----*/ t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); /* Dateilaenge */ /*-------------*/ if( !isdigit( *t ) ) return( -1 ); stat->st_size = AtoLL( t ); t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); /* ?? */ /*----*/ t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); /* Compressed-Laenge */ /*-------------------*/ t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); /* Methode */ /*---------*/ t = Strtok_r( NULL, " \t-", &old ); if( t == NULL ) return( -1 ); /* M-Datum */ /*---------*/ tm_struct.tm_mday = atoi( t ); t = Strtok_r( NULL, " \t-", &old ); if( t == NULL ) return( -1 ); for( i=0; i < 12; i++ ) { if( !strcmp( t, month[i] ) ) break; } if( i >= 12 ) i = 0; tm_struct.tm_mon = i; t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); tm_struct.tm_year = atoi( t ); if(tm_struct.tm_year < 70) tm_struct.tm_year += 100; t = Strtok_r( NULL, " \t:", &old ); if( t == NULL ) return( -1 ); tm_struct.tm_hour = atoi( t ); t = Strtok_r( NULL, " \t:", &old ); if( t == NULL ) return( -1 ); tm_struct.tm_min = atoi( t ); t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); tm_struct.tm_sec = 0; tm_struct.tm_isdst = -1; stat->st_atime = 0; stat->st_ctime = 0; stat->st_mtime = Mktime( &tm_struct ); /* Owner */ /*-------*/ id = getuid(); if( id == -1 ) id = atoi( t ); stat->st_uid = (unsigned) id; /* Group */ /*-------*/ id = getgid(); stat->st_gid = (unsigned) id; /* Dateiname */ /*-----------*/ (void) strcpy( name, t ); return( 0 ); } ytree-1.99pl1/zoo.c000066400000000000000000000073711350711670100142050ustar00rootroot00000000000000/*************************************************************************** * * $Header: /usr/local/cvsroot/utils/ytree/zoo.c,v 1.11 2000/05/20 20:41:11 werner Exp $ * * Funktionen zum Lesen des Dateibaumes aus ZOO-Dateien * ***************************************************************************/ #include "ytree.h" static int GetStatFromZOO(char *zoo_line, char *name, struct stat *stat); /* Dateibaum aus ZOO-Listing lesen */ /*---------------------------------*/ int ReadTreeFromZOO(DirEntry *dir_entry, FILE *f) { char zoo_line[ZOO_LINE_LENGTH + 1]; char path_name[PATH_LENGTH +1]; struct stat stat; BOOL dir_flag = FALSE; *dir_entry->name = '\0'; while( fgets( zoo_line, ZOO_LINE_LENGTH, f ) != NULL ) { /* \n loeschen */ /*-------------*/ zoo_line[ strlen( zoo_line ) - 1 ] = '\0'; if( strlen( zoo_line ) > (unsigned) 50 ) { /* gueltiger Eintrag */ /*-------------------*/ if( GetStatFromZOO( zoo_line, path_name, &stat ) ) { (void) sprintf( message, "unknown zooinfo*%s", zoo_line ); MESSAGE( message ); } else { /* File */ /*------*/ #ifdef DEBUG fprintf( stderr, "FILE: \"%s\"\n", path_name ); #endif (void) InsertArchiveFileEntry( dir_entry, path_name, &stat ); } } } if( dir_flag == FALSE ) { statistic.disk_total_directories++; (void) memset( (char *) &dir_entry->stat_struct, 0, sizeof( struct stat ) ); dir_entry->stat_struct.st_mode = S_IFDIR; } return( MinimizeArchiveTree( dir_entry ) ); } static int GetStatFromZOO(char *zoo_line, char *name, struct stat *stat) { char *t, *old; int i, id; struct tm tm_struct; static char *month[] = { "Jan", "Feb", "Mar", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; (void) memset( stat, 0, sizeof( struct stat ) ); stat->st_nlink = 1; t = Strtok_r( zoo_line, " \t", &old ); if( t == NULL ) return( -1 ); /* Dateilaenge */ /*-------------*/ if( !isdigit( *t ) ) return( -1 ); stat->st_size = AtoLL( t ); t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); /* CF */ /*----*/ if( !isdigit( *t ) ) return( -1 ); t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); /* Size Now */ /*----------*/ if( !isdigit( *t ) ) return( -1 ); t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); /* M-Datum */ /*---------*/ tm_struct.tm_mday = atoi( t ); t = Strtok_r( NULL, " \t:", &old ); if( t == NULL ) return( -1 ); for( i=0; i < 12; i++ ) { if( !strcmp( t, month[i] ) ) break; } if( i >= 12 ) i = 0; tm_struct.tm_mon = i; t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); tm_struct.tm_year = atoi( t ); if(tm_struct.tm_year < 70) tm_struct.tm_year += 100; t = Strtok_r( NULL, " \t:", &old ); if( t == NULL ) return( -1 ); tm_struct.tm_hour = atoi( t ); t = Strtok_r( NULL, " \t:", &old ); if( t == NULL ) return( -1 ); tm_struct.tm_min = atoi( t ); t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); tm_struct.tm_sec = atoi( t ); t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); tm_struct.tm_isdst = -1; stat->st_atime = 0; stat->st_ctime = 0; stat->st_mtime = Mktime( &tm_struct ); /* Attributes */ /*------------*/ (void) sscanf( t, "%o", (unsigned int *) &stat->st_mode ); stat->st_mode |= S_IFREG; t = Strtok_r( NULL, " \t", &old ); if( t == NULL ) return( -1 ); /* Owner */ /*-------*/ id = getuid(); if( id == -1 ) id = atoi( t ); stat->st_uid = (unsigned) id; /* Group */ /*-------*/ id = getgid(); stat->st_gid = (unsigned) id; /* Dateiname */ /*-----------*/ (void) strcpy( name, t ); return( 0 ); }