libkdenetwork Library API Documentation

assuan-defs.h

00001 /* assuan-defs.c - Internal definitions to Assuan 00002 * Copyright (C) 2001, 2002 Free Software Foundation, Inc. 00003 * 00004 * This file is part of Assuan. 00005 * 00006 * Assuan is free software; you can redistribute it and/or modify it 00007 * under the terms of the GNU Lesser General Public License as 00008 * published by the Free Software Foundation; either version 2.1 of 00009 * the License, or (at your option) any later version. 00010 * 00011 * Assuan is distributed in the hope that it will be useful, but 00012 * WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 00019 */ 00020 00021 #ifndef ASSUAN_DEFS_H 00022 #define ASSUAN_DEFS_H 00023 00024 #include <sys/types.h> 00025 #include <sys/socket.h> 00026 #include <sys/un.h> 00027 #include <unistd.h> 00028 00029 #include "assuan.h" 00030 00031 #define LINELENGTH ASSUAN_LINELENGTH 00032 00033 struct cmdtbl_s 00034 { 00035 const char *name; 00036 int (*handler)(ASSUAN_CONTEXT, char *line); 00037 }; 00038 00039 struct assuan_io 00040 { 00041 /* Routine to read from input_fd. */ 00042 ssize_t (*read) (ASSUAN_CONTEXT, void *, size_t); 00043 /* Routine to write to output_fd. */ 00044 ssize_t (*write) (ASSUAN_CONTEXT, const void *, size_t); 00045 /* Send a file descriptor. */ 00046 AssuanError (*sendfd) (ASSUAN_CONTEXT, int); 00047 /* Receive a file descriptor. */ 00048 AssuanError (*receivefd) (ASSUAN_CONTEXT, int *); 00049 }; 00050 00051 struct assuan_context_s 00052 { 00053 AssuanError err_no; 00054 const char *err_str; 00055 int os_errno; /* last system error number used with certain error codes*/ 00056 00057 int confidential; 00058 int is_server; /* set if this is context belongs to a server */ 00059 int in_inquire; 00060 char *hello_line; 00061 char *okay_line; /* see assan_set_okay_line() */ 00062 00063 void *user_pointer; /* for assuan_[gs]et_pointer () */ 00064 00065 FILE *log_fp; 00066 00067 struct { 00068 int fd; 00069 int eof; 00070 char line[LINELENGTH]; 00071 int linelen; /* w/o CR, LF - might not be the same as 00072 strlen(line) due to embedded nuls. However a nul 00073 is always written at this pos */ 00074 struct { 00075 char line[LINELENGTH]; 00076 int linelen ; 00077 int pending; /* i.e. at least one line is available in the attic */ 00078 } attic; 00079 } inbound; 00080 00081 struct { 00082 int fd; 00083 struct { 00084 FILE *fp; 00085 char line[LINELENGTH]; 00086 int linelen; 00087 int error; 00088 } data; 00089 } outbound; 00090 00091 int pipe_mode; /* We are in pipe mode, i.e. we can handle just one 00092 connection and must terminate then */ 00093 pid_t pid; /* In pipe mode, the pid of the child server process. 00094 In socket mode, the pid of the server */ 00095 int listen_fd; /* The fd we are listening on (used by socket servers) */ 00096 int connected_fd; /* helper */ 00097 00098 pid_t client_pid; /* for a socket server the PID of the client or -1 00099 if not available */ 00100 00101 /* Used for Unix domain sockets. */ 00102 struct sockaddr_un myaddr; 00103 struct sockaddr_un serveraddr; 00104 /* When reading from datagram sockets, we must read an entire 00105 message at a time. This means that we have to do our own 00106 buffering to be able to get the semantics of read. */ 00107 void *domainbuffer; 00108 /* Offset of start of buffer. */ 00109 int domainbufferoffset; 00110 /* Bytes buffered. */ 00111 int domainbuffersize; 00112 /* Memory allocated. */ 00113 int domainbufferallocated; 00114 00115 int *pendingfds; 00116 int pendingfdscount; 00117 00118 void (*deinit_handler)(ASSUAN_CONTEXT); 00119 int (*accept_handler)(ASSUAN_CONTEXT); 00120 int (*finish_handler)(ASSUAN_CONTEXT); 00121 00122 struct cmdtbl_s *cmdtbl; 00123 size_t cmdtbl_used; /* used entries */ 00124 size_t cmdtbl_size; /* allocated size of table */ 00125 00126 void (*bye_notify_fnc)(ASSUAN_CONTEXT); 00127 void (*reset_notify_fnc)(ASSUAN_CONTEXT); 00128 void (*cancel_notify_fnc)(ASSUAN_CONTEXT); 00129 int (*option_handler_fnc)(ASSUAN_CONTEXT,const char*, const char*); 00130 void (*input_notify_fnc)(ASSUAN_CONTEXT, const char *); 00131 void (*output_notify_fnc)(ASSUAN_CONTEXT, const char *); 00132 00133 int input_fd; /* set by INPUT command */ 00134 int output_fd; /* set by OUTPUT command */ 00135 00136 /* io routines. */ 00137 struct assuan_io *io; 00138 }; 00139 00140 /*-- assuan-pipe-server.c --*/ 00141 int _assuan_new_context (ASSUAN_CONTEXT *r_ctx); 00142 void _assuan_release_context (ASSUAN_CONTEXT ctx); 00143 00144 /*-- assuan-domain-connect.c --*/ 00145 /* Make a connection to the Unix domain socket NAME and return a new 00146 Assuan context in CTX. SERVER_PID is currently not used but may 00147 become handy in the future. */ 00148 AssuanError _assuan_domain_init (ASSUAN_CONTEXT *r_ctx, 00149 int rendezvousfd, 00150 pid_t peer); 00151 00152 /*-- assuan-handler.c --*/ 00153 int _assuan_register_std_commands (ASSUAN_CONTEXT ctx); 00154 00155 /*-- assuan-buffer.c --*/ 00156 int _assuan_read_line (ASSUAN_CONTEXT ctx); 00157 int _assuan_cookie_write_data (void *cookie, const char *buffer, size_t size); 00158 int _assuan_cookie_write_flush (void *cookie); 00159 00160 /*-- assuan-client.c --*/ 00161 AssuanError _assuan_read_from_server (ASSUAN_CONTEXT ctx, int *okay, int *off); 00162 00163 00164 /*-- assuan-util.c --*/ 00165 void *_assuan_malloc (size_t n); 00166 void *_assuan_calloc (size_t n, size_t m); 00167 void *_assuan_realloc (void *p, size_t n); 00168 void _assuan_free (void *p); 00169 00170 #define xtrymalloc(a) _assuan_malloc ((a)) 00171 #define xtrycalloc(a,b) _assuan_calloc ((a),(b)) 00172 #define xtryrealloc(a,b) _assuan_realloc((a),(b)) 00173 #define xfree(a) _assuan_free ((a)) 00174 00175 #define set_error(c,e,t) assuan_set_error ((c), ASSUAN_ ## e, (t)) 00176 00177 void _assuan_log_print_buffer (FILE *fp, const void *buffer, size_t length); 00178 void _assuan_log_sanitized_string (const char *string); 00179 00180 /*-- assuan-io.c --*/ 00181 ssize_t _assuan_simple_read (ASSUAN_CONTEXT ctx, void *buffer, size_t size); 00182 ssize_t _assuan_simple_write (ASSUAN_CONTEXT ctx, const void *buffer, 00183 size_t size); 00184 00185 #ifdef HAVE_FOPENCOOKIE 00186 /* We have to implement funopen in terms of glibc's fopencookie. */ 00187 FILE *funopen(const void *cookie, cookie_read_function_t *readfn, 00188 cookie_write_function_t *writefn, 00189 cookie_seek_function_t *seekfn, 00190 cookie_close_function_t *closefn); 00191 #endif /*HAVE_FOPENCOOKIE*/ 00192 00193 #endif /*ASSUAN_DEFS_H*/ 00194
KDE Logo
This file is part of the documentation for libkdenetwork Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Aug 27 12:48:39 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003