Index: trunk/ippTools/src/magictool.c
===================================================================
--- trunk/ippTools/src/magictool.c	(revision 14666)
+++ trunk/ippTools/src/magictool.c	(revision 14688)
@@ -1,6 +1,6 @@
 /*
- * warptool.c
+ * magictool.c
  *
- * Copyright (C) 2006  Joshua Hoblitt
+ * Copyright (C) 2006-2007  Joshua Hoblitt
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -43,4 +43,5 @@
 
 static bool setmagicRunState(pxConfig *config, psS64 magic_id, const char *state);
+static bool parseAndInsertNodeDeps(pxConfig *config, psS64 magic_id, const char *filename);
 
 # define MODECASE(caseName, func) \
@@ -220,4 +221,43 @@
 {
     PS_ASSERT_PTR_NON_NULL(config, false);
+
+    bool status = false;
+    psString magic_id = psMetadataLookupStr(&status, config->args, "-magic_id");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -magic_id");
+        return false;
+    }
+    if (!magic_id) {
+        psError(PS_ERR_UNKNOWN, true, "-magic_id is required");
+        return false;
+    }
+
+    psString diff_id = psMetadataLookupStr(&status, config->args, "-diff_id");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -diff_id");
+        return false;
+    }
+    if (!diff_id) {
+        psError(PS_ERR_UNKNOWN, true, "-diff_id is required");
+        return false;
+    }
+
+    psString node = psMetadataLookupStr(&status, config->args, "-node");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -node");
+        return false;
+    }
+    if (!node) {
+        psError(PS_ERR_UNKNOWN, true, "-node is required");
+        return false;
+    }
+
+    magicInputSkyfileInsert(
+            config->dbh,
+            (psS64)atoll(magic_id),
+            (psS64)atoll(diff_id),
+            node
+    );
+
     return true;
 }
@@ -227,4 +267,29 @@
 {
     PS_ASSERT_PTR_NON_NULL(config, false);
+
+    bool status = false;
+    psString magic_id = psMetadataLookupStr(&status, config->args, "-magic_id");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -magic_id");
+        return false;
+    }
+    if (!magic_id) {
+        psError(PS_ERR_UNKNOWN, true, "-magic_id is required");
+        return false;
+    }
+
+    psString dep_file = psMetadataLookupStr(&status, config->args, "-dep_file");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -dep_file");
+        return false;
+    }
+    if (!dep_file) {
+        psError(PS_ERR_UNKNOWN, true, "-dep_file is required");
+        return false;
+    }
+
+    if (!parseAndInsertNodeDeps(config, (psS64)atoll(magic_id), dep_file)) {
+    }
+
     return true;
 }
@@ -1448,2 +1513,47 @@
 }
 #endif
+
+static bool parseAndInsertNodeDeps(pxConfig *config, psS64 magic_id, const char *filename)
+{
+    unsigned int nFail = 0;
+    psMetadata *deps = psMetadataConfigRead(NULL, &nFail, filename, false);
+    if (!deps) {
+        psError(PS_ERR_UNKNOWN, false, "failed to parse file: %s", filename);
+        return false;
+    }
+    if (nFail) {
+        psError(PS_ERR_UNKNOWN, false, "there were %d errors parsing file: %s", nFail, filename);
+        psFree(deps);
+        return false;
+    }
+
+    psMetadataItem *item = NULL;
+    psMetadataIterator *iter = psMetadataIteratorAlloc(deps, 0, NULL);
+    while ((item = psMetadataGetAndIncrement(iter))) {
+        if (item->type != PS_DATA_STRING) {
+            psError(PS_ERR_UNKNOWN, false, "file: %s is in the wrong format", filename);
+            psFree(iter);
+            psFree(deps);
+            return false;
+        }
+
+        char *name = item->name;
+        char *dependsOn = item->data.str;
+
+        if (!magicTreeInsert(
+                config->dbh,
+                magic_id,
+                name,
+                dependsOn
+            )) {
+            psError(PS_ERR_UNKNOWN, false, "database error");
+            psFree(iter);
+            psFree(deps);
+            return false;
+        }
+    }
+    psFree(iter);
+    psFree(deps);
+
+    return true;
+}
