rpmio/tglob.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/rawhide/test/*.rpm"
00014 #if 0
00015 #define HTTPPATH        "http://localhost/rawhide/test/*.rpm"
00016 #else
00017 #define HTTPPATH        "http://localhost/rawhide/*.rpm"
00018 #endif
00019 #define FTPPATH         "ftp://localhost/pub/rawhide/packages/test/*.rpm"
00020 #define DIRPATH         "/var/ftp/pub/rawhide/packages/test/*.rpm"
00021 static char * dirpath = DIRPATH;
00022 static char * ftppath = FTPPATH;
00023 static char * httppath = HTTPPATH;
00024 static char * httpspath = HTTPSPATH;
00025 
00026 static int Glob_error(const char *epath, int eerrno)
00027 {
00028 fprintf(stderr, "*** glob_error(%p,%d) path %s\n", epath, eerrno, epath);
00029     return 1;
00030 }
00031 
00032 static void printGlob(const char * path)
00033 {
00034     glob_t gl;
00035     int rc;
00036     int i;
00037 
00038 fprintf(stderr, "===== %s\n", path);
00039     gl.gl_pathc = 0;
00040     gl.gl_pathv = NULL;
00041     gl.gl_offs = 0;
00042     rc = Glob(path, 0, Glob_error, &gl);
00043 fprintf(stderr, "*** Glob rc %d\n", rc);
00044     if (rc == 0)
00045     for (i = 0; i < gl.gl_pathc; i++)
00046         fprintf(stderr, "%5d %s\n", i, gl.gl_pathv[i]);
00047     Globfree(&gl);
00048 }
00049 
00050 static struct poptOption optionsTable[] = {
00051  { "debug", 'd', POPT_ARG_VAL,  &_debug, -1,            NULL, NULL },
00052  { "ftpdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_ftp_debug, -1,
00053         N_("debug protocol data stream"), NULL},
00054  { "rpmiodebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmio_debug, -1,
00055         N_("debug rpmio I/O"), NULL},
00056  { "urldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_url_debug, -1,
00057         N_("debug URL cache handling"), NULL},
00058  { "verbose", 'v', 0, 0, 'v',                           NULL, NULL },
00059   POPT_AUTOHELP
00060   POPT_TABLEEND
00061 };
00062 
00063 int
00064 main(int argc, const char *argv[])
00065 {
00066     poptContext optCon = poptGetContext(argv[0], argc, argv, optionsTable, 0);
00067     int rc;
00068 
00069     while ((rc = poptGetNextOpt(optCon)) > 0) {
00070         switch (rc) {
00071         case 'v':
00072             rpmIncreaseVerbosity();
00073             /*@switchbreak@*/ break;
00074         default:
00075             /*@switchbreak@*/ break;
00076         }
00077     }
00078 
00079     if (_debug) {
00080         rpmIncreaseVerbosity();
00081         rpmIncreaseVerbosity();
00082     }
00083 
00084 _av_debug = -1;
00085 _ftp_debug = -1;
00086 _dav_debug = -1;
00087 #if 0
00088     printGlob(dirpath);
00089     printGlob(ftppath);
00090 #endif
00091     printGlob(httppath);
00092 #if 0
00093     printGlob(httpspath);
00094 #endif
00095 
00096     return 0;
00097 }

Generated on Tue Feb 19 22:26:21 2008 for rpm by  doxygen 1.5.1