Exemplo n.º 1
0
int AddString(int maxEntries, int *numEntries, 
		char ***stringTable, char *newElement)
{

	char			*fv;
	int			i;


/*
 *	Check to see if we have a string to add, this is not technically
 *	an error. 
 */
	if( ! newElement || ! *newElement )
		return( 0 );

/*
 *	Allocate a table big enough for the maximum possible
 *	entries.  In reality, this is way too big, but there is
 *	no efficient way to guess how many we will need as the
 *	the file is being read by GEMPAK.
 *
 */
	if( ! *stringTable ) {

		*stringTable = 
			(char **) malloc( sizeof(char **) *  maxEntries + 1 );

		memset( *stringTable, 0, sizeof(char **) * maxEntries + 1 );

		*numEntries = 0;
	}

/*
 *	Saftey check for table overrun....
 */
	if( *numEntries >= maxEntries) {
		printf("*** AddString:  table overrun.\n");
		return( -1 );
	}

/*
 *	Loop through the table, looking for matches.  Just return on
 *	a match otherwise bail out and add the newElement to the end
 *	of the list.
 *
 */
	for( i = 0; i < *numEntries; i++ )
		if( EQSTRING( (*stringTable)[i], newElement ) )
			return( 0 );


/*
 *	Append the new entry to the table.
 */
	(*stringTable)[i] = strdup( newElement );
	(*numEntries)++;

	return( 1 );

}
Exemplo n.º 2
0
World OMstatus
OMlaunchEnv(OMconn conn, char *machine, char *cmd, char *env)
{
  if (EQSTRING(machine, "localhost")) {
    return ONlaunchEnvLocal(conn, cmd, env);
  }
  else {
    return OMlaunchEnvRemote(conn, machine, cmd, env);
  }
}
Exemplo n.º 3
0
BooleanType IsGridFieldOnThisVCoord( GridInfoObjectType *gio, 
			char *gridField, char *vCoord )
{

	int		i;
	GridType	*gt;

	if( ! gio )
		return( (BooleanType)NULL );
	
	for( i = 0, gt = gio->gridList; i < gio->numberOfGrids; i++, gt++ )

		if( EQSTRING( gt->verticalCoordinate, vCoord ) )

			if( EQSTRING( gt->gridField, gridField ) )

				return( True );

	return( False );

}
Exemplo n.º 4
0
BooleanType
InRefreshedModelList ( char *model )
{
	int	i;

	for ( i = 0; i < msize; i++ ) {
	    if ( EQSTRING ( mlist[i], model ) )
	    	return (True);
	}
	
	return ( False);	    	

}
Exemplo n.º 5
0
BooleanType 
IsGridFieldAtThisLevel( GridInfoObjectType *gio, char *gridField, int level )
{

	int		i;
	GridType	*gt;

	if( ! gio )
		return( (BooleanType)NULL );
	
	for( i = 0, gt = gio->gridList; i < gio->numberOfGrids; i++, gt++ )

		if( gt->levels[0] == level )

			if( EQSTRING( gt->gridField, gridField ) )

				return( True );

	return( False );

}
Exemplo n.º 6
0
int
main(int argc, char *argv[])
{
  FILE *inFile, *outFile;
  OMdev inDev = (OMdev)NULL;
  OMstatus status;

  /* Check and parse arguments */
  if ((argc == 2) && EQSTRING(argv[1], "-h")) {
    usage(NULL);
  }
  if (argc != 4) {
    usage("Three arguments please...");
  }

  if (EQSTRING(argv[2], "-")) {
    inFile = stdin;
  }
  else {
    inFile = fopen(argv[2], "r");
  }
  if (EQSTRING(argv[3], "-")) {
    outFile = stdout;
  }
  else {
    outFile = fopen(argv[3], "w");
  }

  if (!inFile) {
    usage("Unable to open input file.");
  }
  if (!outFile) {
    usage("Unable to open output file.");
  }

  if (strlen(argv[1]) != 2) {
    usage("Bad first argument.");
  }

  switch (argv[1][1]) {
  case 'x':
    inDev = OMmakeDevice(OMencodingXML, OMmakeIOFile(inFile));
    break;
  case 'b':
    inDev = OMmakeDevice(OMencodingBinary, OMmakeIOFile(inFile));
    break;
  case 'u':
    inDev = OMmakeDevice(OMencodingUnknown, OMmakeIOFile(inFile));
    break;
  default:
    usage("Bad second argument");
  }



  /* Ignore comments */
  OMignoreComment(inDev, OMtrue);

  /* Endless pipe of OpenMath objects */
  while (1) 
	{
    if ((status = pipeObj(inDev, outFile))) 
		{
      if (status == OMnoMoreToken)
				break;			/* OK that's a normal exit condition */
      checkStatus(status);	/* there is something realy wrong */
    }
		fflush(outFile);
  }

  OMcloseDevice(inDev);

  return 0;
}