Switch to unified view

a/src/internfile/internfile.cpp b/src/internfile/internfile.cpp
1
#ifndef lint
1
#ifndef lint
2
static char rcsid[] = "@(#$Id: internfile.cpp,v 1.12 2005-12-06 08:35:48 dockes Exp $ (C) 2004 J.F.Dockes";
2
static char rcsid[] = "@(#$Id: internfile.cpp,v 1.13 2005-12-08 08:44:14 dockes Exp $ (C) 2004 J.F.Dockes";
3
#endif
3
#endif
4
5
#ifndef TEST_INTERNFILE
6
4
#include <unistd.h>
7
#include <unistd.h>
5
#include <sys/types.h>
8
#include <sys/types.h>
6
#include <sys/stat.h>
9
#include <sys/stat.h>
7
#include <errno.h>
10
#include <errno.h>
8
11
...
...
176
{
179
{
177
    delete m_handler; 
180
    delete m_handler; 
178
    m_handler = 0;
181
    m_handler = 0;
179
    tmpcleanup();
182
    tmpcleanup();
180
}
183
}
184
185
#else
186
187
#include <stdio.h>
188
#include <stdlib.h>
189
#include <iostream>
190
#include <string>
191
using namespace std;
192
193
#include "debuglog.h"
194
#include "rclinit.h"
195
#include "internfile.h"
196
197
static string thisprog;
198
199
static string usage =
200
    " internfile <filename> [ipath]\n"
201
    "  \n\n"
202
    ;
203
204
static void
205
Usage(void)
206
{
207
    cerr << thisprog  << ": usage:\n" << usage;
208
    exit(1);
209
}
210
211
static int        op_flags;
212
#define OPT_q   0x1 
213
214
int main(int argc, char **argv)
215
{
216
    thisprog = argv[0];
217
    argc--; argv++;
218
219
    while (argc > 0 && **argv == '-') {
220
  (*argv)++;
221
  if (!(**argv))
222
      /* Cas du "adb - core" */
223
      Usage();
224
  while (**argv)
225
      switch (*(*argv)++) {
226
      default: Usage();   break;
227
      }
228
  argc--; argv++;
229
    }
230
    DebugLog::getdbl()->setloglevel(DEBDEB1);
231
    DebugLog::setfilename("stderr");
232
233
    if (argc < 1)
234
  Usage();
235
    string fn(*argv++);
236
    argc--;
237
    string ipath;
238
    if (argc >= 1) {
239
  ipath.append(*argv++);
240
  argc--;
241
    }
242
    string reason;
243
    RclConfig *config = recollinit(0, 0, reason);
244
245
    if (config == 0 || !config->ok()) {
246
  string str = "Configuration problem: ";
247
  str += reason;
248
  fprintf(stderr, "%s\n", str.c_str());
249
  exit(1);
250
    }
251
252
    FileInterner interner(fn, config, "/tmp");
253
    Rcl::Doc doc;
254
    FileInterner::Status status = interner.internfile(doc, ipath);
255
    switch (status) {
256
    case FileInterner::FIDone:
257
    case FileInterner::FIAgain:
258
  break;
259
    case FileInterner::FIError:
260
    default:
261
  fprintf(stderr, "internfile failed\n");
262
  exit(1);
263
    }
264
    
265
    cout << "doc.url [[[[" << doc.url << 
266
  "]]]]\n-----------------------------------------------------\n" <<
267
  "doc.ipath [[[[" << doc.ipath <<
268
  "]]]]\n-----------------------------------------------------\n" <<
269
  "doc.mimetype [[[[" << doc.mimetype <<
270
  "]]]]\n-----------------------------------------------------\n" <<
271
  "doc.fmtime [[[[" << doc.fmtime <<
272
  "]]]]\n-----------------------------------------------------\n" <<
273
  "doc.dmtime [[[[" << doc.dmtime <<
274
  "]]]]\n-----------------------------------------------------\n" <<
275
  "doc.origcharset [[[[" << doc.origcharset <<
276
  "]]]]\n-----------------------------------------------------\n" <<
277
  "doc.title [[[[" << doc.title <<
278
  "]]]]\n-----------------------------------------------------\n" <<
279
  "doc.keywords [[[[" << doc.keywords <<
280
  "]]]]\n-----------------------------------------------------\n" <<
281
  "doc.abstract [[[[" << doc.abstract <<
282
  "]]]]\n-----------------------------------------------------\n" <<
283
  "doc.text [[[[" << doc.text << "]]]]\n";
284
}
285
286
#endif // TEST_INTERNFILE