libaacs | branch: master | npzacs <[email protected]> | Wed Oct 27 10:34:51 2010 +0300| [0ec210c11fc2e5850a929e61210fb07a804194dd] | committer: npzacs
examples: added libaacs_test > http://git.videolan.org/gitweb.cgi/libaacs.git/?a=commit;h=0ec210c11fc2e5850a929e61210fb07a804194dd --- src/examples/Makefile.am | 6 +++- src/examples/libaacs_test.c | 64 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletions(-) diff --git a/src/examples/Makefile.am b/src/examples/Makefile.am index 9027064..c8820a5 100644 --- a/src/examples/Makefile.am +++ b/src/examples/Makefile.am @@ -12,6 +12,10 @@ AACS_LIB = $(top_builddir)/src/libaacs.la PARSER_TEST_DEPENDENCIES=../keydbcfg-lexer.c ../keydbcfg-parser.c -noinst_PROGRAMS=parser_test +noinst_PROGRAMS=parser_test libaacs_test + parser_test_SOURCE=parser_test.c parser_test_LDADD = $(AACS_LIB) $(PARSER_TEST_DEPENDENCIES) + +libaacs_test_SOURCE=libaacs_test.c +libaacs_test_LDADD = $(AACS_LIB) diff --git a/src/examples/libaacs_test.c b/src/examples/libaacs_test.c new file mode 100644 index 0000000..f495676 --- /dev/null +++ b/src/examples/libaacs_test.c @@ -0,0 +1,64 @@ +/* + * This file is part of libaacs + * Copyright (C) 2010 npzacs + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * <http://www.gnu.org/licenses/>. + */ + +#include "libaacs/aacs.h" + +#include <stdio.h> +#include <stdlib.h> + +static const char *_hex2str(const uint8_t *s, unsigned n) +{ + static const char hex[] = "0123456789ABCDEF"; + static char *str = NULL; + + unsigned ii; + + str = realloc(str, n*2 + 1); + for (ii = 0; ii < n; ii++) { + str[2*ii] = hex[ s[ii] >> 4]; + str[2*ii + 1] = hex[ s[ii] & 0x07]; + } + str[ii] = 0; + + return str; +} + +int main (int argc, char **argv) +{ + if (argc < 2) { + fprintf(stderr, "Usage: %s <path-to-disc-root> [<path-to-config-file>]\n", argv[0]); + exit(EXIT_FAILURE); + } + + AACS *aacs = aacs_open(argv[1], argc > 2 ? argv[2] : NULL); + + if (!aacs) { + fprintf(stderr, "libaacs open failed.\n"); + exit(EXIT_FAILURE); + } + + printf("libaacs open succeed.\n"); + + const uint8_t *vid = aacs_get_vid(aacs); + printf("VID: %s\n", vid ? _hex2str(vid, 20) : "???"); + + aacs_close(aacs); + + return EXIT_SUCCESS; +} _______________________________________________ libaacs-devel mailing list [email protected] http://mailman.videolan.org/listinfo/libaacs-devel
