cgroggs-int.h

00001 /*
00002  * This file is part of Cgroggs.
00003  * Copyright (C) 2008 Richard Kettlewell
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful, but
00011  * WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00018  * USA
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 /* State for a cgroggs_handle */
00038 struct cgroggs_data {
00039   FILE *in, *out;                       /* streams to read/write */
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 /* Invoke X and goto error if it returns non-0 */
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 /* For md5.c */
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 /* INTERNAL_H */
00103 
00104 /*
00105 Local Variables:
00106 c-basic-offset:2
00107 comment-column:40
00108 fill-column:79
00109 indent-tabs-mode:nil
00110 End:
00111 */

Generated on Sat Jan 26 15:15:06 2008 for Cgroggs by  doxygen 1.4.6