robodoc'd lib/silcutil/silcfileutil.h
[runtime.git] / lib / silcutil / silcfileutil.h
1 /*
2
3   silcfileutil.h
4
5   Author: Pekka Riikonen <priikone@silcnet.org>
6
7   Copyright (C) 1997 - 2002 Pekka Riikonen
8
9   This program is free software; you can redistribute it and/or modify
10   it under the terms of the GNU General Public License as published by
11   the Free Software Foundation; version 2 of the License.
12
13   This program is distributed in the hope that it will be useful,
14   but WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16   GNU General Public License for more details.
17
18 */
19
20 /****h* silcutil/SILC File Util Interface
21  *
22  * DESCRIPTION
23  *
24  *    The SILC File Util Interface is a small set of functions that provides a
25  *    portable access method to the filesystem.
26  *
27  ***/
28
29 #ifndef SILCFILEUTIL_H
30 #define SILCFILEUTIL_H
31
32 /* Prototypes */
33
34 /****f* silcutil/SilcFileUtilAPI/silc_file_open
35  *
36  * SYNOPSIS
37  *
38  *    int silc_file_open(const char *filename, int flags);
39  *
40  * DESCRIPTION
41  *
42  *    Opens a file indicated by the filename `filename' with flags indicated
43  *    by `flags'.  The opening permission defaults to 0600.
44  *
45  ***/
46 int silc_file_open(const char *filename, int flags);
47
48 /****f* silcutil/SilcFileUtilAPI/silc_file_open_mode
49  *
50  * SYNOPSIS
51  *
52  *    int silc_file_open_mode(const char *filename, int flags, int mode);
53  *
54  * DESCRIPTION
55  *
56  *    Opens a file indicated by the filename `filename' with flags indicated
57  *    by `flags'.  The argument `mode' specifies the permissions to use in
58  *    case a new file is created.
59  *
60  ***/
61 int silc_file_open_mode(const char *filename, int flags, int mode);
62
63 /****f* silcutil/SilcFileUtilAPI/silc_file_read
64  *
65  * SYNOPSIS
66  *
67  *    int silc_file_read(int fd, unsigned char *buf, SilcUInt32 buf_len);
68  *
69  * DESCRIPTION
70  *
71  *    Reads data from file descriptor `fd' to `buf'.
72  *
73  ***/
74 int silc_file_read(int fd, unsigned char *buf, SilcUInt32 buf_len);
75
76 /****f* silcutil/SilcFileUtilAPI/silc_file_write
77  *
78  * SYNOPSIS
79  *
80  *    int silc_file_write(int fd, const char *buffer, SilcUInt32 len);
81  *
82  * DESCRIPTION
83  *
84  *    Writes `buffer' of length of `len' to file descriptor `fd'.
85  *
86  ***/
87 int silc_file_write(int fd, const char *buffer, SilcUInt32 len);
88
89 /****f* silcutil/SilcFileUtilAPI/silc_file_close
90  *
91  * SYNOPSIS
92  *
93  *    int silc_file_close(int fd);
94  *
95  * DESCRIPTION
96  *
97  *    Closes file descriptor previously opened with silc_file_open().
98  *
99  ***/
100 int silc_file_close(int fd);
101
102 /****f* silcutil/SilcFileUtilAPI/silc_file_readfile
103  *
104  * SYNOPSIS
105  *
106  *    char *silc_file_readfile(const char *filename, SilcUInt32 *return_len);
107  *
108  * DESCRIPTION
109  *
110  *    Reads the content of `filename' to a buffer.  The allocated buffer is
111  *    returned.
112  *    If the `return_len' pointer is not NULL, it's filled with the length of
113  *    the file.
114  *
115  ***/
116 char *silc_file_readfile(const char *filename, SilcUInt32 *return_len);
117
118 /****f* silcutil/SilcFileUtilAPI/silc_file_writefile
119  *
120  * SYNOPSIS
121  *
122  *    int silc_file_writefile(const char *filename, const char *buffer,
123  *                            SilcUInt32 len);
124  *
125  * DESCRIPTION
126  *
127  *    Writes a buffer to the file.  If the file is created specific mode is
128  *    set to the file.
129  *
130  ***/
131 int silc_file_writefile(const char *filename, const char *buffer,
132                         SilcUInt32 len);
133
134 /****f* silcutil/SilcFileUtilAPI/silc_file_writefile_mode
135  *
136  * SYNOPSIS
137  *
138  *    int silc_file_writefile_mode(const char *filename, const char *buffer,
139  *                                 SilcUInt32 len, int mode);
140  *
141  * DESCRIPTION
142  *
143  *    Writes a buffer to the file.  If the file is created the specified `mode'
144  *    is set to the file.
145  *
146  ***/
147 int silc_file_writefile_mode(const char *filename, const char *buffer,
148                              SilcUInt32 len, int mode);
149
150 /****f* silcutil/SilcFileUtilAPI/silc_file_size
151  *
152  * SYNOPSIS
153  *
154  *    SilcUInt64 silc_file_size(const char *filename);
155  *
156  * DESCRIPTION
157  *
158  *    Returns the size of `filename'. Returns 0 on error.
159  *
160  ***/
161 SilcUInt64 silc_file_size(const char *filename);
162
163 #endif  /* !SILCFILEUTIL_H */