* Sebastian Hammer, Adam Dickmeiss
*
* $Log: extract.c,v $
- * Revision 1.52 1996-04-25 13:27:57 adam
+ * Revision 1.53 1996-04-26 12:09:43 adam
+ * Added a few comments.
+ *
+ * Revision 1.52 1996/04/25 13:27:57 adam
* Function recordExtract modified so that files with no keys (possibly empty)
* are ignored.
*
if (fi->fd != -1)
{
+ /* we are going to read from a file, so prepare the extraction */
extractCtrl.fh = fi;
- /* extract keys */
extractCtrl.subType = subType;
extractCtrl.init = wordInit;
extractCtrl.add = addRecordKeyAny;
reckeys.prevAttrSet = -1;
extractCtrl.readf = file_read;
r = (*recType->extract)(&extractCtrl);
-
+
if (r)
{
+ /* error occured during extraction ... */
logf (LOG_WARN, "Couldn't extract file %s, code %d", fname, r);
return 0;
}
if (reckeys.buf_used == 0)
{
+ /* the extraction process returned no information - the record
+ is probably empty */
logf (LOG_WARN, "Empty file %s", fname);
return 0;
}
}
}
- /* new record ? */
if (! *sysno)
{
+ /* new record */
if (deleteFlag)
{
logf (LOG_LOG, "Cannot delete new record");
}
else
{
+ /* record already exists */
struct recKeys delkeys;
rec = rec_get (records, *sysno);
flushRecordKeys (*sysno, 0, &delkeys, rec->info[recInfo_databaseName]);
if (deleteFlag)
{
+ /* record going to be deleted */
logInfo.op = "delete";
if (!delkeys.buf_used)
{
}
else
{
+ /* record going to be updated */
logInfo.op = "update";
if (!delkeys.buf_used)
{
}
}
}
+ /* update file type */
xfree (rec->info[recInfo_fileType]);
rec->info[recInfo_fileType] =
rec_strdup (rGroup->recordType, &rec->size[recInfo_fileType]);
+ /* update filename */
xfree (rec->info[recInfo_filename]);
rec->info[recInfo_filename] =
rec_strdup (fname, &rec->size[recInfo_filename]);
+ /* update delete keys */
xfree (rec->info[recInfo_delKeys]);
if (reckeys.buf_used > 0 && rGroup->flagStoreKeys == 1)
{
rec->size[recInfo_delKeys] = 0;
}
+ /* update store data */
xfree (rec->info[recInfo_storeData]);
if (rGroup->flagStoreData == 1)
{
rec->info[recInfo_storeData] = NULL;
rec->size[recInfo_storeData] = 0;
}
+ /* update database name */
xfree (rec->info[recInfo_databaseName]);
rec->info[recInfo_databaseName] =
rec_strdup (rGroup->databaseName, &rec->size[recInfo_databaseName]);
+ /* commit this record */
rec_put (records, &rec);
return 1;
}