--- /dev/null
+#define _POSIX_C_SOURCE 200809L
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+
+#include "zpm.h"
+
+#define DMARK fprintf(stderr, "mark %s %s:%d\n", __FILE__, __func__, __LINE__)
+
+int zpm_create_pkgid(struct zpm *zpm, char *pkgstr) {
+ int release;
+ char version[32];
+ char package[64];
+ int found;
+
+ if (!pkgstr) {
+ return 0;
+ }
+
+ found = zpm_parse_package(pkgstr, package, version, &release);
+ if (found != 3) {
+ return 0;
+ }
+
+ return zpm_create_package(zpm, package, version, release);
+}
+
+int zpm_create_package(struct zpm *zpm, char *name, char *ver, int rel) {
+ char *ins = "insert into packages (package, version, release) values (%Q,%Q,%d);";
+
+ if (zpm->error) {
+ return 0;
+ }
+
+ zpm_db_run(zpm, ins, name, ver, rel);
+ return zpm->error ? 0 : 1;
+}