Back to index

tetex-bin  3.0
kps.c
Go to the documentation of this file.
00001 /* Functions copied over from kpathsea library.
00002 
00003 Original uppercasify is
00004   Copyright 1993 Karl Berry.
00005 
00006 Original xfopen/xfclose are
00007   Copyright 1992, 93, 95 Free Software Foundation, Inc.
00008 
00009 Further modifications
00010   Copyright 2004 Olaf Weber.
00011   
00012 This library is free software; you can redistribute it and/or
00013 modify it under the terms of the GNU Library General Public
00014 License as published by the Free Software Foundation; either
00015 version 2 of the License, or (at your option) any later version.
00016 
00017 This library is distributed in the hope that it will be useful,
00018 but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020 Library General Public License for more details.
00021 
00022 You should have received a copy of the GNU Library General Public
00023 License along with this library; if not, write to the Free Software
00024 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
00025 
00026 #include "web2c.h"
00027 /* Get rid of kpathsea debug definitions. */
00028 #undef fopen
00029 #undef fclose
00030 
00031 string
00032 uppercasify P1C(const_string, s)
00033 {
00034   string target;
00035   string ret = malloc (strlen(s) + 1);
00036 
00037   target = ret;
00038   while (*s) {
00039       *target = toupper(*s);
00040       target++;
00041       s++;
00042   }
00043   *target = '\0';
00044   
00045   return ret;
00046 }
00047 
00048 /* These routines just check the return status from standard library
00049    routines and abort if an error happens.  */
00050 
00051 FILE *
00052 xfopen P2C(const_string, filename,  const_string, mode)
00053 {
00054   FILE *f;
00055 
00056   assert (filename && mode);
00057 
00058   f = fopen (filename, mode);
00059   if (f == NULL) {
00060     perror(filename);
00061     exit(EXIT_FAILURE);
00062   }
00063 
00064   return f;
00065 }
00066 
00067 
00068 void
00069 xfclose P2C(FILE *, f,  const_string, filename)
00070 {
00071   assert (f);
00072 
00073   if (fclose (f) == EOF) {
00074     perror(filename);
00075     exit(EXIT_FAILURE);
00076   }
00077 }