[srm-cvs] CVS Update: - Cleaned up a lot of things:

From: <d.rethans[@]jdimedia.nl>
Date: Tue Feb 18 2003 - 22:20:02 CET

Date: Tue Feb 18 22:20:01 CET 2003
User: Derick Rethans
Directory: srm/modules/auth

Log Message:
 [4.00]
 - Cleaned up a lot of things:
   * removed support for dmalloc (which doesn't work anyway and valgrind
     works much better)
   * removed protocol version header
   * moved the error handling declarations to srm_error.h
   * moved socket code from connection.c to srm_protocols.c
   * removed unused includes
 
Modified files:
           srm/configure.in (version: 1.59)
           srm/main/main.c (version: 1.69)
           srm/main/srm_com.h (version: 1.13)
           srm/main/srm_config.h.in (version: 1.29)
           srm/main/src/Makefile.am (version: 1.34)
           srm/main/src/connection.c (version: 1.69)
           srm/main/src/connection.h (version: 1.25)
           srm/main/src/srm_client.c (version: 1.17)
           srm/main/src/srm_error.c (version: 1.30)
           srm/main/src/srm_protocols.c (version: 1.5)
           srm/main/src/srm_protocols.h (version: 1.4)
           srm/modules/auth/auth_parse.c (version: 1.13)
Added files:
           srm/main/src/srm_error.h (new version: 1.1)

[FILE: /srm/configure.in]

--- srm/configure.in:1.58 Sat Feb 15 19:45:09 2003 GMT
+++ srm/configure.in Tue Feb 18 20:19:57 2003 GMT
@@ -1,4 +1,4 @@
-dnl $Id: cvstemp,v 1.58 2003/02/15 20:45:09 derick Exp $
+dnl $Id: cvstemp,v 1.59 2003/02/18 21:19:57 derick Exp $
 dnl
 dnl Process this file with autoconf to produce a configure script.
 dnl
@@ -151,24 +151,6 @@
     AC_DEFINE(SRM_DEBUG, 0, [Whether debugging is enabled or not.])
     AC_MSG_RESULT([no])
     CFLAGS="$CFLAGS -Wall -Werror"
