Example #1
0
STATUS
MO_oidmap_set(i4 offset,
	   i4  luserbuf,
	   char *userbuf,
	   i4  objsize,
	   PTR object )
{
    FILE	*fp;
    STATUS	cl_stat;
    STATUS	set_stat;
    LOCATION	loc;
    char	loc_buf[ MAX_LOC ];
    char	line[ SI_MAX_TXT_REC ];
    char	*words[ 2 ];
    i4		wordcount;
    SYSTIME	new_time;
    
    NMloc( FILES, FILENAME, userbuf, &loc );
    LOcopy( &loc, loc_buf, &loc );
    cl_stat = LOlast( &loc, &new_time );

    /* If it's a new file, or old one has changed, read it */

    if( OK == cl_stat && (STcompare( userbuf, MO_oid_map ) ||
			  new_time.TM_secs > MO_map_time.TM_secs ))
    {
	STcopy( userbuf, MO_oid_map );
	MO_map_time = new_time;
	    
	cl_stat = SIfopen( &loc , ERx( "r" ), SI_TXT, (i4) SI_MAX_TXT_REC, &fp );
	if( cl_stat == OK )
	{
	    while( SIgetrec( line, (i4) SI_MAX_TXT_REC, fp ) == OK ) 
	    {
		wordcount = 2;
		STgetwords( line, &wordcount, words );
		if( words[0][0] != '#' && wordcount >= 2 )
		    cl_stat = MOset( ~0, MO_META_OID_CLASS, words[0], words[1] );

	    }
	    SIclose( fp );
	}
    }
    return( cl_stat );
}
Example #2
0
/*{
** Name:	mktimestamp - make time stamp
**
** Description:
**	Convert the system specific time string (from TMstr) into a
**	Replicator timestamp of the form dd-mmm-yyy hh:mm:ss.
**	mktimestamp() is only intended as a temporary fix to the problem
**	regarding availablity of TMbreak().
**
** Inputs:
**	timestr
**
** Outputs:
**	timestamp
**
** Returns:
**	none
*/
static void
mktimestamp(
char *timestr,
char *timestamp)
{
	char	*tmwords[MAX_TMWORDS];
	char	*dom;
	char	*mon;
	char	*yr;
	char	*hms;
	i4	count;

	*timestamp = EOS;
	count = MAX_TMWORDS;

# ifdef VMS
	if CMspace(timestr)
		CMnext(timestr);
	RPgetwords(ERx(" -"), timestr, &count, tmwords);
	if (count < 3)
		return;
	dom = tmwords[0];
	mon = tmwords[1];
	yr = tmwords[2];
	hms = tmwords[3];
# else
	STgetwords(timestr, &count, tmwords);
	if (count < 5)
		return;
	mon = tmwords[1];
	dom = tmwords[2];
	hms = tmwords[3];
	yr = tmwords[4];
# endif

	STprintf(timestamp, ERx("%.2s-%.3s-%.4s %.8s"), dom, mon, yr, hms);
}
Example #3
0
static u_i4 
pp_directive( FILE *input, STACK_FRAME *stack , bool ifdef )
{
	i4 n, len;
	char *words[ MAX_LINE / 2 ], *temp, *p;
	char *parse_val, *parse_end;
	STACK_FRAME stack_frame;
	bool def_dir;
	u_i4 rtn = NONE;

	stack_frame.prev = stack;
	stack_frame.display_mode = TRUE;

	p = temp = STalloc( infile->yytext );
	CMnext( p );
	n = sizeof( words );
	STgetwords( p, &n, words ); 

	/* process the directive, watch out for the empty directive */
	if (n == 0)
	{
		;       /* empty directive */
	}
	else if( STequal( words[ 0 ], ERx( "define" ) ) != 0 )
	{
		/* If a symbol was specified look for the value to give it */
		if (n > 1) 
		{
			/* Scan for the 'define' keyword */
			parse_val = infile->yytext;
			CMnext(parse_val);         /* Skip over the '#' */
			while (CMwhite(parse_val))
				CMnext(parse_val);

			/* Scan past the 'define' keyword */
			while (!CMwhite(parse_val))
				CMnext(parse_val);

			/* Scan over white space separating 'define' */
			/* keyword and the specified symbol name */
			while (CMwhite(parse_val))
				CMnext(parse_val);

			/* Skip over the symbol name */
			while (!CMwhite(parse_val))
				CMnext(parse_val);

			/* Skip over white space after the symbol name */
			while (CMwhite(parse_val))
				CMnext(parse_val);

			/* At this point we have scanned to the beginning */
			/* of the defined value for the symbol, Trim off */
			/* any trailing white space */
			STtrmwhite(parse_val);

			/* Define value found, could be the empty string, "" */
			if( active( &stack_frame ) )
			{
				define( words[ 1 ], parse_val, FALSE );
			}
		}
		rtn = DEFINE;
	}

	else if( active( &stack_frame ) &&
		STequal( words[ 0 ], ERx( "undef" ) ) != 0 )
	{
		if (n > 1)
		{
			undefine( words[ 1 ] );
		}
		rtn = UNDEF;
	}

	else if( STequal( words[ 0 ], ERx( "if" ) ) != 0 )
	{
		/* If an expression was specified look for its evaluation */
		if (n > 1) 
		{
			/* Scan for the 'if' keyword */
			parse_val = infile->yytext;
			CMnext(parse_val);         /* Skip over the '#' */
			while (CMwhite(parse_val))
				CMnext(parse_val);

			/* Scan past the 'if' keyword */
			while (!CMwhite(parse_val))
				CMnext(parse_val);

			/* Scan over white space separating 'if' */
			/* keyword and the expression */
			while (CMwhite(parse_val))
				CMnext(parse_val);

			/* At this point we have scanned to the beginning */
			/* of the expression.*/
			if( active( &stack_frame ) )
			{
				/* Evaluate boolean expression found */
				stack_frame.display_mode = 
					pp_eval_boolexp( &parse_val, ERx("") );
			}
			(void) pp_input( input, &stack_frame, TRUE );
		}
		rtn = IF;
	}

	else if( STequal( words[ 0 ], ERx( "ifdef" ) ) != 0 )
	{
		if( active(&stack_frame) && is_defined(words[1], NULL) == OK)
		{
			stack_frame.display_mode = TRUE;
		}
		else
			stack_frame.display_mode = FALSE;
		(void) pp_input( input, &stack_frame, TRUE );
		rtn = IFDEF;
	}

	else if( STequal( words[ 0 ], ERx( "ifndef" ) ) != 0 )
	{
		if( active(&stack_frame) && is_defined(words[1], NULL) != OK)
		{
			stack_frame.display_mode = TRUE;
		}
		else
			stack_frame.display_mode = FALSE;
		(void) pp_input( input, &stack_frame, TRUE );
		rtn = IFNDEF;
	}

	else if( STequal( words[ 0 ], ERx( "else" ) ) != 0 )
	{
		if( !ifdef )
		{
			SIfprintf( stderr, E_YAPP007 );
			yydump();
		}
		stack_frame.prev->display_mode =
			( stack_frame.prev->display_mode == TRUE ) ?
			FALSE : TRUE;
		rtn = ELSE;
	}

	else if( STequal( words[ 0 ], ERx( "endif" ) ) != 0 )
	{
		rtn = ENDIF;
	}

	else if( STequal( words[ 0 ], ERx( "include" ) ) != 0 )
	{
		/* Look for the include filename */
		if (n > 1) 
		{
			/* Scan for the 'include' keyword */
			parse_val = infile->yytext;
			CMnext(parse_val);         /* Skip over the '#' */
			while (CMwhite(parse_val))
				CMnext(parse_val);

			/* Scan past the include keyword */
			while (!CMwhite(parse_val))
				CMnext(parse_val);

			/* Scan over white space separating 'include' */
			/* keyword and the specified filename */
			while (CMwhite(parse_val))
				CMnext(parse_val);

			/* At this point were expecting "file" or <file> */
			/* remember the character which ends the filename */
			def_dir = TRUE;
			if (CMcmpcase(parse_val, ERx("\"")) == 0)
			{
				parse_end = ERx("\"");
			}
			else if (CMcmpcase(parse_val, ERx("<")) == 0)
			{
				parse_end = ERx(">");
				def_dir = FALSE;
			}
			else
			{
				parse_end = ERx("");
			}

			/* Save the include file name in the temp string. */
			/* Note, this overwrites the parsed words of the  */
			/* record since but these are no longer needed.   */
			p = temp;
			CMnext(parse_val);
			while (*parse_val != EOS)
			{
				if (CMcmpcase(parse_val, parse_end) == 0) 
				{
					/* Terminate the file name and call */
					/* pp_file to process the file. */
					STcopy(ERx(""), p);
					pp_file(stack, temp, def_dir);
					break;
				}
				CMcpychar(parse_val, p);
				CMnext(parse_val);
				CMnext(p);
			}
		}
		rtn = DEFINE;
	}

	/* display everthing but legal directives */ 
	if (rtn == NONE && active( &stack_frame ) )
		yyputline( infile->yytext );

	MEfree( temp );
	return( rtn );
}