summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormjflick <mjflick>2004-05-25 04:40:19 +0000
committermjflick <mjflick>2004-05-25 04:40:19 +0000
commit2f1e8e2af1fb7e8af68ba5976c19edb2f8001d84 (patch)
treebf8f6d17cf5e01be03e377c8a9e34bff88a1cae5
parent76adc924f344340c811cf52cb21e927dd52b4090 (diff)
downloadfontutils-2f1e8e2af1fb7e8af68ba5976c19edb2f8001d84.tar.gz
readded extern calls and removed foreign kpathsea path
-rw-r--r--include/lib.h84
1 files changed, 83 insertions, 1 deletions
diff --git a/include/lib.h b/include/lib.h
index 218106e..0e98fea 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -89,10 +89,92 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* If the environment variable TEST is set, return it; otherwise,
DEFAULT. This is useful for paths that use more than one envvar. */
#define ENVVAR(test, default) (getenv (test) ? (test) : (default))
+
+/* Return a fresh copy of S1 followed by S2, et al. */
+extern string concat P2H(const_string s1, const_string s2);
+extern string concat3 P3H(const_string, const_string, const_string);
+/* `concatn' is declared in its own include file, to avoid pulling in
+ all the varargs stuff. */
+
+/* A fresh copy of just S. */
+extern string xstrdup P1H(const_string s);
+
+/* Convert all lowercase characters in S to uppercase. */
+extern string uppercasify P1H(const_string s);
+
+/* Like `atoi', but disallow negative numbers. */
+extern unsigned atou P1H(const_string);
+
+/* True if FILENAME1 and FILENAME2 are the same file. If stat fails on
+ either name, return false, no error message.
+ Cf. `SAME_FILE_P' in xstat.h. */
+extern boolean same_file_p P2H(const_string filename1,
+ const_string filename2);
+
+/* Return NAME with any leading path stripped off. This returns a
+ pointer into NAME. */
+extern const_string xbasename P1H(const_string name);
+
+/* Return directory part of NAME. This returns a new string. */
+extern string xdirname P1H(const_string name);
+
+#ifndef HAVE_STRSTR
+extern string strstr P2H(const_string haystack, const_string needle);
+#endif
+
+/* If NAME has a suffix, return a pointer to its first character (i.e.,
+ the one after the `.'); otherwise, return NULL. */
+extern string find_suffix P1H(const_string name);
+
+/* Return NAME with any suffix removed. */
+extern string remove_suffix P1H(const_string name);
+
+/* Return S with the suffix SUFFIX, removing any suffix already present.
+ For example, `make_suffix ("/foo/bar.baz", "quux")' returns
+ `/foo/bar.quux'. Returns a string allocated with malloc. */
+extern string make_suffix P2H(const_string s, const_string suffix);
+
+/* Return NAME with STEM_PREFIX prepended to the stem. For example,
+ `make_prefix ("/foo/bar.baz", "x")' returns `/foo/xbar.baz'.
+ Returns a string allocated with malloc. */
+extern string make_prefix P2H(string stem_prefix, string name);
+
+/* If NAME has a suffix, simply return it; otherwise, return
+ `NAME.SUFFIX'. */
+extern string extend_filename P2H(const_string name,
+ const_string suffix);
+
+/* Call putenv with the string `VAR=VALUE' and abort on error. */
+extern void xputenv P2H(const_string var, const_string value);
+extern void xputenv_int P2H(const_string var, int value);
+
+/* Return the current working directory. */
+extern string xgetcwd P1H(void);
+
+/* Returns true if FN is a directory or a symlink to a directory. */
+extern boolean dir_p P1H(const_string fn);
+
+/* If FN is a readable directory, return the number of links it has.
+ Otherwise, return -1. The nlinks parameter is a dummy on UNIX. */
+extern int dir_links P2H(const_string fn, long nlinks);
+
+/* Like their stdio counterparts, but abort on error, after calling
+ perror(3) with FILENAME as its argument. */
+extern FILE *xfopen P2H(const_string filename, const_string mode);
+extern void xfclose P2H(FILE *, const_string filename);
+extern void xfseek P4H(FILE *, long, int, string filename);
+extern unsigned long xftell P2H(FILE *, string filename);
+
+/* These call the corresponding function in the standard library, and
+ abort if those routines fail. Also, `xrealloc' calls `xmalloc' if
+ OLD_ADDRESS is null. */
+extern address xmalloc P1H(unsigned size);
+extern address xrealloc P2H(address old_address, unsigned new_size);
+extern address xcalloc P2H(unsigned nelem, unsigned elsize);
/* (Re)Allocate N items of type T using xmalloc/xrealloc. */
#define XTALLOC(n, t) ((t *) xmalloc ((n) * sizeof (t)))
#define XTALLOC1(t) XTALLOC (1, t)
#define XRETALLOC(addr, n, t) ((addr) = (t *) xrealloc (addr, (n) * sizeof(t)))
-#endif
+#endif /* not KPATHSEA_LIB_H */