Index: trunk/ippTools/src/receivetool.c
===================================================================
--- trunk/ippTools/src/receivetool.c	(revision 23885)
+++ trunk/ippTools/src/receivetool.c	(revision 23894)
@@ -95,9 +95,9 @@
 
     // required
-    PXOPT_LOOKUP_STR(source, config->args, "-stage", true, false);
+    PXOPT_LOOKUP_STR(source, config->args, "-source", true, false);
     PXOPT_LOOKUP_STR(product, config->args, "-product",  true, false);
+    PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", false, false);
 
     // optional
-    PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", false, false);
     PXOPT_LOOKUP_STR(comment, config->args, "-comment",  false, false);
     PXOPT_LOOKUP_STR(last, config->args, "-last",  false, false);
@@ -168,8 +168,34 @@
 
     // required
-    PXOPT_LOOKUP_S64(source_id, config->args, "-source_id", true, false);
-    PXOPT_LOOKUP_STR(fileset, config->args, "-fileset",  true, false);
-
-    if (!receiveFilesetInsert(config->dbh, 0, source_id, fileset)) {
+    PXOPT_LOOKUP_S64(source_id, config->args, "-src_id", true, false);
+    psMetadataItem *filesets = psMetadataLookup(config->args, "-fileset");
+    if (!filesets) {
+        psError(PS_ERR_UNKNOWN, true, "-fileset is required");
+        return false;
+    }
+
+    if (!psDBTransaction(config->dbh)) {
+        psError(PS_ERR_UNKNOWN, false, "Database error");
+        return false;
+    }
+
+    psListIterator *iter = psListIteratorAlloc(filesets->data.list, PS_LIST_HEAD, false); // Iterator
+    psMetadataItem *item = NULL;        // Item from iteration
+    while ((item = psListGetAndIncrement(iter))) {
+        psAssert(item && item->data.V && item->type == PS_DATA_STRING, "Argument is bad");
+
+        if (!receiveFilesetInsert(config->dbh, 0, source_id, item->data.str)) {
+            psError(PS_ERR_UNKNOWN, false, "Unable to add fileset");
+            if (!psDBTransaction(config->dbh)) {
+                psError(PS_ERR_UNKNOWN, false, "Database error");
+                return false;
+            }
+            psFree(iter);
+            return false;
+        }
+    }
+    psFree(iter);
+
+    if (!psDBCommit(config->dbh)) {
         psError(PS_ERR_UNKNOWN, false, "Database error");
         return false;
@@ -184,5 +210,5 @@
 
     // required
-    PXOPT_LOOKUP_S64(source_id, config->args, "-source_id", true, false);
+    PXOPT_LOOKUP_S64(source_id, config->args, "-src_id", true, false);
     PXOPT_LOOKUP_STR(fileset, config->args, "-fileset",  true, false);
 
@@ -212,4 +238,8 @@
     PXOPT_COPY_STR(config->args, where, "-product", "receiveSource.product", "==");
     PXOPT_COPY_STR(config->args, where, "-comment", "receiveSource.comment", "LIKE");
+
+    // optional
+    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
+    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
 
     psString query = pxDataGet("receivetool_pendingfileset.sql");
@@ -227,4 +257,10 @@
     psFree(where);
 
+    if (limit) {
+        psString limitString = psDBGenerateLimitSQL(limit);
+        psStringAppend(&query, " %s", limitString);
+        psFree(limitString);
+    }
+
     if (!p_psDBRunQueryF(config->dbh, query)) {
         psError(PS_ERR_UNKNOWN, false, "Database error");
@@ -244,5 +280,5 @@
         return true;
     }
-    if (!ippdbPrintMetadatas(stdout, output, "receiveFileset", true)) {
+    if (!ippdbPrintMetadatas(stdout, output, "receiveFileset", !simple)) {
         psError(PS_ERR_UNKNOWN, false, "Failed to print array");
         psFree(output);
@@ -260,7 +296,33 @@
     // required
     PXOPT_LOOKUP_S64(fileset_id, config->args, "-fileset_id", true, false);
-    PXOPT_LOOKUP_STR(file, config->args, "-file",  true, false);
-
-    if (!receiveFileInsert(config->dbh, 0, fileset_id, file)) {
+    psMetadataItem *files = psMetadataLookup(config->args, "-file");
+    if (!files) {
+        psError(PS_ERR_UNKNOWN, true, "-file is required");
+        return false;
+    }
+
+    if (!psDBTransaction(config->dbh)) {
+        psError(PS_ERR_UNKNOWN, false, "Database error");
+        return false;
+    }
+
+    psListIterator *iter = psListIteratorAlloc(files->data.list, PS_LIST_HEAD, false); // Iterator
+    psMetadataItem *item = NULL;        // Item from iteration
+    while ((item = psListGetAndIncrement(iter))) {
+        psAssert(item && item->data.V && item->type == PS_DATA_STRING, "Argument is bad");
+
+        if (!receiveFileInsert(config->dbh, 0, fileset_id, item->data.str)) {
+            psError(PS_ERR_UNKNOWN, false, "Unable to add file");
+            if (!psDBTransaction(config->dbh)) {
+                psError(PS_ERR_UNKNOWN, false, "Database error");
+                return false;
+            }
+            psFree(iter);
+            return false;
+        }
+    }
+    psFree(iter);
+
+    if (!psDBCommit(config->dbh)) {
         psError(PS_ERR_UNKNOWN, false, "Database error");
         return false;
@@ -282,4 +344,8 @@
     PXOPT_COPY_S64(config->args, where, "-fileset_id", "receiveFile.file_id", "==");
 
+    // optional
+    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
+    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
+
     psString query = pxDataGet("receivetool_pendingfile.sql");
     if (!query) {
@@ -296,4 +362,10 @@
     psFree(where);
 
+    if (limit) {
+        psString limitString = psDBGenerateLimitSQL(limit);
+        psStringAppend(&query, " %s", limitString);
+        psFree(limitString);
+    }
+
     if (!p_psDBRunQueryF(config->dbh, query)) {
         psError(PS_ERR_UNKNOWN, false, "Database error");
@@ -313,5 +385,5 @@
         return true;
     }
-    if (!ippdbPrintMetadatas(stdout, output, "receiveFile", true)) {
+    if (!ippdbPrintMetadatas(stdout, output, "receiveFile", !simple)) {
         psError(PS_ERR_UNKNOWN, false, "Failed to print array");
         psFree(output);
@@ -328,5 +400,5 @@
 
     // required
-    PXOPT_LOOKUP_S64(fileset_id, config->args, "-source_id", true, false);
+    PXOPT_LOOKUP_S64(file_id, config->args, "-file_id", true, false);
 
     // optional
@@ -335,5 +407,5 @@
     PXOPT_LOOKUP_S32(fault, config->args, "-fault", false, false);
 
-    if (!receiveResultInsert(config->dbh, fileset_id, dtime_copy, dtime_extract, fault)) {
+    if (!receiveResultInsert(config->dbh, file_id, dtime_copy, dtime_extract, fault)) {
         psError(PS_ERR_UNKNOWN, false, "Database error");
         return false;
