File: FnMatch.xs

package info (click to toggle)
libfile-fnmatch-perl 0.02-2
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, sid, stretch
  • size: 188 kB
  • ctags: 422
  • sloc: perl: 12; makefile: 2
file content (72 lines) | stat: -rw-r--r-- 1,427 bytes parent folder | download | duplicates (2)
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
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"

#define NEED_newCONSTSUB
#define NEED_sv_2pv_nolen
#include "ppport.h"

#include <fnmatch.h>

/* $Id: FnMatch.xs,v 1.2 2005/03/30 05:34:57 mjp Exp $ */

MODULE = File::FnMatch		PACKAGE = File::FnMatch		

int
fnmatch(pattern, ...)
    char * pattern

    PROTOTYPE: $$;$

    CODE:
    char * string;
    int flags;

    if (items < 2 || items > 3)
        croak("Usage: File::FnMatch::fnmatch(pattern, string, flags=0)");

    string = (char *)SvPV_nolen(ST(1));

    if (items < 3)
        flags = 0;
    else
        flags = (int)SvIV(ST(2));

    RETVAL = !(fnmatch(pattern, string, flags));

    OUTPUT:
    RETVAL

BOOT:
{
    HV *stash = gv_stashpvn("File::FnMatch", 13, TRUE);
    struct { char *n; I32 v; } File__FnMatch__const[] = {
#ifdef FNM_NOESCAPE
    {"FNM_NOESCAPE", FNM_NOESCAPE},
#endif
#ifdef FNM_PATHNAME
    {"FNM_PATHNAME", FNM_PATHNAME},
#endif
#ifdef FNM_FILE_NAME
    {"FNM_FILE_NAME", FNM_FILE_NAME},
#endif
#ifdef FNM_PERIOD
    {"FNM_PERIOD", FNM_PERIOD},
#endif
#ifdef FNM_LEADING_DIR
    {"FNM_LEADING_DIR", FNM_LEADING_DIR},
#endif
#ifdef FNM_CASEFOLD
    {"FNM_CASEFOLD", FNM_CASEFOLD},
#endif
#ifdef FNM_EXTMATCH
    {"FNM_EXTMATCH", FNM_EXTMATCH},
#endif
    {Nullch, 0}};
    char *name;
    int i;

    for (i = 0; name = File__FnMatch__const[i].n; i++) {
        newCONSTSUB(stash, name, newSViv(File__FnMatch__const[i].v));
    }
}