Index: trunk/ippTools/src/magictool.c
===================================================================
--- trunk/ippTools/src/magictool.c	(revision 18336)
+++ trunk/ippTools/src/magictool.c	(revision 18520)
@@ -41,6 +41,4 @@
 static bool tomaskMode(pxConfig *config);
 static bool addmaskMode(pxConfig *config);
-static bool toskyfilemaskMode(pxConfig *config);
-static bool addskyfilemaskMode(pxConfig *config);
 
 static bool setmagicRunState(pxConfig *config, psS64 magic_id, const char *state);
@@ -75,6 +73,4 @@
         MODECASE(MAGICTOOL_MODE_TOMASK,         tomaskMode);
         MODECASE(MAGICTOOL_MODE_ADDMASK,        addmaskMode);
-        MODECASE(MAGICTOOL_MODE_TOSKYFILEMASK,  toskyfilemaskMode);
-        MODECASE(MAGICTOOL_MODE_ADDSKYFILEMASK, addskyfilemaskMode);
         default:
             psAbort("invalid option (this should not happen)");
@@ -211,5 +207,6 @@
                 NULL,       // label
                 NULL,       // dvodb
-                NULL        // registered
+                NULL,       // registered
+                0           // fault
         );
         if (!run) {
@@ -262,5 +259,5 @@
     PS_ASSERT_PTR_NON_NULL(config, false);
 
-    // required 
+    // required
     PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false);
 
@@ -278,15 +275,16 @@
             label,
             dvodb,
-            registered
+            registered,
+            0
     );
     psFree(registered);
     if (!run) {
         psError(PS_ERR_UNKNOWN, false, "failed to alloc magicRun object");
-        return true;
+        return false;
     }
     if (!magicRunInsertObject(config->dbh, run)) {
         psError(PS_ERR_UNKNOWN, false, "database error");
         psFree(run);
-        return true;
+        return false;
     }
 
@@ -444,5 +442,5 @@
         return false;
     }
-    
+
     return true;
 }
@@ -491,5 +489,5 @@
         return false;
     }
-    
+
     return true;
 }
@@ -589,5 +587,5 @@
         return true;
     }
-     
+
     psHash *forest = psHashAlloc(psArrayLength(magicTree));
 
@@ -642,10 +640,16 @@
     PXOPT_LOOKUP_STR(magic_id, config->args, "-magic_id", true, false);
     PXOPT_LOOKUP_STR(node, config->args, "-node", true, false);
-    PXOPT_LOOKUP_STR(uri, config->args, "-uri", true, false);
+
+    // optional
+    PXOPT_LOOKUP_STR(uri, config->args, "-uri", false, false);
+
+    // default values
+    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
 
     if (!magicNodeResultInsert(config->dbh,
-                (psS64)atoll(magic_id),
-                node,
-                uri
+                               (psS64)atoll(magic_id),
+                               node,
+                               uri,
+                               code
         )) {
         psError(PS_ERR_UNKNOWN, false, "database error");
@@ -726,93 +730,17 @@
     // required
     PXOPT_LOOKUP_STR(magic_id, config->args, "-magic_id", true, false);
-    PXOPT_LOOKUP_STR(uri, config->args, "-uri", true, false);
+
+    // optional
+    PXOPT_LOOKUP_STR(uri, config->args, "-uri", false, false);
+    PXOPT_LOOKUP_S32(streaks, config->args, "-streaks", false, false);
+
+    // default values
+    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
 
     if (!magicMaskInsert(config->dbh,
-                (psS64)atoll(magic_id),
-                uri
-        )) {
-        psError(PS_ERR_UNKNOWN, false, "database error");
-        return false;
-    }
-
-    return true;
-}
-
-
-static bool toskyfilemaskMode(pxConfig *config)
-{
-    PS_ASSERT_PTR_NON_NULL(config, false);
-
-    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
-    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
-
-    psString query = pxDataGet("magictool_toskyfilemask.sql");
-    if (!query) {
-        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
-        return false;
-    }
-
-    // treat limit == 0 as "no limit"
-    if (limit) {
-        psString limitString = psDBGenerateLimitSQL(limit);
-        psStringAppend(&query, " %s", limitString);
-        psFree(limitString);
-    }
-
-    if (!p_psDBRunQuery(config->dbh, query)) {
-        psError(PS_ERR_UNKNOWN, false, "database error");
-        psFree(query);
-        return false;
-    }
-    psFree(query);
-
-    psArray *output = p_psDBFetchResult(config->dbh);
-    if (!output) {
-        psErrorCode err = psErrorCodeLast();
-        switch (err) {
-            case PS_ERR_DB_CLIENT:
-                psError(PXTOOLS_ERR_SYS, false, "database error");
-            case PS_ERR_DB_SERVER:
-                psError(PXTOOLS_ERR_PROG, false, "database error");
-            default:
-                psError(PXTOOLS_ERR_PROG, false, "unknown error");
-        }
-
-        return false;
-    }
-    if (!psArrayLength(output)) {
-        psTrace("magictool", PS_LOG_INFO, "no rows found");
-        psFree(output);
-        return true;
-    }
-
-    if (psArrayLength(output)) {
-        // negative simple so the default is true
-        if (!ippdbPrintMetadatas(stdout, output, "toskyfilemask", !simple)) {
-            psError(PS_ERR_UNKNOWN, false, "failed to print array");
-            psFree(output);
-            return false;
-        }
-    }
-
-    psFree(output);
-
-    return true;
-}
-
-
-static bool addskyfilemaskMode(pxConfig *config)
-{
-    PS_ASSERT_PTR_NON_NULL(config, false);
-
-    // required
-    PXOPT_LOOKUP_STR(magic_id, config->args, "-magic_id", true, false);
-    PXOPT_LOOKUP_STR(diff_id, config->args, "diff_id", true, false);
-    PXOPT_LOOKUP_STR(uri, config->args, "uri", true, false);
-
-    if (!magicSkyfileMaskInsert(config->dbh,
-                (psS64)atoll(magic_id),
-                (psS64)atoll(diff_id),
-                uri
+                         (psS64)atoll(magic_id),
+                         uri,
+                         streaks,
+                         code
         )) {
         psError(PS_ERR_UNKNOWN, false, "database error");
