aboutsummaryrefslogtreecommitdiff
path: root/include/utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/utils.h')
-rw-r--r--include/utils.h31
1 files changed, 29 insertions, 2 deletions
diff --git a/include/utils.h b/include/utils.h
index a3d244a..4ade817 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -8,7 +8,12 @@
#include <unistd.h>
#include <limits.h>
#include <errno.h>
+#include "core.h"
+#include "copy.h"
#include "system.h"
+#include "strlist.h"
+#include "utils.h"
+#include "ini.h"
#if defined(STASIS_OS_WINDOWS)
#define PATH_ENV_VAR "path"
@@ -25,8 +30,6 @@
#define STASIS_XML_PRETTY_PRINT_PROG "xmllint"
#define STASIS_XML_PRETTY_PRINT_ARGS "--format"
-typedef int (ReaderFn)(size_t line, char **);
-
/**
* Change directory. Push path on directory stack.
*
@@ -365,4 +368,28 @@ long get_cpu_count();
*/
int mkdirs(const char *_path, mode_t mode);
+/**
+ * Return pointer to a (possible) version specifier
+ *
+ * ```c
+ * char s[] = "abc==1.2.3";
+ * char *spec_begin = find_version_spec(s);
+ * // spec_begin is "==1.2.3"
+ *
+ * char package_name[255];
+ * char s[] = "abc";
+ * char *spec_pos = find_version_spec(s);
+ * if (spec_pos) {
+ * strncpy(package_name, spec_pos - s);
+ * // use spec
+ * } else {
+ * // spec not found
+ * }
+ *
+ * @param str a pointer to a buffer containing a package spec (i.e. abc==1.2.3, abc>=1.2.3, abc)
+ * @return a pointer to the first occurrence of a version spec character
+ * @return NULL if not found
+ */
+char *find_version_spec(char *package_name);
+
#endif //STASIS_UTILS_H