#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define GTX_STUDY "GTXserver_Tests"
#define GTX_DIR "write"
#define GTX_FILE "grid + fault"
#define GTX_VARIABLE "variable"
#define DEFAULT_GTX_SERVERNAME "localhost"
#define MAX_HOSTNAME_LEN 1024
#define MAX_PATH_LEN 1024
char *GTXvar_types[] =
{
"Float",
"Character",
"X gravity center",
"Y gravity center",
"Z gravity center",
"Macro"
};
static void st_usage(char *exe_name,
int help)
{
(void)printf("Usage: %s [-help] [-host hostname] [-port port_number]\n",
exe_name);
(void)printf(" [-path data_path]");
if (help)
{
(void)printf(" -help : Print this message.\n");
(void)printf(" -debug : Print client/server messages.\n");
(void)printf(" -host hostname : Server's hostname.\n");
(void)printf(" -port port_number : Port used between client and server\n");
(void)printf(" -path data_path : Initialize connection with given data_path.\n");
(void)printf("The default is to run a new server on a random port.");
(void)printf("If -host or -port is specified, a server must have been started first on the given host/port");
}
}
int main(int argc,
char *argv[])
{
char *tmp_str, host[MAX_HOSTNAME_LEN];
unsigned short port;
int i,error,run_server;
char data_path[MAX_PATH_LEN];
double *array = NULL;
error = 1;
run_server = 1;
(void)strcpy(host, DEFAULT_GTX_SERVERNAME);
(void)strcpy(data_path, "");
for (i=1; i<argc; i++)
{
if (!strcmp(argv[i], "-port"))
{
i++;
if (i<argc)
{
run_server = 0;
port = (unsigned short)strtol(argv[i], &tmp_str, 10);
if (port == 0 && tmp_str == argv[i])
{
(void)fprintf(stderr,"Invalid Port Number.");
exit(1);
}
}
else
{
st_usage(argv[0], 0);
exit(1);
}
}
else if (!strcmp(argv[i], "-host"))
{
i++;
if (i<argc)
{
run_server = 0;
if (strlen(argv[i]) > MAX_HOSTNAME_LEN-1)
{
(void)fprintf(stderr,"Host Name must contain less than %d characters.",
MAX_HOSTNAME_LEN);
exit(1);
}
(void)strcpy(host, argv[i]);
}
else
{
st_usage(argv[0], 0);
exit(1);
}
}
else if (!strcmp(argv[i], "-path"))
{
i++;
if (i<argc)
{
if (strlen(argv[i]) > MAX_PATH_LEN-1)
{
(void)fprintf(stderr,"Path must contain less than %d characters.",
MAX_PATH_LEN);
exit(1);
}
(void)strcpy(data_path, argv[i]);
}
else
{
st_usage(argv[0], 0);
exit(1);
}
}
else if (!strcmp(argv[i], "-debug"))
else if (!strcmp(argv[i], "-help"))
{
st_usage(argv[0], 1);
exit(0);
}
}
goto label_end;
if (run_server)
{
port = 0;
goto label_end;
}
goto label_end;
goto label_end;
goto label_end;
if (
GTXClientNewGridFile(GTX_FILE, 2, 0., 0., 0., 10., 10., 0., 10, 10, 0))
goto label_end;
goto label_end;
10, 6, NULL))
goto label_end;
goto label_end;
array = (double*)malloc(10*10*sizeof(double));
if (array == NULL) goto label_end;
for (i=0; i<10*10; i++) array[i] = (double)i;
goto label_end;
error = 1;
label_end:
if (array) free(array);
{
}
return(error);
}