ReactOS  0.4.14-dev-583-g2a1ba2c
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 }
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
EXPORT void gen_add_list(char *file, int n)
Definition: match.c:282
#define EXCLUDE
Definition: match.h:22

◆ 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 }
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
EXPORT int gen_add_match(char *fn, int n)
Definition: match.c:184
#define EXCLUDE
Definition: match.h:22
int ret

Referenced by init_boot_catalog().

◆ 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 }
EXPORT void comerr(char *msg, va_alist)
Definition: comerr.c:84
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLdouble n
Definition: glext.h:7729
static char * mesg[MAX_MAT]
Definition: match.c:39
#define _(X)
Definition: i386-dis.c:36
smooth NULL
Definition: ftsmooth.c:416
EXPORT int gen_add_match(char *fn, int n)
Definition: match.c:184
GLenum GLsizei len
Definition: glext.h:6722
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_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)
Definition: name.c:38
Definition: fci.c:126

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 }
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
Definition: match.c:28
#define free
Definition: debug_ros.c:5
GLdouble n
Definition: glext.h:7729
static const MAT2 mat
Definition: font.c:66
static char * mesg[MAX_MAT]
Definition: match.c:39
static match * mats[MAX_MAT]
Definition: match.c:37
#define _(X)
Definition: i386-dis.c:36
_Check_return_ _CRTIMP char *__cdecl strdup(_In_opt_z_ const char *_Src)
smooth NULL
Definition: ftsmooth.c:416
EXPORT int errmsg(char *msg, va_alist)
Definition: comerr.c:192
#define malloc
Definition: debug_ros.c:4
EXPORT int errmsgno(int err, char *msg, va_alist)
Definition: comerr.c:219
#define MAX_MAT
Definition: match.h:32
#define EX_BAD
Definition: standard.h:62

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 }
Definition: match.c:28
#define free
Definition: debug_ros.c:5
GLdouble n
Definition: glext.h:7729
static const MAT2 mat
Definition: font.c:66
static match * mats[MAX_MAT]
Definition: match.c:37
#define MAX_MAT
Definition: match.h:32

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 }
GLdouble n
Definition: glext.h:7729
static match * mats[MAX_MAT]
Definition: match.c:37
#define MAX_MAT
Definition: match.h:32

◆ 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_PATHNAME
Definition: fnmatch.h:75
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
Definition: match.c:28
#define FNM_IGNORECASE
Definition: fnmatch.h:81
GLdouble n
Definition: glext.h:7729
static const MAT2 mat
Definition: font.c:66
static match * mats[MAX_MAT]
Definition: match.c:37
GLbitfield flags
Definition: glext.h:7161
int match_igncase
Definition: mkisofs.c:231
#define FNM_NOMATCH
Definition: fnmatch.h:62
int fnmatch(char *pattern, const char *string, int flags) const
Definition: fnmatch.c:100
#define MAX_MAT
Definition: match.h:32

◆ 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
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
EXPORT void gen_add_list(char *file, int n)
Definition: match.c:282

◆ 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 }
#define H_HIDE
Definition: match.h:26
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
EXPORT int gen_add_match(char *fn, int n)
Definition: match.c:184
int ret

◆ i_add_list()

EXPORT int i_add_list ( char fn)

Definition at line 320 of file match.c.

322 {
324  return (1);
325 }
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
EXPORT void gen_add_list(char *file, int n)
Definition: match.c:282
#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 }
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
EXPORT int gen_add_match(char *fn, int n)
Definition: match.c:184
int ret
#define I_HIDE
Definition: match.h:23

◆ j_add_list()

EXPORT int j_add_list ( char fn)

Definition at line 336 of file match.c.

338 {
340  return (1);
341 }
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
EXPORT void gen_add_list(char *file, int n)
Definition: match.c:282
#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 }
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
EXPORT int gen_add_match(char *fn, int n)
Definition: match.c:184
int ret
#define J_HIDE
Definition: match.h:24

◆ u_add_list()

EXPORT int u_add_list ( char fn)

Definition at line 344 of file match.c.

346 {
348  return (1);
349 }
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
EXPORT void gen_add_list(char *file, int n)
Definition: match.c:282
#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 }
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
EXPORT int gen_add_match(char *fn, int n)
Definition: match.c:184
int ret
#define U_HIDE
Definition: match.h:25

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.