xref: /openbsd-src/gnu/usr.bin/cvs/emx/system.c (revision 2286d8ed900f26153a3cd5227a124b1c0adce72f)
1*2286d8edStholo /* This program is free software; you can redistribute it and/or modify
2*2286d8edStholo    it under the terms of the GNU General Public License as published by
3*2286d8edStholo    the Free Software Foundation; either version 2, or (at your option)
4*2286d8edStholo    any later version.
5*2286d8edStholo 
6*2286d8edStholo    This program is distributed in the hope that it will be useful,
7*2286d8edStholo    but WITHOUT ANY WARRANTY; without even the implied warranty of
8*2286d8edStholo    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9*2286d8edStholo    GNU General Public License for more details.  */
10*2286d8edStholo 
11*2286d8edStholo #include <io.h>
12*2286d8edStholo #include <stdio.h>
13*2286d8edStholo #include <stdlib.h>
14*2286d8edStholo #include <sys/types.h>
15*2286d8edStholo #include <sys/stat.h>
16*2286d8edStholo #include <sys/param.h>
17*2286d8edStholo #include <fnmatch.h>
18*2286d8edStholo 
19*2286d8edStholo 
20*2286d8edStholo /* Expand wildcards in argv.  We probably should be expanding wildcards
21*2286d8edStholo    via expand_wild instead; that way we could expand only filenames and
22*2286d8edStholo    not tag names and the like.  */
23*2286d8edStholo 
24*2286d8edStholo void
os2_initialize(pargc,pargv)25*2286d8edStholo os2_initialize (pargc, pargv)
26*2286d8edStholo     int *pargc;
27*2286d8edStholo     char **pargv[];
28*2286d8edStholo {
29*2286d8edStholo     _wildcard (pargc, pargv);
30*2286d8edStholo }
31*2286d8edStholo 
32*2286d8edStholo 
33*2286d8edStholo /* Modifies 'stat' so that always the same inode is returned.  EMX never
34*2286d8edStholo    returns the same value for st_ino.  Without this modification,
35*2286d8edStholo    release_delete in module src/release.c refuses to work.  Care must
36*2286d8edStholo    be taken if someone is using the value of st_ino (but as far as I know,
37*2286d8edStholo    no callers are).  */
38*2286d8edStholo 
39*2286d8edStholo int
os2_stat(name,buffer)40*2286d8edStholo os2_stat (name, buffer)
41*2286d8edStholo     const char *name;
42*2286d8edStholo     struct stat *buffer;
43*2286d8edStholo {
44*2286d8edStholo     int rc = stat (name, buffer);
45*2286d8edStholo 
46*2286d8edStholo     /* There are no inodes on OS/2.  */
47*2286d8edStholo     buffer->st_ino = 42;
48*2286d8edStholo 
49*2286d8edStholo     return rc;
50*2286d8edStholo }
51*2286d8edStholo 
52*2286d8edStholo 
53*2286d8edStholo /* We must not only change the directory, but also the current drive.
54*2286d8edStholo    Otherwise it is be impossible to have the working directory and the
55*2286d8edStholo    repository on different drives.  */
56*2286d8edStholo 
57*2286d8edStholo int
os2_chdir(name)58*2286d8edStholo os2_chdir (name)
59*2286d8edStholo     const char *name;
60*2286d8edStholo {
61*2286d8edStholo     return _chdir2 (name);
62*2286d8edStholo }
63*2286d8edStholo 
64*2286d8edStholo 
65*2286d8edStholo /* getwd must return a drive specification.  */
66*2286d8edStholo 
67*2286d8edStholo char *
xgetwd()68*2286d8edStholo xgetwd ()
69*2286d8edStholo {
70*2286d8edStholo     return _getcwd2 (NULL, 1);
71*2286d8edStholo }
72*2286d8edStholo 
73*2286d8edStholo 
74*2286d8edStholo /* fnmatch must recognize OS/2 filename conventions: Filename case
75*2286d8edStholo    must be preserved, but ignored in searches.  It would perhaps be better
76*2286d8edStholo    to just have CVS pick how to match based on FILENAMES_CASE_INSENSITIVE
77*2286d8edStholo    or something rather than having an OS/2-specific version of CVS_FNMATCH.
78*2286d8edStholo    Note that lib/fnmatch.c uses FOLD_FN_CHAR; that is how we get
79*2286d8edStholo    case-insensitivity on NT (and VMS, I think).  */
80*2286d8edStholo 
81*2286d8edStholo #define _FNM_OS2           1
82*2286d8edStholo #define _FNM_IGNORECASE    128
83*2286d8edStholo 
84*2286d8edStholo int
os2_fnmatch(pattern,name,flags)85*2286d8edStholo os2_fnmatch (pattern, name, flags)
86*2286d8edStholo     const char *pattern;
87*2286d8edStholo     const char *name;
88*2286d8edStholo     int flags;
89*2286d8edStholo {
90*2286d8edStholo     return fnmatch (pattern, name, _FNM_IGNORECASE | _FNM_OS2 | flags);
91*2286d8edStholo }
92