backport to buster
[hcoop/debian/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 OPENAFS_FILEUTIL_H
11 #define OPENAFS_FILEUTIL_H
12
13 /* File-oriented utility functions */
14
15 /* Path normalization routines */
16 #define FPN_FORWARD_SLASHES 1
17 #define FPN_BACK_SLASHES 2
18
19 extern void
20 FilepathNormalizeEx(char *path, int slashType);
21
22 /* Just a wrapper for FilepathNormalizeEx(path, FPN_FORWARD_SLASHES); */
23 extern void
24 FilepathNormalize(char *path);
25
26 /*
27 * Data structure used to implement buffered I/O. We cannot
28 * use fopen in the fileserver because the file descriptor
29 * in the FILE structure only has 8 bits.
30 */
31 typedef int BUFIO_FD;
32 #define BUFIO_INVALID_FD (-1)
33
34 #define BUFIO_BUFSIZE 4096
35
36 typedef struct {
37 BUFIO_FD fd;
38 int pos;
39 int len;
40 int eof;
41 char buf[BUFIO_BUFSIZE];
42 } bufio_t, *bufio_p;
43
44 /* Open a file for buffered I/O */
45 extern bufio_p BufioOpen(char *path, int oflag, int mode);
46
47 /* Read the next line of a file */
48 extern int
49 BufioGets(bufio_p bp, char *buf, int len);
50
51 /* Close a buffered I/O handle */
52 extern int
53 BufioClose(bufio_p bp);
54
55 #endif /* OPENAFS_FILEUTIL_H */