source: roaraudio/roarclients/pgptest.c @ 5546:faff3e9677c4

Last change on this file since 5546:faff3e9677c4 was 5381:430b1d26e12d, checked in by phi, 12 years ago

updated copyright years

File size: 2.0 KB
Line 
1//pgptest.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2012
5 *
6 *  This file is part of roarclients a part of RoarAudio,
7 *  a cross-platform sound system for both, home and professional use.
8 *  See README for details.
9 *
10 *  This file is free software; you can redistribute it and/or modify
11 *  it under the terms of the GNU General Public License version 3
12 *  as published by the Free Software Foundation.
13 *
14 *  RoarAudio is distributed in the hope that it will be useful,
15 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 *  GNU General Public License for more details.
18 *
19 *  You should have received a copy of the GNU General Public License
20 *  along with this software; see the file COPYING.  If not, write to
21 *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
22 *  Boston, MA 02110-1301, USA.
23 *
24 */
25
26#include <roaraudio.h>
27
28#define BUF_MAX 1024
29#define FILENAME "/tmp/bla.asc"
30#define PASSWORD "test"
31#define STRING   "Hello world!\n"
32
33int main (void) {
34 char buf[BUF_MAX];
35 size_t len;
36 struct roar_vio_calls file, pgp;
37
38 if ( roar_vio_open_file(&file, FILENAME, O_CREAT|O_TRUNC|O_WRONLY, 0666) == -1 ) {
39  ROAR_ERR("roar_vio_open_file(&file, FILENAME, O_CREAT|O_TRUNC|O_WRONLY, 0666) = -1");
40  return 1;
41 }
42
43 if ( roar_vio_open_pgp_encrypt_sym(&pgp, &file, PASSWORD, ROAR_VIO_PGP_OPTS_ASCII) == -1 ) {
44  ROAR_ERR("roar_vio_open_pgp_encrypt_sym(&pgp, &file, PASSWORD, ROAR_VIO_PGP_OPTS_ASCII) = -1");
45  return 1;
46 }
47
48 roar_vio_write(&pgp, STRING, strlen(STRING));
49
50 roar_vio_close(&pgp);
51
52
53 if ( roar_vio_open_file(&file, FILENAME, O_RDONLY, 0666) == -1 ) {
54  ROAR_ERR("roar_vio_open_file(&file, FILENAME, O_RDONLY, 0666) = -1");
55  return 1;
56 }
57
58 if ( roar_vio_open_pgp_decrypt(&pgp, &file, PASSWORD) == -1 ) {
59  ROAR_ERR("roar_vio_open_pgp_decrypt(&pgp, &file, PASSWORD) = -1");
60  return 1;
61 }
62
63 while ((len = roar_vio_read(&pgp, buf, BUF_MAX)))
64  write(ROAR_STDOUT, buf, len);
65
66 roar_vio_close(&pgp);
67
68 return 0;
69}
70
71//ll
Note: See TracBrowser for help on using the repository browser.