1 /*-------------------------------------------------------------------------
2 SDCCutil.c - Small utility functions.
4 Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999)
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 In other words, you are welcome to use, share and improve this program.
21 You are forbidden to forbid anyone else to use, share and improve
22 what you give them. Help stamp out software-hoarding!
23 -------------------------------------------------------------------------*/
28 #include "SDCChasht.h"
30 /* PENDING: Hacks as I can't work autoconf */
31 #define BINDIR PREFIX "/bin"
33 /** Given an array of name, value string pairs creates a new hash
34 containing all of the pairs.
36 hTab *populateStringHash(const char **pin);
38 /** Given an array of string pointers and another string, adds the
39 string to the end of the list. The end of the list is assumed to
40 be the first NULL pointer.
42 void addToList (const char **list, const char *str);
44 /** Given an array of string pointers returns a string containing all
45 of the strings seperated by spaces. The returned string is on the
46 heap. The join stops when a NULL pointer is hit.
48 char *join(const char **pplist);
50 /** Given an array of string pointers, returns a string containing all
51 of the strings seperated by spaces. The returned string is on the
52 heap. n is the number of strings in the list.
54 char *joinn(char **pplist, int n);
56 /** Returns the characters in the path p2 past the last matching characters in
57 p1. Processes in a host dependent way. For example, on win32 the
58 test is case insensitive and treats '/' and '\' as the same.
60 char *getPathDifference (char *pinto, const char *p1, const char *p2);
62 /** Given a file with path information in the binary files directory,
63 returns what PREFIX must be to get this path. Used for discovery
64 of where SDCC is installed. Returns NULL if the path is
67 char *getPrefixFromBinPath (const char *prel);
69 /** Returns true if the given path exists.
71 bool pathExists (const char *ppath);
73 void setMainValue (const char *pname, const char *pvalue);
75 void populateMainValues (const char **ppin);
77 void buildCmdLine2 (char *pbuffer, const char *pcmd);
79 /** Returns true if sz starts with the string given in key.
81 bool startsWith (const char *sz, const char *key);
83 /** Removes any newline characters from the string. Not strictly the
86 void chomp (char *sz);
89 getRuntimeVariables(void);