1 /*************************************************************************** 2 * 3 * $Header: /usr/local/cvsroot/utils/ytree/ytree.h,v 1.47 2016/09/04 14:41:12 werner Exp $ 4 * 5 * Header-Datei fuer YTREE 6 * 7 ***************************************************************************/ 8 9 10 #define _LARGEFILE64_SOURCE 1 11 #define _FILE_OFFSET_BITS 64 12 13 #include <stdio.h> 14 #include <ctype.h> 15 #include <math.h> 16 #include <locale.h> 17 18 #if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__) 19 #include <locale.h> 20 #endif 21 22 #ifdef XCURSES 23 #include <xcurses.h> 24 #define HAVE_CURSES 1 25 #endif 26 27 #ifdef _IBMR2 28 #define NLS 29 #endif /* _IBMR2 */ 30 31 #ifdef ultrix 32 #ifndef HAVE_CURSES 33 #include <cursesX.h> 34 #endif 35 #else 36 #ifdef __FreeBSD__ 37 #ifndef HAVE_CURSES 38 #include <ncurses.h> 39 #endif 40 #else 41 #ifndef HAVE_CURSES 42 #include <curses.h> 43 #endif 44 #endif /* __FreeBSD__ */ 45 #endif /* ultrix */ 46 47 #include <limits.h> 48 #include <sys/types.h> 49 #include <sys/stat.h> 50 #include <time.h> 51 #if defined(linux) || defined(__GNU__) 52 #include <locale.h> 53 #include <sys/wait.h> 54 #include <sys/time.h> /* needed vor RedHed5 (thanks to Robert Spier) */ 55 #endif 56 57 58 #if __STDC__ || defined( _IBMR2 ) 59 #include <stdlib.h> 60 #endif /* __STDC__ || _IBMR2 */ 61 62 #ifdef __NeXT__ 63 extern char *getcwd(); 64 #include <sys/dir.h> 65 #define dirent direct 66 #else 67 #include <unistd.h> 68 #include <dirent.h> 69 #endif /* __NeXT__ */ 70 71 #include <errno.h> 72 #include <fcntl.h> 73 #include <grp.h> 74 #ifndef __QNX__ 75 #include <memory.h> 76 #endif 77 #include <pwd.h> 78 #include <setjmp.h> 79 #include <signal.h> 80 #include <string.h> 81 82 #if defined( TERMCAP ) && !defined( __NeXT__ ) 83 #include <termcap.h> 84 #endif 85 86 #ifdef WITH_UTF8 87 #include <wchar.h> 88 #endif 89 90 #ifdef __OpenBSD__ 91 #define STATFS(a, b, c, d ) statfs( a, b ) 92 #define LONGLONG long long 93 #define HAS_LONGLONG 1 94 #else 95 #ifdef __NetBSD__ 96 #define STATFS(a, b, c, d ) statvfs( a, b ) 97 #define LONGLONG long long 98 #define HAS_LONGLONG 1 99 #define typeahead( file ) 100 #define vidattr( attr ) 101 #define putp( str ) tputs( str, 1, putchar ) 102 #else 103 #ifdef __APPLE__ 104 #define STATFS(a, b, c, d ) statfs( a, b ) 105 #define LONGLONG long long 106 #define HAS_LONGLONG 1 107 #else 108 #ifdef __FreeBSD__ 109 #define STATFS(a, b, c, d ) statfs( a, b ) 110 #define LONGLONG long long 111 #define HAS_LONGLONG 1 112 #else 113 #ifdef OSF1 114 #define STATFS(a, b, c, d ) statvfs( a, b ) 115 #define echochar( ch ) { addch( ch ); refresh(); } 116 #define LONGLONG unsigned long 117 #else 118 #ifdef SVR4 119 #define STATFS(a, b, c, d ) statvfs( a, b ) 120 #define LONGLONG unsigned long 121 #else 122 #ifdef SVR3 123 #define LONGLONG unsigned long 124 #define STATFS(a, b, c, d ) statfs( a, b, c, d ) 125 #define LONGLONG unsigned long 126 #else 127 #ifdef _IBMR2 128 #define STATFS(a, b, c, d ) statfs( a, b ) 129 #define LONGLONG long long 130 #define HAS_LONGLONG 1 131 #else 132 #if defined(linux) 133 #define STATFS(a, b, c, d ) statfs( a, b ) 134 #define LONGLONG long long 135 #define HAS_LONGLONG 1 136 #else 137 #if defined(__GNU__) 138 #define STATFS(a, b, c, d ) statfs( a, b ) 139 #define LONGLONG long long 140 #define HAS_LONGLONG 1 141 #else 142 #ifdef hpux 143 #define STATFS(a, b, c, d ) statfs( a, b ) 144 #define echochar( ch ) { addch( ch ); refresh(); } 145 #define LONGLONG long long 146 #define HAS_LONGLONG 1 147 #else 148 #ifdef ultrix 149 #define STATFS(a, b, c, d ) statfs( a, b ) 150 #define echochar( ch ) { addch( ch ); refresh(); } 151 #define LONGLONG unsigned long 152 #else 153 #ifdef __QNX__ 154 #define STATFS(a, b, c, d ) statfs( a, b ) 155 #define LONGLONG unsigned long 156 #else 157 #define STATFS(a, b, c, d ) statfs( a, b, c, d ) 158 #define LONGLONG long long 159 #define HAS_LONGLONG 1 160 #endif /* __QNX__ */ 161 #endif /* ultrix */ 162 #endif /* hpux */ 163 #endif /* __GNU__ */ 164 #endif /* linux */ 165 #endif /* _IBMR2 */ 166 #endif /* SVR4 */ 167 #endif /* SVR3 */ 168 #endif /* OSF1 */ 169 #endif /* __APPLE__ */ 170 #endif /* __FreeBSD__ */ 171 #endif /* __NetBSD__ */ 172 #endif /* __OpenBSD__ */ 173 174 175 /* Some handy macros... */ 176 177 #define MINIMUM( a, b ) ( ( (a) < (b) ) ? (a) : (b) ) 178 #define MAXIMUM( a, b ) ( ( (a) > (b) ) ? (a) : (b) ) 179 180 181 #ifdef WIN32 182 183 #define S_IREAD S_IRUSR 184 #define S_IWRITE S_IWUSR 185 #define S_IEXEC S_IXUSR 186 187 #define popen _popen 188 #define pclose _pclose 189 #define sys_errlist _sys_errlist 190 191 #endif /* WIN32 */ 192 193 #ifdef __NeXT__ 194 195 #define S_IRUSR S_IREAD 196 #define S_IWUSR S_IWRITE 197 #define S_IXUSR S_IEXEC 198 #define S_IRGRP (S_IREAD >> 3) 199 #define S_IWGRP (S_IWRITE >> 3) 200 #define S_IXGRP (S_IEXEC >> 3) 201 #define S_IROTH (S_IREAD >> 6) 202 #define S_IWOTH (S_IWRITE >> 6) 203 #define S_IXOTH (S_IEXEC >> 6) 204 #define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH) 205 #define S_IRWXG (S_IRGRP|S_IWGRP|S_IXGRP) 206 #define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR) 207 208 #endif /* __NeXT__ */ 209 210 211 #if defined(linux) || defined (__GNU__) 212 #define HAVE_RENAME 213 #endif /* linux || __GNU__ */ 214 215 216 217 #ifdef WIN32 218 219 /* Diese Funktionen koennen direkt umgesetzt werden */ 220 /*--------------------------------------------------*/ 221 222 #define echochar( ch ) { addch( ch ); refresh(); } 223 #define putp( str ) puts( str ) 224 225 226 /* ... hier ist ein wenig mehr Arbeit noetig ... */ 227 /*-----------------------------------------------*/ 228 229 #define vidattr( attr ) 230 231 232 /* ... und hier gibt's keine entsprechende Funktion. */ 233 /*---------------------------------------------------*/ 234 235 #define typeahead( file ) 236 237 #endif /* WIN32 */ 238 239 240 241 #ifdef __DJGPP__ 242 243 /* DJGPP GNU DOS Compiler */ 244 /*--------------------------------------------------*/ 245 246 #define putp( str ) puts( str ) 247 #define vidattr( attr ) 248 #define typeahead( file ) 249 250 #endif /* __DJGPP__*/ 251 252 253 254 255 #ifdef TERMCAP 256 257 #define KEY_BTAB 5000 258 #define KEY_DOWN 5001 259 #define KEY_UP 5002 260 #define KEY_LEFT 5003 261 #define KEY_RIGHT 5004 262 #define KEY_END 5005 263 #define KEY_HOME 5006 264 #define KEY_NPAGE 5007 265 #define KEY_PPAGE 5008 266 #define KEY_DC 5009 267 #define KEY_BACKSPACE 5010 268 #define KEY_EIC 5011 269 #define KEY_IC 5012 270 #define KEY_DL 5013 271 272 #define NO_HIGHLIGHT 273 274 #define A_REVERSE 1 275 #define A_BLINK 2 276 277 #define BELL 0x07 278 279 280 281 /* Diese Funktionen koennen direkt umgesetzt werden */ 282 /*--------------------------------------------------*/ 283 284 #undef cbreak 285 #define cbreak() raw() 286 #define beep() putchar( BELL ) 287 #define echochar( ch ) { addch( ch ); refresh(); } 288 #define putp( str ) tputs( str, 1, putchar ) 289 #define wnoutrefresh( win ) wrefresh( win ) 290 291 292 /* ... hier ist ein wenig mehr Arbeit noetig ... */ 293 /*-----------------------------------------------*/ 294 295 #define wgetch( win ) TermcapWgetch( win ) 296 #define vidattr( attr ) TermcapVidattr( attr ) 297 #define initscr() TermcapInitscr() 298 #define endwin() TermcapEndwin() 299 300 301 /* ... und hier gibt's keine entsprechende Funktion. */ 302 /*---------------------------------------------------*/ 303 304 #define doupdate() 305 #define wattrset( win, attr ) 306 #define typeahead( file ) 307 #define keypad( win, flag ) 308 309 #endif /* TERMCAP */ 310 311 312 #ifndef KEY_BTAB 313 #define KEY_BTAB 0x1d 314 #endif 315 316 #ifndef KEY_END 317 #define KEY_END KEY_EOL 318 #endif 319 320 #if defined(_IBMR2) && !defined(_AIX41) 321 #define echochar( c ) { addch( c ); refresh(); } 322 #define wgetch( w ) AixWgetch( w ) 323 #endif 324 325 326 #if defined( S_IFLNK ) && !defined( isc386 ) 327 #define STAT_(a, b) lstat(a, b) 328 #else 329 #define STAT_(a, b) stat(a, b) 330 #define readlink( a, b, c ) (-1) 331 #endif /* S_IFLNK */ 332 333 #ifndef S_ISREG 334 #define S_ISREG( mode ) (((mode) & S_IFMT) == S_IFREG) 335 #endif /* S_ISREG */ 336 337 #ifndef S_ISDIR 338 #define S_ISDIR( mode ) (((mode) & S_IFMT) == S_IFDIR) 339 #endif /* S_ISDIR */ 340 341 #ifndef S_ISCHR 342 #define S_ISCHR( mode ) (((mode) & S_IFMT) == S_IFCHR) 343 #endif /* S_ISCHR */ 344 345 #ifndef S_ISBLK 346 #define S_ISBLK( mode ) (((mode) & S_IFMT) == S_IFBLK) 347 #endif /* S_ISBLK */ 348 349 #ifndef S_ISFIFO 350 #define S_ISFIFO( mode ) (((mode) & S_IFMT) == S_IFIFO) 351 #endif /* S_ISFIFO */ 352 353 #ifndef S_ISLNK 354 #ifdef S_IFLNK 355 #define S_ISLNK( mode ) (((mode) & S_IFMT) == S_IFLNK) 356 #else 357 #define S_ISLNK( mode ) FALSE 358 #endif /* S_IFLNK */ 359 #endif /* S_ISLNK */ 360 361 #ifndef S_ISSOCK 362 #ifdef S_IFSOCK 363 #define S_ISSOCK( mode ) (((mode) & S_IFMT) == S_IFSOCK) 364 #else 365 #define S_ISSOCK( mode ) FALSE 366 #endif /* S_IFSOCK */ 367 #endif /* S_ISSOCK */ 368 369 370 #define VI_KEY_UP 'k' 371 #define VI_KEY_DOWN 'j' 372 #define VI_KEY_RIGHT 'l' 373 #define VI_KEY_LEFT 'h' 374 #define VI_KEY_NPAGE ( 'D' & 0x1F ) 375 #define VI_KEY_PPAGE ( 'U' & 0x1F ) 376 377 378 #define OWNER_NAME_MAX 64 379 #define GROUP_NAME_MAX 64 380 #define DISPLAY_OWNER_NAME_MAX 12 381 #define DISPLAY_GROUP_NAME_MAX 12 382 383 384 /* Sonderzeichen fuer Liniengrafik */ 385 /*---------------------------------*/ 386 387 #ifndef ACS_ULCORNER 388 #define ACS_ULCORNER '+' 389 #endif 390 #ifndef ACS_URCORNER 391 #define ACS_URCORNER '+' 392 #endif 393 #ifndef ACS_LLCORNER 394 #define ACS_LLCORNER '+' 395 #endif 396 #ifndef ACS_LRCORNER 397 #define ACS_LRCORNER '+' 398 #endif 399 #ifndef ACS_VLINE 400 #define ACS_VLINE '|' 401 #endif 402 #ifndef ACS_HLINE 403 #define ACS_HLINE '-' 404 #endif 405 #ifndef ACS_RTEE 406 #define ACS_RTEE '+' 407 #endif 408 #ifndef ACS_LTEE 409 #define ACS_LTEE '+' 410 #endif 411 #ifndef ACS_BTEE 412 #define ACS_BTEE '+' 413 #endif 414 #ifndef ACS_TTEE 415 #define ACS_TTEE '+' 416 #endif 417 #ifndef ACS_BLOCK 418 #define ACS_BLOCK '?' 419 #endif 420 #ifndef ACS_LARROW 421 #define ACS_LARROW '<' 422 #endif 423 424 425 426 /* Color Definitionen */ 427 428 #define DIR_COLOR 1 429 #define FILE_COLOR 2 430 #define STATS_COLOR 3 431 #define BORDERS_COLOR 4 432 #define MENU_COLOR 5 433 #define WINDIR_COLOR 6 434 #define WINFILE_COLOR 7 435 #define WINSTATS_COLOR 8 436 #define WINERR_COLOR 9 437 #define HIDIR_COLOR 10 438 #define HIFILE_COLOR 11 439 #define HISTATS_COLOR 12 440 #define HIMENUS_COLOR 13 441 #define WINHST_COLOR 14 442 #define HST_COLOR 15 443 #define HIHST_COLOR 16 444 #define WINMTCH_COLOR 14 445 #define MTCH_COLOR 15 446 #define HIMTCH_COLOR 16 447 #define GLOBAL_COLOR 17 448 #define HIGLOBAL_COLOR 18 449 450 451 #define PROFILE_FILENAME ".ytree" 452 #define HISTORY_FILENAME ".ytree-hst" 453 454 455 /* User-Defines */ 456 /*--------------*/ 457 458 #include "config.h" 459 460 461 /* Auswahl der benutzten UNIX-Kommandos */ 462 /*--------------------------------------*/ 463 464 #define CAT GetProfileValue( "CAT" ) 465 #define HEXDUMP GetProfileValue( "HEXDUMP" ) 466 #define EDITOR GetProfileValue( "EDITOR" ) 467 #define PAGER GetProfileValue( "PAGER" ) 468 #define MELT GetProfileValue( "MELT" ) 469 #define UNCOMPRESS GetProfileValue( "UNCOMPRESS" ) 470 #define GNUUNZIP GetProfileValue( "GNUUNZIP" ) 471 #define BUNZIP GetProfileValue( "BUNZIP" ) 472 #define MANROFF GetProfileValue( "MANROFF" ) 473 #define TARLIST GetProfileValue( "TARLIST" ) 474 #define TAREXPAND GetProfileValue( "TAREXPAND" ) 475 #define RPMLIST GetProfileValue( "RPMLIST" ) 476 #define RPMEXPAND GetProfileValue( "RPMEXPAND" ) 477 #define ZOOLIST GetProfileValue( "ZOOLIST" ) 478 #define ZOOEXPAND GetProfileValue( "ZOOEXPAND" ) 479 #define ZIPLIST GetProfileValue( "ZIPLIST" ) 480 #define ZIPEXPAND GetProfileValue( "ZIPEXPAND" ) 481 #define LHALIST GetProfileValue( "LHALIST" ) 482 #define LHAEXPAND GetProfileValue( "LHAEXPAND" ) 483 #define ARCLIST GetProfileValue( "ARCLIST" ) 484 #define ARCEXPAND GetProfileValue( "ARCEXPAND" ) 485 #define TREEDEPTH GetProfileValue( "TREEDEPTH" ) 486 #define USERVIEW GetProfileValue( "USERVIEW" ) 487 #define RARLIST GetProfileValue( "RARLIST" ) 488 #define RAREXPAND GetProfileValue( "RAREXPAND" ) 489 #define FILEMODE GetProfileValue( "FILEMODE" ) 490 #define NUMBERSEP GetProfileValue( "NUMBERSEP" ) 491 #define NOSMALLWINDOW GetProfileValue( "NOSMALLWINDOW" ) 492 #define INITIALDIR GetProfileValue( "INITIALDIR" ) 493 #define DIR1 GetProfileValue( "DIR1" ) 494 #define DIR2 GetProfileValue( "DIR2" ) 495 #define FILE1 GetProfileValue( "FILE1" ) 496 #define FILE2 GetProfileValue( "FILE2" ) 497 #define SEARCHCOMMAND GetProfileValue( "SEARCHCOMMAND" ) 498 #define HEXEDITOFFSET GetProfileValue( "HEXEDITOFFSET" ) 499 #define LISTJUMPSEARCH GetProfileValue( "LISTJUMPSEARCH" ) 500 501 502 #define DEFAULT_TREE "." 503 504 505 #define ERROR_MSG( msg ) Error( msg, __FILE__, __LINE__ ) 506 #define WARNING( msg ) Warning( msg ) 507 #define MESSAGE( msg ) Message( msg ) 508 #define NOTICE( msg ) Notice( msg ) 509 510 #define TAGGED_SYMBOL '*' 511 #define MAX_MODES 11 512 #define DISK_MODE 0 513 #define LL_FILE_MODE 1 514 #define TAR_FILE_MODE 2 515 #define ZOO_FILE_MODE 3 516 #define ZIP_FILE_MODE 4 517 #define LHA_FILE_MODE 5 518 #define ARC_FILE_MODE 6 519 #define RPM_FILE_MODE 7 520 #define RAR_FILE_MODE 8 521 #define TAPE_MODE 9 522 #define USER_MODE 10 523 524 #define NO_COMPRESS 0 525 #define FREEZE_COMPRESS 1 526 #define MULTIPLE_FREEZE_COMPRESS 2 527 #define COMPRESS_COMPRESS 3 528 #define MULTIPLE_COMPRESS_COMPRESS 4 529 #define GZIP_COMPRESS 5 530 #define BZIP_COMPRESS 6 531 #define MULTIPLE_GZIP_COMPRESS 7 532 #define ZOO_COMPRESS 8 533 #define LHA_COMPRESS 9 534 #define ARC_COMPRESS 10 535 #define ZIP_COMPRESS 11 536 #define RPM_COMPRESS 12 537 #define TAPE_DIR_NO_COMPRESS 13 538 #define TAPE_DIR_FREEZE_COMPRESS 14 539 #define TAPE_DIR_COMPRESS_COMPRESS 15 540 #define TAPE_DIR_GZIP_COMPRESS 16 541 #define TAPE_DIR_BZIP_COMPRESS 17 542 #define RAR_COMPRESS 18 543 544 #define FILE_EXTENSIONS { \ 545 { ".TAP", TAPE_DIR_NO_COMPRESS }, \ 546 { ".tap", TAPE_DIR_NO_COMPRESS }, \ 547 { ".TAP.F", TAPE_DIR_FREEZE_COMPRESS }, \ 548 { ".tap.F", TAPE_DIR_FREEZE_COMPRESS }, \ 549 { ".TAP.Z", TAPE_DIR_COMPRESS_COMPRESS }, \ 550 { ".tap.Z", TAPE_DIR_COMPRESS_COMPRESS }, \ 551 { ".TAP.z", TAPE_DIR_GZIP_COMPRESS }, \ 552 { ".tap.z", TAPE_DIR_GZIP_COMPRESS }, \ 553 { ".tap.gz", TAPE_DIR_GZIP_COMPRESS }, \ 554 { ".tap.bz2", TAPE_DIR_BZIP_COMPRESS }, \ 555 { ".TAP.BZ2", TAPE_DIR_BZIP_COMPRESS }, \ 556 { ".F", FREEZE_COMPRESS }, \ 557 { ".TFR", FREEZE_COMPRESS }, \ 558 { ".Faa", MULTIPLE_FREEZE_COMPRESS }, \ 559 { ".Z", COMPRESS_COMPRESS }, \ 560 { ".TZ", COMPRESS_COMPRESS }, \ 561 { ".TZR", COMPRESS_COMPRESS }, \ 562 { ".Xaa", MULTIPLE_COMPRESS_COMPRESS }, \ 563 { ".bz2", BZIP_COMPRESS }, \ 564 { ".z", GZIP_COMPRESS }, \ 565 { ".gz", GZIP_COMPRESS }, \ 566 { ".tz", GZIP_COMPRESS }, \ 567 { ".tzr", GZIP_COMPRESS }, \ 568 { ".tgz", GZIP_COMPRESS }, \ 569 { ".TGZ", GZIP_COMPRESS }, \ 570 { ".taz", GZIP_COMPRESS }, \ 571 { ".TAZ", GZIP_COMPRESS }, \ 572 { ".tpz", GZIP_COMPRESS }, \ 573 { ".TPZ", GZIP_COMPRESS }, \ 574 { ".xaa", MULTIPLE_GZIP_COMPRESS }, \ 575 { ".zoo", ZOO_COMPRESS }, \ 576 { ".ZOO", ZOO_COMPRESS }, \ 577 { ".lzh", LHA_COMPRESS }, \ 578 { ".LZH", LHA_COMPRESS }, \ 579 { ".arc", ARC_COMPRESS }, \ 580 { ".ARC", ARC_COMPRESS }, \ 581 { ".rar", RAR_COMPRESS }, \ 582 { ".RAR", RAR_COMPRESS }, \ 583 { ".jar", ZIP_COMPRESS }, \ 584 { ".zip", ZIP_COMPRESS }, \ 585 { ".ZIP", ZIP_COMPRESS }, \ 586 { ".JAR", ZIP_COMPRESS }, \ 587 { ".rpm", RPM_COMPRESS }, \ 588 { ".RPM", RPM_COMPRESS }, \ 589 { ".spm", RPM_COMPRESS }, \ 590 { ".SPM", RPM_COMPRESS } \ 591 } 592 593 594 595 #define SORT_BY_NAME 1 596 #define SORT_BY_MOD_TIME 2 597 #define SORT_BY_CHG_TIME 3 598 #define SORT_BY_ACC_TIME 4 599 #define SORT_BY_SIZE 5 600 #define SORT_BY_OWNER 6 601 #define SORT_BY_GROUP 7 602 #define SORT_BY_EXTENSION 8 603 #define SORT_ASC 10 604 #define SORT_DSC 20 605 #define SORT_CASE 40 606 #define SORT_ICASE 80 607 608 #define DEFAULT_FILE_SPEC "*" 609 610 #define TAGSYMBOL_VIEWNAME "tag" 611 #define FILENAME_VIEWNAME "fnm" 612 #define ATTRIBUTE_VIEWNAME "atr" 613 #define LINKCOUNT_VIEWNAME "lct" 614 #define FILESIZE_VIEWNAME "fsz" 615 #define MODTIME_VIEWNAME "mot" 616 #define SYMLINK_VIEWNAME "lnm" 617 #define UID_VIEWNAME "uid" 618 #define GID_VIEWNAME "gid" 619 #define INODE_VIEWNAME "ino" 620 #define ACCTIME_VIEWNAME "act" 621 #define CHGTIME_VIEWNAME "sct" 622 623 624 #define BLKSIZ 512 /* Blockgroesse fuer SVR3 */ 625 626 #define CLOCK_INTERVAL 1 627 628 #define FILE_SEPARATOR_CHAR '/' 629 #define FILE_SEPARATOR_STRING "/" 630 631 #define ERR_TO_NULL " 2> /dev/null" 632 #define ERR_TO_STDOUT " 2>&1 " 633 634 #define BOOL unsigned char 635 #define LF 10 636 #define ESC 27 637 #define LOGIN_ESC '.' 638 639 #ifdef sgi 640 #define SGI_CR 0x157 /* Irix 3.2.2 special ? */ 641 #endif 642 643 #define CR 13 644 645 #define DIR_WINDOW_X 1 646 #define DIR_WINDOW_Y 2 647 #define DIR_WINDOW_WIDTH (COLS - 26) 648 #define DIR_WINDOW_HEIGHT ((LINES * 8 / 14)-1) 649 650 #define F2_WINDOW_X DIR_WINDOW_X 651 #define F2_WINDOW_Y DIR_WINDOW_Y 652 #define F2_WINDOW_WIDTH DIR_WINDOW_WIDTH 653 #define F2_WINDOW_HEIGHT (DIR_WINDOW_HEIGHT + 1) 654 655 #define FILE_WINDOW_1_X 1 656 #define FILE_WINDOW_1_Y DIR_WINDOW_HEIGHT + 3 657 #define FILE_WINDOW_1_WIDTH (COLS - 26) 658 #define FILE_WINDOW_1_HEIGHT (LINES - DIR_WINDOW_HEIGHT - 7 ) 659 660 #define FILE_WINDOW_2_X 1 661 #define FILE_WINDOW_2_Y 2 662 #define FILE_WINDOW_2_WIDTH (COLS - 26) 663 #define FILE_WINDOW_2_HEIGHT (LINES - 6) 664 665 #define ERROR_WINDOW_WIDTH 40 666 #define ERROR_WINDOW_HEIGHT 10 667 #define ERROR_WINDOW_X ((COLS - ERROR_WINDOW_WIDTH) >> 1) 668 #define ERROR_WINDOW_Y ((LINES - ERROR_WINDOW_HEIGHT) >> 1) 669 670 #define HISTORY_WINDOW_X 1 671 #define HISTORY_WINDOW_Y 2 672 #define HISTORY_WINDOW_WIDTH (COLS - 26) 673 #define HISTORY_WINDOW_HEIGHT (LINES - 6) 674 675 #define MATCHES_WINDOW_X 1 676 #define MATCHES_WINDOW_Y 2 677 #define MATCHES_WINDOW_WIDTH (COLS - 26) 678 #define MATCHES_WINDOW_HEIGHT (LINES - 6) 679 680 #define TIME_WINDOW_X ((COLS > 20) ? (COLS - 20) : 1) 681 #define TIME_WINDOW_Y 1 682 #define TIME_WINDOW_WIDTH ((COLS > 15) ? 15 : COLS) 683 #define TIME_WINDOW_HEIGHT 1 684 685 686 #define PATH_LENGTH 1024 687 #define FILE_SPEC_LENGTH (12 + 1) 688 #define DISK_NAME_LENGTH (12 + 1) 689 #define LL_LINE_LENGTH 512 690 #define TAR_LINE_LENGTH 512 691 #define RPM_LINE_LENGTH 512 692 #define ZOO_LINE_LENGTH 512 693 #define ZIP_LINE_LENGTH 512 694 #define LHA_LINE_LENGTH 512 695 #define ARC_LINE_LENGTH 512 696 #define RAR_LINE_LENGTH 512 697 #define MESSAGE_LENGTH (PATH_LENGTH + 80 + 1) 698 #define COMMAND_LINE_LENGTH 4096 699 #define MODE_1 0 700 #define MODE_2 1 701 #define MODE_3 2 702 #define MODE_4 3 703 #define MODE_5 4 704 705 706 #ifdef __NeXT__ 707 #include <sys/ttydev.h> 708 #define QUICK_BAUD_RATE B9600 709 #else 710 #define QUICK_BAUD_RATE 9600 711 #endif /* __NeXT__ */ 712 713 #define ESCAPE goto FNC_XIT 714 715 #define PRINT(ch) (iscntrl(ch) && (((unsigned char)(ch)) < ' ')) ? (ACS_BLOCK) : ((unsigned char)(ch)) 716 /* #define PRINT(ch) (ch) */ 717 718 #ifdef COLOR_SUPPORT 719 extern void StartColors(void); 720 extern void WbkgdSet(WINDOW *w, chtype c); 721 #else 722 #define StartColors() ; 723 #define WbkgdSet(a, b) ; 724 #endif /* COLOR_SUPPORT */ 725 726 727 728 typedef struct _file_entry 729 { 730 struct _file_entry *next; 731 struct _file_entry *prev; 732 struct _dir_entry *dir_entry; 733 struct stat stat_struct; 734 BOOL tagged; 735 BOOL matching; 736 char name[1]; 737 /*char symlink_name[]; */ /* Folgt direkt dem Namen, falls */ 738 /* Eintrag == symbolischer Link */ 739 } FileEntry; 740 741 742 743 typedef struct _dir_entry 744 { 745 struct _file_entry *file; 746 struct _dir_entry *next; 747 struct _dir_entry *prev; 748 struct _dir_entry *sub_tree; 749 struct _dir_entry *up_tree; 750 LONGLONG total_bytes; 751 LONGLONG matching_bytes; 752 LONGLONG tagged_bytes; 753 unsigned int total_files; 754 unsigned int matching_files; 755 unsigned int tagged_files; 756 int cursor_pos; 757 int start_file; 758 struct stat stat_struct; 759 BOOL access_denied; 760 BOOL global_flag; 761 BOOL tagged_flag; 762 BOOL only_tagged; 763 BOOL not_scanned; 764 BOOL big_window; 765 BOOL login_flag; 766 char name[1]; 767 } DirEntry; 768 769 770 771 typedef struct 772 { 773 unsigned long indent; 774 DirEntry *dir_entry; 775 unsigned short level; 776 } DirEntryList; 777 778 779 typedef struct 780 { 781 FileEntry *file; 782 } FileEntryList; 783 784 785 typedef struct 786 { 787 DirEntry *tree; 788 LONGLONG disk_space; 789 LONGLONG disk_capacity; 790 LONGLONG disk_total_files; 791 LONGLONG disk_total_bytes; 792 LONGLONG disk_matching_files; 793 LONGLONG disk_matching_bytes; 794 LONGLONG disk_tagged_files; 795 LONGLONG disk_tagged_bytes; 796 unsigned int disk_total_directories; 797 int disp_begin_pos; 798 int cursor_pos; 799 int kind_of_sort; 800 char login_path[PATH_LENGTH + 1]; 801 char path[PATH_LENGTH + 1]; 802 char tape_name[PATH_LENGTH + 1]; 803 char file_spec[FILE_SPEC_LENGTH + 1]; 804 char disk_name[DISK_NAME_LENGTH + 1]; 805 } Statistic; 806 807 808 typedef union 809 { 810 struct 811 { 812 char new_modus[11]; 813 } change_modus; 814 815 struct 816 { 817 unsigned new_owner_id; 818 } change_owner; 819 820 struct 821 { 822 unsigned new_group_id; 823 } change_group; 824 825 struct 826 { 827 char *command; 828 } execute; 829 830 struct 831 { 832 Statistic *statistic_ptr; 833 DirEntry *dest_dir_entry; 834 char *to_file; 835 char *to_path; 836 BOOL path_copy; 837 BOOL confirm; 838 } copy; 839 840 struct 841 { 842 char *new_name; 843 BOOL confirm; 844 } rename; 845 846 struct 847 { 848 DirEntry *dest_dir_entry; 849 char *to_file; 850 char *to_path; 851 BOOL confirm; 852 } mv; 853 854 struct 855 { 856 FILE *pipe_file; 857 } pipe_cmd; 858 859 struct 860 { 861 FILE *zipfile; 862 int method; 863 } compress_cmd; 864 865 } FunctionData; 866 867 868 typedef struct 869 { 870 FileEntry *new_fe_ptr; 871 FunctionData function_data; 872 } WalkingPackage; 873 874 /* strerror() is POSIX, and all modern operating systems provide it. */ 875 #define HAVE_STRERROR 1 876 877 #ifndef HAVE_STRERROR 878 extern const char *StrError(int); 879 #endif /* HAVE_STRERROR */ 880 881 882 extern WINDOW *dir_window; 883 extern WINDOW *small_file_window; 884 extern WINDOW *big_file_window; 885 extern WINDOW *file_window; 886 extern WINDOW *error_window; 887 extern WINDOW *history_window; 888 extern WINDOW *matches_window; 889 extern WINDOW *f2_window; 890 extern WINDOW *time_window; 891 892 extern Statistic statistic; 893 extern Statistic disk_statistic; 894 extern int mode; 895 extern int user_umask; 896 extern char message[]; 897 extern BOOL print_time; 898 extern BOOL resize_request; 899 extern char number_seperator; 900 extern BOOL bypass_small_window; 901 extern char *initial_directory; 902 extern char builtin_hexdump_cmd[]; 903 904 905 #if defined(ultrix) 906 extern char *getenv(char *); 907 #else 908 extern char *getenv(const char *); 909 #endif 910 911 extern int ytree(int argc, char *argv[]); 912 extern void DisplayMenu(void); 913 extern void DisplayDiskStatistic(void); 914 extern void DisplayDirStatistic(DirEntry *dir_entry); 915 extern void DisplayDirParameter(DirEntry *dir_entry); 916 extern void DisplayDirTagged(DirEntry *dir_entry); 917 extern void DisplayDiskTagged(void); 918 extern void DisplayDiskName(void); 919 extern void DisplayFileParameter(FileEntry *file_entry); 920 extern void DisplayGlobalFileParameter(FileEntry *file_entry); 921 extern void RefreshWindow(WINDOW *win); 922 extern int ReadTree(DirEntry *dir_entry, char *path, int depth); 923 extern void UnReadTree(DirEntry *dir_entry); 924 extern int ReadTreeFromTAR(DirEntry *dir_entry, FILE *f); 925 extern int ReadTreeFromRPM(DirEntry *dir_entry, FILE *f); 926 extern int ReadTreeFromZOO(DirEntry *dir_entry, FILE *f); 927 extern int ReadTreeFromZIP(DirEntry *dir_entry, FILE *f); 928 extern int ReadTreeFromLHA(DirEntry *dir_entry, FILE *f); 929 extern int ReadTreeFromARC(DirEntry *dir_entry, FILE *f); 930 extern int ReadTreeFromRAR(DirEntry *dir_entry, FILE *f); 931 extern int GetDiskParameter(char *path, 932 char *volume_name, 933 LONGLONG *avail_bytes, 934 LONGLONG *capacity 935 ); 936 extern int HandleDirWindow(DirEntry *start_dir_entry); 937 extern void DisplayFileWindow(DirEntry *dir_entry); 938 extern int Init(char *configuration_file, char *history_file); 939 extern char *GetPath(DirEntry *dir_entry, char *buffer); 940 extern BOOL Match(char *file_name); 941 extern int SetMatchSpec(char *new_spec); 942 extern int SetFileSpec(char *file_spec); 943 extern void SetMatchingParam(DirEntry *dir_entry); 944 extern void Error(char *msg, char *module, int line); 945 extern void Warning(char *msg); 946 extern void Notice(char *msg); 947 extern void UnmapNoticeWindow(void); 948 extern void SetFileMode(int new_file_mode); 949 extern int HandleFileWindow(DirEntry *dir_entry); 950 extern char *GetAttributes(unsigned short modus, char *buffer); 951 extern void SwitchToSmallFileWindow(void); 952 extern void SwitchToBigFileWindow(void); 953 extern int ReadGroupEntries(void); 954 extern char *GetGroupName(unsigned int gid); 955 extern char *GetDisplayGroupName(unsigned int gid); 956 extern int GetGroupId(char *name); 957 extern int ReadPasswdEntries(void); 958 extern char *GetPasswdName(unsigned int uid); 959 extern char *GetDisplayPasswdName(unsigned int uid); 960 extern int GetPasswdUid(char *name); 961 extern char *GetFileNamePath(FileEntry *file_entry, char *buffer); 962 extern char *GetRealFileNamePath(FileEntry *file_entry, char *buffer); 963 extern int SystemCall(char *command_line); 964 extern int QuerySystemCall(char *command_line); 965 extern int SilentSystemCall(char *command_line); 966 extern int SilentSystemCallEx(char *command_line, BOOL enable_clock); 967 extern int View(DirEntry * dir_entry, char *file_path); 968 extern int ViewHex(char *file_path); 969 extern int InternalView(char *file_path); 970 extern int Edit(DirEntry * dir_entry, char *file_path); 971 extern void DisplayAvailBytes(void); 972 extern void DisplayFileSpec(void); 973 extern void QuitTo(DirEntry * dir_entry); 974 extern void Quit(void); 975 extern int ReadFileSpec(void); 976 extern int InputString(char *s, int y, int x, int cursor_pos, int length, char *term); 977 extern void RotateFileMode(void); 978 extern int Execute(DirEntry *dir_entry, FileEntry *file_entry); 979 extern int Pipe(DirEntry *dir_entry, FileEntry *file_entry); 980 extern int PipeTaggedFiles(FileEntry *fe_ptr, WalkingPackage *walking_package); 981 extern int GetPipeCommand(char *pipe_command); 982 extern void GetKindOfSort(void); 983 extern void SetKindOfSort(int new_kind_of_sort); 984 extern int ChangeFileModus(FileEntry *fe_ptr); 985 extern int ChangeDirModus(DirEntry *de_ptr); 986 extern int GetNewFileModus(int y, int x, char *modus, char *term); 987 extern int GetModus(char *modus); 988 extern int SetFileModus(FileEntry *fe_ptr, WalkingPackage *walking_package); 989 extern int CopyTaggedFiles(FileEntry *fe_ptr, WalkingPackage *walking_package); 990 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); 991 extern int MoveTaggedFiles(FileEntry *fe_ptr, WalkingPackage *walking_package); 992 extern int MoveFile(FileEntry *fe_ptr, unsigned char confirm, char *to_file, DirEntry *dest_dir_entry, char *to_dir_path, FileEntry **new_fe_ptr); 993 extern int InputChoise(char *msg, char *term); 994 extern void Message(char *msg); 995 extern int GetDirEntry(DirEntry *tree, DirEntry *current_dir_entry, char *dir_path, DirEntry **dir_entry, char *to_path); 996 extern int GetFileEntry(DirEntry *de_ptr, char *file_name, FileEntry **file_entry); 997 extern int GetCopyParameter(char *from_file, BOOL path_copy, char *to_file, char *to_dir); 998 extern int GetMoveParameter(char *from_file, char *to_file, char *to_dir); 999 extern int ChangeFileOwner(FileEntry *fe_ptr); 1000 extern int GetNewOwner(int st_uid); 1001 extern int SetFileOwner(FileEntry *fe_ptr, WalkingPackage *walking_package); 1002 extern int ChangeDirOwner(DirEntry *de_ptr); 1003 extern int ChangeFileGroup(FileEntry *fe_ptr); 1004 extern int GetNewGroup(int st_gid); 1005 extern int SetFileGroup(FileEntry *fe_ptr, WalkingPackage *walking_package); 1006 extern int ChangeDirGroup(DirEntry *de_ptr); 1007 extern void DisplayDirHelp(void); 1008 extern void DisplayFileHelp(void); 1009 extern void ClearHelp(void); 1010 extern int GetAvailBytes(LONGLONG *avail_bytes); 1011 extern int DeleteDirectory(DirEntry *dir_entry); 1012 extern int ExecuteCommand(FileEntry *fe_ptr, WalkingPackage *walking_package); 1013 extern int GetCommandLine(char *command_line); 1014 extern int GetSearchCommandLine(char *command_line); 1015 extern int DeleteFile(FileEntry *fe_ptr); 1016 extern int RemoveFile(FileEntry *fe_ptr); 1017 extern int RenameDirectory(DirEntry *de_ptr, char *new_name); 1018 extern int RenameFile(FileEntry *fe_ptr, char *new_name, FileEntry **new_fe_ptr); 1019 extern int RenameTaggedFiles(FileEntry *fe_ptr, WalkingPackage *walking_package); 1020 extern int GetRenameParameter(char *old_name, char *new_name); 1021 extern char *CTime(time_t f_time, char *buffer); 1022 extern int LoginDisk(char *path); 1023 extern int GetNewLoginPath(char *path); 1024 extern void PrintSpecialString(WINDOW *win, int y, int x, char *str, int color); 1025 extern void Print(WINDOW *, int, int, char *, int); 1026 extern void PrintOptions(WINDOW *,int, int, char *); 1027 extern void PrintMenuOptions(WINDOW *,int, int, char *, int, int); 1028 extern char *FormFilename(char *dest, char *src, unsigned int max_len); 1029 extern char *CutFilename(char *dest, char *src, unsigned int max_len); 1030 extern char *CutPathname(char *dest, char *src, unsigned int max_len); 1031 extern void Fnsplit(char *path, char *dir, char *name); 1032 extern void MakeExtractCommandLine(char *command_line, char *path, char *file, char *cmd); 1033 extern int MakeDirectory(DirEntry *father_dir_entry); 1034 extern time_t Mktime(struct tm *tm); 1035 extern int TryInsertArchiveDirEntry(DirEntry *tree, char *dir, struct stat *stat); 1036 extern int InsertArchiveFileEntry(DirEntry *tree, char *path, struct stat *stat); 1037 extern int MinimizeArchiveTree(DirEntry *tree); 1038 extern void HitReturnToContinue(void); 1039 extern int TermcapWgetch(WINDOW *win); 1040 extern void TermcapVidattr(int attr ); 1041 extern void TermcapInitscr(void); 1042 extern void TermcapEndwin(void); 1043 extern int BuildFilename( char *in_filename, char *pattern, char *out_filename); 1044 extern int ViKey( int ch ); 1045 extern int GetFileMethod( char *filename ); 1046 extern int AixWgetch( WINDOW *w ); 1047 extern BOOL KeyPressed(void); 1048 extern BOOL EscapeKeyPressed(void); 1049 extern int GetTapeDeviceName(void); 1050 extern int MakePath( DirEntry *tree, char *dir_path, DirEntry **dest_dir_entry ); 1051 extern int MakeDirEntry( DirEntry *father_dir_entry, char *dir_name ); 1052 extern void NormPath( char *in_path, char *out_path ); 1053 extern char *Strtok_r( char *str, char *delim, char **old ); 1054 extern int ReadProfile( char *filename ); 1055 extern char *GetProfileValue( char *key ); 1056 extern int ScanSubTree( DirEntry *dir_entry ); 1057 extern void GetMaxYX(WINDOW *win, int *height, int *width); 1058 1059 extern char *GetHistory(void); 1060 extern void InsHistory(char *new_hist); 1061 extern void ReadHistory(char *filename); 1062 extern void SaveHistory(char *filename); 1063 extern char *GetMatches(char *); 1064 extern int KeyF2Get(DirEntry *start_dir_entry, 1065 int disp_begin_pos, 1066 int cursor_pos, 1067 char *path); 1068 extern void Switch2F2Window(void); 1069 extern void MapF2Window(void); 1070 extern void UnmapF2Window(void); 1071 extern void ReadExtFile(char *); 1072 extern char *GetExtCmd(char *); 1073 extern int MvAddStr(int y, int x, char *str); 1074 extern int MvWAddStr(WINDOW *win, int y, int x, char *str); 1075 extern int WAddStr(WINDOW *win, char *str); 1076 extern int AddStr(char *str); 1077 extern void ClockHandler(int); 1078 extern int Strrcmp(char *s1, char* s2); 1079 extern char *Strdup(const char *s); 1080 extern char *GetExtViewer(char *filename); 1081 extern void InitClock(void); 1082 extern void SuspendClock(void); 1083 extern char *GetExtension(char *filename); 1084 extern void StrCp(char *dest, const char *src); 1085 extern int BuildUserFileEntry(FileEntry *fe_ptr, 1086 int max_filename_len, int max_linkname_len, 1087 char *template, int linelen, char *line); 1088 extern int GetUserFileEntryLength(int max_filename_len, 1089 int max_linkname_len, char *template); 1090 extern LONGLONG AtoLL(char* cptr); 1091 extern void DisplayTree(WINDOW *win, int start_entry_no, int hilight_no); 1092 extern void ReCreateWindows(void); 1093 extern int Getch(void); 1094 extern int DirUserMode(DirEntry *dir_entry, int ch); 1095 extern int FileUserMode(FileEntryList *file_entry_list, int ch); 1096 extern char *GetUserFileAction(int chkey, int *pchremap); 1097 extern char *GetUserDirAction(int chkey, int *pchremap); 1098 extern BOOL IsUserActionDefined(void); 1099 extern char *Getcwd(char *buffer, unsigned int len); 1100 extern int RefreshDirWindow(); 1101 extern char *StrLeft(const char *str, size_t count); 1102 extern int StrVisualLength(const char *str); 1103 extern int WAttrAddStr(WINDOW *win, int attr, char *str); 1104 extern char *Strndup(const char *s, int len); 1105 extern char *CutName(char *dest, char *src, unsigned int max_len); 1106