Commit Graph

21 Commits

Author SHA1 Message Date
martin 007d27feeb Introduce sc_ctx_log_to_file to set the debug file of libopensc.
On Windows every DLL has their own file descriptor table, thus specifying
-v from any of the OpenSC tools resulted in a crash when the tool tried to override
ctx->debug_file with stderr.

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5359 c6295689-39f2-0310-b995-f0e70906c6a9
2011-04-18 10:01:27 +00:00
martin 4dde0476b1 Fix some of the spelling errors in westcos-tool man page and utility, triggered by lintian
I: opensc: spelling-error-in-manpage usr/share/man/man1/westcos-tool.1.gz authentification authentication
I: opensc: spelling-error-in-binary ./usr/bin/westcos-tool attemps attempts

Make text in westcos-tool manpage more readable, harmonize PIN/PUK capitalization.

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5242 c6295689-39f2-0310-b995-f0e70906c6a9
2011-03-20 13:17:29 +00:00
vtarasov a576582701 libioensc: use 'struct sc_atr' instead of 'u8 *atr, size_t atr_len'
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5061 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-07 17:18:58 +00:00
martin 6a750e6cc0 tools: -v sets ctx->debug only if set more than once. -vv also makes the debug go to stderr.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4818 c6295689-39f2-0310-b995-f0e70906c6a9
2010-10-20 07:53:19 +00:00
ludovic.rousseau f47416d60e Do not cast the return value of malloc(3) and calloc(3)
From http://en.wikipedia.org/wiki/Malloc#Casting_and_type_safety
" Casting and type safety

malloc returns a void pointer (void *), which indicates that it is a
pointer to a region of unknown data type. One may "cast" (see type
conversion) this pointer to a specific type, as in

int *ptr = (int*)malloc(10 * sizeof (int));

When using C, this is considered bad practice; it is redundant under the
C standard. Moreover, putting in a cast may mask failure to include the
header stdlib.h, in which the prototype for malloc is found. In the
absence of a prototype for malloc, the C compiler will assume that
malloc returns an int, and will issue a warning in a context such as the
above, provided the error is not masked by a cast. On certain
architectures and data models (such as LP64 on 64 bit systems, where
long and pointers are 64 bit and int is 32 bit), this error can actually
result in undefined behavior, as the implicitly declared malloc returns
a 32 bit value whereas the actually defined function returns a 64 bit
value. Depending on calling conventions and memory layout, this may
result in stack smashing.

The returned pointer need not be explicitly cast to a more specific
pointer type, since ANSI C defines an implicit conversion between the
void pointer type and other pointers to objects. An explicit cast of
malloc's return value is sometimes performed because malloc originally
returned a char *, but this cast is unnecessary in standard C
code.[4][5] Omitting the cast, however, creates an incompatibility with
C++, which does require it.

The lack of a specific pointer type returned from malloc is type-unsafe
behaviour: malloc allocates based on byte count but not on type. This
distinguishes it from the C++ new operator that returns a pointer whose
type relies on the operand. (see C Type Safety). "

See also
http://www.opensc-project.org/pipermail/opensc-devel/2010-August/014586.html


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4636 c6295689-39f2-0310-b995-f0e70906c6a9
2010-08-18 15:08:51 +00:00
martin df64d39f68 westcos-tool: remove compiler warnings
westcos-tool.c: In function ‘main’:
westcos-tool.c:375: warning: unused variable ‘lecteur’
westcos-tool.c:373: warning: unused variable ‘card_presente’
westcos-tool.c:372: warning: unused variable ‘p’
westcos-tool.c:371: warning: unused variable ‘i’
westcos-tool.c: At top level:
westcos-tool.c:43: warning: ‘version’ defined but not used
westcos-tool.c:45: warning: ‘nom_card’ defined but not used
westcos-tool.c:103: warning: ‘no_lecteur’ defined but not used

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4420 c6295689-39f2-0310-b995-f0e70906c6a9
2010-06-16 14:11:39 +00:00
martin 3cfc64ee6b style: // -> /* */
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4412 c6295689-39f2-0310-b995-f0e70906c6a9
2010-06-11 07:35:45 +00:00
flc 5ae92ebcec clean some code and use more opensc standard
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4336 c6295689-39f2-0310-b995-f0e70906c6a9
2010-05-11 14:34:39 +00:00
martin 349b31ecf3 westcos-tool: fix header, the file is .c not .exe
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4230 c6295689-39f2-0310-b995-f0e70906c6a9
2010-04-13 11:29:37 +00:00
ludovic.rousseau 0c60be861c Use a "const char *" to store a const C-string ptr.
Fix
westcos-tool.c:41: warning: initialization discards qualifiers from pointer target type
westcos-tool.c:43: warning: initialization discards qualifiers from pointer target type


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4168 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-28 19:57:24 +00:00
ludovic.rousseau 2b57feadf2 Use a temporary variable to not lose negative values (errors)
Fix
westcos-tool.c:591: warning: comparison of unsigned expression < 0 is always false
westcos-tool.c:615: warning: comparison of unsigned expression < 0 is always false


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4166 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-28 16:15:26 +00:00
ludovic.rousseau 9b73e45a07 Fix westcos-tool.c:322: warning: no previous prototype for ‘usage’
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4146 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-28 08:33:14 +00:00
aj 6545b42c02 cleanup of the debug code:
* reduce to a few, supported functions.
* change all functions to take the debug level as parameter.
* use symbolic names for the debug levels.
* fix tools to pass "verbose"/"opt_debug" as ctx->debug.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4118 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-15 12:17:13 +00:00
aj d22a2483c0 Header file cleanup.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4081 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-04 08:14:36 +00:00
flc 7a48d4a6f2 add support for westcos card with crypto component and minor renames to westcos-tool
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4072 c6295689-39f2-0310-b995-f0e70906c6a9
2010-02-25 15:16:23 +00:00
martin 5a0cc50123 tools: remove slots; implement change in sc_disconnect_card(); convert util_connect_card()/--wait to support the changes in r3931
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3933 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-24 15:29:47 +00:00
martin 2dfbf4f934 Fix compiler warnings
git-svn-id: https://www.opensc-project.org/svnp/opensc/branches/martin/0.12@3837 c6295689-39f2-0310-b995-f0e70906c6a9
2009-11-13 11:21:58 +00:00
martin 30ab50600b Merged [3783:3794/trunk]
git-svn-id: https://www.opensc-project.org/svnp/opensc/branches/martin/0.12@3795 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-25 20:22:11 +00:00
martin 56fb57603b Merge [3758:3783/trunk]
git-svn-id: https://www.opensc-project.org/svnp/opensc/branches/martin/0.12@3785 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-22 09:18:16 +00:00
martin d672fde449 Remove sc_error and sc_ctx_suppress_errors_* in favor of sc_debug/fprintf
git-svn-id: https://www.opensc-project.org/svnp/opensc/branches/martin/0.12@3721 c6295689-39f2-0310-b995-f0e70906c6a9
2009-09-14 08:46:59 +00:00
martin d3201511c7 r3717:3719 from trunk
git-svn-id: https://www.opensc-project.org/svnp/opensc/branches/martin/0.12@3720 c6295689-39f2-0310-b995-f0e70906c6a9
2009-09-12 11:46:00 +00:00