ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/porting.C
Revision: 1.23
Committed: Wed Nov 4 00:02:48 2009 UTC (14 years, 6 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.22: +0 -0 lines
State: FILE REMOVED
Log Message:
agpl reorganisation

File Contents

# Content
1 /*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 *
4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 *
8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * the terms of the Affero GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the Affero GNU General Public License
19 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>.
21 *
22 * The authors can be reached via e-mail to <support@deliantra.net>
23 */
24
25 /* This file contains various functions that are not really unique for
26 * crossfire, but rather provides what should be standard functions
27 * for systems that do not have them. In this way, most of the
28 * nasty system dependent stuff is contained here, with the program
29 * calling these functions.
30 */
31
32
33 /* Need to pull in the HAVE_... values somehow */
34
35 #include <autoconf.h>
36
37 #include <cstdio>
38 #include <cstdlib>
39 #include <cstdarg>
40
41 #include <cctype>
42
43 #include <sys/stat.h>
44 #include <sys/wait.h>
45
46 #include <sys/param.h>
47
48 #include <unistd.h>
49
50 /* Has to be after above includes so we don't redefine some values */
51 #include "global.h"
52
53 #define DIGIT(x) (isdigit(x) ? (x) - '0' : \
54 islower (x) ? (x) + 10 - 'a' : (x) + 10 - 'A')
55 #define MBASE ('z' - 'a' + 1 + 10)
56
57 char *
58 strcasestr_local (const char *s, const char *find)
59 {
60 char c, sc;
61 size_t len;
62
63 if ((c = *find++) != 0)
64 {
65 c = tolower (c);
66 len = strlen (find);
67 do
68 {
69 do
70 {
71 if ((sc = *s++) == 0)
72 return NULL;
73 }
74 while (tolower (sc) != c);
75 }
76 while (strncasecmp (s, find, len) != 0);
77 s--;
78 }
79 return (char *) s;
80 }
81
82 /**
83 * open_and_uncompress() first searches for the original filename. If it exist,
84 * then it opens it and returns the file-pointer.
85 */
86 FILE *
87 open_and_uncompress (const char *name, int flag, int *compressed)
88 {
89 *compressed = 0;
90 return fopen (name, "r");
91 }
92
93 /*
94 * See open_and_uncompress().
95 */
96
97 void
98 close_and_delete (FILE * fp, int compressed)
99 {
100 fclose (fp);
101 }
102