Back to index

tetex-bin  3.0
fn.h
Go to the documentation of this file.
00001 /* fn.h: arbitrarily long filenames (or just strings).
00002 
00003 Copyright (C) 1993 Karl Berry.
00004 
00005 This library is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU Library General Public
00007 License as published by the Free Software Foundation; either
00008 version 2 of the License, or (at your option) any later version.
00009 
00010 This library is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 Library General Public License for more details.
00014 
00015 You should have received a copy of the GNU Library General Public
00016 License along with this library; if not, write to the Free Software
00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
00018 
00019 #ifndef KPATHSEA_FN_H
00020 #define KPATHSEA_FN_H
00021 
00022 #include <kpathsea/c-proto.h>
00023 #include <kpathsea/types.h>
00024 
00025 /* Arbitrarily long filenames; it's inconvenient to use obstacks here,
00026    because we want to maintain a null terminator.  Also used for
00027    dynamically growing strings even when the null byte isn't necessary,
00028    e.g., in `variable.c', since I don't want to pass obstacks around
00029    everywhere, and one can't free parts of an obstack arbitrarily.  */
00030 
00031 typedef struct
00032 {
00033   string str;
00034   unsigned allocated;
00035   unsigned length; /* includes the terminating null byte, if any */
00036 } fn_type;
00037 
00038 #define FN_STRING(fn) ((fn).str)
00039 #define FN_ALLOCATED(fn) ((fn).allocated)
00040 #define FN_LENGTH(fn) ((fn).length)
00041 
00042 
00043 /* Create a new empty fn.  */
00044 extern KPSEDLL fn_type fn_init P1H(void);
00045 
00046 /* Create a new fn from the first LEN characters from S and a null.  */
00047 extern KPSEDLL fn_type fn_copy0 P2H(const_string s,  unsigned len);
00048 
00049 /* Free what's been allocated.  Can also just free the string if it's
00050    been extracted out.  Fatal error if nothing allocated in F.  */
00051 extern KPSEDLL void fn_free P1H(fn_type *f);
00052 
00053 /* Append the character C to the fn F.  Don't append trailing null.  */
00054 extern KPSEDLL void fn_1grow P2H(fn_type *f, char c);
00055 
00056 /* Append LENGTH bytes from SOURCE to F.  */
00057 extern KPSEDLL void fn_grow P3H(fn_type *f, const_string source, unsigned length);
00058 
00059 /* Concatenate the component S to the fn F.  Assumes string currently in
00060    F is null terminated.  */
00061 extern KPSEDLL void fn_str_grow P2H(fn_type *f, const_string s);
00062 
00063 /* Add a null to F's string at position LOC, and update its length.
00064    Fatal error if LOC is past the end of the string.  */
00065 extern KPSEDLL void fn_shrink_to P2H(fn_type *f, unsigned loc);
00066 
00067 #endif /* not KPATHSEA_FN_H */