2009-10-27 06:16:00 +05:30
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2009-10-30 16:47:26 +05:30
|
|
|
#include <string.h>
|
2009-10-27 06:16:00 +05:30
|
|
|
#include <xbps_api.h>
|
2009-10-30 16:47:26 +05:30
|
|
|
#include "fetch.h"
|
|
|
|
|
|
|
|
static void
|
|
|
|
usage(void)
|
|
|
|
{
|
|
|
|
printf("usage: xbps-fetch [-v] URL\n");
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
2009-10-27 06:16:00 +05:30
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
2009-10-30 16:47:26 +05:30
|
|
|
char flags[8];
|
|
|
|
int c, rv = 0;
|
2009-10-30 07:43:03 +05:30
|
|
|
|
2009-10-30 16:47:26 +05:30
|
|
|
while ((c = getopt(argc, argv, "v")) != -1) {
|
|
|
|
switch (c) {
|
|
|
|
case 'v':
|
|
|
|
strcat(flags, "v");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
usage();
|
|
|
|
}
|
2009-10-27 06:16:00 +05:30
|
|
|
}
|
2009-10-30 16:47:26 +05:30
|
|
|
argc -= optind;
|
|
|
|
argv += optind;
|
|
|
|
|
|
|
|
if (argc != 1)
|
|
|
|
usage();
|
2009-10-27 06:16:00 +05:30
|
|
|
|
2009-11-18 11:58:14 +05:30
|
|
|
rv = xbps_fetch_file(argv[0], ".", false, flags);
|
2009-10-30 07:43:03 +05:30
|
|
|
if (rv != 0) {
|
2009-10-30 16:47:26 +05:30
|
|
|
printf("%s: %s\n", argv[0], xbps_fetch_error_string());
|
2009-10-30 07:43:03 +05:30
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
exit(EXIT_SUCCESS);
|
2009-10-27 06:16:00 +05:30
|
|
|
}
|