File: pxfile.man

package info (click to toggle)
bibtool 2.67%2Bds-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,608 kB
  • sloc: ansic: 11,646; perl: 7,482; makefile: 543; sh: 301; tcl: 51
file content (114 lines) | stat: -rw-r--r-- 2,565 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
.TH pxfile 3 local
.SH NAME
pxfile \- Extended file opening with search path and optional extensions.
.SH SYNOPSIS
.nf
.B #include "pxfile.h"

.B FILE* px_fopen(filename,mode,pattern,path,show)
.B char * filename;
.B char * mode;
.B char ** pattern;
.B char ** path;
.B int (*show)();

.B char **px_s2p(specification,seperator)
.B char *specification;
.B int  seperator;
.fi
.SH DESCRIPTION
The extended file opening routine allows to open a file like
.B fopen(3)
.
The file is searched on a path and additional modifications of the
file name are possible. E.g. the addion of an extension or prepending
a fixed prefix is posible.

.BR px_fopen ()
opens a file named 
.I filename
with the mode
.I mode
which is the same as the mode used by
.BR fopen (3).
.I path
is a NULL terminated array of strings indicating the possible directories to 
search for the file. A value of
.I NULL
indicates that only the current directory should be examined.
.BR px_s2p ()
can be used to allocate and fill a path array form a simple string
specification.

.I pattern
is a NULL terminated array of format specifications to be used with 
.BR fprintf (3).
Two strings are indicated with the special '%s'. The first '%s' is replaced by 
the directory name. The second '%s' is replaced by the file name given.
A value of
.I NULL
is the same as

.nf
{ "%s/%s",
  NULL
}
.fi

The following example value of
.I pattern
shows how default extensions can be tried. First the pure file name
is tried. Afterwards the extensions
.B .tex
and
.B .TeX
are tried.

.nf
{ "%s/%s",
  "%s/%s.tex",
  "%s/%s.TeX",
  NULL
}
.fi

.I show
is a pointer to a function. This function is called before an attempt
is made to open a file. The argument of the function is the complete
file name as string. The open is tried only if
.I show
returns an integer different from 0.
This function can be used to display the file names before trying to open.
A value of
.I NULL
can be used to indicate that no such function should be used.

.BR px_s2p ()
constructs a
.I pattern
for
.BR px_fopen ()
from a
.I specification.
Memory is allocated to store the array and the strings contained.
.I specification
is a strings where the different directories are separated by the character
.I seperator.
If not enough memory is available
.I NULL
is returned. The memory allocated consists of one block which can be 
freed with
.BR free (3).

.SH FILES
pxfile.h
.SH SEE ALSO
.BR fopen (3),
.BR fprintf (3),
.BR free (3)

.SH DIAGNOSTICS
NULL is returned to indicate failure. 
.SH BUGS
Mainly UN*X type file names are supported.