chiark / gitweb /
Initial revision
[ssr] / StraySrc / Utilities / h / gf
1 /*
2  * gf.h
3  *
4  * Read directories in a buffered way
5  *
6  * © 1998 Straylight/Edgeware
7  */
8
9 /*----- Licensing note ----------------------------------------------------*
10  *
11  * This file is part of Straylight's core utilities (coreutils).
12  *
13  * Coreutils is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 2, or (at your option)
16  * any later version.
17  *
18  * Coreutils is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with coreutils.  If not, write to the Free Software Foundation,
25  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26  */
27
28 #ifndef GF_H
29 #define GF_H
30
31 #ifdef __cplusplus
32   extern "C" {
33 #endif
34
35 /*----- Type definitions --------------------------------------------------*/
36
37 /* --- Wildcard matcher context --- */
38
39 typedef struct gf_ctx {
40   char buf[1024];                       /* Buffer for OS_HeebieJeebie */
41   int ctx;                              /* Context for OS_HeebieJeebie */
42   const char *dir;                      /* Pointer to directory to scan */
43   const char *pat;                      /* Pointer to pattern string */
44   int nleft;                            /* Number left in buffer */
45   char *p;                              /* Pointer into the buffer */
46 } gf_ctx;
47
48 /*----- Functions ---------------------------------------------------------*/
49
50 /* --- @gf_init@ --- *
51  *
52  * Arguments:   @gf_ctx *g@ = pointer to a context buffer for me
53  *              @const char *pat@ = pointer to a (RISC OS) pattern string
54  *              @cost char *dir@ = pointer to name of parent directory
55  *
56  * Returns:     ---
57  *
58  * Use:         Initialise a wildcard match context ready for scanning.
59  */
60
61 extern void gf_init(gf_ctx */*g*/, const char */*pat*/, const char */*dir*/);
62
63 /* --- @gf_next@ --- *
64  *
65  * Arguments:   @gf_ctx *g@ = pointer to my context
66  *
67  * Returns:     Pointer to a filename, or zero for end
68  *
69  * Use:         Returns the next matching file from the block.
70  */
71
72 extern char *gf_next(gf_ctx */*g*/);
73
74 /*----- That's all, folks -------------------------------------------------*/
75
76 #ifdef __cplusplus
77   }
78 #endif
79
80 #endif