1 #undef GC       /* use Boehm memory allocator */
2 
3 #if !HAVE_TCSETPGRP
4 #   define tcsetpgrp(fd,pgrp)	ioctl (fd, TIOCSPGRP, &pgrp)
5 #endif
6 
7 #if !HAVE_KILLPG
8 #   define killpg(pid,sig)      kill (-pid, sig)
9 #endif
10 
11 /* width of directory window */
12 
13 #define PAGEWID         (widewin ? 77 : 39)
14 
15 /* number of displayable files in directory window */
16 
17 #define PAGELEN(c)      pagelen ((c)->view)
18 
19 #define BASECOL(c)      (widewin ? 0 : (c)->basecol)
20 
21 #define CMDLEN          512             /* length of command string */
22 
23 struct dir;
24 struct file;
25 struct menu;
26 
27 extern struct dir left, right;          /* left and right directories */
28 extern struct dir *cur;                 /* current directory */
29 extern widewin;                         /* wide window mode */
30 extern H;                               /* file window height */
31 extern cmdreg;                          /* command line mode */
32 extern char command [];                 /* command line */
33 extern cpos;                            /* command line cursor */
34 extern char *user;                      /* user name */
35 extern char *group;                     /* user group name */
36 extern char *tty;                       /* tty name */
37 extern char *machine;                   /* machine name */
38 extern visualwin;                       /* cursor in command line */
39 extern showhidden;                      /* show hidden files ".*" */
40 extern uid;                             /* real user id */
41 extern main_pid;                        /* our process id */
42 extern ppid;                            /* parent id */
43 extern lang;                            /* language */
44 extern char editname [40], viewname [40];
45 extern useredit, userview, usecshell;
46 extern int viewraw, viewhex, viewtabs;
47 extern char *home;
48 extern int errno;
49 extern struct palette palette, dflt_palette;
50 
51 #define ENG 0                           /* English */
52 #define RUS 1                           /* Russian */
53 #define UKR 2                           /* Ukranian */
54 #define DEU 3                           /* German */
55 #define FRA 4                           /* France */
56 
57 #define VIEW_BRIEF	0
58 #define VIEW_LONG	1
59 #define VIEW_WIDE	2
60 #define VIEW_FULL	3
61 #define VIEW_INFO	4
62 
63 struct palette {
64 	int fg, bg;
65 	int revfg, revbg;
66 	int boldfg, boldbg;
67 	int boldrevfg, boldrevbg;
68 	int dimfg, dimbg;
69 	int dimrevfg, dimrevbg;
70 };
71 
72 /*
73  * mcheck (type& array, type, int& bound, int quant, int index)
74  *      Check index of dynamic array.
75  *      Enlarge array if needed.
76  */
77 #define mcheck(array, type, bound, quant, index)\
78 	if ((index) >= (bound)) (array) = (type) realloc (array,\
79 		(int) ((bound) += (quant)) * (int) sizeof (*(array)))
80 
81 #if !HAVE_MEMCPY
82 #   define memcpy(t,f,n)       bcopy(f,t,n)
83 #   define memcmp(a,b,n)       bcmp(a,b,n)
84 #endif
85 
86 #ifdef GC
87 #   include <gc.h>
88 #   define malloc(n)            GC_malloc (n)
89 #   define calloc(n,m)          GC_malloc ((n)*(m))
90 #   define realloc(a,n)         ((a) ? GC_realloc (a, n) : GC_malloc (n))
91 #   define free(a)              if (a) GC_free (a)
92 #endif
93 
94 void error (char *s, ...);
95 void message (char *name, char *s, ...);
96 int setdir (struct dir *d, char *dirname);
97 void hidecursor (void);
98 int getchoice (int bold, char *head, char *msg, char *mesg2,
99 	char *c1, char *c2, char *c3);
100 char *username (int u);
101 char *groupname (int g);
102 void sigign (void);
103 void sigdfl (void);
104 void outerr (char *msg, ...);
105 int runv (int silent, char *name, char **a0);
106 char *getmachine ();
107 const char *extension (const char *p);
108 char *ltoac (long l);
109 char *basename (char *p);
110 char *strtail (char *p, int delim, int maxlen);
111 int strbcmp (char *s, char *b);
112 int match (unsigned char *name, unsigned char *pat);
113 int getmenu (void);
114 void downmenu (struct menu *m);
115 char *timestr (long tim);
116 int hexview (char *filename);
117 void viewpage (int line, int col);
118 void viewchar (int c);
119 void viewline (int line, int col, int scrline);
120 int offset (int l, int n);
121 int column (int l, int n);
122 int search (char *str, int l, int c, int *pline, int *pcol);
123 void runhelp (char *name);
124 char *getstring (int w, char *str, char *head, char *mesg);
125 void endmesg (void);
126 char *mdup (char *s);
127 int pagelen (int f);
128 char *getwstring (int w, char *str, char *head, char *mesg);
129 void syscmd (char *s);
130 void viewfile (int d, char *filename);
131 void editfile (int d, char *filename, char *basename);
132 void quitdeco (void);
133 int doexec (char *str);
134 void runset (char *dest);
135 void runarg (char *name);
136 int rundone (char *name, char *a0, char *a1, char *a2);
137 void runcancel ();
138 int runl (int silent, char *name, ...);
139 void findfile (struct dir *d, char *name);
140 int compfile (const void *arg1, const void *arg2);
141 int exist (char *name);
142 void counttag (struct dir *d);
143 void rightcmd (void);
144 void mvcaddstr (int r, int c, char *s);
145 void inscmd (int key);
146 int quote (void);
147 void fullscreen (int k, int sk);
148 int tagged (void);
149 void draw (void);
150 void drawbanners (void);
151 int filetype (struct file *f);
152 char *filemode (int m);
153 void setinfo (struct file *f, struct dir *d);
154 char *filesize (struct file *f);
155 char *filedate (long d);
156 void execmd (int hit, int savhist);
157 void directory (int k, int sk);
158 void switchcmdreg ();
159 void switchpanels ();
160 void setstatus ();
161 void reread (int k, int sk);
162 void setdwid ();
163 void view ();
164 void edit ();
165 void menuedit ();
166 void extedit ();
167 void quit ();
168 void swappanels ();
169 void copy ();
170 void renmove ();
171 void makedir ();
172 void delete ();
173 void findname ();
174 void tagall ();
175 void untagall ();
176 void drawcmd ();
177 void namecmd ();
178 void delcmd ();
179 void homecmd ();
180 void endcmd ();
181 void leftcmd ();
182 void upcmd ();
183 void downcmd ();
184 void nextcmd ();
185 void prevcmd ();
186 void histmenu ();
187 void drawdir (struct dir *c, int statusflag);
188 void drawcursor ();
189 void undrawcursor ();
190 void excommand (char *cp, char *fname);
191 void usermenu ();
192 void readinitfile ();
193 void genhelp ();
194 int hexview (char *filename);
195 void runmenu (int mkey);
196 void jobcmd (int pid, char *cmd);
197 RETSIGTYPE sigchild (int sig);
198 int mygroup (int gid);
199