Resurrected native codesetslib from r27301
[cake.git] / workbench / libs / codesetslib / developer / examples / b64e.c
bloba8e776fba289382db9c7361284ed3dd688b0e5d8
1 /***************************************************************************
3 codesets.library - Amiga shared library for handling different codesets
4 Copyright (C) 2001-2005 by Alfonso [alfie] Ranieri <alforan@tin.it>.
5 Copyright (C) 2005-2007 by codesets.library Open Source Team
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 codesets.library project: http://sourceforge.net/projects/codesetslib/
19 Most of the code included in this file was relicensed from GPL to LGPL
20 from the source code of SimpleMail (http://www.sf.net/projects/simplemail)
21 with full permissions by its authors.
23 $Id$
25 ***************************************************************************/
27 #include <proto/exec.h>
28 #include <proto/codesets.h>
29 #include <stdio.h>
30 #include <string.h>
32 struct Library *CodesetsBase = NULL;
33 #if defined(__amigaos4__)
34 struct CodesetsIFace* ICodesets = NULL;
35 #endif
37 #if defined(__amigaos4__)
38 #define GETINTERFACE(iface, base) (iface = (APTR)GetInterface((struct Library *)(base), "main", 1L, NULL))
39 #define DROPINTERFACE(iface) (DropInterface((struct Interface *)iface), iface = NULL)
40 #else
41 #define GETINTERFACE(iface, base) TRUE
42 #define DROPINTERFACE(iface)
43 #endif
45 int main(int argc,char **argv)
47 int res;
49 if (argc==3)
51 if((CodesetsBase = OpenLibrary(CODESETSNAME,CODESETSVER)) &&
52 GETINTERFACE(ICodesets, CodesetsBase))
54 ULONG r;
56 r = CodesetsEncodeB64(CSA_B64SourceFile, argv[1],
57 CSA_B64DestFile, argv[2],
58 TAG_DONE);
59 printf("Res %ld\n",r);
61 DROPINTERFACE(ICodesets);
62 CloseLibrary(CodesetsBase);
63 CodesetsBase = NULL;
65 res = 0;
67 else
69 printf("can't open %s %d+\n",CODESETSNAME,CODESETSVER);
70 res = 20;
73 else
75 printf("Usage: b64e <in_file> <out_file>\n");
76 res = 10;
79 return res;