--- deliantra/server/common/path.C 2007/11/08 19:43:23 1.7
+++ deliantra/server/common/path.C 2009/10/15 20:45:01 1.10
@@ -1,22 +1,23 @@
/*
* This file is part of Deliantra, the Roguelike Realtime MMORPG.
*
- * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
+ * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
* Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
* Copyright (©) 1992,2007 Frank Tore Johansen
*
- * Deliantra is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * Deliantra is free software: you can redistribute it and/or modify it under
+ * the terms of the Affero GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the Affero GNU General Public License
+ * and the GNU General Public License along with this program. If not, see
+ * .
*
* The authors can be reached via e-mail to
*/
@@ -25,10 +26,14 @@
#include
#include
#include
+#include
#include "define.h"
#include "path.h"
+#ifndef PATH_MAX
+# define PATH_MAX 8192
+#endif
#if 0
@@ -56,7 +61,7 @@
path_combine (const char *src, const char *dst)
{
char *p;
- static char path[HUGE_BUF];
+ static char path[PATH_MAX];
if (*dst == '/')
{
@@ -68,23 +73,22 @@
/* relative destination path => add after last '/' of source */
strcpy (path, src);
p = strrchr (path, '/');
- if (p != NULL)
- {
- p++;
- }
+ if (p)
+ p++;
else
{
p = path;
if (*src == '/')
*p++ = '/';
}
+
strcpy (p, dst);
}
#if defined(DEBUG_PATH)
LOG (llevDebug, "path_combine(%s, %s) = %s\n", src, dst, path);
#endif
- return (path);
+ return path;
}
void
@@ -208,8 +212,8 @@
static void
check_normalize (const char *path, const char *exp0)
{
- char tmp[HUGE_BUF];
- char exp[HUGE_BUF];
+ char tmp[PATH_MAX];
+ char exp[PATH_MAX];
strcpy (exp, exp0 == NULL ? path : exp0);
@@ -218,13 +222,9 @@
path_normalize (tmp);
fprintf (stderr, "%s", tmp);
if (strcmp (tmp, exp) != 0)
- {
- fprintf (stderr, ", should be %s\n", exp);
- }
+ fprintf (stderr, ", should be %s\n", exp);
else
- {
- fprintf (stderr, " (OK)\n");
- }
+ fprintf (stderr, " (OK)\n");
}
static void
@@ -236,13 +236,9 @@
res = path_combine_and_normalize (src, dst);
fprintf (stderr, "%s", res);
if (strcmp (res, exp) != 0)
- {
- fprintf (stderr, ", should be %s\n", exp);
- }
+ fprintf (stderr, ", should be %s\n", exp);
else
- {
- fprintf (stderr, " (OK)\n");
- }
+ fprintf (stderr, " (OK)\n");
}
int