#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define DEFAULT_GTX_SERVERNAME "localhost"
#define MAX_HOSTNAME_LEN 1024
#define MAX_PATH_LEN 1024
#define MAX_STUDY_LEN 50
static void st_usage(char *exe_name,
int help)
{
(void)printf("Usage: %s -study XXXX [-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(" -sutdy data_path : Name of an existing study to write in.\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");
}
}
static int st_list_palettes(int dump_rgbs)
{
int i,nb_palettes,icol,ncol,*rgbs = NULL;
char **palettes;
int error = 1;
goto label_end;
if (nb_palettes)
printf("List of existing Palettes in the study:\n");
else
printf("No existing Palette in the study.\n");
for (i = 0; i < nb_palettes; i++)
{
printf("- %s\n", palettes[i]);
if (dump_rgbs)
{
goto label_end;
printf(" this palette has the following %d colors\n", ncol);
for (icol = 0; icol < ncol; icol++)
printf(" - R(%d), G(%d), B(%d)\n",
rgbs[icol], rgbs[ncol+icol], rgbs[2*ncol+icol]);
}
}
error = 0;
label_end:
return (error);
}
static int st_create_palette(const char* new_pal_name)
{
int icol, ncol, error;
int rgbs[3*10];
error = 1;
printf("Creating Palette named %s...\n", new_pal_name);
icol = 0;
ncol = 6;
rgbs[icol] = 255; rgbs[ncol+icol] = 0; rgbs[2*ncol+icol] = 0; icol++;
rgbs[icol] = 0; rgbs[ncol+icol] = 255; rgbs[2*ncol+icol] = 0; icol++;
rgbs[icol] = 0; rgbs[ncol+icol] = 0; rgbs[2*ncol+icol] = 255; icol++;
rgbs[icol] = 255; rgbs[ncol+icol] = 255; rgbs[2*ncol+icol] = 0; icol++;
rgbs[icol] = 0; rgbs[ncol+icol] = 255; rgbs[2*ncol+icol] = 255; icol++;
rgbs[icol] = 255; rgbs[ncol+icol] = 0; rgbs[2*ncol+icol] = 255; icol++;
goto label_end;
error = 0;
label_end:
return (error);
}
static int st_list_color_scales()
{
int nb_cscales,i;
char **cscales;
int error = 1;
goto label_end;
if (nb_cscales)
printf("List of existing Color Scales in the study:\n");
else
printf("No existing Color Scale in the study.\n");
for (i = 0; i < nb_cscales; i++)
printf("- %s\n", cscales[i]);
error = 0;
label_end:
return (error);
}
static int st_create_manual_color_scale(const char* pal_name,
const char* color_scale_name)
{
int icl, ncol, error, exists;
int *rgbs = NULL;
printf("Creating Manual Color Scale named %s...\n", color_scale_name);
error = 1;
goto label_end;
goto label_end;
if (exists &&
goto label_end;
for (icl = 0; icl < cscale.
nclasses; icl++)
{
}
goto label_end;
goto label_end;
error = 0;
label_end:
return (error);
}
static int st_create_facies_color_scale(const char* color_scale_name)
{
int icl, iint, error, exists;
int *rgbs = NULL;
printf("Creating Facies Color Scale named %s...\n", color_scale_name);
error = 1;
goto label_end;
if (exists &&
goto label_end;
for (icl = 0; icl < 3; icl++)
for (iint = 0; iint < 6; iint++)
{
}
for (icl = 0; icl < cscale.
nclasses; icl++)
{
}
goto label_end;
error = 0;
label_end:
{
for (icl = 0; icl < 3; icl++)
}
return (error);
}
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];
char study_name[MAX_STUDY_LEN];
char new_pal_name[50];
error = 1;
run_server = 1;
(void)strcpy(host, DEFAULT_GTX_SERVERNAME);
(void)strcpy(data_path, "");
(void)strcpy(study_name, "");
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], "-study"))
{
i++;
if (i < argc)
{
if (strlen(argv[i]) > MAX_STUDY_LEN-1)
{
(void)fprintf(stderr,"Study name must contain less than %d characters.",
MAX_STUDY_LEN);
exit(1);
}
(void)strcpy(study_name, 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 (st_list_palettes(0)) goto label_end;
(void)strcpy(new_pal_name, "GTXserver Palette");
if (st_create_palette(new_pal_name)) goto label_end;
if (st_list_color_scales()) goto label_end;
if (st_create_manual_color_scale(new_pal_name, "GTXserver Manual Color Scale"))
goto label_end;
if (st_create_facies_color_scale("GTXserver Facies Color Scale"))
goto label_end;
error = 0;
label_end:
return(error);
}