Advertisement
Le_BuG63

base64.h

Sep 17th, 2013
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.39 KB | None | 0 0
  1. #ifndef __BASE64_H__
  2. #define __BASE64_H__
  3.  
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6.  
  7. static const char cb64[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  8. static const char cd64[]="|$$$}rstuvwxyz{$$$$$$$>?@ABCDEFGHIJKLMNOPQRSTUVW$$$$$$XYZ[\\]^_`abcdefghijklmnopq";
  9.  
  10. #define B64_SYNTAX_ERROR        1
  11. #define B64_FILE_ERROR          2
  12. #define B64_FILE_IO_ERROR       3
  13. #define B64_ERROR_OUT_CLOSE     4
  14. #define B64_LINE_SIZE_TO_MIN    5
  15. #define B64_SYNTAX_TOOMANYARGS  6
  16.  
  17. /*
  18. ** b64_message
  19. **
  20. ** Gather text messages in one place.
  21. **
  22. */
  23. #define B64_MAX_MESSAGES 7
  24. static char *b64_msgs[ B64_MAX_MESSAGES ] = {
  25.             "b64:000:Invalid Message Code.",
  26.             "b64:001:Syntax Error -- check help (-h) for usage.",
  27.             "b64:002:File Error Opening/Creating Files.",
  28.             "b64:003:File I/O Error -- Note: output file not removed.",
  29.             "b64:004:Error on output file close.",
  30.             "b64:005:linesize set to minimum.",
  31.             "b64:006:Syntax: Too many arguments."
  32. };
  33.  
  34. #define b64_message( ec ) ((ec > 0 && ec < B64_MAX_MESSAGES ) ? b64_msgs[ ec ] : b64_msgs[ 0 ])
  35.  
  36.  
  37. int encode( FILE *infile, FILE *outfile, int linesize );
  38. void decodeblock( unsigned char *in, unsigned char *out );
  39. int decode( FILE *infile, FILE *outfile );
  40. int b64( char opt, char *infilename, char *outfilename, int linesize );
  41.  
  42.  
  43. #endif /* __BASE_H__ */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement