Index: trunk/ippTools/src/receivetool.c
===================================================================
--- trunk/ippTools/src/receivetool.c	(revision 23883)
+++ trunk/ippTools/src/receivetool.c	(revision 23885)
@@ -33,7 +33,9 @@
 static bool definesourceMode(pxConfig *config);
 static bool listMode(pxConfig *config);
-static bool definerunMode(pxConfig *config);
+static bool addfilesetMode(pxConfig *config);
 static bool updatelastMode(pxConfig *config);
-static bool pendingrunMode(pxConfig *config);
+static bool pendingfilesetMode(pxConfig *config);
+static bool addfileMode(pxConfig *config);
+static bool pendingfileMode(pxConfig *config);
 static bool addresultMode(pxConfig *config);
 static bool revertMode(pxConfig *config);
@@ -60,7 +62,9 @@
         MODECASE(RECEIVETOOL_MODE_DEFINESOURCE, definesourceMode);
         MODECASE(RECEIVETOOL_MODE_LIST, listMode);
-        MODECASE(RECEIVETOOL_MODE_DEFINERUN, definerunMode);
+        MODECASE(RECEIVETOOL_MODE_ADDFILESET, addfilesetMode);
         MODECASE(RECEIVETOOL_MODE_UPDATELAST, updatelastMode);
-        MODECASE(RECEIVETOOL_MODE_PENDINGRUN, pendingrunMode);
+        MODECASE(RECEIVETOOL_MODE_PENDINGFILESET, pendingfilesetMode);
+        MODECASE(RECEIVETOOL_MODE_ADDFILE, addfileMode);
+        MODECASE(RECEIVETOOL_MODE_PENDINGFILE, pendingfileMode);
         MODECASE(RECEIVETOOL_MODE_ADDRESULT, addresultMode);
         MODECASE(RECEIVETOOL_MODE_REVERT, revertMode);
@@ -100,5 +104,5 @@
 
     if (!receiveSourceInsert(config->dbh, 0, source, product, workdir, comment, last)) {
-        psError(PS_ERR_UNKNOWN, false, "database error");
+        psError(PS_ERR_UNKNOWN, false, "Database error");
         return false;
     }
@@ -159,5 +163,5 @@
 }
 
