summaryrefslogtreecommitdiffstats
path: root/cpukit/libmisc/shell/extern-ls.h
blob: 01575ba7dfe5064fe5620daf5650de948b902fb6 (plain) (blame)
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/*-
 * Copyright (c) 1989, 1993
 *	The Regents of the University of California.  All rights reserved.
 *
 * This code is derived from software contributed to Berkeley by
 * Michael Fischbein.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 4. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 *	from: @(#)ls.h	8.1 (Berkeley) 5/31/93
 * $FreeBSD: src/bin/ls/ls.h,v 1.23 2008/04/04 03:57:46 grog Exp $
 */

#ifndef _EXTERN_LS_H_
#define _EXTERN_LS_H_

#define NO_PRINT	1
//#define COLORLS   1

#include <sys/cdefs.h>
#include <setjmp.h>

#define major(d) rtems_filesystem_dev_major_t(d)
#define minor(d) rtems_filesystem_dev_minor_t(d)

const char *user_from_uid(uid_t uid, int nouser);

typedef struct {
  int blocksize;
  int termwidth;
  int sortkey;
  int rval;
  int output;
  time_t now;

  int f_accesstime;
  int f_column;
  int f_columnacross;
  int f_flags;
  int f_grouponly;
  int f_humanize;
  int f_inode;
  int f_listdir;
  int f_listdot;
  int f_longform;
  int f_nonprint;
  int f_nosort;
  int f_numericonly;
  int f_octal;
  int f_octal_escape;
  int f_recursive;
  int f_reversesort;
  int f_sectime;
  int f_singlecol;
  int f_size;
  int f_statustime;
  int f_stream;
  int f_type;
  int f_typedir;
  int f_whiteout;

  int exit_code;
  jmp_buf exit_jmp;
} rtems_shell_ls_globals;

#define blocksize      globals->blocksize
#define termwidth      globals->termwidth
#define sortkey        globals->sortkey
#define rval           globals->rval
#define output         globals->output
#define now            globals->now

#define f_accesstime   globals->f_accesstime
#define f_column       globals->f_column
#define f_columnacross globals->f_columnacross
#define f_flags        globals->f_flags
#define f_grouponly    globals->f_grouponly
#define f_humanize     globals->f_humanize
#define f_inode        globals->f_inode
#define f_listdir      globals->f_listdir
#define f_listdot      globals->f_listdot
#define f_longform     globals->f_longform
#define f_nonprint     globals->f_nonprint
#define f_nosort       globals->f_nosort
#define f_numericonly  globals->f_numericonly
#define f_octal        globals->f_octal
#define f_octal_escape globals->f_octal_escape
#define f_recursive    globals->f_recursive
#define f_reversesort  globals->f_reversesort
#define f_sectime      globals->f_sectime
#define f_singlecol    globals->f_singlecol
#define f_size         globals->f_size
#define f_statustime   globals->f_statustime
#define f_stream       globals->f_stream
#define f_type         globals->f_type
#define f_typedir      globals->f_typedir
#define f_whiteout     globals->f_whiteout

#define exit_jump      &(globals->exit_jmp)

void rtems_shell_ls_exit(rtems_shell_ls_globals* globals, int code);

#define exit(ec) rtems_shell_ls_exit(globals, ec)


typedef struct {
        FTSENT *list;
        u_int64_t btotal;
        u_int64_t stotal;
        int entries;
        int maxlen;
        int s_block;
        int s_flags;
        int s_group;
        int s_inode;
        int s_nlink;
        int s_size;
        int s_user;
        int s_major;
        int s_minor;
} DISPLAY;

typedef struct {
        char *user;
        char *group;
        char *flags;
        char data[1];
} NAMES;

#define acccmp        rtems_shell_ls_acccmp
#define revacccmp     rtems_shell_ls_revacccmp
#define modcmp        rtems_shell_ls_modcmp
#define revmodcmp     rtems_shell_ls_revmodcmp
#define namecmp       rtems_shell_ls_namecmp
#define revnamecmp    rtems_shell_ls_revnamecmp
#define statcmp       rtems_shell_ls_statcmp
#define revstatcmp    rtems_shell_ls_revstatcmp
#define sizecmp       rtems_shell_ls_sizecmp
#define revsizecmp    rtems_shell_ls_revsizecmp
#define printescaped  rtems_shell_ls_printescaped
#define printacol     rtems_shell_ls_printacol
#define printcol      rtems_shell_ls_printcol
#define printlong     rtems_shell_ls_printlong
#define printscol     rtems_shell_ls_printscol
#define printstream   rtems_shell_ls_printstream
#define usage         rtems_shell_ls_usage

int      acccmp(const FTSENT *, const FTSENT *);
int      revacccmp(const FTSENT *, const FTSENT *);
int      modcmp(const FTSENT *, const FTSENT *);
int      revmodcmp(const FTSENT *, const FTSENT *);
int      namecmp(const FTSENT *, const FTSENT *);
int      revnamecmp(const FTSENT *, const FTSENT *);
int      statcmp(const FTSENT *, const FTSENT *);
int      revstatcmp(const FTSENT *, const FTSENT *);
int      sizecmp(const FTSENT *, const FTSENT *);
int      revsizecmp(const FTSENT *, const FTSENT *);

int      printescaped(rtems_shell_ls_globals* globals, const char *);
void     printacol(rtems_shell_ls_globals* globals, DISPLAY *);
void     printcol(rtems_shell_ls_globals* globals, DISPLAY *);
void     printlong(rtems_shell_ls_globals* globals, DISPLAY *);
void     printscol(rtems_shell_ls_globals* globals, DISPLAY *);
void     printstream(rtems_shell_ls_globals* globals, DISPLAY *);
int      safe_print(rtems_shell_ls_globals* globals, const char *);
void     usage(rtems_shell_ls_globals* globals);

void strmode(mode_t mode, char *p);

#define DAYSPERNYEAR 365
#define SECSPERDAY   (60 * 60 * 24)

#endif /* !_EXTERN_H_ */