00001
00002 #include <errno.h>
00003 #include <stdio.h>
00004 #include <string.h>
00005 #include <stdlib.h>
00006 #include <fcntl.h>
00007 #include <getopt.h>
00008 #if defined(_WIN32)
00009 #include <io.h>
00010 #else
00011 #include <unistd.h>
00012 #endif
00013 #include "../src/securestorage.h"
00014
00015 extern int errno;
00016
00017
00018 int main (int argc, char *argv[]) {
00019
00020 int c;
00021 int aflag=0;
00022 char *se=NULL;
00023 char *lfn=NULL;
00024 static struct option longopts[] = {
00025 {"help", no_argument, 0, 'H'},
00026 {"se", no_argument, 0, 'S'},
00027 {0, 0, 0, 0}
00028 };
00029
00030 opterr = 0;
00031 while ((c = getopt_long (argc, argv, "ahs:", longopts, NULL)) != EOF) {
00032 switch (c) {
00033 case 'a':
00034 aflag = 1;
00035 break;
00036 case 'h':
00037 fprintf(stdout,"Usage: %s [-a | -s SE] <lfn>\n",argv[0]);
00038 break;
00039 case 'H':
00040 fprintf(stdout,"Usage: %s [-a | -s SE] <lfn>\n",argv[0]);
00041 break;
00042 case 's':
00043 se = optarg;
00044 break;
00045 case 'S':
00046 se = optarg;
00047 break;
00048 case '?':
00049 fprintf(stdout,"Usage: %s [-a | -s SE] <lfn>\n",argv[0]);
00050 break;
00051 default:
00052 break;
00053 }
00054 }
00055 lfn = argv[optind];
00056 if (lfn==NULL) {
00057 fprintf(stdout,"Usage: %s [-a | -s SE] <lfn>\n",argv[0]);
00058 exit(1);
00059 }
00060 if ( securestorage_del ( lfn, aflag, se ) < 0 ) {
00061 int errno_save = errno;
00062 fprintf(stderr, "securestorage_del: %s\n", securestorage_error(errno_save));
00063 exit(1);
00064 }
00065
00066 exit (0);
00067 }