rpmio/tget.c

Go to the documentation of this file.
00001 #include "system.h"
00002 
00003 #include <rpmio_internal.h>
00004 #include <rpmmacro.h>
00005 #include <rpmmessages.h>
00006 #include <popt.h>
00007 
00008 #include "debug.h"
00009 
00010 static int _debug = 0;
00011 
00012 
00013 #define HTTPSPATH       "https://localhost/test.txt"
00014 #define HTTPPATH        "http://localhost/test.txt"
00015 #define FTPPATH         "ftp://localhost/test.txt"
00016 #define DIRPATH         "/var/ftp/test.txt"
00017 static char * httpspath = HTTPSPATH;
00018 static char * httppath = HTTPPATH;
00019 static char * ftppath = FTPPATH;
00020 static char * dirpath = DIRPATH;
00021 
00022 static void readFile(const char * path)
00023 {
00024     FD_t fd;
00025 
00026 fprintf(stderr, "===== %s\n", path);
00027     fd = Fopen(path, "r.ufdio");
00028     if (fd != NULL) {
00029         char buf[BUFSIZ];
00030         size_t len = Fread(buf, 1, sizeof(buf), fd);
00031         int xx = Fclose(fd);
00032 
00033         if (len > 0)
00034             fwrite(buf, 1, len, stderr);
00035     }
00036 }
00037 
00038 static struct poptOption optionsTable[] = {
00039  { "debug", 'd', POPT_ARG_VAL,  &_debug, -1,            NULL, NULL },
00040  { "ftpdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_ftp_debug, -1,
00041         N_("debug protocol data stream"), NULL},
00042  { "rpmiodebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmio_debug, -1,
00043         N_("debug rpmio I/O"), NULL},
00044  { "urldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_url_debug, -1,
00045         N_("debug URL cache handling"), NULL},
00046  { "verbose", 'v', 0, 0, 'v',                           NULL, NULL },
00047   POPT_AUTOHELP
00048   POPT_TABLEEND
00049 };
00050 
00051 int
00052 main(int argc, const char *argv[])
00053 {
00054     poptContext optCon = poptGetContext(argv[0], argc, argv, optionsTable, 0);
00055     int rc;
00056 
00057     while ((rc = poptGetNextOpt(optCon)) > 0) {
00058         switch (rc) {
00059         case 'v':
00060             rpmIncreaseVerbosity();
00061             /*@switchbreak@*/ break;
00062         default:
00063             /*@switchbreak@*/ break;
00064         }
00065     }
00066 
00067     if (_debug) {
00068         rpmIncreaseVerbosity();
00069         rpmIncreaseVerbosity();
00070     }
00071 
00072 _av_debug = -1;
00073 _ftp_debug = -1;
00074 _dav_debug = 1;
00075 #if 1
00076     readFile(dirpath);
00077 #endif
00078 #if 1
00079     readFile(ftppath);
00080     readFile(ftppath);
00081     readFile(ftppath);
00082 #endif
00083 #if 1
00084     readFile(httppath);
00085     readFile(httppath);
00086     readFile(httppath);
00087 #endif
00088 #if 1
00089     readFile(httpspath);
00090     readFile(httpspath);
00091     readFile(httpspath);
00092 #endif
00093 
00094 /*@i@*/ urlFreeCache();
00095 
00096     return 0;
00097 }

Generated on Tue Feb 19 22:27:03 2008 for rpm by  doxygen 1.5.1