--- a/src/internfile/internfile.cpp
+++ b/src/internfile/internfile.cpp
@@ -1,6 +1,9 @@
#ifndef lint
-static char rcsid[] = "@(#$Id: internfile.cpp,v 1.12 2005-12-06 08:35:48 dockes Exp $ (C) 2004 J.F.Dockes";
+static char rcsid[] = "@(#$Id: internfile.cpp,v 1.13 2005-12-08 08:44:14 dockes Exp $ (C) 2004 J.F.Dockes";
#endif
+
+#ifndef TEST_INTERNFILE
+
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -178,3 +181,106 @@
m_handler = 0;
tmpcleanup();
}
+
+#else
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <iostream>
+#include <string>
+using namespace std;
+
+#include "debuglog.h"
+#include "rclinit.h"
+#include "internfile.h"
+
+static string thisprog;
+
+static string usage =
+ " internfile <filename> [ipath]\n"
+ " \n\n"
+ ;
+
+static void
+Usage(void)
+{
+ cerr << thisprog << ": usage:\n" << usage;
+ exit(1);
+}
+
+static int op_flags;
+#define OPT_q 0x1
+
+int main(int argc, char **argv)
+{
+ thisprog = argv[0];
+ argc--; argv++;
+
+ while (argc > 0 && **argv == '-') {
+ (*argv)++;
+ if (!(**argv))
+ /* Cas du "adb - core" */
+ Usage();
+ while (**argv)
+ switch (*(*argv)++) {
+ default: Usage(); break;
+ }
+ argc--; argv++;
+ }
+ DebugLog::getdbl()->setloglevel(DEBDEB1);
+ DebugLog::setfilename("stderr");
+
+ if (argc < 1)
+ Usage();
+ string fn(*argv++);
+ argc--;
+ string ipath;
+ if (argc >= 1) {
+ ipath.append(*argv++);
+ argc--;
+ }
+ string reason;
+ RclConfig *config = recollinit(0, 0, reason);
+
+ if (config == 0 || !config->ok()) {
+ string str = "Configuration problem: ";
+ str += reason;
+ fprintf(stderr, "%s\n", str.c_str());
+ exit(1);
+ }
+
+ FileInterner interner(fn, config, "/tmp");
+ Rcl::Doc doc;
+ FileInterner::Status status = interner.internfile(doc, ipath);
+ switch (status) {
+ case FileInterner::FIDone:
+ case FileInterner::FIAgain:
+ break;
+ case FileInterner::FIError:
+ default:
+ fprintf(stderr, "internfile failed\n");
+ exit(1);
+ }
+
+ cout << "doc.url [[[[" << doc.url <<
+ "]]]]\n-----------------------------------------------------\n" <<
+ "doc.ipath [[[[" << doc.ipath <<
+ "]]]]\n-----------------------------------------------------\n" <<
+ "doc.mimetype [[[[" << doc.mimetype <<
+ "]]]]\n-----------------------------------------------------\n" <<
+ "doc.fmtime [[[[" << doc.fmtime <<
+ "]]]]\n-----------------------------------------------------\n" <<
+ "doc.dmtime [[[[" << doc.dmtime <<
+ "]]]]\n-----------------------------------------------------\n" <<
+ "doc.origcharset [[[[" << doc.origcharset <<
+ "]]]]\n-----------------------------------------------------\n" <<
+ "doc.title [[[[" << doc.title <<
+ "]]]]\n-----------------------------------------------------\n" <<
+ "doc.keywords [[[[" << doc.keywords <<
+ "]]]]\n-----------------------------------------------------\n" <<
+ "doc.abstract [[[[" << doc.abstract <<
+ "]]]]\n-----------------------------------------------------\n" <<
+ "doc.text [[[[" << doc.text << "]]]]\n";
+}
+
+#endif // TEST_INTERNFILE