~ubuntu-branches/debian/jessie/acfax/jessie

« back to all changes in this revision

Viewing changes to .pc/remove-getwd.patch/Directory.h

  • Committer: Package Import Robot
  • Author(s): Colin Tuckley
  • Date: 2014-02-10 20:23:51 UTC
  • Revision ID: package-import@ubuntu.com-20140210202351-id1r9lub15jv2dti
Tags: 981011-16
* Convert to source format 3.0 (quilt)
* Remove refs to unused and deprecated getwd
* Change Arch to linux-any since osspd isn't available elsewhere
* Fix various implicit def warnings by adding required .h file includes

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
 
 
3
        Directory.h
 
4
 
 
5
        This file contains the C definitions and declarations for the
 
6
        Directory.c directory iteration code.
 
7
 
 
8
        This code is intended to be used as a convenient, machine
 
9
        independent interface to iterate through the contents of a
 
10
        directory.
 
11
 
 
12
 ****************************************************************************/
 
13
 
 
14
/*
 
15
 * Author:
 
16
 *      Brian Totty
 
17
 *      Department of Computer Science
 
18
 *      University Of Illinois at Urbana-Champaign
 
19
 *      1304 West Springfield Avenue
 
20
 *      Urbana, IL 61801
 
21
 * 
 
22
 *      totty@cs.uiuc.edu
 
23
 *      
 
24
 */ 
 
25
 
 
26
#ifndef _DIRECTORY_H_
 
27
#define _DIRECTORY_H_
 
28
 
 
29
#include <stdio.h>
 
30
#include <string.h>
 
31
#include <sys/param.h>
 
32
#include <sys/types.h>
 
33
#include <sys/stat.h>
 
34
#include <unistd.h>
 
35
 
 
36
#if defined(SYSV) || defined(SVR4)
 
37
#define getwd(path) getcwd(path, MAXPATHLEN)
 
38
#endif
 
39
 
 
40
#ifndef NO_DIRENT
 
41
#include <dirent.h>
 
42
#else
 
43
#include <sys/dir.h>
 
44
#define dirent direct
 
45
#endif
 
46
 
 
47
#ifndef _SYS_NAME_MAX
 
48
#ifndef MAXNAMLEN
 
49
ERROR, ONE OF THESE MUST BE DEFINED
 
50
#else
 
51
#define MAX_NAME_LENGTH MAXNAMLEN
 
52
#endif
 
53
#else
 
54
#define MAX_NAME_LENGTH _SYS_NAME_MAX
 
55
#endif
 
56
 
 
57
#ifndef TRUE
 
58
#define TRUE                            1
 
59
#endif
 
60
 
 
61
#ifndef FALSE
 
62
#define FALSE                           0
 
63
#endif
 
64
 
 
65
#define PERM_READ                       4
 
66
#define PERM_WRITE                      2       
 
67
#define PERM_EXECUTE                    1
 
68
 
 
69
#define F_TYPE_DIR                      1
 
70
#define F_TYPE_FILE                     2
 
71
#define F_TYPE_CHAR_SPECIAL             3
 
72
#define F_TYPE_BLOCK_SPECIAL            4
 
73
#define F_TYPE_SYM_LINK                 5
 
74
#define F_TYPE_SOCKET                   6
 
75
#define F_TYPE_FIFO                     7
 
76
 
 
77
/*--------------------------------------------------------------------------*
 
78
 
 
79
            D A T A    T Y P E    A C C E S S    M A C R O S
 
80
 
 
81
 *--------------------------------------------------------------------------*/
 
82
 
 
83
        /* Directory: Directory Iterator */
 
84
 
 
85
#define DirectoryDir(dp)                ((dp)->filep)
 
86
#define DirectoryPath(dp)               ((dp)->path)
 
87
 
 
88
        /* FileInfo: Information About A File Or Link */
 
89
 
 
90
#define FileInfoProt(fi)                ((fi)->protections)
 
91
#define FileInfoOrigMode(fi)            ((fi)->orig_mode)
 
92
#define FileInfoUserID(fi)              ((fi)->user_id)
 
93
#define FileInfoGroupID(fi)             ((fi)->group_id)
 
94
#define FileInfoFileSize(fi)            ((fi)->size)
 
95
#define FileInfoLastAccess(fi)          ((fi)->last_access)
 
96
#define FileInfoLastModify(fi)          ((fi)->last_modify)
 
97
#define FileInfoLastStatusChange(fi)    ((fi)->last_status_change)
 
98
 
 
99
#define FIProt(fi)                      FileInfoProt(fi)
 
100
#define FIOrigMode(fi)                  FileInfoOrigMode(fi)
 
101
#define FIUserID(fi)                    FileInfoUserID(fi)
 
102
#define FIGroupID(fi)                   FileInfoGroupID(fi)
 
103
#define FIFileSize(fi)                  FileInfoFileSize(fi)
 
104
#define FILastAccess(fi)                FileInfoLastAccess(fi)
 
105
#define FILastModify(fi)                FileInfoLastModify(fi)
 
106
#define FILastStatusChange(fi)          FileInfoLastStatusChange(fi)
 
107
 
 
108
        /* FType: File Type Macros */
 
109
 
 
110
#define FTypeIsDir(ft)                  ((ft) == F_TYPE_DIR)
 
111
#define FTypeIsFile(ft)                 ((ft) == F_TYPE_FILE)
 
112
#define FTypeIsCharSpecial(ft)          ((ft) == F_TYPE_CHAR_SPECIAL)
 
113
#define FTypeIsBlockSpecial(ft)         ((ft) == F_TYPE_BLOCK_SPECIAL)
 
