ReactOS 0.4.16-dev-297-gc569aee
match.c File Reference
#include <schily/mconfig.h>
#include <schily/stdio.h>
#include <schily/stdlib.h>
#include <schily/unistd.h>
#include <schily/string.h>
#include <schily/standard.h>
#include <schily/schily.h>
#include <schily/libport.h>
#include <schily/nlsdefs.h>
#include "match.h"
Include dependency graph for match.c:

Go to the source code of this file.

Classes

struct  match
 

Typedefs

typedef struct match match
 

Functions

EXPORT int gen_add_match (char *fn, int n)
 
EXPORT int add_match (char *fn)
 
EXPORT int i_add_match (char *fn)
 
EXPORT int h_add_match (char *fn)
 
EXPORT int j_add_match (char *fn)
 
EXPORT int u_add_match (char *fn)
 
EXPORT void gen_add_list (char *file, int n)
 
EXPORT int add_list (char *fn)
 
EXPORT int i_add_list (char *fn)
 
EXPORT int h_add_list (char *fn)
 
EXPORT int j_add_list (char *fn)
 
EXPORT int u_add_list (char *fn)
 
EXPORT int gen_matches (char *fn, int n)
 
EXPORT int gen_ishidden (int n)
 
EXPORT void gen_del_match (int n)
 

Variables

static UConst char sccsid []
 
static BOOL isort
 
static matchmats [MAX_MAT]
 
static charmesg [MAX_MAT]
 

Typedef Documentation

◆ match

typedef struct match match

Definition at line 33 of file match.c.

Function Documentation

◆ add_list()

EXPORT int add_list ( char fn)

Definition at line 312 of file match.c.

314{
316 return (1);
317}
EXPORT void gen_add_list(char *file, int n)
Definition: match.c:282
#define EXCLUDE
Definition: match.h:22
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159

◆ add_match()

EXPORT int add_match ( char fn)

Definition at line 214 of file match.c.

216{
217 int ret = gen_add_match(fn, EXCLUDE);
218
219 if (ret == 0)
220 return (-1);
221 return (1);
222}
EXPORT int gen_add_match(char *fn, int n)
Definition: match.c:184
int ret

◆ gen_add_list()

EXPORT void gen_add_list ( char file,
int  n 
)

Definition at line 282 of file match.c.

