Skip to content
Snippets Groups Projects
Commit 94321500 authored by edgrif's avatar edgrif
Browse files

add data format to server init.

parent e9f15262
No related branches found
No related tags found
No related merge requests found
......@@ -26,9 +26,9 @@
* details from caller.
*
* HISTORY:
* Last edited: Feb 2 14:12 2005 (edgrif)
* Last edited: Feb 3 14:39 2005 (edgrif)
* Created: Wed Aug 6 15:48:47 2003 (edgrif)
* CVS info: $Id: zmapServer.h,v 1.11 2005-02-02 14:34:56 edgrif Exp $
* CVS info: $Id: zmapServer.h,v 1.12 2005-02-03 14:54:32 edgrif Exp $
*-------------------------------------------------------------------
*/
#ifndef ZMAP_SERVER_H
......@@ -51,8 +51,8 @@ typedef enum {ZMAP_SERVERRESPONSE_OK,
* Provide matching Termination routine ???? */
gboolean zMapServerGlobalInit(char *protocol, void **server_global_data_out) ;
gboolean zMapServerCreateConnection(ZMapServer *server_out, void *server_global_data,
char *host, int port, char *protocol, int timeout,
char *version_str,
char *host, int port, char *protocol, char *format,
int timeout, char *version_str,
char *userid, char *passwd) ;
ZMapServerResponseType zMapServerOpenConnection(ZMapServer server) ;
ZMapServerResponseType zMapServerSetContext(ZMapServer server, char *sequence,
......
......@@ -28,9 +28,9 @@
* give all the information/fields for the request/reply.
*
* HISTORY:
* Last edited: Feb 2 11:56 2005 (edgrif)
* Last edited: Feb 3 14:33 2005 (edgrif)
* Created: Wed Feb 2 11:47:16 2005 (edgrif)
* CVS info: $Id: zmapServerProtocol.h,v 1.1 2005-02-02 14:54:41 edgrif Exp $
* CVS info: $Id: zmapServerProtocol.h,v 1.2 2005-02-03 14:54:32 edgrif Exp $
*-------------------------------------------------------------------
*/
#ifndef ZMAP_PROTOCOL_H
......@@ -88,9 +88,10 @@ typedef struct
{
ZMapServerReqType type ;
char *protocol ;
char *machine ;
int port ;
char *protocol ;
char *format ;
int timeout ;
char *version ;
} ZMapServerReqOpenStruct, *ZMapServerReqOpen ;
......@@ -153,11 +154,11 @@ typedef union
/* Handler routine which decodes the request into server calls in the thread. */
ZMapThreadReturnCode zMapServerRequestHandler(void **slave_data,
void *request_in, void **reply_out,
char **err_msg_out) ;
ZMapThreadReturnCode zMapServerTerminateHandler(void **slave_data, char **err_msg_out) ;
#endif /* !ZMAP_PROTOCOL_H */
......@@ -26,9 +26,9 @@
* Description:
* Exported functions: See zmapServer.h
* HISTORY:
* Last edited: Feb 1 15:55 2005 (edgrif)
* Last edited: Feb 3 14:36 2005 (edgrif)
* Created: Wed Aug 6 15:46:38 2003 (edgrif)
* CVS info: $Id: acedbServer.c,v 1.22 2005-02-02 14:36:44 edgrif Exp $
* CVS info: $Id: acedbServer.c,v 1.23 2005-02-03 14:59:46 edgrif Exp $
*-------------------------------------------------------------------
*/
......@@ -49,7 +49,7 @@ typedef struct
static gboolean globalInit(void) ;
static gboolean createConnection(void **server_out,
char *host, int port, char *version_str,
char *host, int port, char *format, char *version_str,
char *userid, char *passwd, int timeout) ;
static ZMapServerResponseType openConnection(void *server) ;
static ZMapServerResponseType setContext(void *server, char *sequence,
......@@ -119,7 +119,7 @@ static gboolean globalInit(void)
static gboolean createConnection(void **server_out,
char *host, int port, char *version_str,
char *host, int port, char *format, char *version_str,
char *userid, char *passwd, int timeout)
{
gboolean result = FALSE ;
......
......@@ -27,9 +27,9 @@
*
* Exported functions: See ZMap/zmapServerPrototype.h
* HISTORY:
* Last edited: Feb 2 14:29 2005 (edgrif)
* Last edited: Feb 3 14:37 2005 (edgrif)
* Created: Wed Aug 6 15:46:38 2003 (edgrif)
* CVS info: $Id: dasServer.c,v 1.9 2005-02-02 14:36:22 edgrif Exp $
* CVS info: $Id: dasServer.c,v 1.10 2005-02-03 14:59:30 edgrif Exp $
*-------------------------------------------------------------------
*/
......@@ -41,7 +41,7 @@
static gboolean globalInit(void) ;
static gboolean createConnection(void **server_out,
char *host, int port, char *version_str,
char *host, int port, char *format, char *version_str,
char *userid, char *passwd, int timeout) ;
static ZMapServerResponseType openConnection(void *server) ;
static ZMapServerResponseType setContext(void *server, char *sequence,
......@@ -111,7 +111,7 @@ static gboolean globalInit(void)
* are usually on a well known port, perhaps we should only set the port if we get passed
* a port of zero........ */
static gboolean createConnection(void **server_out,
char *host, int port, char *version_str,
char *host, int port, char *format, char *version_str,
char *userid, char *passwd, int timeout)
{
gboolean result = TRUE ;
......
......@@ -30,9 +30,9 @@
*
* Exported functions: See ZMap/zmapServerPrototype.h
* HISTORY:
* Last edited: Feb 3 10:24 2005 (rds)
* Last edited: Feb 3 14:56 2005 (edgrif)
* Created: Fri Sep 10 18:29:18 2004 (edgrif)
* CVS info: $Id: fileServer.c,v 1.12 2005-02-03 10:28:10 rds Exp $
* CVS info: $Id: fileServer.c,v 1.13 2005-02-03 14:57:15 edgrif Exp $
*-------------------------------------------------------------------
*/
......@@ -45,7 +45,7 @@
static gboolean globalInit(void) ;
static gboolean createConnection(void **server_out,
char *host, int port, char *version_str,
char *host, int port, char *format, char *version_str,
char *userid, char *passwd, int timeout) ;
static ZMapServerResponseType openConnection(void *server) ;
static ZMapServerResponseType setContext(void *server, char *sequence,
......@@ -106,7 +106,7 @@ static gboolean globalInit(void)
*
* */
static gboolean createConnection(void **server_out,
char *host, int port, char *version_str,
char *host, int port, char *format, char *version_str,
char *userid, char *passwd, int timeout)
{
gboolean result = TRUE ;
......
......@@ -26,9 +26,9 @@
* Description:
* Exported functions: See ZMap/zmapServer.h
* HISTORY:
* Last edited: Feb 2 14:20 2005 (edgrif)
* Last edited: Feb 3 14:37 2005 (edgrif)
* Created: Wed Aug 6 15:46:38 2003 (edgrif)
* CVS info: $Id: zmapServer.c,v 1.19 2005-02-02 14:38:02 edgrif Exp $
* CVS info: $Id: zmapServer.c,v 1.20 2005-02-03 14:59:02 edgrif Exp $
*-------------------------------------------------------------------
*/
......@@ -97,16 +97,20 @@ gboolean zMapServerGlobalInit(char *protocol, void **server_global_data_out)
gboolean zMapServerCreateConnection(ZMapServer *server_out, void *global_data,
char *host, int port, char *protocol, int timeout,
char *version_str,
char *host, int port, char *protocol, char *format,
int timeout, char *version_str,
char *userid, char *passwd)
{
gboolean result = TRUE ;
ZMapServer server ;
ZMapServerFuncs serverfuncs = (ZMapServerFuncs)global_data ;
#ifdef ED_G_NEVER_INCLUDE_THIS_CODE
/* we must have as a minumum the host name and a protocol, everything else is optional. */
zMapAssert(host && *host && protocol && *protocol) ;
#endif /* ED_G_NEVER_INCLUDE_THIS_CODE */
server = g_new0(ZMapServerStruct, 1) ; /* n.b. crashes on failure. */
*server_out = server ;
......@@ -116,7 +120,7 @@ gboolean zMapServerCreateConnection(ZMapServer *server_out, void *global_data,
if (result)
{
if ((server->funcs->create)(&(server->server_conn), host, port, version_str,
if ((server->funcs->create)(&(server->server_conn), host, port, format, version_str,
userid, passwd, timeout))
{
server->host = g_strdup(host) ;
......
......@@ -28,9 +28,9 @@
* include this header, its not really for general consumption.
*
* HISTORY:
* Last edited: Feb 1 15:21 2005 (edgrif)
* Last edited: Feb 3 14:35 2005 (edgrif)
* Created: Wed Aug 6 15:48:47 2003 (edgrif)
* CVS info: $Id: zmapServerPrototype.h,v 1.7 2005-02-02 14:38:31 edgrif Exp $
* CVS info: $Id: zmapServerPrototype.h,v 1.8 2005-02-03 15:01:55 edgrif Exp $
*-------------------------------------------------------------------
*/
#ifndef ZMAP_SERVER_PROTOTYPEP_H
......@@ -48,7 +48,7 @@
* of a particular protocol. */
typedef gboolean (*ZMapServerGlobalFunc)(void) ;
typedef gboolean (*ZMapServerCreateFunc)(void **server_conn,
char *host, int port, char *version_str,
char *host, int port, char *format, char *version_str,
char *userid, char *passwd, int timeout) ;
typedef ZMapServerResponseType (*ZMapServerOpenFunc)(void *server_conn) ;
......
......@@ -25,9 +25,9 @@
* Description:
* Exported functions: See ZMap/zmapView.h
* HISTORY:
* Last edited: Feb 1 16:24 2005 (edgrif)
* Last edited: Feb 3 14:50 2005 (edgrif)
* Created: Thu May 13 15:28:26 2004 (edgrif)
* CVS info: $Id: zmapView.c,v 1.42 2005-02-02 14:52:48 edgrif Exp $
* CVS info: $Id: zmapView.c,v 1.43 2005-02-03 15:00:22 edgrif Exp $
*-------------------------------------------------------------------
*/
......@@ -71,7 +71,7 @@ static void killGUI(ZMapView zmap_view) ;
static void killConnections(ZMapView zmap_view) ;
static ZMapViewConnection createConnection(ZMapView zmap_view,
char *machine, int port, char *protocol,
char *machine, int port, char *protocol, char *format,
int timeout, char *version, char *types_file,
gboolean sequence_server, gboolean writeback_server,
char *sequence, int start, int end) ;
......@@ -310,20 +310,28 @@ gboolean zMapViewConnect(ZMapView zmap_view)
zmapViewBusy(zmap_view, TRUE) ;
/* IT WOULD PROBABLY BE BETTER IF THIS CONFIG READING CODE WAS PART OF THE ZMAPSERVER
* CODE AS IT IS MORECLOSELY TIED TO THAT THAN TO ZMAPVIEW..... */
/* We need to retrieve the connect data here from the config stuff.... */
if (result && (config = zMapConfigCreate()))
{
ZMapConfigStanza server_stanza ;
/* If you change this resource array be sure to check that the subsequent
/* NOTE: If you change this resource array be sure to check that the subsequent
* initialisation is still correct. */
ZMapConfigStanzaElementStruct server_elements[] = {{"host", ZMAPCONFIG_STRING, {NULL}},
{"port", ZMAPCONFIG_INT, {NULL}},
{"protocol", ZMAPCONFIG_STRING, {NULL}},
{"timeout", ZMAPCONFIG_INT, {NULL}},
{"version", ZMAPCONFIG_STRING, {"4.9.28"}},
{"version", ZMAPCONFIG_STRING, {NULL}},
{"sequence", ZMAPCONFIG_BOOL, {NULL}},
{"writeback", ZMAPCONFIG_BOOL, {NULL}},
{"typesfile", ZMAPCONFIG_STRING, {NULL}},
{"stylesfile", ZMAPCONFIG_STRING, {NULL}},
{"format", ZMAPCONFIG_STRING, {NULL}},
{NULL, -1, {NULL}}} ;
/* Set defaults for any element that is not a string. */
......@@ -333,7 +341,7 @@ gboolean zMapViewConnect(ZMapView zmap_view)
server_elements[6].data.b = FALSE ;
server_stanza = zMapConfigMakeStanza("server", server_elements) ;
server_stanza = zMapConfigMakeStanza("source", server_elements) ;
if (!zMapConfigFindStanzas(config, server_stanza, &server_list))
result = FALSE ;
......@@ -355,9 +363,9 @@ gboolean zMapViewConnect(ZMapView zmap_view)
while (result
&& ((next_server = zMapConfigGetNextStanza(server_list, next_server)) != NULL))
{
char *machine, *protocol ;
char *machine, *protocol, *format ;
int port, timeout ;
char *version, *types_file ;
char *version, *styles_file ;
gboolean sequence_server, writeback_server ;
ZMapViewConnection view_con ;
......@@ -366,9 +374,10 @@ gboolean zMapViewConnect(ZMapView zmap_view)
machine = zMapConfigGetElementString(next_server, "host") ;
port = zMapConfigGetElementInt(next_server, "port") ;
protocol = zMapConfigGetElementString(next_server, "protocol") ;
format = zMapConfigGetElementString(next_server, "format") ;
timeout = zMapConfigGetElementInt(next_server, "timeout") ;
version = zMapConfigGetElementString(next_server, "version") ;
types_file = zMapConfigGetElementString(next_server, "typesfile") ;
styles_file = zMapConfigGetElementString(next_server, "stylesfile") ;
/* We only record the first sequence and writeback servers found, this means you
* can only have one each of these which seems sensible. */
......@@ -377,16 +386,27 @@ gboolean zMapViewConnect(ZMapView zmap_view)
if (!zmap_view->writeback_server)
writeback_server = zMapConfigGetElementBool(next_server, "writeback") ;
if (!machine || !protocol || !types_file)
if (strcmp(protocol, "file") != 0 && (!machine || !protocol || !styles_file))
{
/* Types is temporary, in the end no types file will mean we read the types
* dynamically from the server. */
zMapLogWarning("%s",
"Found \"server\" stanza without valid \"host\", \"protocol\" "
"Found \"source\" stanza for a server "
"without valid \"host\", \"protocol\" "
"or \"typesfile\", so stanza was ignored.") ;
}
else if (strcmp(protocol, "file") == 0 && (!format || !styles_file))
{
/* Types is temporary, in the end no types file will mean we read the types
* dynamically from the server. */
zMapLogWarning("%s",
"Found \"source\" stanza for a file "
"without valid \"format\" "
"or \"typesfile\", so stanza was ignored.") ;
}
else if ((view_con = createConnection(zmap_view, machine, port, protocol,
timeout, version, types_file,
format,
timeout, version, styles_file,
sequence_server, writeback_server,
zmap_view->sequence,
zmap_view->start, zmap_view->end)))
......@@ -1163,10 +1183,6 @@ static void loadDataConnections(ZMapView zmap_view)
do
{
ZMapViewConnection view_con ;
#ifdef ED_G_NEVER_INCLUDE_THIS_CODE
ZMapConnection connection ;
#endif /* ED_G_NEVER_INCLUDE_THIS_CODE */
ZMapThread thread ;
ZMapServerReqGetFeatures req_features ;
......@@ -1245,10 +1261,6 @@ static void killConnections(ZMapView zmap_view)
do
{
ZMapViewConnection view_con ;
#ifdef ED_G_NEVER_INCLUDE_THIS_CODE
ZMapConnection connection ;
#endif /* ED_G_NEVER_INCLUDE_THIS_CODE */
ZMapThread thread ;
view_con = list_item->data ;
......@@ -1266,37 +1278,34 @@ static void killConnections(ZMapView zmap_view)
/* Allocate a connection and send over the request to get the sequence displayed. */
static ZMapViewConnection createConnection(ZMapView zmap_view,
char *machine, int port, char *protocol,
int timeout, char *version, char *types_file,
char *machine, int port, char *protocol, char *format,
int timeout, char *version, char *styles_file,
gboolean sequence_server, gboolean writeback_server,
char *sequence, int start, int end)
{
ZMapViewConnection view_con = NULL ;
#ifdef ED_G_NEVER_INCLUDE_THIS_CODE
ZMapConnection connection ;
#endif /* ED_G_NEVER_INCLUDE_THIS_CODE */
ZMapThread thread ;
/* Create the thread to service the connection requests, we give it a function that it will call
* to decode the requests we send it. */
if ((thread = zMapThreadCreate(zMapServerRequestHandler)))
* to decode the requests we send it and a terminate function. */
if ((thread = zMapThreadCreate(zMapServerRequestHandler, zMapServerTerminateHandler)))
{
ZMapServerReqOpenLoad open_load = NULL ;
GData *types ;
/* in the end the types files will be optional..... */
types = zMapFeatureTypeGetFromFile(types_file) ;
types = zMapFeatureTypeGetFromFile(styles_file) ;
/* Build the intial request. */
open_load = g_new0(ZMapServerReqOpenLoadStruct, 1) ;
open_load->type = ZMAP_SERVERREQ_OPENLOAD ;
open_load->open.protocol = g_strdup(protocol) ;
open_load->open.machine = g_strdup(machine) ;
open_load->open.port = port ;
open_load->open.protocol = g_strdup(protocol) ;
open_load->open.format = g_strdup(format) ;
open_load->open.timeout = timeout ;
open_load->open.version = g_strdup(version) ;
......@@ -1311,15 +1320,6 @@ static ZMapViewConnection createConnection(ZMapView zmap_view,
open_load->features.type = ZMAP_SERVERREQ_FEATURES ;
#ifdef ED_G_NEVER_INCLUDE_THIS_CODE
if ((thread = zMapThreadCreate(machine, port, protocol, timeout, version,
sequence, start, end, types,
(void *)open_load))) ;
#endif /* ED_G_NEVER_INCLUDE_THIS_CODE */
zMapThreadRequest(thread, (void *)open_load) ;
view_con = g_new0(ZMapViewConnectionStruct, 1) ;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment