* sim/ucsim/cmd.src/cmdutil.cc: NUL device is detected as CG_FILE type
[fw/sdcc] / src / SDCCutil.h
index e5f64d74ad35c50e3bfbcc802adb81b688731cfd..aa29272f18f1e9fb17e57a6144d07c96f19f3d3c 100644 (file)
@@ -26,6 +26,7 @@
 #define SDCCUTIL_H
 
 #include "SDCChasht.h"
+#include "dbuf.h"
 #include <stdarg.h>
 
 /** Given an array of name, value string pairs creates a new hash
@@ -47,12 +48,26 @@ set *appendStrSet(set *list, const char *pre, const char *post);
 */
 const char *joinStrSet(set *list);
 
+/** Split the path string to the directory and file name (including extension) components.
+    The directory component doesn't contain trailing directory separator.
+    Returns true if the path contains the directory separator. */
+int dbuf_splitPath(const char *path, struct dbuf_s *dir, struct dbuf_s *file);
+
+/** Split the path string to the file name (including directory) and file extension components.
+    The file name component doesn't contain trailing extension separator.
+    Returns true if the path contains the extension separator. */
+int dbuf_splitFile(const char *path, struct dbuf_s *file, struct dbuf_s *ext);
+
+/** Combile directory and the file name to a path string using the DIR_SEPARATOR_CHAR.
+ */
+void dbuf_makePath(struct dbuf_s *path, const char *dir, const char *file);
+
 /** Given a file with path information in the binary files directory,
     returns the directory component. Used for discovery of bin
     directory of SDCC installation. Returns NULL if the path is
     impossible.
 */
-char *getBinPath (const char *prel);
+const char *getBinPath (const char *prel);
 
 /** Returns true if the given path exists.
  */
@@ -85,6 +100,9 @@ char *strncpyz(char *dest, const char *src, size_t n);
  */
 char *strncatz(char *dest, const char *src, size_t n);
 
+/* return SDCC build number */
+const char *getBuildNumber(void);
+
 /* snprintf, by hook or by crook. */
 size_t SDCCsnprintf(char *, size_t, const char *, ...);
 
@@ -109,4 +127,21 @@ size_t SDCCsnprintf(char *, size_t, const char *, ...);
 #  error "Need at least one of snprintf, vsnprintf, vsprintf!"
 # endif
 
+/** Pragma tokenizer
+ */
+enum pragma_token_e { TOKEN_UNKNOWN, TOKEN_STR, TOKEN_INT, TOKEN_EOL };
+
+struct pragma_token_s {
+  enum pragma_token_e type;
+  struct dbuf_s dbuf;
+  union {
+    int int_val;
+  } val;
+};
+
+void init_pragma_token(struct pragma_token_s *token);
+char *get_pragma_token(const char *s, struct pragma_token_s *token);
+const char *get_pragma_string(struct pragma_token_s *token);
+void free_pragma_token(struct pragma_token_s *token);
+
 #endif