285{
286 FILE *fp;
287 char name[4096];
288 int len;
289
290 if ((fp = fopen(file, "r")) == NULL) {
291 comerr(_("Can't open %s file list %s\n"), mesg[n], file);
292 }
293
294 while (fgets(name, sizeof (name), fp) != NULL) {
295 /*
296 * strip of '\n'
297 */
298 len = strlen(name);
299 if (name[len - 1] == '\n') {
300 name[len - 1] = '\0';
301 }
302 if (!gen_add_match(name, n)) {
303 fclose(fp);
304 return;
305 }
306 }
307
308 fclose(fp);
309}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
EXPORT void comerr(char *msg, va_alist)
Definition: comerr.c:84
#define NULL
Definition: types.h:112
GLdouble n
Definition: glext.h:7729
GLenum GLsizei len
Definition: glext.h:6722
#define _(X)
Definition: i386-dis.c:35
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP char *__cdecl fgets(_Out_writes_z_(_MaxCount) char *_Buf, _In_ int _MaxCount, _Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
static char * mesg[MAX_MAT]
Definition: match.c:39
Definition: fci.c:127
Definition: name.c:39

Referenced by add_list(), h_add_list(), i_add_list(), j_add_list(), and u_add_list().

◆ gen_add_match()

EXPORT int gen_add_match ( char fn,
int  n 
)

Definition at line 184 of file match.c.

187{
188 match *mat;
189
190 if (n >= MAX_MAT) {
191 errmsgno(EX_BAD, _("Too many patterns.\n"));
192 return (0);
193 }
194
195 mat = (match *)malloc(sizeof (match));
196 if (mat == NULL) {
197 errmsg(_("Can't allocate memory for %s filename\n"), mesg[n]);
198 return (0);
199 }
200
201 if ((mat->name = strdup(fn)) == NULL) {
202 errmsg(_("Can't allocate memory for %s filename\n"), mesg[n]);
203 free(mat);
204 return (0);
205 }
206
207 mat->next = mats[n];
208 mats[n] = mat;
209
210 return (1);
211}
EXPORT int errmsgno(int err, char *msg, va_alist)
Definition: comerr.c:219
EXPORT int errmsg(char *msg, va_alist)
Definition: comerr.c:192
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
static match * mats[MAX_MAT]
Definition: match.c:37
#define MAX_MAT
Definition: match.h:32
static const MAT2 mat
Definition: font.c:66
_Check_return_ _CRTIMP char *__cdecl strdup(_In_opt_z_ const char *_Src)
#define EX_BAD
Definition: standard.h:62
Definition: match.c:28

Referenced by add_match(), gen_add_list(), h_add_match(), i_add_match(), j_add_match(), and u_add_match().

◆ gen_del_match()

EXPORT void gen_del_match ( int  n)

Definition at line 395 of file match.c.

397{
398 register match *mat;
399 register match *mat1;
400
401 if (n >= MAX_MAT)
402 return;
403
404 mat = mats[n];
405
406 while (mat) {
407 mat1 = mat->next;
408
409 free(mat->name);
410 free(mat);
411
412 mat = mat1;
413 }
414
415 mats[n] = 0;
416}

Referenced by main().

◆ gen_ishidden()

EXPORT int gen_ishidden ( int  n)

Definition at line 385 of file match.c.

387{
388 if (n >= MAX_MAT)
389 return (0);
390
391 return ((int)(mats[n] != 0));
392}

◆ gen_matches()

EXPORT int gen_matches ( char fn,
int  n 
)

Definition at line 362 of file match.c.

365{
366 register match * mat;
367 int flags = FNM_PATHNAME;
368
369
370 if (n >= MAX_MAT)
371 return (0);
372
373 if (match_igncase)
375
376 for (mat = mats[n]; mat; mat = mat->next) {
377 if (fnmatch(mat->name, fn, flags) != FNM_NOMATCH) {
378 return (1); /* found -> excluded filename */
379 }
380 }
381 return (0); /* not found -> not excluded */
382}
#define FNM_IGNORECASE
Definition: fnmatch.h:81
#define fnmatch
Definition: fnmatch.h:96
#define FNM_PATHNAME
Definition: fnmatch.h:75
#define FNM_NOMATCH
Definition: fnmatch.h:62
GLbitfield flags
Definition: glext.h:7161
int match_igncase
Definition: mkisofs.c:231

◆ h_add_list()

EXPORT int h_add_list ( char fn)

Definition at line 328 of file match.c.

330{
332 return (1);
333}
#define H_HIDE
Definition: match.h:26

◆ h_add_match()

EXPORT int h_add_match ( char fn)

Definition at line 236 of file match.c.

238{
239 int ret = gen_add_match(fn, H_HIDE);
240
241 if (ret == 0)
242 return (-1);
243 return (1);
244}

◆ i_add_list()

EXPORT int i_add_list ( char fn)

Definition at line 320 of file match.c.

322{
324 return (1);
325}
#define I_HIDE
Definition: match.h:23

◆ i_add_match()

EXPORT int i_add_match ( char fn)

Definition at line 225 of file match.c.

227{
228 int ret = gen_add_match(fn, I_HIDE);
229
230 if (ret == 0)
231 return (-1);
232 return (1);
233}

◆ j_add_list()

EXPORT int j_add_list ( char fn)

Definition at line 336 of file match.c.

338{
340 return (1);
341}
#define J_HIDE
Definition: match.h:24

◆ j_add_match()

EXPORT int j_add_match ( char fn)

Definition at line 260 of file match.c.

262{
263 int ret = gen_add_match(fn, J_HIDE);
264
265 if (ret == 0)
266 return (-1);
267 return (1);
268}

◆ u_add_list()

EXPORT int u_add_list ( char fn)

Definition at line 344 of file match.c.

346{
348 return (1);
349}
#define U_HIDE
Definition: match.h:25

◆ u_add_match()

EXPORT int u_add_match ( char fn)

Definition at line 271 of file match.c.

273{
274 int ret = gen_add_match(fn, U_HIDE);
275
276 if (ret == 0)
277 return (-1);
278 return (1);
279}

Variable Documentation

◆ isort

BOOL isort
static

Definition at line 35 of file match.c.

◆ mats

match* mats[MAX_MAT]
static

Definition at line 37 of file match.c.

Referenced by gen_add_match(), gen_del_match(), gen_ishidden(), and gen_matches().

◆ mesg

char* mesg[MAX_MAT]
static
Initial value:
= {
"excluded",
"excluded ISO-9660",
"excluded Joliet",
"excluded UDF",
"hidden attribute ISO-9660",
}

Definition at line 39 of file match.c.

Referenced by gen_add_list(), and gen_add_match().

◆ sccsid

UConst char sccsid[]
static
Initial value:
=
"@(#)match.c 1.34 16/11/27 joerg"

Definition at line 4 of file match.c.