EmuProxyZA / base64.c

From TivoZA

Back to emuProxyZA.
Download source (You will need to rename it to: base64.c)

To update the below source file, select Upload file and upload your new base64.c file (there is no need to upload it as a .txt). If you do upload a new version, please add a brief description to the change log at the bottom of this page indicating what changes you made and why.

Source

  1. /*
  2. * base64.c
  3. *
  4. * Base64 encoding/decoding command line filter
  5. * http://www.rtner.de/software/base64.html
  6. *
  7. * Copyright (c) 2002 Matthias Gaertner 29.06.2002
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program 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 program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. */
  23.  
  24. /*
  25. * Small dedicated Base64 encoder and decoder for the command line.
  26. *
  27. * Usage examples:
  28. *
  29. * Encode CRL file to Base64 on stdout
  30. * base64 foo.crl
  31. * base64 -e foo.crl
  32. * base64 -in foo.crl
  33. * base64 -e -in foo.crl
  34. *
  35. * Encode certificate file to PEM-ish Base64 output file foo.pem
  36. * base64 -E "CERTIFICATE" foo.crt foo.pem
  37. *
  38. * Encode file, output no line breaks in Base64 area. Not recommended with -E.
  39. * base64 -n 0 foo.crt
  40. *
  41. * Encode file, maximum number of characters per line is 32.
  42. * base64 -n 32 foo.crt
  43. *
  44. * Decode file to output file
  45. * base64 -d foo.pem foo.crt
  46. * base64 -d -i foo.pem foo.crt
  47. * base64 -d -i foo.pem -o foo.crt
  48. *
  49. * Decode file and pipe to next program
  50. * base64 -d foo.pem | md5sum
  51. * ls / | base64 | base64 -d
  52. *
  53. * Invoke as b642bin: decoding is the default.
  54. * b642bin foo.pem foo.bin
  55. *
  56. * Note: when decoding, this decoder ignores all non-Base64 caharcters.
  57. * After a hyphen (-) all characters are ignored up to the next \n.
  58. * The first non-ignored equals sign (=) indicates the end of b64 data.
  59. */
  60.  
  61. /*
  62. * Installation:
  63. * Simply compile with
  64. * gcc -O2 -o base64 base64.c
  65. * then install the executable somewhere on your PATH.
  66. * Optionally, make a symbolic link to it under the name b642bin
  67. * ln -s base64 b642bin
  68. *
  69. * De-installation:
  70. * Remove the installade program and the optional link.
  71. *
  72. * Other files are neither needed nor created.
  73. */
  74.  
  75. #include <stdio.h>
  76. #include <string.h>
  77. #include <stdlib.h>
  78.  
  79. #ifdef WIN32
  80. #ifndef _WIN32
  81. #define _WIN32 1
  82. #endif
  83. #endif
  84.  
  85. #ifdef _WIN32
  86. #include <io.h>
  87. #include <fcntl.h>
  88. #endif
  89.  
  90.  
  91. #ifdef _WIN32
  92. #define STRCMP strcmp
  93. #define USE_CRLF 1
  94. #else
  95. #define STRCMP strcmp
  96. #define USE_LF 1
  97. #endif
  98.  
  99. #ifndef TRUE
  100. #define TRUE 1
  101. #endif
  102. #ifndef FALSE
  103. #define FALSE 0
  104. #endif
  105. #ifndef NULL
  106. #define NULL ((void*)0)
  107. #endif
  108.  
  109.  
  110. #define B64_OK 0
  111. #define B64_ERR_CMDLINE 1
  112. #define B64_ERR_INPUT 2
  113. #define B64_ERR_OUTPUT 3
  114. #define B64_ERR_MEMORY 4
  115. #define B64_ERR_READING 5
  116. #define B64_ERR_WRITING 6
  117. #define B64_ERR_SYNTAX 7
  118.  
  119. #define ENCODE_BUFFER_SIZE_IN (8192*3)
  120. #define ENCODE_BUFFER_SIZE_OUT (8192*6)
  121.  
  122. #define DECODE_BUFFER_SIZE_IN (8192*4)
  123. #define DECODE_BUFFER_SIZE_OUT (8192*3)
  124.  
  125.  
  126. /* Option variables */
  127. static int g_fDecode = FALSE;
  128. static int g_fUseCRLF = FALSE;
  129.  
  130. static char *g_pszFilenameIn = NULL;
  131. static FILE *g_fIn = NULL;
  132.  
  133. static char *g_pszFilenameOut = NULL;
  134. static FILE *g_fOut = NULL;
  135.  
  136. static char *g_pszCharsPerLine = NULL;
  137. static unsigned int g_nCharsPerLine = 64;
  138.  
  139. static char *g_pszHeaderLine = NULL;
  140. static unsigned int g_nHeaderLine = 0;
  141.  
  142.  
  143. static void help( void )
  144. {
  145. fprintf(stderr,"Base64 [options] [input file] [output file]\n");
  146. fprintf(stderr," options are:\n");
  147. fprintf(stderr," -i <filename> input file (default: stdin)\n");
  148. fprintf(stderr," -o <filename> output file (default: stdout)\n");
  149. fprintf(stderr," -e encode binary to Base64 (default)\n");
  150. fprintf(stderr," -d decode Base64 to binary\n");
  151. fprintf(stderr," -n <n> encode n characters per line (0:no line breaks,default:64)\n");
  152. fprintf(stderr," -E <STRING> encode and put -----BEGIN/END <STRING>----- around output\n");
  153. fprintf(stderr," -- indicate end of options\n");
  154. fprintf(stderr,"Call as b642bin to preselect decoding\n");
  155. fprintf(stderr,"(c) Matthias Gaertner 2002 - v1.00\n\n");
  156. fprintf(stderr,"This program is distributed in the hope that it will be useful,\n");
  157. fprintf(stderr,"but WITHOUT ANY WARRANTY; without even the implied warranty of\n");
  158. fprintf(stderr,"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n");
  159. fprintf(stderr,"GNU General Public License for more details.\n");
  160. }
  161.  
  162. static int parseCmdLine( int argc, char **argv )
  163. {
  164. int r = B64_OK;
  165. int n = 1;
  166. int z = 0; // 0: normal, 1: 2nd argument expected,
  167. // 4: end of params detected (--)
  168. char **ppSecondArg = NULL;
  169.  
  170. while( n < argc )
  171. {
  172. if( z == 4 )
  173. {
  174. if( g_pszFilenameIn == NULL )
  175. {
  176. g_pszFilenameIn = argv[n];
  177. }
  178. else if( g_pszFilenameIn != NULL && g_pszFilenameOut == NULL )
  179. {
  180. g_pszFilenameOut = argv[n];
  181. }
  182. }
  183. else if( z > 0 )
  184. {
  185. *ppSecondArg = argv[n];
  186. if( z == 2 )
  187. {
  188. // decode bytes per line
  189. char *p = *ppSecondArg;
  190. g_nCharsPerLine = 0;
  191. while( *p >= '0' && *p <= '9' )
  192. {
  193. g_nCharsPerLine = (g_nCharsPerLine*10)+(*p-'0');
  194. p++;
  195. }
  196. if( *p != '\0' || p == *ppSecondArg )
  197. {
  198. r = B64_ERR_CMDLINE;
  199. break;
  200. }
  201. if( g_nCharsPerLine > 0 && g_nCharsPerLine < 4 )
  202. {
  203. g_nCharsPerLine = 4;
  204. }
  205. }
  206. if( z == 3 )
  207. {
  208. g_nHeaderLine = strlen( *ppSecondArg );
  209. }
  210. z = 0;
  211. }
  212. else if( STRCMP( argv[n], "-?" ) == 0 )
  213. {
  214. help();
  215. r = B64_ERR_CMDLINE;
  216. break;
  217. }
  218. else if( STRCMP( argv[n], "--help" ) == 0 )
  219. {
  220. help();
  221. r = B64_ERR_CMDLINE;
  222. break;
  223. }
  224. else if( STRCMP( argv[n], "-i" ) == 0 )
  225. {
  226. z=1;
  227. ppSecondArg = &g_pszFilenameIn;
  228. }
  229. else if( STRCMP( argv[n], "-o" ) == 0 )
  230. {
  231. z=1;
  232. ppSecondArg = &g_pszFilenameOut;
  233. }
  234. else if( STRCMP( argv[n], "-e" ) == 0 )
  235. {
  236. g_fDecode = FALSE;
  237. }
  238. else if( STRCMP( argv[n], "-E" ) == 0 )
  239. {
  240. g_fDecode = FALSE;
  241. z = 3;
  242. ppSecondArg = &g_pszHeaderLine;
  243. }
  244. else if( STRCMP( argv[n], "-d" ) == 0 )
  245. {
  246. g_fDecode = TRUE;
  247. }
  248. else if( STRCMP( argv[n], "-n" ) == 0 )
  249. {
  250. z = 2;
  251. ppSecondArg = &g_pszCharsPerLine;
  252. }
  253. else if( STRCMP( argv[n], "--" ) == 0 )
  254. {
  255. z = 4;
  256. }
  257. else if( argv[n][0] == '-' )
  258. {
  259. help();
  260. r = B64_ERR_CMDLINE;
  261. break;
  262. }
  263. else if( g_pszFilenameIn == NULL )
  264. {
  265. g_pszFilenameIn = argv[n];
  266. }
  267. else if( g_pszFilenameIn != NULL && g_pszFilenameOut == NULL )
  268. {
  269. g_pszFilenameOut = argv[n];
  270. }
  271. else
  272. {
  273. help();
  274. r = B64_ERR_CMDLINE;
  275. break;
  276. }
  277. n++;
  278. }
  279. if( z > 0 )
  280. {
  281. r = B64_ERR_CMDLINE;
  282. }
  283. return r;
  284. }
  285.  
  286. static int openFiles()
  287. {
  288. if( g_pszFilenameIn != NULL )
  289. {
  290. g_fIn = fopen( g_pszFilenameIn, "rb" );
  291. if( g_fIn == NULL )
  292. {
  293. return B64_ERR_INPUT;
  294. }
  295. }
  296. else
  297. {
  298. g_fIn = stdin;
  299. #ifdef WIN32
  300. _setmode(fileno(stdin), _O_BINARY);
  301. #endif
  302. }
  303.  
  304. if( g_pszFilenameOut != NULL )
  305. {
  306. g_fOut = fopen( g_pszFilenameOut, "wb" );
  307. if( g_fOut == NULL )
  308. {
  309. return B64_ERR_OUTPUT;
  310. }
  311. }
  312. else
  313. {
  314. g_fOut = stdout;
  315. #ifdef WIN32
  316. setmode(fileno(stdout), O_BINARY);
  317. #endif
  318. }
  319.  
  320. return B64_OK;
  321. }
  322.  
  323. static void closeFiles( int r )
  324. {
  325. if( g_fIn != NULL && g_pszFilenameIn != NULL )
  326. {
  327. fclose(g_fIn);
  328. g_fIn = NULL;
  329. }
  330.  
  331. if( g_fOut != NULL && g_pszFilenameOut != NULL )
  332. {
  333. fclose(g_fOut);
  334. g_fOut = NULL;
  335. if( r != B64_OK )
  336. {
  337. unlink( g_pszFilenameOut );
  338. }
  339. }
  340. }
  341.  
  342. static const char* to_b64 =
  343. "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  344.  
  345.  
  346. static int encodeB64(unsigned char* pIn, char *pbBufferOut, unsigned long nRem)
  347. {
  348. unsigned long nDiv = 0;
  349. //unsigned long nRem = 0;
  350. unsigned long nChars = 0;
  351. //unsigned char* pIn; // = (unsigned char*) pbBufferIn;
  352.  
  353. unsigned int nOut = 0;
  354.  
  355. size_t nRead = strlen(pIn); //???
  356.  
  357. nDiv = ((unsigned long)nRead) / 3;
  358. nRem = ((unsigned long)nRead) % 3;
  359. nChars = 0;
  360.  
  361. while( nDiv > 0 )
  362. {
  363. pbBufferOut[nOut+0] = to_b64[ (pIn[0] >> 2) & 0x3f];
  364. pbBufferOut[nOut+1] = to_b64[((pIn[0] << 4) & 0x30) + ((pIn[1] >> 4) & 0xf)];
  365. pbBufferOut[nOut+2] = to_b64[((pIn[1] << 2) & 0x3c) + ((pIn[2] >> 6) & 0x3)];
  366. pbBufferOut[nOut+3] = to_b64[ pIn[2] & 0x3f];
  367. pIn += 3;
  368. nOut += 4;
  369. nDiv--;
  370. nChars += 4;
  371. if( nChars >= g_nCharsPerLine && g_nCharsPerLine != 0 )
  372. {
  373. nChars = 0;
  374. if( g_fUseCRLF )
  375. {
  376. pbBufferOut[nOut++] = '\r';
  377. }
  378. pbBufferOut[nOut++] = '\n';
  379. }
  380. }
  381.  
  382. switch( nRem )
  383. {
  384. case 2:
  385. pbBufferOut[nOut+0] = to_b64[ (pIn[0] >> 2) & 0x3f];
  386. pbBufferOut[nOut+1] = to_b64[((pIn[0] << 4) & 0x30) + ((pIn[1] >> 4) & 0xf)];
  387. pbBufferOut[nOut+2] = to_b64[ (pIn[1] << 2) & 0x3c];
  388. pbBufferOut[nOut+3] = '=';
  389. nOut += 4;
  390. nChars += 4;
  391. if( nChars >= g_nCharsPerLine && g_nCharsPerLine != 0 )
  392. {
  393. nChars = 0;
  394. if( g_fUseCRLF )
  395. {
  396. pbBufferOut[nOut++] = '\r';
  397. }
  398. pbBufferOut[nOut++] = '\n';
  399. }
  400. break;
  401. case 1:
  402. pbBufferOut[nOut+0] = to_b64[ (pIn[0] >> 2) & 0x3f];
  403. pbBufferOut[nOut+1] = to_b64[ (pIn[0] << 4) & 0x30];
  404. pbBufferOut[nOut+2] = '=';
  405. pbBufferOut[nOut+3] = '=';
  406. nOut += 4;
  407. nChars += 4;
  408. if( nChars >= g_nCharsPerLine && g_nCharsPerLine != 0 )
  409. {
  410. nChars = 0;
  411. if( g_fUseCRLF )
  412. {
  413. pbBufferOut[nOut++] = '\r';
  414. }
  415. pbBufferOut[nOut++] = '\n';
  416. }
  417. break;
  418. }
  419.  
  420. /* if( nRem > 0 || feof( g_fIn ) )
  421. {
  422. if( nChars > 0 )
  423. {
  424. nChars = 0;
  425. if( g_fUseCRLF )
  426. {
  427. pbBufferOut[nOut++] = '\r';
  428. }
  429. pbBufferOut[nOut++] = '\n';
  430. }
  431. }*/
  432.  
  433. return nOut;
  434.  
  435. }
  436.  
  437.  
  438. static char *encodeB64str(const char* pbBufferIn)
  439. {
  440. char *pbBufferOut = (char*) malloc( ENCODE_BUFFER_SIZE_OUT );
  441.  
  442. // pbBufferOut = strdup(pbBufferIn);
  443.  
  444. // for(;;)
  445. {
  446. unsigned long nRem = 0;
  447. unsigned char* pIn = (unsigned char*) pbBufferIn;
  448. size_t nWritten = 0;
  449.  
  450. nWritten = encodeB64(pIn, pbBufferOut, nRem);
  451. /* if( nWritten > 0 )
  452. break;
  453. if( nRem > 0 || feof( g_fIn ) )
  454. break;*/
  455. }
  456.  
  457. return pbBufferOut;
  458. }
  459.  
  460. static int encodeB64file()
  461. {
  462. int r = B64_OK;
  463. char *pbBufferIn = (char*) malloc( ENCODE_BUFFER_SIZE_IN );
  464. char *pbBufferOut = (char*) malloc( ENCODE_BUFFER_SIZE_OUT );
  465.  
  466. for(;;)
  467. {
  468. if( pbBufferIn == NULL || pbBufferOut == NULL )
  469. {
  470. r = B64_ERR_MEMORY;
  471. break;
  472. }
  473.  
  474. if( g_nHeaderLine > 0 )
  475. {
  476. size_t n = fwrite( (void*)"-----BEGIN ", 1, 11, g_fOut );
  477. if( ferror( g_fOut ) || n < 11 )
  478. {
  479. r = B64_ERR_WRITING;
  480. break;
  481. }
  482. n = fwrite( (void*)g_pszHeaderLine, 1, g_nHeaderLine, g_fOut );
  483. if( ferror( g_fOut ) || n < g_nHeaderLine )
  484. {
  485. r = B64_ERR_WRITING;
  486. break;
  487. }
  488. n = fwrite( (void*)"-----", 1, 5, g_fOut );
  489. if( ferror( g_fOut ) || n < 5 )
  490. {
  491. r = B64_ERR_WRITING;
  492. break;
  493. }
  494. if( g_fUseCRLF )
  495. {
  496. n = fwrite( (void*)"\r", 1, 1, g_fOut );
  497. if( ferror( g_fOut ) || n < 1 )
  498. {
  499. r = B64_ERR_WRITING;
  500. break;
  501. }
  502. }
  503. n = fwrite( (void*)"\n", 1, 1, g_fOut );
  504. if( ferror( g_fOut ) || n < 1 )
  505. {
  506. r = B64_ERR_WRITING;
  507. break;
  508. }
  509. }
  510.  
  511. for(;;)
  512. {
  513. unsigned long nRem = 0;
  514. unsigned char* pIn = (unsigned char*) pbBufferIn;
  515. size_t nWritten = 0;
  516.  
  517. size_t nRead = fread( (void*)pIn, 1, ENCODE_BUFFER_SIZE_IN, g_fIn );
  518. if( ferror( g_fIn ) )
  519. {
  520. r = B64_ERR_READING;
  521. break;
  522. }
  523. if( nRead == 0 )
  524. {
  525. break;
  526. }
  527.  
  528. nWritten = encodeB64(pIn, pbBufferOut, nRem);
  529. if( nWritten > 0 )
  530. {
  531. size_t n = fwrite( (void*)pbBufferOut, 1, nWritten, g_fOut );
  532. if( ferror( g_fOut ) || n < nWritten )
  533. {
  534. r = B64_ERR_WRITING;
  535. break;
  536. }
  537. }
  538.  
  539. if( nRem > 0 || feof( g_fIn ) )
  540. {
  541. break;
  542. }
  543. }
  544. break;
  545. }
  546.  
  547. if( r == B64_OK )
  548. {
  549. while( g_nHeaderLine > 0 )
  550. {
  551. size_t n = fwrite( (void*)"-----END ", 1, 9, g_fOut );
  552. if( ferror( g_fOut ) || n < 9 )
  553. {
  554. r = B64_ERR_WRITING;
  555. break;
  556. }
  557. n = fwrite( (void*)g_pszHeaderLine, 1, g_nHeaderLine, g_fOut );
  558. if( ferror( g_fOut ) || n < g_nHeaderLine )
  559. {
  560. r = B64_ERR_WRITING;
  561. break;
  562. }
  563. n = fwrite( (void*)"-----", 1, 5, g_fOut );
  564. if( ferror( g_fOut ) || n < 5 )
  565. {
  566. r = B64_ERR_WRITING;
  567. break;
  568. }
  569. if( g_fUseCRLF )
  570. {
  571. n = fwrite( (void*)"\r", 1, 1, g_fOut );
  572. if( ferror( g_fOut ) || n < 1 )
  573. {
  574. r = B64_ERR_WRITING;
  575. break;
  576. }
  577. }
  578. n = fwrite( (void*)"\n", 1, 1, g_fOut );
  579. if( ferror( g_fOut ) || n < 1 )
  580. {
  581. r = B64_ERR_WRITING;
  582. break;
  583. }
  584. break;
  585. }
  586. }
  587.  
  588. if( pbBufferIn != NULL )
  589. {
  590. free( pbBufferIn );
  591. }
  592. if( pbBufferOut != NULL )
  593. {
  594. free( pbBufferOut );
  595. }
  596. return r;
  597. }
  598.  
  599. static int decodeB64file()
  600. {
  601. int r = B64_OK;
  602. int z = 0; // 0 Normal, 1 skip MIME separator (---) to end of line
  603. char c = '\0';
  604. unsigned char data[3];
  605. unsigned int nData = 0;
  606.  
  607. for(;;)
  608. {
  609. unsigned char bits = 'z';
  610. size_t nRead = fread( (void*)&c, 1, 1, g_fIn );
  611. if( ferror( g_fIn ) )
  612. {
  613. r = B64_ERR_READING;
  614. break;
  615. }
  616. if( nRead == 0 )
  617. {
  618. break;
  619. }
  620.  
  621. if( z > 0 )
  622. {
  623. if( c == '\n' )
  624. {
  625. z = 0;
  626. }
  627. }
  628. else if( c >= 'A' && c <= 'Z' )
  629. {
  630. bits = (unsigned char) (c - 'A');
  631. }
  632. else if( c >= 'a' && c <= 'z' )
  633. {
  634. bits = (unsigned char) (c - 'a' + (char)26);
  635. }
  636. else if( c >= '0' && c <= '9' )
  637. {
  638. bits = (unsigned char) (c - '0' + (char)52);
  639. }
  640. else if( c == '+' )
  641. {
  642. bits = (unsigned char) 62;
  643. }
  644. else if( c == '/' )
  645. {
  646. bits = (unsigned char) 63;
  647. }
  648. else if( c == '-' )
  649. {
  650. z = 1;
  651. }
  652. else if( c == '=' )
  653. {
  654. break;
  655. }
  656. else
  657. {
  658. bits = (unsigned char) 'y';
  659. }
  660.  
  661. if( bits < (unsigned char) 64 )
  662. {
  663. switch(nData++)
  664. {
  665. case 0:
  666. data[0] = (bits << 2) & 0xfc;
  667. break;
  668. case 1:
  669. data[0] |= (bits >> 4) & 0x03;
  670. data[1] = (bits << 4) & 0xf0;
  671. break;
  672. case 2:
  673. data[1] |= (bits >> 2) & 0x0f;
  674. data[2] = (bits << 6) & 0xc0;
  675. break;
  676. case 3:
  677. data[2] |= bits & 0x3f;
  678. break;
  679. }
  680.  
  681. if( nData == 4 )
  682. {
  683. size_t n = fwrite( (void*)data, 1, 3, g_fOut );
  684. if( ferror( g_fOut ) || n < 3 )
  685. {
  686. r = B64_ERR_WRITING;
  687. break;
  688. }
  689.  
  690. nData = 0;
  691. }
  692. }
  693.  
  694. if( feof( g_fIn ) )
  695. {
  696. break;
  697. }
  698. }
  699. if( r == B64_OK && nData > 0 )
  700. {
  701. if( nData == 1 )
  702. {
  703. r = B64_ERR_SYNTAX;
  704. }
  705. else
  706. {
  707. size_t n = fwrite( (void*)data, 1, nData-1, g_fOut );
  708. if( ferror( g_fOut ) || n < (nData-1) )
  709. {
  710. r = B64_ERR_WRITING;
  711. }
  712. }
  713. }
  714. return r;
  715. }
  716.  
  717. static void setOptionsFromProgname( char *fn )
  718. {
  719. #ifdef _WIN32
  720. char c = '\\';
  721. char *pn = "b642bin.exe";
  722. #else
  723. char c = '/';
  724. char *pn = "b642bin";
  725. #endif
  726.  
  727. char *p = strrchr( fn, c );
  728. if( p == NULL )
  729. {
  730. p = fn;
  731. }
  732. else
  733. {
  734. p++;
  735. }
  736. if( STRCMP( p, pn ) == 0 )
  737. {
  738. g_fDecode = TRUE;
  739. }
  740. }
  741.  
  742. /*
  743. int main( int argc, char ** argv )
  744. {
  745. int r = B64_OK;
  746. int nArgv = 1;
  747. for(;;)
  748. {
  749. #ifdef USE_CRLF
  750. g_fUseCRLF = TRUE;
  751. #endif
  752. setOptionsFromProgname( argv[0] );
  753. if( (r=parseCmdLine( argc, argv )) != 0 )
  754. {
  755. break;
  756. }
  757. if( (r=openFiles()) != 0 )
  758. {
  759. break;
  760. }
  761. if( g_fDecode != TRUE )
  762. {
  763. if( (r=encodeB64file()) != 0 )
  764. {
  765. break;
  766. }
  767. }
  768. else
  769. {
  770. if( (r=decodeB64file()) != 0 )
  771. {
  772. break;
  773. }
  774. }
  775. break;
  776. }
  777. closeFiles(r);
  778. return r;
  779. }
  780. */

Change Log

20 Oct 2006 - TivoZA: Uploaded the file

Advertisement