{\scriptsize \begin{lstlisting}
     1	/**
     2	   @file
     3	
     4	   Definitions for libcomm.
     5	*/
     6	
     7	/*
     8	  Copyright (c) Andreas Hofmeier
     9	  (www.an-h.de, www.an-h.de.vu, www.lgut.uni-bremen.de/an-h/)
    10	  
    11	  This program is free software; you can redistribute it and/or modify
    12	  it under the terms of the GNU General Public License as published by
    13	  the Free Software Foundation; either version 2 of the License, or
    14	  (at your option) any later version.
    15	
    16	  This program is distributed in the hope that it will be useful, but
    17	  WITHOUT ANY WARRANTY; without even the implied warranty of
    18	  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    19	  General Public License for more details.
    20	
    21	  You should have received a copy of the GNU General Public License
    22	  along with this program; if not, write to the Free Software
    23	  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    24	*/
    25	
    26	
    27	
    28	//#include "md5.h"
    29	#include <stdio.h>
    30	#include <sys/types.h>
    31	#include <sys/socket.h>
    32	#include <netinet/in.h>
    33	#include <arpa/inet.h>
    34	
    35	#define true 1
    36	#define false 0
    37	
    38	#ifndef nothread
    39	  #include <pthread.h>
    40	#endif
    41	
    42	// declaration
    43	
    44	// md5auth
    45	// the first authfile, which is fould will be used
    46	// first authfile. 
    47	#define authfile0 "./libcomm_md5auth.pwd"
    48	// second authfile
    49	#define authfile1 "/etc/libcomm_md5auth.pwd"
    50	// one char/byte which seperates the field in the authfile
    51	#define authfilefieldseperator ':'
    52	// maxinam lenght of a line in the authfile
    53	#define authfilemaxlinelenght 4096
    54	// how much random bytes are generated for the authentication
    55	#define authrandomstringsize (int) 16
    56	// Define the message-type for the auth blocks
    57	#define authmessagetype 65535
    58	
    59	// structure to stroe the authentication infromationen
    60	struct AUTHINFO {
    61	  // network name
    62	  char *netname;
    63	  // login name
    64	  char *name;
    65	  // login passwd
    66	  char *passwd;
    67	  // Key for encryption (not used yet)
    68	  char *keyencrypt;
    69	  // Key for decryption (not used yet)
    70	  char *keydecrypt;
    71	};
    72	
    73	int socket_md5auth(int fd, char *netname, char *name,
    74			   struct AUTHINFO **locallogin,
    75			   struct AUTHINFO **remotelogin);
    76	struct AUTHINFO *getauthinfo(char *netname, char *name);
    77	
    78	
    79	
    80	// socket_acceept
    81	#ifndef nothread
    82	struct LIBCOMMPTHREADP {
    83	  void (*socket_accept_do)(int fd, int id, char *pip,
    84				    struct sockaddr_in their_addr);
    85	
    86	  pthread_t        thrd_2;
    87	  pthread_attr_t   thrd_2_attr;
    88	  int              sockport;
    89	  int              id;
    90	};
    91	void socket_accept_thread(struct LIBCOMMPTHREADP *libcommpthreadp);
    92	int socket_accept(int sockport, int id,
    93		   void (*socket_accept_do)(int fd, int id, char *pip,
    94				    struct sockaddr_in their_addr));
    95	#endif
    96	
    97	
    98	// block_receive
    99	#ifndef nothread
   100	struct LIBCOMMPTHREADS {
   101	  void (*block_call_do)(int fd, int id, unsigned int type,
   102				char *buf, unsigned int size, int term);
   103	  void (*block_call_term)(int fd, int id);
   104	
   105	  pthread_t        thrd_1;
   106	  pthread_attr_t   thrd_1_attr;
   107	  int              fd;
   108	  int              id;
   109	  int              term;
   110	};
   111	void thread1(struct LIBCOMMPTHREADS *libcommpthreads);
   112	int block_call(int fd, int id, int term,
   113		   void (*block_call_do)(int fd, int id, unsigned int type,
   114					 char *buf, unsigned int size,
   115					 int term), 
   116		   void (*block_call_term)(int fd, int id));
   117	#endif
   118	char *block_receive_poll(int fd, unsigned int *type, char *buf,
   119				 unsigned int *size, unsigned int maxsize,
   120				 int term);
   121	char *block_receive(int fd, unsigned int *type, char *buf,
   122			    unsigned int *size, unsigned int maxsize,
   123			    int term);
   124	int block_receive_integer(int fd, unsigned int *recvi);
   125	int block_receive_nbytes(int fd, char *buf, int n);
   126	
   127	
   128	
   129	// block_send
   130	int block_send(int fd, unsigned int type, char *buf, unsigned int size);
   131	
   132	
   133	
   134	// block_random
   135	char *block_random(char *buf, int size);
   136	
   137	
   138	
   139	// socket_bind
   140	int socket_bind(int port, int cqueue);
   141	
   142	
   143	
   144	// socket_connect
   145	int socket_connect(char *host, int port);
   146	
   147	
   148	
   149	// line monitor
   150	struct LINEMONITOR_THREAD_DATA {
   151	  char *server;
   152	  int port;
   153	  int soft_msec;
   154	  int hard_msec;
   155	  int wait_msec;
   156	  void (*linemonitor_exception)(char *server, int port, int type);
   157	  int sock;
   158	};
   159	
   160	
   161	void linemonitor_server_thread(struct LINEMONITOR_THREAD_DATA
   162				  *linemonitor_thread_data);
   163	int linemonitor_server(int port,
   164			int soft_msec, int hard_msec, int wait_msec,
   165			void (*linemonitor_exception)(char *server, int port,
   166						      int type));
   167	void linemonitor_emergencystop(int sock);
   168	int linemonitor_thread(struct LINEMONITOR_THREAD_DATA
   169			       *linemonitor_thread_data);
   170	int linemonitor(char *server, int port,
   171			int soft_msec, int hard_msec, int wait_msec,
   172			void (*linemonitor_exception)(char *server, int port,
   173						      int type));
   174	
   175	
\end{lstlisting}}
