Back to index

nagios-plugins  1.4.16
dirname.c
Go to the documentation of this file.
00001 /* dirname.c -- return all but the last element in a file name
00002 
00003    Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2010 Free Software
00004    Foundation, Inc.
00005 
00006    This program is free software: you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 3 of the License, or
00009    (at your option) any later version.
00010 
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014    GNU General Public License for more details.
00015 
00016    You should have received a copy of the GNU General Public License
00017    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00018 
00019 #include <config.h>
00020 
00021 #include "dirname.h"
00022 
00023 #include <stdlib.h>
00024 #include <string.h>
00025 #include "xalloc.h"
00026 
00027 /* Just like mdir_name (dirname-lgpl.c), except, rather than
00028    returning NULL upon malloc failure, here, we report the
00029    "memory exhausted" condition and exit.  */
00030 
00031 char *
00032 dir_name (char const *file)
00033 {
00034   char *result = mdir_name (file);
00035   if (!result)
00036     xalloc_die ();
00037   return result;
00038 }