#ifdef PAKFIRE_PRIVATE
+#include <ctype.h>
#include <stdarg.h>
#include <stdlib.h>
#include <time.h>
char* pakfire_string_replace(const char* s, const char* pattern, const char* repl);
char* pakfire_string_join(char** list, const char* delim);
+/*
+ Simple operations, usually used in the linter...
+*/
+static inline int pakfire_string_contains_whitespace(const char* s) {
+ while (s && *s) {
+ if (isspace(*s))
+ return 1;
+
+ s++;
+ }
+
+ return 0;
+}
+
/*
Cleanup Stuff
*/
#include <pakfire/linter.h>
#include <pakfire/logging.h>
#include <pakfire/package.h>
+#include <pakfire/string.h>
struct pakfire_linter_result {
TAILQ_ENTRY(pakfire_linter_result) nodes;
return 0;
}
+#define pakfire_linter_info(linter, format, ...) \
+ pakfire_linter_result(linter, PAKFIRE_LINTER_INFO, format, ## __VA_ARGS__)
+#define pakfire_linter_warning(linter, format, ...) \
+ pakfire_linter_result(linter, PAKFIRE_LINTER_WARNING, format, ## __VA_ARGS__)
+#define pakfire_linter_error(linter, format, ...) \
+ pakfire_linter_result(linter, PAKFIRE_LINTER_ERROR, format, ## __VA_ARGS__)
+
int pakfire_linter_create(struct pakfire_linter** linter,
struct pakfire_ctx* ctx, struct pakfire_archive* archive) {
struct pakfire_linter* l = NULL;
// Fetch the package name
const char* name = pakfire_package_get_string(linter->pkg, PAKFIRE_PKG_NAME);
+ if (!name)
+ return -errno;
+
+ // Check for whitespace
+ if (pakfire_string_contains_whitespace(name)) {
+ r = pakfire_linter_error(linter, "Package name contains whitespace");
+ if (r < 0)
+ return r;
+ }
+
- // XXX Do something here...
return 0;
}