- fi
-],[
- AC_MSG_RESULT([no])
-])
-
-AC_MSG_CHECKING([whether to use dmalloc debugging])
-AC_ARG_ENABLE(dmalloc,
-[ --enable-dmalloc Enable dmalloc debugging ],
-[
- if test "$enableval" = "yes" ; then
- AC_MSG_RESULT([yes])
- AC_CHECK_LIB(dmalloc, dmalloc_error,
- [
- AC_DEFINE(HAVE_DMALLOC, 1, [Dmalloc])
- LIBS="-ldmalloc $LIBS"
- ])
- else
- AC_MSG_RESULT([no])
   fi
 ],[
   AC_MSG_RESULT([no])

[FILE: /srm/main/main.c]

--- srm/main/main.c:1.68 Sat Feb 15 23:25:14 2003 GMT
+++ srm/main/main.c Tue Feb 18 20:19:57 2003 GMT
@@ -1,4 +1,4 @@
-/* $Id: cvstemp,v 1.68 2003/02/16 00:25:14 derick Exp $ */
+/* $Id: cvstemp,v 1.69 2003/02/18 21:19:57 derick Exp $ */
 
 /* The contents of this file are subject to the Vulcan Logic Public
  * License Version 1.1 (the "License"); you may not use this file
@@ -386,7 +386,7 @@
         srm_cleanup_ini_settings();
 
 /* Closing sockets */
- for (fd = 0; fd < CP.max_fd; fd++) {
+ for (fd = 3; fd < CP.max_fd; fd++) {
                 if (CP.status[fd] != SRM_STATUS_NOT_USED) {
                         close(fd);
                 }

[FILE: /srm/main/srm_com.h]

--- srm/main/srm_com.h:1.12 Mon Jan 14 18:53:51 2002 GMT
+++ srm/main/srm_com.h Tue Feb 18 20:19:57 2003 GMT
@@ -1,4 +1,4 @@
-/* $Id: cvstemp,v 1.12 2002/01/14 19:53:51 peter Exp $ */
+/* $Id: cvstemp,v 1.13 2003/02/18 21:19:57 derick Exp $ */
 
 /* The contents of this file are subject to the Vulcan Logic Public
  * License Version 1.1 (the "License"); you may not use this file
@@ -69,9 +69,5 @@
         srm_ui8 smxs[16];
         srm_ui8 reserved2[64];
 } pkt_header;
-
-/* Function prototypes (for libs/connection.h) */
-void dump_packet (srm_ui8* packet, srm_ui8 size);
-void srm_pkt_set_version (pkt_header* header);
 
 #endif

[FILE: /srm/main/srm_config.h.in]

--- srm/main/srm_config.h.in:1.28 Sun Jan 26 15:34:09 2003 GMT
+++ srm/main/srm_config.h.in Tue Feb 18 20:19:57 2003 GMT
@@ -1,4 +1,4 @@
-/* $Id: cvstemp,v 1.28 2003/01/26 16:34:09 derick Exp $ */
+/* $Id: cvstemp,v 1.29 2003/02/18 21:19:57 derick Exp $ */
 
 /* The contents of this file are subject to the Vulcan Logic Public
  * License Version 1.1 (the "License"); you may not use this file
@@ -24,10 +24,6 @@
 #ifndef __SRM_CONFIG_H__
 #define __SRM_CONFIG_H__
 
-#ifdef HAVE_DMALLOC
-#include <dmalloc.h>
-#endif
-
 /* Version */
 #define SRM_VERSION "@SRM_VERSION@"
 #define SRM_API_VERSION @SRM_API_VERSION@
@@ -35,58 +31,6 @@
 #define SRM_MINOR_VERSION @SRM_MINOR_VERSION@
 #define SRM_MICRO_VERSION @SRM_MICRO_VERSION@
 
-/* Exit codes (server part, for network part see main/srm_com.h) */
-#define ERROR_CREATE_PTHREAD -1
-#define ERROR_END_PTHREAD -2
-
-#define ERROR_CANT_OPEN_INIFILE -3
-
-#define ERROR_LIST_CREATE -4
-#define ERROR_HASH -5
-
-#define ERROR_OPEN_MODULE -6
-#define ERROR_LOAD_MODULE -6
-#define ERROR_GET_SYMBOLS -6
-
-#define ERROR_INIT_HASH -7
-#define ERROR_UNKNOWN_STORE -7
-#define ERROR_KEY_EXISTS -8
-#define ERROR_KEY_NOT_EXISTS -9
-
-#define ERROR_USAGE -10
-#define ERROR_CANT_OPEN_LOGFILE -11
-#define ERROR_SIGQUIT -12
-#define ERROR_SIGSEGV -13
-#define ERROR_SERIALIZE -14
-
-#define LL_FATAL 1
-#define LL_USAGE 1
-#define LL_SIGNAL 5
-#define LL_STARTUP 10
-#define LL_SHUTDOWN 10
-#define LL_LOAD 10
-#define LL_SECURITY 20
-#define LL_CONNECTION_ERROR 20
-#define LL_QUERY_ERROR 30
-#define LL_INFO 35
-#define LL_CONNECTION 40
-#define LL_LOCKING 45
-#define LL_PROTOCOL 45
-#define LL_DATA 50
-#define LL_STATS 60
-
-#define ERRMSG_FUNC_NOT_EXIST "This function does not exist"
-#define ERRMSG_FUNC_NOT_IMPLEMENTED "This function is not implemented"
-#define ERRMSG_KEY_EXISTS "There is already data stored with this key"
-#define ERRMSG_KEY_NOT_EXISTS "There is no data stored with this key"
-
-#define ERRMSG_UNKNOWN "There was an error, but we don't know what went wrong"
-
-/* Function prototypes */
-void srm_init_logging (char *file, int loglevel, int log_to_screen);
-void srm_stop_logging (void);
-
-void srm_error (int value, char *format, ...);
-void srm_fmt_message (int level, char *group, char *format, ...);
+#include "srm_error.h"
 
 #endif

[FILE: /srm/main/src/srm_error.h]

/* $Id: cvstemp,v 1.1 2003/02/18 21:19:59 derick Exp $ */

/* The contents of this file are subject to the Vulcan Logic Public
 * License Version 1.1 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a copy of
 * the License at http://www.vl-srm.net/vlpl/
 *
 * Software distributed under the License is distributed on an "AS
 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 * implied. See the License for the specific language governing
 * rights and limitations under the License.
 *
 * The Original Code is vl-srm.net code.
 *
 * The Initial Developer of the Original Code is the Vulcan Logic
 * Group. Portions created by Vulcan Logic Group are Copyright (C)
 * 2000, 2001, 2002 Vulcan Logic Group. All Rights Reserved.
 *
 * Contributor(s):
 * Derick Rethans <d.rethans@jdimedia.nl>
 */

#ifndef __SRM_ERROR_H__
#define __SRM_ERROR_H__

/* Exit codes (server part, for network part see main/srm_com.h) */
#define ERROR_CREATE_PTHREAD -1
#define ERROR_END_PTHREAD -2

#define ERROR_CANT_OPEN_INIFILE -3

#define ERROR_LIST_CREATE -4
#define ERROR_HASH -5

#define ERROR_OPEN_MODULE -6
#define ERROR_LOAD_MODULE -6
#define ERROR_GET_SYMBOLS -6

#define ERROR_INIT_HASH -7
#define ERROR_UNKNOWN_STORE -7
#define ERROR_KEY_EXISTS -8
#define ERROR_KEY_NOT_EXISTS -9

#define ERROR_USAGE -10
#define ERROR_CANT_OPEN_LOGFILE -11
#define ERROR_SIGQUIT -12
#define ERROR_SIGSEGV -13
#define ERROR_SERIALIZE -14

#define LL_FATAL 1
#define LL_USAGE 1
#define LL_SIGNAL 5
#define LL_STARTUP 10
#define LL_SHUTDOWN 10
#define LL_LOAD 10
#define LL_SECURITY 20
#define LL_CONNECTION_ERROR 20
#define LL_QUERY_ERROR 30
#define LL_INFO 35
#define LL_CONNECTION 40
#define LL_LOCKING 45
#define LL_PROTOCOL 45
#define LL_DATA 50
#define LL_STATS 60

#define ERRMSG_FUNC_NOT_EXIST "This function does not exist"
#define ERRMSG_FUNC_NOT_IMPLEMENTED "This function is not implemented"
#define ERRMSG_KEY_EXISTS "There is already data stored with this key"
#define ERRMSG_KEY_NOT_EXISTS "There is no data stored with this key"

#define ERRMSG_UNKNOWN "There was an error, but we don't know what went wrong"

/* Function prototypes */
void srm_init_logging (char *file, int loglevel, int log_to_screen);
void srm_stop_logging (void);

void srm_error (int value, char *format, ...);
void srm_fmt_message (int level, char *group, char *format, ...);

#endif

[FILE: /srm/main/src/Makefile.am]

--- srm/main/src/Makefile.am:1.33 Sun Feb 16 12:01:09 2003 GMT
+++ srm/main/src/Makefile.am Tue Feb 18 20:19:58 2003 GMT
@@ -1,5 +1,5 @@
 ##
-## $Id: cvstemp,v 1.33 2003/02/16 13:01:09 derick Exp $
+## $Id: cvstemp,v 1.34 2003/02/18 21:19:58 derick Exp $
 ##
 
 ## The contents of this file are subject to the Vulcan Logic Public
@@ -25,11 +25,11 @@
 lib_LTLIBRARIES = libsrm_client.la
 noinst_LIBRARIES = libsrm.a
 
-libsrm_client_la_SOURCES = srm_client.c storage.c connection.c functions.c srm_error.c srm_hash.c srm_llist.c srm_value.c srm_compat.c srm_storage.c srm_queue.c
+libsrm_client_la_SOURCES = srm_client.c storage.c srm_error.c srm_hash.c srm_llist.c srm_value.c srm_compat.c srm_storage.c srm_queue.c
 
 libsrm_a_SOURCES = connection.c srm_error.c srm_modules.c functions.c srm_hash.c srm_llist.c srm_value.c srm_compat.c srm_protocols.c srm_storage.c srm_ini_parser.y srm_ini_scanner.l
 
-noinst_HEADERS = connection.h ini_parser.h srm_modules.h srm_storage.h
+noinst_HEADERS = connection.h srm_error.h ini_parser.h srm_modules.h srm_storage.h
 include_HEADERS = functions.h srm_hash.h srm_client.h srm_modules.h srm_value.h srm_compat.h srm_llist.h srm_queue.h
 
 libsrm_client_la_LDFLAGS = -version-info @SRM_VERSION_INFO@

[FILE: /srm/main/src/connection.c]

--- srm/main/src/connection.c:1.68 Sun Feb 16 12:02:18 2003 GMT
+++ srm/main/src/connection.c Tue Feb 18 20:19:59 2003 GMT
@@ -1,4 +1,4 @@
-/* $Id: cvstemp,v 1.68 2003/02/16 13:02:18 derick Exp $ */
+/* $Id: cvstemp,v 1.69 2003/02/18 21:19:59 derick Exp $ */
 
 /* The contents of this file are subject to the Vulcan Logic Public
  * License Version 1.1 (the "License"); you may not use this file
@@ -21,89 +21,25 @@
  */
 
 #include <stdio.h>
-#include <sys/types.h>
 #include <unistd.h>
 #include <stdlib.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <sys/un.h>
-#include <sys/stat.h>
 
+#include "config.h"
 #include "srm_client.h"
 #include "srm_config.h"
-#include "srm_com.h"
-#include "srm_value.h"
 #include "connection.h"
-#include "functions.h"
+#include "srm_protocols.h"
 #include "srm_storage.h"
 
-/* Protocol Version */
-#define PROTOCOL_V_MAJOR 0
-#define PROTOCOL_V_MINOR 1
-
-/* Connection pool */
-struct con_pool connection_pool;
-
 /* Function prototypes (local) */
+static void dump_packet (srm_ui8* packet, srm_ui8 size);
 static srm_bool srm_session_key_is_empty (srm_ui8* packet);
 static void srm_gen_session_key (srm_ui8* session_key);
 
 /******************************************************************************
-** socket
-**/
-
-int srm_setup_socket (int domain, int port, char* path) /* {{{1 */
-{
- int ssocket = socket(domain, SOCK_STREAM, 0);
-
- if (ssocket < 0) {
- perror("srm_setup_socket");
- srm_error(COM_ERROR_CREATE_SOCKET, "setup_socket: couldn't create socket");
- }
-
- switch(domain) {
- case AF_INET: {
- struct sockaddr_in server_in;
-
- memset(&server_in, 0, sizeof(struct sockaddr));
- server_in.sin_family = AF_INET;
- server_in.sin_addr.s_addr = htonl(INADDR_ANY);
- server_in.sin_port = htons((int) port);
-
- if (bind(ssocket, (struct sockaddr *) &server_in, sizeof(struct sockaddr_in)) < 0) {
- srm_error(COM_ERROR_BIND, "setup_socket: couldn't bind AF_INET socket. Is there an srmd already running?");
- }
- break;
- }
- case AF_UNIX: {
- struct sockaddr_un server_un;
-
- memset(&server_un, 0, sizeof(struct sockaddr));
- server_un.sun_family = AF_UNIX;
- strcpy(server_un.sun_path, path);
- (void) unlink(path);
- umask(0);
- if (bind(ssocket, (struct sockaddr *) &server_un, sizeof(struct sockaddr_un)) < 0) {
- srm_error(COM_ERROR_BIND, "setup_socket: couldn't bind AF_UNIX socket");
- }
- umask(0777);
- }
- break;
- }
-
- if (listen(ssocket, 5) == -1) {
- srm_error(COM_ERROR_LISTEN, "setup_socket: listen call failed");
- }
- return ssocket;
-} /* 1}}} */
-
-
-/******************************************************************************
 ** Functions that deal with packets
 **/
-
-void dump_packet (srm_ui8* packet, srm_ui8 size) /* {{{1 */
+static void dump_packet (srm_ui8* packet, srm_ui8 size) /* {{{1 */
 {
         int i;
         for (i = 0; i < size; i++) {
@@ -115,12 +51,6 @@
         printf("\n\n");
 } /* 1}}} */
 
-void srm_pkt_set_version (pkt_header* header) /* {{{1 */
-{
- header->version_major = PROTOCOL_V_MAJOR;
- header->version_minor = PROTOCOL_V_MINOR;
-} /* 1}}} */
-
 static void server_send_packet (int fd, int type, srm_ui8* data, srm_ui32 size, srm_ui8* old_packet) /* {{{1 */
 {
         struct pkt_header header;
@@ -128,7 +58,6 @@
 /* Return data, first the header */
         memset (&header, 0, sizeof (header));
         header.type = type;
- srm_pkt_set_version(&header);
         if (old_packet != NULL) {
                 header.protocol = ((pkt_header*) old_packet)->protocol;
                 header.encryption = ((pkt_header*) old_packet)->encryption;
@@ -438,20 +367,20 @@
 static void connection_abort (int fd) /* {{{1 */
 {
         srm_fmt_message(LL_CONNECTION_ERROR, "Notice", "Connection aborted");
- CP_CLOSE_CONNECTION(fd);
+ srm_close_connection(fd);
 } /* 1}}} */
 
 static void connection_close (int fd) /* {{{1 */
 {
         srm_fmt_message(LL_CONNECTION, "Notice", "Connection closed");
- CP_CLOSE_CONNECTION(fd);
+ srm_close_connection(fd);
 } /* 1}}} */
 
 static void connection_abort_with_error (int fd, char* string) /* {{{1 */
 {
         srm_fmt_message(LL_CONNECTION_ERROR, "Notice", "Connection aborted with error: %s", string);
         server_send_packet(fd, PKT_ABORT, NULL, 0, NULL);
- CP_CLOSE_CONNECTION(fd);
+ srm_close_connection(fd);
 } /* 1}}} */
 
 /******************************************************************************

[FILE: /srm/main/src/connection.h]

--- srm/main/src/connection.h:1.24 Sun Feb 16 12:02:18 2003 GMT
+++ srm/main/src/connection.h Tue Feb 18 20:19:59 2003 GMT
@@ -1,4 +1,4 @@
-/* $Id: cvstemp,v 1.24 2003/02/16 13:02:18 derick Exp $ */
+/* $Id: cvstemp,v 1.25 2003/02/18 21:19:59 derick Exp $ */
 
 /* The contents of this file are subject to the Vulcan Logic Public
  * License Version 1.1 (the "License"); you may not use this file
@@ -30,62 +30,7 @@
         sess_key_t* session_key;
 } con_def;
 
-#define CP connection_pool
 
-#define CP_RESET memcpy (&connection_pool.ready_set, \
- &connection_pool.test_set, sizeof connection_pool.test_set);
-
-#define CP_SELECT(to) select ((connection_pool.max_fd) + 1, \
- &connection_pool.ready_set, NULL, NULL, (&to));
-
-#define CP_ISNEWCONNECT(sock) FD_ISSET ((sock), &connection_pool.ready_set)
-
-#define CP_NEW_CONNECTION(fd,pfd) FD_SET ((fd), &connection_pool.test_set); \
- connection_pool.counter++; \
- if ((fd) > (connection_pool.max_fd)) \
- connection_pool.max_fd = fd; \
- connection_pool.status[fd] = SRM_STATUS_NORMAL; \
- connection_pool.protocol[fd] = connection_pool.protocol[pfd];
-
-#define CP_CONNECTION_AVAILABLE(fd) \
- FD_ISSET ((fd), &connection_pool.ready_set)
-
-#define CP_CLOSE_CONNECTION(fd) FD_CLR ((fd), &connection_pool.test_set); \
- connection_pool.status[fd] = SRM_STATUS_NOT_USED; \
- close (fd)
-
-extern struct con_pool connection_pool;
-
-typedef int (*prot_init_t)(int sock);
-typedef int (*prot_deinit_t)(int sock);
-typedef int (*prot_process_t)(int sock);
-
-typedef struct srm_protocol {
- srm_host_t host; /* Connection specifier */
-
- prot_init_t init; /* Initialization function */
- prot_deinit_t deinit; /* De-initialization function */
-
- prot_process_t process;
-} srm_protocol;
-
-#define SRM_STATUS_NOT_USED 0
-#define SRM_STATUS_RENDEZVOUS 1
-#define SRM_STATUS_NORMAL 2
-
-typedef struct con_pool {
- srm_bool status[FD_SETSIZE];
- con_def connection[FD_SETSIZE];
- srm_protocol *protocol[FD_SETSIZE];
- srm_ui16 max_fd;
- srm_ui32 counter;
- fd_set test_set;
- fd_set ready_set;
-} con_pool;
-
-
-void dump_packet (srm_ui8* packet, srm_ui8 size);
 int srm_process_data (int fd);
-int srm_setup_socket (int domain, int port, char *path);
 
 #endif

[FILE: /srm/main/src/srm_client.c]

--- srm/main/src/srm_client.c:1.16 Sun Feb 16 12:02:19 2003 GMT
+++ srm/main/src/srm_client.c Tue Feb 18 20:19:59 2003 GMT
@@ -1,4 +1,4 @@
-/* $Id: cvstemp,v 1.16 2003/02/16 13:02:19 derick Exp $ */
+/* $Id: cvstemp,v 1.17 2003/02/18 21:19:59 derick Exp $ */
 
 /* The contents of this file are subject to the Vulcan Logic Public
  * License Version 1.1 (the "License"); you may not use this file
@@ -50,7 +50,6 @@
 
         memset(&header, 0, sizeof(header));
         header.type = type;
- srm_pkt_set_version(&header);
         header.protocol = connect_data.protocol;
         header.encryption = connect_data.encryption;
         header.data_length = datasize;

[FILE: /srm/main/src/srm_error.c]

--- srm/main/src/srm_error.c:1.29 Sun Feb 16 12:02:19 2003 GMT
+++ srm/main/src/srm_error.c Tue Feb 18 20:19:59 2003 GMT
@@ -1,4 +1,4 @@
-/* $Id: cvstemp,v 1.29 2003/02/16 13:02:19 derick Exp $ */
+/* $Id: cvstemp,v 1.30 2003/02/18 21:19:59 derick Exp $ */
 
 /* The contents of this file are subject to the Vulcan Logic Public
  * License Version 1.1 (the "License"); you may not use this file
@@ -27,7 +27,7 @@
 #include <time.h>
 #include <pthread.h>
 
-#include "srm_config.h"
+#include "srm_error.h"
 #include "srm_value.h"
 
 static FILE *logfile;

[FILE: /srm/main/src/srm_protocols.c]

--- srm/main/src/srm_protocols.c:1.4 Sun Feb 16 12:02:19 2003 GMT
+++ srm/main/src/srm_protocols.c Tue Feb 18 20:19:59 2003 GMT
@@ -1,4 +1,4 @@
-/* $Id: cvstemp,v 1.4 2003/02/16 13:02:19 derick Exp $ */
+/* $Id: cvstemp,v 1.5 2003/02/18 21:19:59 derick Exp $ */
 
 /* The contents of this file are subject to the Vulcan Logic Public
  * License Version 1.1 (the "License"); you may not use this file
@@ -20,16 +20,83 @@
  * Derick Rethans <d.rethans@jdimedia.nl>
  */
 
-#include "connection.h"
-#include "srm_protocols.h"
 #include <stdlib.h>
 #include <stdio.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <netinet/in.h>
+#include <sys/un.h>
 #include <sys/socket.h>
+#include <string.h>
+#include <sys/stat.h>
+
+#include "connection.h"
+#include "srm_protocols.h"
 
 #define SRM_MAX_PROTOCOLS 32
 
 static int srm_protocol_count;
 static srm_protocol *srm_protocol_list[SRM_MAX_PROTOCOLS];
+
+/* Connection pool */
+struct con_pool connection_pool;
+
+/******************************************************************************
+** socket
+**/
+
+int srm_setup_socket (int domain, int port, char* path) /* {{{1 */
+{
+ int ssocket = socket(domain, SOCK_STREAM, 0);
+
+ if (ssocket < 0) {
+ perror("srm_setup_socket");
+ srm_error(COM_ERROR_CREATE_SOCKET, "setup_socket: couldn't create socket");
+ }
+
+ switch(domain) {
+ case AF_INET: {
+ struct sockaddr_in server_in;
+
+ memset(&server_in, 0, sizeof(struct sockaddr));
+ server_in.sin_family = AF_INET;
+ server_in.sin_addr.s_addr = htonl(INADDR_ANY);
+ server_in.sin_port = htons((int) port);
+
+ if (bind(ssocket, (struct sockaddr *) &server_in, sizeof(struct sockaddr_in)) < 0) {
+ srm_error(COM_ERROR_BIND, "setup_socket: couldn't bind AF_INET socket. Is there an srmd already running?");
+ }
+ break;
+ }
+ case AF_UNIX: {
+ struct sockaddr_un server_un;
+
+ memset(&server_un, 0, sizeof(struct sockaddr));
+ server_un.sun_family = AF_UNIX;
+ strcpy(server_un.sun_path, path);
+ (void) unlink(path);
+ umask(0);
+ if (bind(ssocket, (struct sockaddr *) &server_un, sizeof(struct sockaddr_un)) < 0) {
+ srm_error(COM_ERROR_BIND, "setup_socket: couldn't bind AF_UNIX socket");
+ }
+ umask(0777);
+ }
+ break;
+ }
+
+ if (listen(ssocket, 5) == -1) {
+ srm_error(COM_ERROR_LISTEN, "setup_socket: listen call failed");
+ }
+ return ssocket;
+}
+
+void srm_close_connection (int fd)
+{
+ FD_CLR((fd), &connection_pool.test_set);
+ connection_pool.status[fd] = SRM_STATUS_NOT_USED;
+ close(fd);
+}
+
 
 /******************************************************************************
 ** (de)register protocol

[FILE: /srm/main/src/srm_protocols.h]

--- srm/main/src/srm_protocols.h:1.3 Sun Feb 16 12:02:19 2003 GMT
+++ srm/main/src/srm_protocols.h Tue Feb 18 20:19:59 2003 GMT
@@ -1,4 +1,4 @@
-/* $Id: cvstemp,v 1.3 2003/02/16 13:02:19 derick Exp $ */
+/* $Id: cvstemp,v 1.4 2003/02/18 21:19:59 derick Exp $ */
 
 /* The contents of this file are subject to the Vulcan Logic Public
  * License Version 1.1 (the "License"); you may not use this file
@@ -26,11 +26,68 @@
 #include "srm_value.h"
 #include "connection.h"
 
-int srm_process_data (int fd);
+#define CP connection_pool
+
+#define CP_RESET memcpy (&connection_pool.ready_set, \
+ &connection_pool.test_set, sizeof connection_pool.test_set);
+
+#define CP_SELECT(to) select ((connection_pool.max_fd) + 1, \
+ &connection_pool.ready_set, NULL, NULL, (&to));
+
+#define CP_ISNEWCONNECT(sock) FD_ISSET ((sock), &connection_pool.ready_set)
+
+#define CP_NEW_CONNECTION(fd,pfd) FD_SET ((fd), &connection_pool.test_set); \
+ connection_pool.counter++; \
+ if ((fd) > (connection_pool.max_fd)) \
+ connection_pool.max_fd = fd; \
+ connection_pool.status[fd] = SRM_STATUS_NORMAL; \
+ connection_pool.protocol[fd] = connection_pool.protocol[pfd];
+
+#define CP_CONNECTION_AVAILABLE(fd) \
+ FD_ISSET ((fd), &connection_pool.ready_set)
+
+#define CP_CLOSE_CONNECTION(fd) FD_CLR ((fd), &connection_pool.test_set); \
+ connection_pool.status[fd] = SRM_STATUS_NOT_USED; \
+ close (fd)
+
+extern struct con_pool connection_pool;
+
+typedef int (*prot_init_t)(int sock);
+typedef int (*prot_deinit_t)(int sock);
+typedef int (*prot_process_t)(int sock);
+
+typedef struct srm_protocol {
+ srm_host_t host; /* Connection specifier */
+
+ prot_init_t init; /* Initialization function */
+ prot_deinit_t deinit; /* De-initialization function */
+
+ prot_process_t process;
+} srm_protocol;
+
+#define SRM_STATUS_NOT_USED 0
+#define SRM_STATUS_RENDEZVOUS 1
+#define SRM_STATUS_NORMAL 2
+
+typedef struct con_pool {
+ srm_bool status[FD_SETSIZE];
+ con_def connection[FD_SETSIZE];
+ srm_protocol *protocol[FD_SETSIZE];
+ srm_ui16 max_fd;
+ srm_ui32 counter;
+ fd_set test_set;
+ fd_set ready_set;
+} con_pool;
+
+
+int srm_setup_socket (int domain, int port, char *path);
+void srm_close_connection (int fd);
 
 int srm_register_protocol (srm_protocol *prot);
+
 void srm_init_protocol_registry (void);
 void srm_deinit_protocol_registry (void);
+
 void srm_setup_protocols (struct con_pool* cp);
 
 #endif

[FILE: /srm/modules/auth/auth_parse.c]

--- srm/modules/auth/auth_parse.c:1.12 Tue Feb 19 17:42:51 2002 GMT
+++ srm/modules/auth/auth_parse.c Tue Feb 18 20:20:01 2003 GMT
@@ -1,4 +1,4 @@
-/* $Id: cvstemp,v 1.12 2002/02/19 18:42:51 derick Exp $ */
+/* $Id: cvstemp,v 1.13 2003/02/18 21:20:01 derick Exp $ */
 
 /* The contents of this file are subject to the Vulcan Logic Public
  * License Version 1.1 (the "License"); you may not use this file
@@ -39,6 +39,7 @@
 #include "split.h"
 #include "srm_value.h"
 #include "srm_auth.h"
+#include "srm_config.h"
 
 extern int errno;
 
Received on Tue Feb 18 22:20:03 2003

This archive was generated by hypermail 2.1.8 : Tue Jan 06 2009 - 09:00:03 CET