1MBKFOPEN(3) MBK UTILITY FUNCTIONS MBKFOPEN(3)
2
3
4
6 mbkfopen - open a file with several search paths
7
9 #include "mut.h"
10 FILE ∗mbkfopen(name, extension, mode)
11 char ∗name, ∗extension, ∗mode;
12
14 name Name of the file to be opened
15
16 extension Extension to the file name
17
18 model File opening mode
19
21 mbkfopen opens a file, searching it through the paths given in the
22 environment variables MBK_CATA_LIB(1) and MBK_WORK_LIB(1). Its main
23 issue is to enable simple file access for any program that works with
24 mbk path environment variables.
25 The file to be opened is called name.extension, if extension is not
26 NULL, else it is name. If extension is the empty string, "", then the
27 file name will be name. .
28 The legal values for mode are
29
30 READ_TEXT opens for reading
31
32 WRITE_TEXT discards and opens for writing
33 since disk access should be a straight forward
34 operation knowing mbk's needs.
35
36 The search algorithm depends on the value of mode. If mode is
37 WRITE_TEXT, then the file is open for writing in MBK_WORK_LIB(1). If
38 mode is READ_TEXT then the file is first searched through
39 MBK_WORK_LIB(1), and if not found, through each directory specified in
40 MBK_CATA_LIB(1), in the order of declaration under unix. No internal
41 hash table is generated, in order to let the user choose its directory
42 priority. As soon as the file is found, it is opened. There is no
43 check for redundant files in the specified paths, since it is neither
44 illegal nor bad to have many files with the same names.
45
47 mbkfopen returns a pointer to the opened file. If the file read or
48 write access are violated, or the file not found, a NULL pointer is
49 returned.
50
52 "∗∗∗ mbk error ∗∗∗ mbkfopen : unknown file opening mode mode"
53 The mode parameter is not one of the two legal values.
54
56 #include "mut.h"
57 #include "mph.h"
58 phfig_list ∗load_vti_ph(name)
59 char ∗name;
60 {
61 FILE ∗file;
62 if ((file = mbkfopen(name, "cp", READ_TEXT)) == NULL) {
63 (void)fprintf(stderr, "Pfhhh, can't open name.cp\n");
64 EXIT();
65 }
66 ph_parse(file);
67 }
68
70 mbk(1), MBK_CATA_LIB(1), MBK_WORK_LIB(1), loadlofig(3), loadphfig(3),
71 savelofig(3), savephfig(3), fopen(3).
72
73
74
75
76
77
78ASIM/LIP6 October 1, 1997 MBKFOPEN(3)