00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef INTERNAL_H
00022 #define INTERNAL_H
00023
00024 #include <config.h>
00025
00026 #include "cgroggs.h"
00027
00028 #include <stdlib.h>
00029 #include <stdio.h>
00030 #include <stdarg.h>
00031 #include <string.h>
00032 #include <time.h>
00033 #include <assert.h>
00034
00035 #include <inttypes.h>
00036
00037
00038 struct cgroggs_data {
00039 FILE *in, *out;
00040 char *host, *port;
00041 char *user, *secret;
00042 int want_level, got_level;
00043 int debug;
00044 };
00045
00046 #define DEBUG_READ 0x0001
00047 #define DEBUG_WRITE 0x0002
00048 #define DEBUG_CONN 0x0004
00049 #define DEBUG_AUTH 0x0008
00050
00051
00052 #define eg(X) do { \
00053 if((rc = X)) \
00054 goto error; \
00055 } while(0)
00056
00057 char *cgroggs__strdup(const char *s);
00058 cgroggs_error cgroggs__readline(cgroggs_handle c,
00059 char **linep,
00060 int *rcp);
00061 cgroggs_error cgroggs__writeline(cgroggs_handle c,
00062 const char *fmt,
00063 ...);
00064 cgroggs_error cgroggs__connect(cgroggs_handle c);
00065 cgroggs_error cgroggs__disconnect(cgroggs_handle c);
00066 int cgroggs__connected(cgroggs_handle c);
00067 int cgroggs__split(char *line,
00068 char **vec,
00069 int maxvec);
00070 cgroggs_error cgroggs__hex2bin(const char *hex,
00071 uint8_t *bin,
00072 size_t maxlen);
00073 char *cgroggs__bin2hex(char hex[],
00074 const uint8_t *bin,
00075 size_t nbytes);
00076 cgroggs_error cgroggs__utf8_to_wire(cgroggs_handle c,
00077 const char *utf,
00078 char **wirep);
00079 cgroggs_error cgroggs__wire_to_utf8(cgroggs_handle c,
00080 const char *wire,
00081 char **utfp);
00082 cgroggs_error cgroggs__getdata(cgroggs_handle c,
00083 char ***vecp,
00084 int *nvecp);
00085
00086 #define FREE(x) do { if(x) { cgroggs_free(x); x = 0; } } while(0)
00087
00088
00089 typedef struct cgroggs__MD5 {
00090 uint32_t buf[4];
00091 uint32_t bytes[2];
00092 uint32_t in[16];
00093 } cgroggs__MD5;
00094
00095 void cgroggs__MD5Init(cgroggs__MD5 *context);
00096 void cgroggs__MD5Update(cgroggs__MD5 *context,
00097 const void *buf, unsigned len);
00098 void cgroggs__MD5Final(cgroggs__MD5 *context,
00099 uint8_t digest[16]);
00100
00101
00102 #endif
00103
00104
00105
00106
00107
00108
00109
00110
00111