This is hstat.c in view mode; [Download] [Up]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "hippo.h"
#ifdef sun
#define EXIT_FAILURE 1
#define EXIT_SUCCESS 0
#endif
extern int getopt(int, char **, char *);
int main(int argc, char **argv)
{
extern char *optarg;
extern int optind;
int c;
int i,j,n;
int i_appnt=0, i_thisnt=0;
int append = 0;
int verbose = 0;
char infilenm[80] = "";
ntuple *nt_list; /* hippo objects */
ntuple appnt=NULL;
display *d_list;
const float *ntlow, *nthigh;
while ((c = getopt( argc, argv, "f:i:")) != -1)
{
switch (c)
{
case 'i':
case 'f':
sscanf(optarg,"%s",infilenm);
if (verbose) fprintf(stderr,"Input text file = %s\n",infilenm);
break;
default:
case '?':
fprintf(stderr,"Usage: [-f <inputfile>]\n");
fprintf(stderr,"[<inputfile> | stdin]\n");
exit(EXIT_FAILURE);
}
}
/*
* input file not in option form.
*/
if (optind < argc)
{
sscanf(argv[optind],"%s",infilenm);
if (verbose) fprintf(stderr,"Input text file = %s\n",infilenm);
optind++;
}
/*
* read in file.
*/
if (strlen(infilenm) == 0)
i = h_readStream(stdin,&d_list,&nt_list);
else
i = h_read(infilenm,&d_list,&nt_list);
if (i != 0)
{
fprintf(stderr,"Could not read file\n");
exit(EXIT_FAILURE);
}
n = 0;
while (nt_list[n] != NULL) n++;
printf("%d ntuple",n);
if (n != 1) printf("s");
printf(" in file\n");
for (i=0; i<n; i++)
{
printf("Ntuple %d: Dim %d, Title \"%s\"\n",i,h_getNtDim(nt_list[i]),
h_getNtTitle(nt_list[i]));
nthigh = h_getNtHigh(nt_list[i]);
ntlow = h_getNtLow(nt_list[i]);
for (j=0; j<h_getNtDim(nt_list[i]); j++)
{
int k;
printf(" Column %2d \"%s\"",j,h_getNtLabel(nt_list[i],j));
for (k=20-strlen(h_getNtLabel(nt_list[i],j));k>0;k--)
printf(" ");
printf(" range: %g to %g\n",ntlow[j],nthigh[j]);
}
printf(" Number of rows %d\n", h_getNtNdata(nt_list[i]));
printf("\n");
}
n = 0;
while (d_list[n] != NULL) n++;
printf("%d display",n);
if (n != 1) printf("s");
printf(" in file\n");
for (i=0; i<n; i++)
{
printf("Display %d: Title \"%s\"\n",i,h_getTitle(d_list[i]));
printf(" Bound to ntuple with title \"%s\"\n",
h_getNtTitle(h_getNtuple(d_list[i])) );
printf(" Plot type is ");
switch(h_getDrawType(d_list[i]))
{
case HISTOGRAM:
printf("Histogram\n");
break;
case XYPLOT:
printf("x-y Plot\n");
break;
case STRIPCHART:
printf("Stripchart\n");
break;
case LEGOPLOT:
printf("Legoplot\n");
break;
case COLORPLOT:
printf("Greyscale/color plot\n");
break;
case SCATTERPLOT:
printf("Scatterplot\n");
break;
case THREEDSCATTER:
printf("3D Scatterplot\n");
break;
}
printf(" x-axis -> ntuple column %d\n",
h_getBinding(d_list[i],XAXIS));
if (h_getBinding(d_list[i],YAXIS) >= 0)
printf(" y-axis -> ntuple column %d\n",
h_getBinding(d_list[i],YAXIS));
if (h_getBinding(d_list[i],ZAXIS) >= 0)
printf(" z-axis -> ntuple column %d\n",
h_getBinding(d_list[i],ZAXIS));
if (h_getBinding(d_list[i],WEIGHT) >= 0)
printf(" weight -> ntuple column %d\n",
h_getBinding(d_list[i],WEIGHT));
if (h_getBinding(d_list[i],XERROR) >= 0)
printf(" x-error -> ntuple column %d\n",
h_getBinding(d_list[i],XERROR));
if (h_getBinding(d_list[i],YERROR) >= 0)
printf(" y-error -> ntuple column %d\n",
h_getBinding(d_list[i],YERROR));
printf("\n");
}
exit(EXIT_SUCCESS);
}
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.