Ejemplo n.º 1
0
int main(int argc, char *argv[])
{
  int i;
  int cpuflg = 0, dpyflg = 0, raflg = 0, memflg = 0;
  int doathenaV = 0;
  int dosyspV = 0;
  int dolocalV = 0;
  int dobosN = 0;
  int dobosV = 0;
  int dosysnam = 0;
  int dosyscompatnam = 0;
  int verbose = 0;
  FILE *f;
  char *progname, *cp;

  progname = argv[0];
  cp = strrchr(progname, '/');
  if (cp != NULL)
    progname = cp+1;

  while ((i = getopt(argc, argv, "cdrMALPNESCv")) != EOF)
    {
      switch (i)
	{
	case 'c':
	  cpuflg = 1;
	  break;
	case 'd':
	  dpyflg = 1;
	  break;
	case 'r':
	  raflg = 1;
	  break;
	case 'M':
	  memflg = 1;
	  break;
	case 'A':
	  doathenaV = 1;
	  break;
	case 'L':
	  dolocalV = 1;
	  break;
	case 'P':
	  dosyspV = 1;
	  break;
	case 'N':
	  dobosN = 1;
	  break;
	case 'E':
	  dobosV = 1;
	  break;
	case 'S':
	  dosysnam = 1;
	  break;
	case 'C':
	  dosyscompatnam = 1;
	  break;
	case 'v':
	  verbose++;
	  break;
	default:
	  usage(progname);
	}
    }
  if (argv[optind] != NULL)
    usage(progname);

  if (!(cpuflg || dpyflg || raflg || memflg || doathenaV || dolocalV ||
	dosyspV || dobosN || dobosV || dosysnam || dosyscompatnam))
    {
      do_machtype();
      exit(0);
    }

  /* Print out version of Athena machtype compiled against */
  if (doathenaV)
    {
      if (verbose)
	fputs("Machtype version: ", stdout);
      printf("%s.%s\n", ATHMAJV, ATHMINV);
    }

    /* Print out version of attached packs */
    if (dosyspV)
      {
	char buf[256], *rvd_version, *p;
	if ((f = fopen("/srvd/.rvdinfo","r")) == NULL)
	    puts("Syspack information unavailable.");
	else
	  {
	    fgets(buf, sizeof(buf), f);
	    fclose(f);
	    /* If it is verbose, give the whole line, else just the vers # */
	    if (verbose)
		fputs(buf, stdout);
	    else
	      {
		p = strchr(buf,' '); /* skip "Athena" */
		p = strchr(p+1,' '); /* skip "RVD" */
		p = strchr(p+1,' '); /* Skip machtype */
		p = strchr(p+1,' '); /* skip "version" */
		rvd_version = p+1;
		p = strchr(rvd_version,' ');
		*p = '\0';
		puts(rvd_version);
	      }
	  }
      }

  /* Print out local version from /etc/athena/version */
  if (dolocalV)
    {
      char buf[256], *loc_version, *p;
      if ((f = fopen("/etc/athena/version","r")) == NULL)
	  puts("Local version information unavailable.");
      else
	{
	  while (fgets(buf, sizeof(buf), f) != NULL)
	    ;
	  fclose(f);
	  if (verbose)
	      fputs(buf, stdout);
	  else
	    {
	      p = strchr(buf,' '); /* skip "Athena" */
	      p = strchr(p+1,' '); /* skip "Workstation/Server" */
	      p = strchr(p+1,' '); /* Skip machtype */
	      p = strchr(p+1,' '); /* skip "version" */
	      loc_version = p+1;
	      p = strchr(loc_version,' ');
	      *p = '\0';
	      puts(loc_version);
	    }
	}
    }

  /* Print out vendor OS name */
  if (dobosN)
    {
      if (verbose)
	puts(OSNAME " " OSVERS);
      else
	puts(OSNAME);
    }

  /* Print out vendor OS version */
  if (dobosV)
    puts(OSVERS);

  /* Print out Athena System name */
  if (dosysnam)
    puts(ATHSYS);

  /* Print out compatible Athena System names */
  if (dosyscompatnam)
    puts(ATHSYSCOMPAT);

  if (cpuflg)
    do_cpu(verbose);
  if (dpyflg)
    do_dpy(verbose);
  if (raflg)
    do_disk(verbose);
  if (memflg)
    do_memory(verbose);
  exit(0);
}
Ejemplo n.º 2
0
int
PLP_venndisk()
{
char attr[NAMEMAXLEN], val[256];
char *line, *lineval;
int first, nt, lvp;
double cenx, ceny, area, radius;
char color[COLORLEN];
char leglabel[128];
double densfact;
char outline[128];
double ofs;
int botflag;
double areascale;
int datadriven, xfld, areafld, clrfld;
double yloc;
int irow;
double y;
int solidfill;
int lblfld;
char lbldet[128];
double adjx, adjy;
int align;

TDH_errprog( "pl proc venn" );

cenx = ceny = area = -1.0;
densfact = 1.0;
strcpy( leglabel, "" );
strcpy( color, "red" );
strcpy( outline, "" );
botflag = 0;
areascale = 1.0;
ofs = 0.0;
datadriven = xfld = areafld = clrfld = 0;
yloc = 0.5;
solidfill = 0;
lblfld = 0;
strcpy( lbldet, "" );

/* get attributes.. */

first = 1;
while( 1 ) {
	line = getnextattr( first, attr, val, &lvp, &nt );
	if( line == NULL ) break;
	first = 0;
	lineval = &line[lvp];

	if( stricmp( attr, "location" )==0 ) getcoords( "location", lineval, &cenx, &ceny );
	else if( stricmp( attr, "bottomlocation" )==0 ) {
		getcoords( "bottomlocation", lineval, &cenx, &ceny ); /* given in scale units */
		botflag = 1;
		}
	else if( stricmp( attr, "area" )==0 ) area = atof( val );        /* square inches unless areascale given */
	else if( stricmp( attr, "areascale" )==0 ) areascale = atof( val );        
	else if( stricmp( attr, "color" )==0 ) strcpy( color, val );
	else if( stricmp( attr, "legendlabel" )==0 || stricmp( attr, "label" )==0 ) strcpy( leglabel, lineval );
	else if( stricmp( attr, "labelfield" )==0 ) lblfld = fref( val );
	else if( stricmp( attr, "labeldetails" )==0 ) strcpy( lbldet, lineval );
	else if( stricmp( attr, "density" )==0 ) densfact = atof( val );
	else if( stricmp( attr, "outline" )==0 ) strcpy( outline, lineval );
	else if( stricmp( attr, "dotsize" )==0 ) ofs = atof( val );

	else if( stricmp( attr, "areafld" )==0 ) { areafld = fref( val ); datadriven = 1; }
	else if( stricmp( attr, "xfld" )==0 ) xfld = fref( val );
	else if( stricmp( attr, "colorfld" )==0 ) clrfld = fref( val );
	else if( stricmp( attr, "yloc" )==0 ) yloc = atof( val );
 	else if( stricmp( attr, "solidfill" )==0 ) {
                if( strnicmp( val, YESANS, 1 )==0 ) solidfill = 1;
                else solidfill = 0;
                }


	else Eerr( 1, "attribute not recognized", attr );
	}


/* sanity checks.. */
if( !datadriven ) {
	if( cenx < 0.0 || ceny < 0.0 || area < 0.0 ) return( Eerr( 428, "The attributes x, y, and area must all be specified", "" ) );
	}

if( datadriven && !scalebeenset() ) return( Eerr( 51, "datadriven requires scaled units.. no scaled plotting area has been defined yet w/ proc areadef", "" ));

/* overrides.. */
if( solidfill ) densfact = 0.0;

if( datadriven ) {
	ceny = Ea( Y, yloc );
	for( irow = 0; irow < Nrecords; irow++ ) {
		area = atof( da( irow, areafld-1 ) );
		area *= areascale;
		if( area > 50.0 ) { Eerr( 72405, "skipping a very large disk", da( irow, areafld ) ); continue; }
		radius = sqrt( area / PI );

		if( xfld > 0 ) cenx = Ea( X, fda( irow, xfld-1, X ));
		else cenx = Ea( X, (double)(irow+1) );

		if( clrfld > 0 ) strcpy( color, da( irow, clrfld-1 ));
		y = ceny + radius;  /* so all disk bottoms are on the line.. */
		do_disk( cenx, y, radius, color, densfact, ofs, outline, solidfill );
		if( lblfld > 0 ) {
			double labx, laby;
			textdet( "labeldetails", lbldet, &align, &adjx, &adjy, -2, "R", 1.0 );
			if( align == '?' ) align = 'C';
			labx = cenx+adjx;
			laby = (Elimit( Y, 'l', 'a' )-(Ecurtextheight*2.0))+adjy;
			Emov( labx, laby );
			Edotext( da( irow, lblfld-1 ), align );
			}
		}
	}

else	{   /* individual disks */
	
	/* now do the plotting work.. */
	/* convert area to a radius in inches.. */
	area *= areascale;
	if( area > 50.0 ) return( Eerr( 72405, "disk area is too large.. reduce 'area' or reduce 'areascale'", "" ) );
	
	radius = sqrt( area / PI );
	if( PLS.usingcm ) { cenx /= 2.54; ceny /= 2.54; ofs /= 2.54; radius /= 2.54; }
	
	if( botflag ) ceny += radius;
	
	do_disk( cenx, ceny, radius, color, densfact, ofs, outline, solidfill );
	
	if( leglabel[0] != '\0' ) PL_add_legent( LEGEND_COLOR, leglabel, "", color, "", "" );
	}

return( 0 );
}