114
#define FTypeIsSymLink(ft)              ((ft) == F_TYPE_SYM_LINK)
 
115
#define FTypeIsSocket(ft)               ((ft) == F_TYPE_SOCKET)
 
116
#define FTypeIsFifo(ft)                 ((ft) == F_TYPE_FIFO)
 
117
 
 
118
        /* DirEntry: Information About A Item In A Directory */
 
119
 
 
120
#define DirEntryFileName(fi)            ((fi)->filename)
 
121
#define DirEntryType(fi)                ((fi)->file_type)
 
122
#define DirEntrySelfInfo(fi)            (&((fi)->self_info))
 
123
#define DirEntryActualInfo(fi)          (&((fi)->actual_info))
 
124
 
 
125
#define DirEntryIsBrokenLink(fi)        ((fi)->broken_link)
 
126
#define DirEntryIsDirectoryLink(fi)     ((fi)->directory_link)
 
127
#define DirEntryIsDir(fi)               (FTypeIsDir(DirEntryType(fi)))
 
128
#define DirEntryIsFile(fi)              (FTypeIsFile(DirEntryType(fi)))
 
129
#define DirEntryIsCharSpecial(fi)       (FTypeIsCharSpecial(DirEntryType(fi)))
 
130
#define DirEntryIsBlockSpecial(fi)      (FTypeIsBlockSpecial(DirEntryType(fi)))
 
131
#define DirEntryIsSymLink(fi)           (FTypeIsSymLink(DirEntryType(fi)))
 
132
#define DirEntryIsSocket(fi)            (FTypeIsSocket(DirEntryType(fi)))
 
133
#define DirEntryIsFifo(fi)              (FTypeIsFifo(DirEntryType(fi)))
 
134
#define DirEntryLeadsToDir(fi)          (DirEntryIsDir(fi) ||           \
 
135
                                         DirEntryIsDirectoryLink(fi))
 
136
 
 
137
#define DirEntryProt(d)                 FIProt(DirEntrySelfInfo(d))
 
138
#define DirEntryOrigMode(d)             FIOrigMode(DirEntrySelfInfo(d))
 
139
#define DirEntryUserID(d)               FIUserID(DirEntrySelfInfo(d))
 
140
#define DirEntryGroupID(d)              FIGroupID(DirEntrySelfInfo(d))
 
141
#define DirEntryFileSize(d)             FIFileSize(DirEntrySelfInfo(d))
 
142
#define DirEntryLastAccess(d)           FILastAccess(DirEntrySelfInfo(d))
 
143
#define DirEntryLastModify(d)           FILastModify(DirEntrySelfInfo(d))
 
144
#define DirEntryLastStatusChange(d)     FILastStatusChange(DirEntrySelfInfo(d))
 
145
 
 
146
/*--------------------------------------------------------------------------*
 
147
 
 
148
             D A T A    T Y P E    D E F I N I T I O N S
 
149
 
 
150
 *--------------------------------------------------------------------------*/
 
151
 
 
152
        /* Directory: Directory Iterator */
 
153
 
 
154
typedef struct
 
155
{
 
156
        DIR *filep;
 
157
        char path[MAXPATHLEN + 2];
 
158
} DIRECTORY;
 
159
 
 
160
typedef DIRECTORY Directory;
 
161
 
 
162
        /* FileInfo: Information About A File Or Link */
 
163
 
 
164
typedef struct
 
165
{
 
166
        short protections;
 
167
        short orig_mode;
 
168
        short user_id;
 
169
        short group_id;
 
170
        long size;
 
171
        time_t last_access;
 
172
        time_t last_modify;
 
173
        time_t last_status_change;
 
174
} FILE_INFO;
 
175
 
 
176
typedef FILE_INFO FileInfo;
 
177
 
 
178
        /* DirEntry: Information About A Item In A Directory */
 
179
 
 
180
typedef struct
 
181
{
 
182
        char filename[MAX_NAME_LENGTH + 1];
 
183
        short file_type;
 
184
        short broken_link;
 
185
        short directory_link;
 
186
        FileInfo self_info;
 
187
        FileInfo actual_info;
 
188
} DIR_ENTRY;
 
189
 
 
190
typedef DIR_ENTRY DirEntry;
 
191
 
 
192
/*--------------------------------------------------------------------------*
 
193
 
 
194
        L O W    L E V E L    D I R E C T O R Y    I N T E R F A C E
 
195
 
 
196
 *--------------------------------------------------------------------------*/
 
197
 
 
198
#if (!NeedFunctionPrototypes)
 
199
 
 
200
int     DirectoryOpen();
 
201
void    DirectoryRestart();
 
202
void    DirectoryClose();
 
203
long    DirectoryTellPosition();
 
204
void    DirectorySetPosition();
 
205
int     DirectoryReadNextEntry();
 
206
char *  DirectoryPathExpand();
 
207
void    DirEntryDump();
 
208
 
 
209
#else
 
210
 
 
211
int     DirectoryOpen(char *dir_name, Directory *dp);
 
212
void    DirectoryRestart(Directory *dp);
 
213
void    DirectoryClose(Directory *dp);
 
214
long    DirectoryTellPosition(Directory *dp);
 
215
void    DirectorySetPosition(Directory *dp, long int pos);
 
216
int     DirectoryReadNextEntry(Directory *dp, DirEntry *de);
 
217
char *  DirectoryPathExpand(char *old_path, char *new_path);
 
218
void    DirEntryDump(FILE *fp, DirEntry *de);
 
219
 
 
220
#endif
 
221
 
 
222
#endif
 
223
 
 
224