use-consistent-data-typing-for-hosts-20010404
[openafs.git] / src / util / fileutil.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 #ifndef TRANSARC_FILEUTIL_H
11 #define TRANSARC_FILEUTIL_H
12
13 /* File-oriented utility functions */
14
15 extern int
16 renamefile(const char *oldname, const char *newname);
17
18 /* Path normalization routines */
19 #define FPN_FORWARD_SLASHES 1
20 #define FPN_BACK_SLASHES    2
21
22 extern void
23 FilepathNormalizeEx(char *path, int slashType);
24
25 /* Just a wrapper for FilepathNormalizeEx(path, FPN_FORWARD_SLASHES); */
26 extern void
27 FilepathNormalize(char *path);
28
29 /*
30  * Data structure used to implement buffered I/O. We cannot
31  * use fopen in the fileserver because the file descriptor
32  * in the FILE structure only has 8 bits.
33  */
34 typedef int BUFIO_FD;
35 #define BUFIO_INVALID_FD (-1)
36
37 #define BUFIO_BUFSIZE 4096
38
39 typedef struct {
40     BUFIO_FD fd;
41     int pos;
42     int len;
43     int eof;
44     char buf[BUFIO_BUFSIZE];
45 } bufio_t, *bufio_p;
46
47 /* Open a file for buffered I/O */
48 extern bufio_p
49 BufioOpen(char *path, int oflag, int mode);
50
51 /* Read the next line of a file */
52 extern int
53 BufioGets(bufio_p bp, char *buf, int len);
54
55 /* Close a buffered I/O handle */
56 extern int
57 BufioClose(bufio_p bp);
58
59 #endif /* TRANSARC_FILEUTIL_H */