X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=util%2Fres.c;h=c1f5c12b979cc49d745b141c85693314ea2a41ac;hb=9bbaa63b531cc24a1bc79e0447a9d6fbde113a3f;hp=f9e6689176a6279ea6042ec2edaa67446b2ed903;hpb=98e21f950e6d0babe88a6a1ccb03b90f0b3a6b1a;p=idzebra-moved-to-github.git diff --git a/util/res.c b/util/res.c index f9e6689..c1f5c12 100644 --- a/util/res.c +++ b/util/res.c @@ -1,10 +1,26 @@ -/* - * Copyright (C) 1994-2002, Index Data - * All rights reserved. - * Sebastian Hammer, Adam Dickmeiss - * - * $Id: res.c,v 1.30 2002-04-04 20:50:37 adam Exp $ - */ +/* $Id: res.c,v 1.33 2002-10-22 09:37:56 heikki Exp $ + Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 + Index Data Aps + +This file is part of the Zebra server. + +Zebra 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 2, or (at your option) any later +version. + +Zebra 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 Zebra; see the file LICENSE.zebra. If not, write to the +Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. +*/ + + #include #include #include @@ -62,10 +78,13 @@ static void reread (Res r) val_buf = (char*) xmalloc (val_max); + if (!r->name) + return; + fr = fopen (r->name, "r"); if (!fr) { - logf (LOG_WARN|LOG_ERRNO, "Cannot open %s", r->name); + logf (LOG_WARN|LOG_ERRNO, "Cannot open `%s'", r->name); return ; } while (1) @@ -159,19 +178,26 @@ static void reread (Res r) Res res_open (const char *name, Res def_res) { Res r; + + if (name) + { #ifdef WIN32 - if (access (name, 4)) + if (access (name, 4)) #else - if (access (name, R_OK)) + if (access (name, R_OK)) #endif - { - logf (LOG_WARN|LOG_ERRNO, "Cannot access resource file `%s'", name); - return 0; + { + logf (LOG_WARN|LOG_ERRNO, "Cannot open `%s'", name); + return 0; + } } r = (Res) xmalloc (sizeof(*r)); r->init = 0; r->first = r->last = NULL; - r->name = xstrdup (name); + if (name) + r->name = xstrdup (name); + else + r->name=0; r->def_res = def_res; return r; } @@ -289,10 +315,12 @@ int res_write (Res r) assert (r); if (!r->init) reread (r); + if (!r->name) + return 0; /* ok, this was not from a file */ fr = fopen (r->name, "w"); if (!fr) { - logf (LOG_FATAL|LOG_ERRNO, "Cannot create %s", r->name); + logf (LOG_FATAL|LOG_ERRNO, "Cannot create `%s'", r->name); exit (1); }