#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define DEFAULT_GTX_SERVERNAME "localhost"
#define MAX_HOSTNAME_LEN 1024
#define MAX_PATH_LEN 1024
char *GTXfile_types[] =
{
"Points",
"Lines",
"Grid"
};
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 *comment;
char *tmp_str, host[MAX_HOSTNAME_LEN];
unsigned short port;
int istud,jdir,kfile,lvar;
int i,j,error,run_server;
char data_path[MAX_PATH_LEN];
int nb_study;
int nb_dir;
int nb_file;
int nb_var;
int nb_indices;
char **studies = NULL;
char **dirs = NULL;
char **files = NULL;
char **vars = NULL;
int *indices = NULL;
char **alpha_indices = NULL;
error = 1;
run_server = 1;
goto label_end;
(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);
}
}
if (run_server)
{
port = 0;
goto label_end;
}
goto label_end;
goto label_end;
for (istud=0; istud<nb_study; istud++)
{
(void)printf("Study: %s\n", studies[istud]);
goto label_end;
goto label_end;
for (jdir=0; jdir<nb_dir; jdir++)
{
(void)printf("\n Directory: %s\n", dirs[jdir]);
goto label_end;
goto label_end;
for (kfile=0; kfile<nb_file; kfile++)
{
(void)printf("\n File: %s\n", files[kfile]);
goto label_end;
(void)printf(
" Type: %s\n", GTXfile_types[file_info.
type]);
(void)printf(
" Linked File: %s\n", file_info.
linked_file);
(void)printf(
" Dimension: %dD\n",file_info.
dimension);
(void)printf(
" Number of Samples: %"GTXLONG_FORMAT
"\n",file_info.
s_number);
(void)printf(
" Number of Lines: %d\n",file_info.
item_number);
{
{
(void)printf(" Number of Nodes: (%d,%d)\n",
file_info.
NX,file_info.
NY);
(void)printf(" Origin : (%g,%g)\n",
file_info.
X0,file_info.
Y0);
(void)printf(" Mesh Dimensions: (%g,%g)\n",
file_info.
DX,file_info.
DY);
(void)printf(
" Rotation Angle: %g\n", file_info.
angle_z);
else
(void)printf(" No Rotation\n");
}
{
(void)printf(" Number of Nodes: (%d,%d,%d)\n",
file_info.
NX,file_info.
NY,file_info.
NZ);
(void)printf(" Origin : (%g,%g,%g)\n",
file_info.
X0,file_info.
Y0,file_info.
Z0);
(void)printf(" Mesh Dimensions: (%g,%g,%g)\n",
file_info.
DX,file_info.
DY,file_info.
DZ);
{
(void)printf(" Rotation Angle around Z: %g\n",
(void)printf(" Rotation Angle around Y: %g\n",
(void)printf(" Rotation Angle around X: %g\n",
}
else
(void)printf(" No Rotation\n");
}
}
(void)printf(" Sample Number variable : %s\n",
{
(void)printf(" Line Number variable : %s\n",
(void)printf(" Relative Number variable : %s\n",
}
(void)printf(" X Gravity Center variable: %s\n",
(void)printf(" Y Gravity Center variable: %s\n",
(void)printf(" Z Gravity Center variable: %s\n",
{
(void)printf("\n Faulted File:\n");
(void)printf(" 2D Faults : %c\n",
(void)printf(" Auxiliary Variable Used: %c\n",
(void)printf(" Number of faults : %d\n",
(void)printf(" Number of segments : %d\n",
(void)printf(" Minimum Used Priority : %d\n",
(void)printf(" Maximum Used Priority : %d\n",
(void)printf(" Authorized Priority : %d\n",
goto label_end;
(void)printf("\n Dump of Faults:\n");
{
(void)printf(
" Fault \"%s\":\n", fault_system.
faults[i].
name);
(void)printf(
" %sPolygonal fault\n", fault_system.
faults[i].
polygon ?
"" :
"Not a ");
{
(void)printf(" Segment %d\n", j+1);
{
}
{
}
}
}
}
goto label_end;
for (lvar=0; lvar<nb_var; lvar++)
{
(void)printf("\n Variable: %s\n", vars[lvar]);
goto label_end;
(void)printf(
" Type: %s\n", GTXvar_types[var_info.
type]);
else
{
(void)printf(" Precision: 1 bit (selection)\n");
else
(
void)printf(
" Precision: %d bits\n",var_info.
bit_length);
(void)printf(
" Unit: %s\n", var_info.
unit);
}
if (comment[0] != '\0')
(void)printf(" Comment: %s\n", comment);
{
&alpha_indices))
goto label_end;
(void)printf(" Number of Indices: %d\n", nb_indices);
if (nb_indices == 0) continue;
if (alpha_indices)
{
(void)printf(" Index -> Alpha Index:\n");
for (i=0, j=0; i<nb_indices; i++)
(void)printf("%06d -> %s\n", indices[i], alpha_indices[i]);
}
else
{
(void)printf(" Indices:\n");
for (i=0, j=0; i<nb_indices; i++)
{
(void)printf("%6d", indices[i]);
if (++j == 5)
{
(void)printf("\n");
j = 0;
}
}
}
}
}
}
}
(void)puts("\n");
}
error = 1;
label_end:
return(error);
}