File: main.c

package info (click to toggle)
ytree 1.94-1.1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 836 kB
  • ctags: 1,510
  • sloc: ansic: 15,271; makefile: 208
file content (111 lines) | stat: -rw-r--r-- 2,022 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/***************************************************************************
 *
 * $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();
  }
}