[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r143 - in GNUnet: . doc/man src/applications/fs/ecrs src/ap
From: |
grothoff |
Subject: |
[GNUnet-SVN] r143 - in GNUnet: . doc/man src/applications/fs/ecrs src/applications/fs/tools src/include |
Date: |
Tue, 1 Feb 2005 02:35:24 -0800 (PST) |
Author: grothoff
Date: 2005-02-01 02:35:23 -0800 (Tue, 01 Feb 2005)
New Revision: 143
Modified:
GNUnet/doc/man/gnunet-download.1
GNUnet/doc/man/gnunet-insert.1
GNUnet/src/applications/fs/ecrs/meta.c
GNUnet/src/applications/fs/tools/gnunet-download.c
GNUnet/src/include/gnunet_ecrs_lib.h
GNUnet/todo
Log:
completing gnunet-download code
Modified: GNUnet/doc/man/gnunet-download.1
===================================================================
--- GNUnet/doc/man/gnunet-download.1 2005-02-01 04:48:09 UTC (rev 142)
+++ GNUnet/doc/man/gnunet-download.1 2005-02-01 10:35:23 UTC (rev 143)
@@ -12,32 +12,28 @@
set additional receiver anonymity enforcing level. If unset,
value specified in config file is used. Default is 0.
.TP
+\fB\-c \fIFILENAME\fR, \fB\-\-config=FILENAME\fR
+use config file (defaults: ~/.gnunet/gnunet.conf)
+.TP
\fB\-h\fR, \fB\-\-help\fR
print help page
.TP
-\fB\-c \fIFILENAME\fR, \fB\-\-config=FILENAME\fR
-use config file (defaults: ~/.gnunet/gnunet.conf)
+\fB\-L \fILOGLEVEL\fR, \fB\-\-loglevel=LOGLEVEL\fR
+change the loglevel. Possible values for LOGLEVEL are NOTHING, FATAL, ERROR,
FAILURE, WARNING, MESSAGE, INFO, DEBUG, CRON and EVERYTHING.
.TP
\fB\-o \fIFILENAME\fR, \fB\-\-output=FILENAME\fR
-write the file to FILENAME. Otherwise gnunet-download constructs a temporary
ID from the URI of the file. The final filename is constructed based on
meta-data extracted using libextractor (if available).
+write the file to FILENAME. Otherwise gnunet\-download constructs a temporary
ID from the URI of the file. The final filename is constructed based on
meta-data extracted using libextractor (if available).
.TP
\fB\-R\fR, \fB\-\-recursive\fR
download directories recursively and in parallel
.TP
-\fB\-t\fINUMBER\fR, \fB\-\-threads=NUMBER\fR
-when downloading directories recursively, this option specifies how many
downloads are done in parallel. The default is 30. If you have not so much
memory or if your system cannot support about 64 threads, you may want to pass
a smaller value here. The default can be changed by adding an option
PARALLELIZATION in the gnunet.conf file in the section [GNUNET-DOWNLOAD].
-.TP
\fB\-v\fR, \fB\-\-version\fR
print the version number
.TP
\fB\-V\fR, \fB\-\-verbose\fR
print progress information
-.TP
-\fB\-L \fILOGLEVEL\fR, \fB\-\-loglevel=LOGLEVEL\fR
-change the loglevel. Possible values for LOGLEVEL are NOTHING, FATAL, ERROR,
FAILURE, WARNING, MESSAGE, INFO, DEBUG, CRON and EVERYTHING.
.SH NOTES
-The GNUNET_URI is typically obtained from gnunet-search. gnunet-gtk
-can also be used instead of gnunet-download.
+The GNUNET_URI is typically obtained from gnunet\-search. gnunet\-gtk can also
be used instead of gnunet\-download.
If youever have to abort a download, you can at any time continue it by
re\-issuing gnunet\-download with the same filename. In that case GNUnet will
not download blocks again that are already present. GNUnets file\-encoding will
ensure file integrity, even if the existing file was not downloaded from GNUnet
in the first place. Temporary information will be stored in FILENAME.X files
until the download is completed. These files are used only if a download is
resumed later. If you abort a download for good, you should remember to delete
these files.
.SH SETTING ANONYMITY LEVEL
Modified: GNUnet/doc/man/gnunet-insert.1
===================================================================
--- GNUnet/doc/man/gnunet-insert.1 2005-02-01 04:48:09 UTC (rev 142)
+++ GNUnet/doc/man/gnunet-insert.1 2005-02-01 10:35:23 UTC (rev 143)
@@ -62,7 +62,7 @@
\-u to specify the identifier of the previous version of the content that
you want to update.
.PP
-You can use automatic meta-data extraction (based on libextractor)
+You can use automatic meta\-data extraction (based on libextractor)
or the command\-line option \-m to specify meta-data. For the \-m
option you need to use the form keyword-type:value. For example,
use "\-m os:Linux" to specify that the operating system is Linux.
@@ -259,4 +259,4 @@
.SH "REPORTING BUGS"
Report bugs by using mantis <https://gnunet.org/mantis/> or by sending
electronic mail to <address@hidden>
.SH "SEE ALSO"
-\fBgnunet\-gtk\fP(1), \fBgnunet\-pseudonym\fP(1), \fBgnunet\-search\fP(1),
\fBgnunet\-download\fP(1), \fBgnunet.conf\fP(5), \fBgnunetd\fP(1)
+\fBgnunet\-gtk\fP(1), \fBgnunet\-pseudonym\fP(1), \fBgnunet\-search\fP(1),
\fBgnunet\-download\fP(1), \fBgnunet.conf\fP(5), \fBgnunetd\fP(1),
\fBextract\fP(1)
Modified: GNUnet/src/applications/fs/ecrs/meta.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/meta.c 2005-02-01 04:48:09 UTC (rev
142)
+++ GNUnet/src/applications/fs/ecrs/meta.c 2005-02-01 10:35:23 UTC (rev
143)
@@ -487,4 +487,156 @@
return SYSERR;
}
+static char * mimeMap[][2] = {
+ { "application/bz2", ".bz2" },
+ { "application/gnunet-directory", ".gnd" },
+ { "application/java", ".class" },
+ { "application/msword", ".doc" },
+ { "application/ogg", ".ogg" },
+ { "application/pdf", ".pdf" },
+ { "application/pgp-keys", ".key" },
+ { "application/pgp-signature", ".pgp" },
+ { "application/postscript", ".ps" },
+ { "application/rar", ".rar" },
+ { "application/rtf", ".rtf" },
+ { "application/xml", ".xml" },
+ { "application/x-debian-package", ".deb" },
+ { "application/x-dvi", ".dvi" },
+ { "applixation/x-flac", ".flac" },
+ { "applixation/x-gzip", ".gz" },
+ { "application/x-java-archive", ".jar" },
+ { "application/x-java-vm", ".class" },
+ { "application/x-python-code", ".pyc" },
+ { "application/x-redhat-package-manager", ".rpm" },
+ { "application/x-rpm", ".rpm" },
+ { "application/x-tar", ".tar" },
+ { "application/x-tex-pk", ".pk" },
+ { "application/x-texinfo", ".texinfo" },
+ { "application/x-xcf", ".xcf" },
+ { "application/x-xfig", ".xfig" },
+ { "application/zip", ".zip" },
+
+ { "audio/midi", ".midi" },
+ { "audio/mpeg", ".mpg" },
+ { "audio/real", ".rm"},
+ { "audio/x-wav", ".wav" },
+
+ { "image/gif", ".gif"},
+ { "image/jpeg", ".jpg"},
+ { "image/pcx", ".pcx"},
+ { "image/png", ".png"},
+ { "image/tiff", ".tiff" },
+ { "image/x-ms-bmp", ".bmp"},
+ { "image/x-xpixmap", ".xpm"},
+
+ { "text/css", ".css" },
+ { "text/html", ".html" },
+ { "text/plain", ".txt" },
+ { "text/rtf", ".rtf" },
+ { "text/x-c++hdr", ".h++" },
+ { "text/x-c++src", ".c++" },
+ { "text/x-chdr", ".h" },
+ { "text/x-csrc", ".c" },
+ { "text/x-java", ".java" },
+ { "text/x-moc", ".moc" },
+ { "text/x-pascal", ".pas" },
+ { "text/x-perl", ".pl" },
+ { "text/x-python", ".py" },
+ { "text/x-tex", ".tex" },
+
+ { "video/avi", ".avi" },
+ { "video/mpeg", ".mpeg" },
+ { "video/quicktime", ".qt" },
+ { "video/real", ".rm"},
+ { "video/x-msvideo", ".avi"},
+ { NULL, NULL },
+};
+
+
+/**
+ * Suggest a better filename for a file (and do the
+ * renaming).
+ */
+char * ECRS_suggestFilename(const char * filename) {
+ EXTRACTOR_ExtractorList * l;
+ EXTRACTOR_KeywordList * list;
+ const char * key;
+ const char * mime;
+ int i;
+ char * renameTo;
+ char * ret;
+
+ ret = NULL;
+ l = EXTRACTOR_loadDefaultLibraries();
+ list = EXTRACTOR_getKeywords(l, filename);
+ key = EXTRACTOR_extractLast(EXTRACTOR_TITLE,
+ list);
+ if (key == NULL)
+ key = EXTRACTOR_extractLast(EXTRACTOR_DESCRIPTION,
+ list);
+ if (key == NULL)
+ key = EXTRACTOR_extractLast(EXTRACTOR_COMMENT,
+ list);
+ if (key == NULL)
+ key = EXTRACTOR_extractLast(EXTRACTOR_SUBJECT,
+ list);
+ if (key == NULL)
+ key = EXTRACTOR_extractLast(EXTRACTOR_ALBUM,
+ list);
+ if (key == NULL)
+ key = EXTRACTOR_extractLast(EXTRACTOR_UNKNOWN,
+ list);
+ mime = EXTRACTOR_extractLast(EXTRACTOR_MIMETYPE,
+ list);
+ if (mime != NULL) {
+ i = 0;
+ while ( (mimeMap[i][0] != NULL) &&
+ (0 != strcmp(mime, mimeMap[i][0])) )
+ i++;
+ if (mimeMap[i][1] == NULL)
+ LOG(LOG_DEBUG,
+ "Did not find mime type '%s' in extension list.\n",
+ mime);
+ mime = mimeMap[i][1];
+ }
+ if (mime != NULL) {
+ if (0 == strcmp(&key[strlen(key)-strlen(mime)],
+ mime))
+ mime = NULL;
+ }
+ if (key == NULL)
+ key = filename;
+ if (mime == NULL) {
+ renameTo = STRDUP(key);
+ } else {
+ renameTo = MALLOC(strlen(key) + strlen(mime) + 1);
+ strcpy(renameTo, key);
+ strcat(renameTo, mime);
+ }
+ for (i=strlen(renameTo)-1;i>=0;i--)
+ if (! isprint(renameTo[i]))
+ renameTo[i] = '_';
+ if (0 != strcmp(renameTo, filename)) {
+ struct stat filestat;
+ if (0 != STAT(renameTo,
+ &filestat)) {
+ if (0 != RENAME(filename, renameTo))
+ LOG(LOG_ERROR,
+ _("Renaming of file '%s' to '%s' failed: %s\n"),
+ filename, renameTo, strerror(errno));
+ else
+ ret = STRDUP(renameTo);
+ } else {
+ LOG(LOG_ERROR,
+ _("Could not rename file '%s' to '%s': file exists\n"),
+ filename, renameTo);
+ }
+ }
+ FREE(renameTo);
+ EXTRACTOR_freeKeywords(list);
+ EXTRACTOR_removeAll(l);
+ return ret;
+}
+
+
/* end of meta.c */
Modified: GNUnet/src/applications/fs/tools/gnunet-download.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-download.c 2005-02-01 04:48:09 UTC
(rev 142)
+++ GNUnet/src/applications/fs/tools/gnunet-download.c 2005-02-01 10:35:23 UTC
(rev 143)
@@ -27,6 +27,9 @@
#include "platform.h"
#include "gnunet_fsui_lib.h"
+
+static Semaphore * signalFinished;
+
/**
* Prints the usage information for this command if the user errs.
* Aborts the program.
@@ -89,7 +92,7 @@
"-a");
return -1;
}
- setConfigurationInt("AFS",
+ setConfigurationInt("FS",
"ANONYMITY-RECEIVE",
receivePolicy);
break;
@@ -126,7 +129,7 @@
if (argc - GNoptind != 1) {
LOG(LOG_WARNING,
_("Not enough arguments. "
- "You must specify a GNUnet AFS URI\n"));
+ "You must specify a GNUnet file URI\n"));
printhelp();
return SYSERR;
}
@@ -141,36 +144,41 @@
* The current incarnation just ensures that the main
* method exits once the download is complete.
*/
-static void progressModel(void * unused,
+static void progressModel(void * okVal,
const FSUI_Event * event) {
+ int * ok = okVal;
+
switch (event->type) {
case download_progress:
if (YES == testConfigurationString("GNUNET-DOWNLOAD",
"VERBOSE",
"YES")) {
-#if 0
printf(_("Download at %16llu out of %16llu bytes (%8.3f kbps)"),
- (unsigned int) stats->progress,
- (unsigned int) stats->filesize,
- (stats->progress/1024.0) /
- (((double)(cronTime(NULL)-(data->startTime-1))) /
(double)cronSECONDS) );
+ event->data.DownloadProgress.completed,
+ event->data.DownloadProgress.total,
+ (event->data.DownloadProgress.completed/1024.0) /
+ (((double)(cronTime(NULL)-(event->data.DownloadProgress.start_time
- 1)))
+ / (double)cronSECONDS) );
printf("\r");
-#endif
}
break;
case download_error:
printf(_("Error downloading: %s\n"),
event->data.message);
+ *ok = SYSERR;
+ SEMAPHORE_UP(signalFinished);
break;
case download_complete:
-#if 0
- printf(_("\nDownload %s %s. Speed was %8.3f kilobyte per second.\n"),
- di->filename,
- (ntohl(di->fid->file_length) == di->lastProgress) ?
- _("complete") : _("incomplete"),
- (di->lastProgress/1024.0) /
- (((double)(cronTime(NULL)-di->startTime)) / (double)cronSECONDS) );
-#endif
+ printf(_("\nDownload of file '%s' comlete. Speed was %8.3f kilobyte per
second.\n"),
+ event->data.DownloadProgress.filename,
+ (event->data.DownloadProgress.completed/1024.0) /
+ (((double)(cronTime(NULL)-(event->data.DownloadProgress.start_time -
1)))
+ / (double)cronSECONDS) );
+ if (event->data.DownloadProgress.completed
+ == event->data.DownloadProgress.total) {
+ *ok = OK;
+ SEMAPHORE_UP(signalFinished);
+ }
break;
default:
BREAK();
@@ -178,36 +186,9 @@
}
}
-static char * mimeMap[][2] = {
- { "image/jpeg", ".jpg"},
- { "image/x-xpm", ".xpm"},
- { "image/gif", ".gif"},
- { "audio/real", ".rm"},
- { "video/real", ".rm"},
- { "image/tiff", ".tiff" },
- { "application/pdf", ".pdf" },
- { "video/avi", ".avi" },
- { "audio/midi", "midi" },
- { "application/x-tar", ".tar" },
- { "application/x-rpm", ".rpm" },
- { "applixation/x-gzip", ".gz" },
- { "application/rtf", ".rtf" },
- { "application/x-dvi", ".dvi" },
- { "audio/x-wav", ".wav" },
- { "audio/mpeg", ".mpg" },
- { "application/ogg", ".ogg" },
- { "application/bz2", ".bz2" },
- { "application/gnunet-directory", ".gnd" },
- { "application/postscript", ".ps" },
- { "image/xcf", ".xcf" },
- { "application/java", ".class" },
- { "image/x-png", ".png"},
- { "image/x-bmp", ".bmp"},
- { NULL, NULL },
-};
-
/**
* Main function to download files from GNUnet.
+ *
* @param argc number of arguments from the command line
* @param argv command line arguments
* @return return value from download file: 0: ok, -1, 1: error
@@ -219,6 +200,7 @@
char * filename;
int ok;
int try_rename;
+ struct FSUI_Context * ctx;
if (SYSERR == initUtil(argc, argv, &parseOptions))
return 0;
@@ -251,97 +233,35 @@
try_rename = YES;
}
+ signalFinished = SEMAPHORE_NEW(0);
+ ctx = FSUI_start(&progressModel,
+ &ok);
startCron();
- /* FIXME: actually do the download! */
-#if 0
- scheduleDownload(&fid,
- filename);
- ok = run(threadLimit);
-#endif
- ok = SYSERR;
+ if (testConfigurationString("GNUNET-DOWNLOAD",
+ "RECURSIVE",
+ "YES"))
+ ok = FSUI_startDownloadAll(ctx,
+ uri,
+ filename);
+ else
+ ok = FSUI_startDownload(ctx,
+ uri,
+ filename);
+ if (OK == ok)
+ SEMAPHORE_DOWN(signalFinished);
+ FSUI_stop(ctx);
+ SEMAPHORE_FREE(signalFinished);
- /* FIXME:
- move this code to ECRS! */
if ( (ok == OK) && (try_rename == YES) ) {
- EXTRACTOR_ExtractorList * l;
- EXTRACTOR_KeywordList * list;
- const char * key;
- const char * mime;
- int i;
- char * renameTo;
-
- l = EXTRACTOR_loadDefaultLibraries();
- list = EXTRACTOR_getKeywords(l, filename);
- key = EXTRACTOR_extractLast(EXTRACTOR_TITLE,
- list);
- if (key == NULL)
- key = EXTRACTOR_extractLast(EXTRACTOR_DESCRIPTION,
- list);
- if (key == NULL)
- key = EXTRACTOR_extractLast(EXTRACTOR_COMMENT,
- list);
- if (key == NULL)
- key = EXTRACTOR_extractLast(EXTRACTOR_SUBJECT,
- list);
- if (key == NULL)
- key = EXTRACTOR_extractLast(EXTRACTOR_ALBUM,
- list);
- if (key == NULL)
- key = EXTRACTOR_extractLast(EXTRACTOR_UNKNOWN,
- list);
- mime = EXTRACTOR_extractLast(EXTRACTOR_MIMETYPE,
- list);
- if (mime != NULL) {
- i = 0;
- while ( (mimeMap[i][0] != NULL) &&
- (0 != strcmp(mime, mimeMap[i][0])) )
- i++;
- if (mimeMap[i][1] == NULL)
- LOG(LOG_DEBUG,
- "Did not find mime type '%s' in extension list.\n",
- mime);
- mime = mimeMap[i][1];
+ char * newname = ECRS_suggestFilename(filename);
+
+ if (newname != NULL) {
+ fprintf(stdout,
+ _("File stored as '%s'.\n"),
+ newname);
+ FREE(newname);
}
- if (mime != NULL) {
- if (0 == strcmp(&key[strlen(key)-strlen(mime)],
- mime))
- mime = NULL;
- }
- if (key == NULL)
- key = filename;
- if (mime == NULL) {
- renameTo = STRDUP(key);
- } else {
- renameTo = MALLOC(strlen(key) + strlen(mime) + 1);
- strcpy(renameTo, key);
- strcat(renameTo, mime);
- }
- for (i=strlen(renameTo)-1;i>=0;i--)
- if (! isprint(renameTo[i]))
- renameTo[i] = '_';
- if (0 != strcmp(renameTo, filename)) {
- struct stat filestat;
- if (0 != STAT(renameTo,
- &filestat)) {
- if (0 != RENAME(filename, renameTo))
- fprintf(stdout,
- _("Renaming of file '%s' to '%s' failed: %s\n"),
- filename, renameTo, strerror(errno));
- else
- fprintf(stdout,
- _("File stored as '%s'.\n"),
- renameTo);
- } else {
- fprintf(stdout,
- _("Could not rename file '%s' to '%s': file exists\n"),
- filename, renameTo);
- }
- }
- FREE(renameTo);
- EXTRACTOR_freeKeywords(list);
- EXTRACTOR_removeAll(l);
}
-
FREE(filename);
stopCron();
Modified: GNUnet/src/include/gnunet_ecrs_lib.h
===================================================================
--- GNUnet/src/include/gnunet_ecrs_lib.h 2005-02-01 04:48:09 UTC (rev
142)
+++ GNUnet/src/include/gnunet_ecrs_lib.h 2005-02-01 10:35:23 UTC (rev
143)
@@ -169,6 +169,12 @@
*/
int ECRS_isDirectory(struct ECRS_MetaData * md);
+/**
+ * Suggest a better filename for a file (and do the
+ * renaming).
+ */
+char * ECRS_suggestFilename(const char * filename);
+
/* ******************** URI (uri.c) ************************ */
/**
Modified: GNUnet/todo
===================================================================
--- GNUnet/todo 2005-02-01 04:48:09 UTC (rev 142)
+++ GNUnet/todo 2005-02-01 10:35:23 UTC (rev 143)
@@ -7,8 +7,6 @@
- 593???
0.7.0pre0 [4'05] (aka "preview"):
-- complete gnunet-afs-tools:
- * download - COMPILES
- Missing Features:
* fs/module/fs+migration: anonymity level and expiration time considerations
(Christian)
* gap: economy for local queries, forwardQuery dead?, anonymityLevel
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r143 - in GNUnet: . doc/man src/applications/fs/ecrs src/applications/fs/tools src/include,
grothoff <=