-static bool definerunMode(pxConfig *config)
+static bool addfilesetMode(pxConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(config, false);
@@ -167,6 +171,6 @@
     PXOPT_LOOKUP_STR(fileset, config->args, "-fileset",  true, false);
 
-    if (!receiveRunInsert(config->dbh, 0, source_id, fileset)) {
-        psError(PS_ERR_UNKNOWN, false, "database error");
+    if (!receiveFilesetInsert(config->dbh, 0, source_id, fileset)) {
+        psError(PS_ERR_UNKNOWN, false, "Database error");
         return false;
     }
@@ -198,5 +202,5 @@
 
 
-static bool pendingrunMode(pxConfig *config)
+static bool pendingfilesetMode(pxConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(config, false);
@@ -207,7 +211,7 @@
     PXOPT_COPY_STR(config->args, where, "-source", "receiveSource.source", "==");
     PXOPT_COPY_STR(config->args, where, "-product", "receiveSource.product", "==");
-    PXOPT_COPY_S64(config->args, where, "-comment", "receiveSource.comment", "LIKE");
-
-    psString query = pxDataGet("receivetool_pendingrun.sql");
+    PXOPT_COPY_STR(config->args, where, "-comment", "receiveSource.comment", "LIKE");
+
+    psString query = pxDataGet("receivetool_pendingfileset.sql");
     if (!query) {
         psError(PXTOOLS_ERR_DATA, false, "Failed to retreive SQL statement");
@@ -240,5 +244,5 @@
         return true;
     }
-    if (!ippdbPrintMetadatas(stdout, output, "receiveRun", true)) {
+    if (!ippdbPrintMetadatas(stdout, output, "receiveFileset", true)) {
         psError(PS_ERR_UNKNOWN, false, "Failed to print array");
         psFree(output);
@@ -250,4 +254,73 @@
 }
 
+static bool addfileMode(pxConfig *config)
+{
+    PS_ASSERT_PTR_NON_NULL(config, false);
+
+    // 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)) {
+        psError(PS_ERR_UNKNOWN, false, "Database error");
+        return false;
+    }
+
+    return true;
+}
+
+static bool pendingfileMode(pxConfig *config)
+{
+    PS_ASSERT_PTR_NON_NULL(config, false);
+
+    psMetadata *where = psMetadataAlloc(); // WHERE conditions
+
+    // required
+    PXOPT_COPY_STR(config->args, where, "-source", "receiveSource.source", "==");
+    PXOPT_COPY_STR(config->args, where, "-product", "receiveSource.product", "==");
+    PXOPT_COPY_STR(config->args, where, "-comment", "receiveSource.comment", "LIKE");
+    PXOPT_COPY_S64(config->args, where, "-fileset_id", "receiveFile.file_id", "==");
+
+    psString query = pxDataGet("receivetool_pendingfile.sql");
+    if (!query) {
+        psError(PXTOOLS_ERR_DATA, false, "Failed to retreive SQL statement");
+        psFree(where);
+        return false;
+    }
+
+    if (psListLength(where->list)) {
+        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
+        psStringAppend(&query, " AND %s", whereClause);
+        psFree(whereClause);
+    }
+    psFree(where);
+
+    if (!p_psDBRunQueryF(config->dbh, query)) {
+        psError(PS_ERR_UNKNOWN, false, "Database error");
+        psFree(query);
+        return false;
+    }
+    psFree(query);
+
+    psArray *output = p_psDBFetchResult(config->dbh);
+    if (!output) {
+        psError(PS_ERR_UNKNOWN, false, "Database error");
+        return false;
+    }
+    if (!psArrayLength(output)) {
+        psTrace("receivetool", PS_LOG_INFO, "No rows found");
+        psFree(output);
+        return true;
+    }
+    if (!ippdbPrintMetadatas(stdout, output, "receiveFile", true)) {
+        psError(PS_ERR_UNKNOWN, false, "Failed to print array");
+        psFree(output);
+        return false;
+    }
+    psFree(output);
+
+    return true;
+}
+
 static bool addresultMode(pxConfig *config)
 {
@@ -255,5 +328,5 @@
 
     // required
-    PXOPT_LOOKUP_S64(receive_id, config->args, "-source_id", true, false);
+    PXOPT_LOOKUP_S64(fileset_id, config->args, "-source_id", true, false);
 
     // optional
@@ -262,5 +335,5 @@
     PXOPT_LOOKUP_S32(fault, config->args, "-fault", false, false);
 
-    if (!receiveResultInsert(config->dbh, receive_id, dtime_copy, dtime_extract, fault)) {
+    if (!receiveResultInsert(config->dbh, fileset_id, dtime_copy, dtime_extract, fault)) {
         psError(PS_ERR_UNKNOWN, false, "Database error");
         return false;
@@ -276,5 +349,5 @@
     psMetadata *where = psMetadataAlloc(); // WHERE conditions
 
-    PXOPT_COPY_S64(config->args, where, "-receive_id", "receiveResult.receive_id", "==");
+    PXOPT_COPY_S64(config->args, where, "-fileset_id", "receiveResult.fileset_id", "==");
     PXOPT_COPY_S32(config->args, where, "-fault", "receiveResult.fault", "==");
     PXOPT_COPY_STR(config->args, where, "-source", "receiveSource.source", "==");
Index: trunk/ippTools/src/receivetool.h
===================================================================
--- trunk/ippTools/src/receivetool.h	(revision 23883)
+++ trunk/ippTools/src/receivetool.h	(revision 23885)
@@ -27,7 +27,9 @@
     RECEIVETOOL_MODE_DEFINESOURCE,
     RECEIVETOOL_MODE_LIST,
-    RECEIVETOOL_MODE_DEFINERUN,
+    RECEIVETOOL_MODE_ADDFILESET,
     RECEIVETOOL_MODE_UPDATELAST,
-    RECEIVETOOL_MODE_PENDINGRUN,
+    RECEIVETOOL_MODE_PENDINGFILESET,
+    RECEIVETOOL_MODE_ADDFILE,
+    RECEIVETOOL_MODE_PENDINGFILE,
     RECEIVETOOL_MODE_ADDRESULT,
     RECEIVETOOL_MODE_REVERT,
Index: trunk/ippTools/src/receivetoolConfig.c
===================================================================
--- trunk/ippTools/src/receivetoolConfig.c	(revision 23883)
+++ trunk/ippTools/src/receivetoolConfig.c	(revision 23885)
@@ -57,8 +57,8 @@
     psMetadataAddStr(listArgs, PS_LIST_TAIL, "-comment", 0, "search on comment (LIKE)", NULL);
 
-    // -definerun
-    psMetadata *definerunArgs = psMetadataAlloc();
-    psMetadataAddS64(definerunArgs, PS_LIST_TAIL, "-source_id", 0, "define source_id (required)", 0);
-    psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-fileset", 0, "define fileset (required)", NULL);
+    // -addfileset
+    psMetadata *addfilesetArgs = psMetadataAlloc();
+    psMetadataAddS64(addfilesetArgs, PS_LIST_TAIL, "-source_id", 0, "define source_id (required)", 0);
+    psMetadataAddStr(addfilesetArgs, PS_LIST_TAIL, "-fileset", 0, "define fileset (required)", NULL);
 
     // -updatelast
@@ -67,13 +67,25 @@
     psMetadataAddStr(updatelastArgs, PS_LIST_TAIL, "-fileset", 0, "define last fileset (required)", NULL);
 
-    // -pendingrun
-    psMetadata *pendingrunArgs = psMetadataAlloc();
-    psMetadataAddStr(pendingrunArgs, PS_LIST_TAIL, "-source", 0, "search on source", NULL);
-    psMetadataAddStr(pendingrunArgs, PS_LIST_TAIL, "-product", 0, "search on product", NULL);
-    psMetadataAddStr(pendingrunArgs, PS_LIST_TAIL, "-comment", 0, "search on comment (LIKE)", NULL);
+    // -pendingfileset
+    psMetadata *pendingfilesetArgs = psMetadataAlloc();
+    psMetadataAddStr(pendingfilesetArgs, PS_LIST_TAIL, "-source", 0, "search on source", NULL);
+    psMetadataAddStr(pendingfilesetArgs, PS_LIST_TAIL, "-product", 0, "search on product", NULL);
+    psMetadataAddStr(pendingfilesetArgs, PS_LIST_TAIL, "-comment", 0, "search on comment (LIKE)", NULL);
+
+    // -addfile
+    psMetadata *addfileArgs = psMetadataAlloc();
+    psMetadataAddS64(addfileArgs, PS_LIST_TAIL, "-fileset_id", 0, "define fileset_id (required)", 0);
+    psMetadataAddStr(addfileArgs, PS_LIST_TAIL, "-file", PS_META_DUPLICATE_OK, "define file (multiple OK, required)", NULL);
+
+    // -pendingfile
+    psMetadata *pendingfileArgs = psMetadataAlloc();
+    psMetadataAddStr(pendingfileArgs, PS_LIST_TAIL, "-source", 0, "search on source", NULL);
+    psMetadataAddStr(pendingfileArgs, PS_LIST_TAIL, "-product", 0, "search on product", NULL);
+    psMetadataAddStr(pendingfileArgs, PS_LIST_TAIL, "-comment", 0, "search on comment (LIKE)", NULL);
+    psMetadataAddS64(pendingfileArgs, PS_LIST_TAIL, "-fileset_id", 0, "search on fileset_id", 0);
 
     // -addresult
     psMetadata *addresultArgs = psMetadataAlloc();
-    psMetadataAddS64(addresultArgs, PS_LIST_TAIL, "-receive_id", 0, "define receive_id (required)", 0);
+    psMetadataAddS64(addresultArgs, PS_LIST_TAIL, "-file_id", 0, "define receive_id (required)", 0);
     psMetadataAddF32(addresultArgs, PS_LIST_TAIL, "-dtime_copy", 0, "define time to copy", NAN);
     psMetadataAddF32(addresultArgs, PS_LIST_TAIL, "-dtime_extract", 0, "define time to extract", NAN);
@@ -82,5 +94,6 @@
     // -revert
     psMetadata *revertArgs = psMetadataAlloc();
-    psMetadataAddS64(revertArgs, PS_LIST_TAIL, "-receive_id", 0, "search on receive_id", 0);
+    psMetadataAddS64(revertArgs, PS_LIST_TAIL, "-file_id", 0, "search on file_id", 0);
+    psMetadataAddS64(revertArgs, PS_LIST_TAIL, "-fileset_id", 0, "search on fileset_id", 0);
     psMetadataAddS32(revertArgs, PS_LIST_TAIL, "-fault", 0, "search on fault code", 0);
     psMetadataAddStr(revertArgs, PS_LIST_TAIL, "-source", 0, "search on source", NULL);
@@ -93,7 +106,9 @@
     PXOPT_ADD_MODE("-definesource", "", RECEIVETOOL_MODE_DEFINESOURCE, definesourceArgs);
     PXOPT_ADD_MODE("-list", "", RECEIVETOOL_MODE_LIST, listArgs);
-    PXOPT_ADD_MODE("-definerun", "", RECEIVETOOL_MODE_DEFINERUN, definerunArgs);
+    PXOPT_ADD_MODE("-addfileset", "", RECEIVETOOL_MODE_ADDFILESET, addfilesetArgs);
     PXOPT_ADD_MODE("-updatelast", "", RECEIVETOOL_MODE_UPDATELAST, updatelastArgs);
-    PXOPT_ADD_MODE("-pendingrun", "", RECEIVETOOL_MODE_PENDINGRUN, pendingrunArgs);
+    PXOPT_ADD_MODE("-pendingfileset", "", RECEIVETOOL_MODE_PENDINGFILESET, pendingfilesetArgs);
+    PXOPT_ADD_MODE("-addfile", "", RECEIVETOOL_MODE_ADDFILE, addfileArgs);
+    PXOPT_ADD_MODE("-pendingfile", "", RECEIVETOOL_MODE_PENDINGFILE, pendingfileArgs);
     PXOPT_ADD_MODE("-addresult", "", RECEIVETOOL_MODE_ADDRESULT, addresultArgs);
     PXOPT_ADD_MODE("-revert", "", RECEIVETOOL_MODE_REVERT, revertArgs);
