improved "get" function:

- path is now by default like 3F00_5015_5031 instead of "3F00"
 - the final message shows not only number of bytes but also the filename.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1087 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
aj 2003-05-02 14:57:44 +00:00
parent 782f5d39e6
commit a58e5e5d19
1 changed files with 10 additions and 3 deletions

View File

@ -788,6 +788,7 @@ usage:
int do_get(int argc, char **argv) int do_get(int argc, char **argv)
{ {
u8 buf[256]; u8 buf[256];
u8 fbuf[256];
int r, error = 0; int r, error = 0;
size_t count = 0; size_t count = 0;
unsigned int idx = 0; unsigned int idx = 0;
@ -803,8 +804,13 @@ int do_get(int argc, char **argv)
if (argc == 2) if (argc == 2)
filename = argv[1]; filename = argv[1];
else { else {
sprintf((char *) buf, "%02X%02X", path.value[0], path.value[1]); int i = 0;
filename = (char *) buf; while (2*i < path.len) {
sprintf(&fbuf[5*i], "%02X%02X_", path.value[2*i], path.value[2*i+1]);
i++;
}
fbuf[5*i-1] = 0;
filename =(char *) &fbuf;
} }
outf = fopen(filename, "w"); outf = fopen(filename, "w");
if (outf == NULL) { if (outf == NULL) {
@ -840,7 +846,8 @@ int do_get(int argc, char **argv)
idx += c; idx += c;
count -= c; count -= c;
} }
printf("Total of %d bytes read.\n", idx); printf("Total of %d bytes read from %s and saved to %s.\n",
idx, argv[0], filename);
err: err:
sc_file_free(file); sc_file_free(file);
r = sc_select_file(card, &current_path, NULL); r = sc_select_file(card, &current_path, NULL);