Exemplo n.º 1
0
/* Name: adu_csnormalize - Normalizes a platform characterset 
**				 string in the alias table or as obtained
**				 by CM_getcharset.
** Description:
**
**	       As per the Unicode technical report UTR22. Ref: 
**	http://www.unicode.org/reports/tr22/ section 1.4, recommended 
**	method to compare the alias values in an alias table to a character 
**	set is to normalize the string in following manner.
**
** 	1. Delete all characters except a-z, A-Z, and 0-9. 
**	2. Map uppercase A-Z to the corresponding lowercase a-z. 
**	3. From left to right, delete each 0 that is not preceded by a digit.
**
** 	For example, the following names should match: "UTF-8", "utf8",
** 	"u.t.f-008", but not "utf-80" or "ut8".
**
** Input:
**      instring -     Unnormalized converter name string.
**
** Output:
**      instring -     Normalized converter name string. 
**
** History:
**      23-Jan-2004 (gupsh01)
**          Added.
*/
void
adu_csnormalize(
    char        *instring,
    i4          inlength,
    char        *outstring)
{
    char *iptr = instring;
    char *endinput = instring + inlength;
    char *optr = outstring;
    char nopreceding = '0';

    while (iptr < endinput)
    {
      if (CMdigit(iptr) || CMalpha(iptr))
      {
        if (CMalpha(iptr))
          nopreceding = *iptr;
        else
          nopreceding = '0';

        CMtolower(iptr,iptr);

        if (nopreceding != '0'&& *iptr == '0')
        {
          *iptr++;
          continue;
        }

        CMcpyinc(iptr, optr);
      }
      else
        iptr++;
    }
    *optr = '\0';
}
Exemplo n.º 2
0
static void
map_funny(char *str)
{
    register char	*from = str;
    register char	*to = str;

    /*
    **	Fix 9005: using wrong test, wasn't mapping Kanji chars, so VMS 
    **		filenames were bad.
    **	WARNING: this means we won't support Kanji filenames!
    **		Also, this doesn't solve the problem of 8-bit chars in the
    **		European character sets.  We need a CMlegal_filename_char
    **		routine.
    */

    /* map any funny bytes to underscores. */
    while (*from != EOS)
    {
	i4	cnt = CMbytecnt(from);

	if ( (!CMalpha(from) && !CMdigit(from)) || CMdbl1st(from) )
	    *to++ = '_';
	else
	    *to++ = *from;
	from += cnt;
    }
    *to = EOS;
}
Exemplo n.º 3
0
/*
** Name: check_path_chars   - test path characters are supported.
**
** Description:
**  Test that the characters in the path are permitted.
**
** Inputs:
**  loc                 Pointer to location structure containing path.
**
** Outputs:
**  status              More detailed error code for failure.
**
** Returns:
**  result      OK      No invalid characters found.
**              FAIL    Invalid characters found in path.
**
** History:
**      14-Feb-2005 (fanra01)
**          Create to replace call to LOisvalid.
**	03-Jun-2005 (drivi01)
**	    Replaced Window's portion of check_path_chars
**	    with LOisvalid.
**  11-Jul-2005 (fanra01)
**      Add status output.
*/
static i4
check_path_chars( LOCATION* loc, STATUS* status )
{
    i4 result = OK;
    char	dev[MAX_LOC];
    char	path[MAX_LOC];
    char	file[MAX_LOC];
    char	ext[MAX_LOC];
    char	vers[MAX_LOC];
    char	*p;

# if defined(NT_GENERIC)

    if (!LOisvalid( loc, &result ))
    {
        if (status != NULL)
        {
            *status = result;
        }
        return FAIL;
    }

# else  /* NT_GENERIC */
    if (LOdetail( loc, dev, path, file, ext, vers ) != OK)
        return FAIL;
    for (p = path; *p != EOS; CMnext(p))
    {
	if (!(CMalpha(p) || CMdigit(p) || CMcmpnocase(p, PATH_SEPARATOR) ||
        '_' || *p == ' '))
	    return FAIL;
    }
    for (p = file; *p != EOS; CMnext(p))
    {
	if (!(CMalpha(p) || CMdigit(p) || *p == '_' || *p == ' '))
	    return FAIL;
    }
    for (p = ext; *p != EOS; CMnext(p))
    {
	if (!(CMalpha(p) || CMdigit(p) || *p == '_' || *p == ' '))
	    return FAIL;
    }
# endif /* NT_GENERIC */
    
    return(result);
}
Exemplo n.º 4
0
VOID
s_cmd_skip()
{
	i4	type;
	i4     rtn_char;               /* dummy variable for sgskip */

	type = s_g_skip(FALSE, &rtn_char);
	while (!((type == TK_PERIOD && CMalpha(Tokchar+CMbytecnt(Tokchar))) ||
		 type == TK_ENDFILE))
	{
		type = s_g_skip(TRUE, &rtn_char);
	}
}
Exemplo n.º 5
0
STATUS
s_lrem_set()
{
    char	*b;
    char	*bend;
    i4		pos;
    i4		n;
    i4		length;
    # ifdef UNIX
    char	word[OOLONGREMSIZE+1]; 
    # else
    char        word[MAXCMD+1];
    # endif
    i4		code;
    i4		count;
    char	*save_Tokchar;
    char	long_remark[OOLONGREMSIZE+1];
    i4          rtn_char;               /* dummy variable for sgskip */

    if (St_lr_given)
    {
	s_error(0x3A9, NONFATAL, NULL);
	s_cmd_skip();
	return FAIL;
    }
    if (Cact_ren == NULL)
    {
	    s_error(0x38A, FATAL, NULL);
    }
    St_lr_given = TRUE;

    /* skip leading white space */

    s_g_skip(TRUE, &rtn_char);

    /* handle rest of remark up to the .ENDREMARK */

    code = S_ERROR;
    b = long_remark;
    bend = b + OOLONGREMSIZE;

    for (;;)
    {
	while (*Tokchar != '\n' && *Tokchar != EOS)
	{
	    if (*Tokchar == '.' && CMalpha(Tokchar+1))
	    {
		/* check for .ENDREMARK */

		save_Tokchar = Tokchar;
		Tokchar++;
		r_gt_word(word);
		CVlower(word);
		code = s_get_scode(word);
		if (code == S_ENDREMARK)
		{
		    break;
		}
		else
		{
		    Tokchar = save_Tokchar;
		}
	    }

	    if (b <= bend-CMbytecnt(Tokchar))
	    {
		if (*Tokchar == '\t')
		{
			/* if tab, replace it with the one blank */
			*b = ' ';
			b++;
			Tokchar++;
		}
		else
		{
		    CMcpyinc(Tokchar, b);
		}
	    }
	    else
	    {
		CMnext(Tokchar);
	    }
	}

	if (code == S_ENDREMARK)
	{
	    *b = EOS;
	    Cact_ren->ren_longrem = STalloc(long_remark);
	    break;
	}
	else
	{
	    if (b < bend)
	    {
	        *b++ = ' ';
	    }
	    count = s_next_line();
	    if (count == 0)
	    {
		/* ERROR: EOF in middle of remark */
		s_error(0x3A3, FATAL, NULL);
		break;
	    }
	}
    }

    return OK;
}
Exemplo n.º 6
0
/*{
**  Name:	MOdetach - detach an attached instance
**
**  Description:
**
**	Detaches an attached instance.  Subsequent attempts to get or
**	set it will fail, and an attempts to attach it will succeed.
**
**	Frees memory allocated by MOattach using MEfree.
**
**	If the call succeeds, it must also call the monitors for the
**	class with the MO_DETACH event, the instance id, and a NULL
**	value.
**
**  Inputs:
**	 classid
**		the classid of the object.
**	 instance
**		the instance of the object.
**  Outputs:
**	 none
**  Returns:
**	 OK
**		if the classid was detached.
**	 MO_NO_INSTANCE
**		if classid is not attached.
**	 MO_NO_DETACH
**		if the object was attached as MO_PERMANENT.
**
**    History:
**	15-jul-92 (daveb)
**	    Go back to single-instance attach/detach, as with
**	    MOcdata_index most bulky static one-offs will be
**	    right in the class definitions anyway, and this
**	    is simpler for the dynamic attach.
**	02-sep-1999 (somsa01)
**	    We were calling MO_tell_class AFTER releasing the MO mutex.
*/
STATUS
MOdetach( char *classid, char *instance )
{
    MO_INSTANCE	*ip;
    MO_CLASS	*cp;
    STATUS stat = OK;
    STATUS mutex_stat = OK;

    MO_once();
    mutex_stat = MO_mutex();
    do
    {
	if( mutex_stat != OK )		/* got mutex */
	    break;

	MO_ndetach++;

	ip = MO_getinstance( classid, instance );
	if( NULL == ip )
	{
	    stat = MO_NO_INSTANCE;
	    break;
	}

	cp = ip->classdef;
	if( cp->perms & MO_PERMANENT )
	{
	    stat = MO_NO_DETACH;
	    break;
	}

	/*
	** We have detachable instance, do it
	*/

	/* detach twin, if any, giving up it it won't go away */

	if( CMalpha( classid ) && NULL != cp->twin &&
	   (stat = MOdetach( cp->twin->node.key, ip->instance)) != OK )
	    break;

	/* delete saved instance string */

	if( (ip->iflags & MO_INSTANCE_VAR) != 0 )
	    MO_delstring( ip->instance );

	/* and finally delete this node */

	SPdelete( &ip->node, MO_instances );
	MO_free( (PTR)ip, sizeof(*ip) );

    } while( FALSE );

    if( mutex_stat == OK )
	(VOID) MO_unmutex();
    else
	stat = mutex_stat;

    if( stat == OK )
    {
	if ( (stat = MO_mutex()) == OK)
	{
	    (VOID) MO_tell_class( cp, instance, (char *)NULL, MO_DETACH );
            MO_unmutex ();
	}
    }

    return( stat );
}
Exemplo n.º 7
0
i4
yylex()
{
	bool pattern;
	bool component;
	bool keyword;
	char *keyhead;
	char yytext[ SI_MAX_TXT_REC + 1 ];
	i4 yyleng;

	/* skip whitespace and comments */
	while( CMwhite( yyp ) || *yyp == EOS || *yyp == '-' )
	{
		/* check for comment */
		if( *yyp == '-' )
		{
			if( STbcompare( yyp, 2, ERx( "--" ), 2, FALSE ) == 0 )
			{
				while( *yyp != EOS )
					CMnext( yyp );
			}
			else
				break;
		}

		if( *yyp == EOS )
		{
			if( SIgetrec( yybuf, sizeof( yybuf ), yyin ) != OK &&
				yywrap() )
			{
				return( 0 );
			}
			else
			{
				yyp = yybuf;
				++yylineno;
			}
		}
		else
			CMnext( yyp );
	}

	/* check for a SYMBOL, PATTERN or keyword */
	yyleng = 0;
	pattern = FALSE;
	keyword = TRUE;
	keyhead = yyp;
	while( CMalpha( yyp ) || *yyp == '%' || *yyp == '$' || *yyp == '*' )
	{
		/* check for component of legal SYMBOL or PATTERN */ 
		component = FALSE;

		/* check for single-character component */
		switch( *yyp )
		{
			case '%':
				pattern = TRUE;
			case '*':
			case '$':
				component = TRUE;
				++yyleng;
				CMnext( yyp );
				if( *yyp == '.' )
				{
					++yyleng;
					CMnext( yyp );
					keyword = FALSE;
					continue;
				}
				else if( CMalpha( yyp ) )
					yyerror(); 
				continue;
		}

		while( CMalpha( yyp ) || CMdigit( yyp ) ||
			*yyp == '_' || *yyp == '-' )
		{
			++yyleng;
			CMnext( yyp );
			component = TRUE;
		}
		if( component )
		{
			if( *yyp == '.' )
			{
				++yyleng;
				CMnext( yyp );
				keyword = FALSE;
				continue;
			}
			continue;
		}
	}

	/* check for uneaten '.' */
	if( *yyp == '.' )
		yyerror();

	if( yyleng > 0 )
	{
		/* A keyword, SYMBOL or PATTERN was scanned */
		char *p;
		i4 i;

		/* put NULL-terminated copy in yytext */
		STlcopy( keyhead, yytext, yyleng );	
		for( p = yytext, i = 0; i <= yyleng; CMnext( p ), i++ );
		*p = EOS;	

		/* check for keywords */
		if( CMalpha( keyhead) && keyword )
		{
			if( STequal( ERx( "IF" ), yytext ) != 0 )
				return( IF );

			if( STequal( ERx( "ELSE" ), yytext ) != 0 )
				return( ELSE );

			if( STequal( ERx( "ELSEIF" ), yytext ) != 0 )
				return( ELSEIF );

			if( STequal( ERx( "ENDIF" ), yytext ) != 0 )
				return( ENDIF );

			if( STequal( ERx( "MIN" ), yytext ) != 0 )
				return( MIN );

			if( STequal( ERx( "MAX" ), yytext ) != 0 )
				return( MAX );

			if( STequal( ERx( "VALID" ), yytext ) != 0 )
				return( VALID );

			if( STequal( ERx( "PRIME" ), yytext ) != 0 )
				return( PRIME );

			if( STequal( ERx( "SIGNED_INT" ), yytext ) != 0 )
				return( SIGNED_INT );

			if( STequal( ERx( "DECIMAL" ), yytext ) != 0 )
				return( DECIMAL );

			if( STequal( ERx( "SIZETYPE" ), yytext ) != 0 )
				return( SIZETYPE );

			if( STequal( ERx( "POWER2" ), yytext ) != 0 )
				return( POWER2 );

			if( STequal( ERx( "REQUIRES" ), yytext ) != 0 )
				return( REQUIRES );

			if( STequal( ERx( "UNDEFINED" ), yytext ) != 0 )
				return( UNDEFINED );

			if( STequal( ERx( "SUM" ), yytext ) != 0 )
			{
				yylval.integer = SUM;
				return( SUM );
			}

			if( STequal( ERx( "ON" ), yytext ) != 0 )
			{
				yylval.real = 1;
				return( BOOL_CON );
			}

			if( STequal( ERx( "OFF" ), yytext ) != 0 )
			{
				yylval.real = 0;
				return( BOOL_CON );
			}

			if( STequal( ERx( "IS" ), yytext ) != 0 )
			{
				yylval.string = STalloc( yytext );
				return( COMPARE_OP );
			}

			if( STequal( ERx( "DIRECTORY" ), yytext ) != 0 )
				return( DIRECTORY );

			if( STequal( ERx( "FILE" ), yytext ) != 0 )
				return( FILESPEC );

		}
		/* valid SYMBOL or PATTERN */
		yylval.string = STalloc( yytext );
		if( pattern )
			return( PATTERN );
		/* don't accept a single '*' as SYMBOL */
		if( yyleng != 1 || *yytext != '*' )
			return( SYMBOL );

		/* push '*' back onto the input stream */
		CMprev( yyp, yybuf );
	}

	/* check for EXEC_TEXT, STR_CON, or EXEC_TEXT_STR */
	if( *yyp == '`' || *yyp == '"' )
	{
		int exec_str = 0;
		char *initstr = yyp;
		char *p = yyp, *text, *yyprev;

		if ( *yyp == '"' )
		{
			CMnext( yyp );
			if ( *yyp == '`' )
			{
				CMnext( p );
				exec_str = 1;
			}
			else
				yyp = p;
		}
		for( yyleng = 0, CMnext( yyp ), yyprev = ERx( "" );
			*yyp != *p || *yyprev == '\\';
			yyprev = ( *yyprev == EOS ) ? yyp : CMnext( yyprev ),
			CMnext( yyp ), ++yyleng )
		{
			if( *yyp == *p && *yyprev == '\\' )
			{
				/* remove escape character */
				char *p1, *p2;

				for( p1 = p2 = yyprev, CMprev( p1, p );
					p1 >= p; CMprev( p1, p ),
					CMprev( p2, p ) )
				{
					CMcpychar( p1, p2 );
				}
				--yyleng;
				CMnext( p );
			}

			if( *yyp == EOS )
				yyerror();
		}
		CMnext( yyp );
		if ( exec_str )
		{
			if ( *yyp == '"' )
				CMnext( yyp );
			else
			{
				/* keep scanning to final '"' */
				p = initstr;
				exec_str = 0;
				yyleng++;
				for( ; *yyp != *p || *yyprev == '\\';
					yyprev = ( *yyprev == EOS ) ? yyp : 
					CMnext( yyprev ),
					CMnext( yyp ), ++yyleng )
				{
					if( *yyp == EOS )
						yyerror();
				}
			}
		}
		text = p;
		CMnext( text );
		STlcopy( text, yytext, yyleng );
		yytext[ yyleng ] = EOS;
		yylval.string = STalloc( yytext );
		if( *p == '`' )
		{
			if ( exec_str )
				return( EXEC_TEXT_STR );
			return( EXEC_TEXT );
		}
		return( STR_CON );
	}

	/* check for NUM_CON */
	yyleng = 0;
	if( *yyp == '-' || CMdigit( yyp ) )
	{
		f8 factor;
		char *p = yyp;

		if( *yyp == '-' )
		{
			++yyleng;
			factor = -1;
			CMnext( yyp );
		}
		else
			factor = 1;
		
		if( !CMdigit( yyp ) )
			CMprev( yyp, yybuf );
		else
		{
			if( *yyp == '-' )
			{
				CMnext( yyp );	
				
			}
			else
				factor = 1;

			while( CMdigit( yyp ) )
			{
				++yyleng;
				CMnext( yyp );
			}

			if( *yyp == '.' )
			{
				++yyleng;
				CMnext( yyp );
				if( !CMdigit( yyp ) )
					yyerror();
				while( CMdigit( yyp ) )
				{
					++yyleng;
					CMnext( yyp );
				}
			}
			else if( *yyp == 'K' || *yyp == 'M' )
			{
				++yyleng;
				CMnext( yyp );
			}

			STlcopy( p, yytext, yyleng ); 
			yytext[ yyleng ] = EOS;

			if( yytext[ yyleng - 1 ] == 'K' )
			{
				factor = 1024;
				yytext[ yyleng - 1 ] = EOS;
			}
			else if( yytext[ yyleng - 1 ] == 'M' )
			{
				factor = 1048576;
				yytext[ yyleng - 1 ] = EOS;
			}
			CVaf( yytext, ERx( '.' ), &yylval.real );
			yylval.real *= factor;
			return( NUM_CON );
		}
	}

	if( STbcompare( yyp, 2, ERx( ">=" ), 2, FALSE ) == 0 )
	{
		yylval.string = STalloc( ERx( ">=" ) );
		CMnext( yyp );
		CMnext( yyp );
		return( COMPARE_OP );
	}
	if( STbcompare( yyp, 2, ERx( "<=" ), 2, FALSE ) == 0 )
	{
		yylval.string = STalloc( ERx( "<=" ) );
		CMnext( yyp );
		CMnext( yyp );
		return( COMPARE_OP );
	}
	/* check for COMPARE_OP */
	if( STbcompare( yyp, 1, ERx( "<" ), 1, FALSE ) == 0 )
	{
		yylval.string = STalloc( ERx( "<" ) );
		CMnext( yyp );
		return( COMPARE_OP );
	}
	if( STbcompare( yyp, 1, ERx( ">" ), 1, FALSE ) == 0 ) 
	{
		yylval.string = STalloc( ERx( ">" ) );
		CMnext( yyp );
		return( COMPARE_OP );
	}
	if( STbcompare( yyp, 2, ERx( "==" ), 2, FALSE ) == 0 )
	{
		yylval.string = STalloc( ERx( "==" ) );
		CMnext( yyp );
		CMnext( yyp );
		return( COMPARE_OP );
	}

	/* check for characters which get passed directly */
	switch( *yyp )
	{
		char *p;

		case '(':
		case ')':
		case '[':
		case ']':
		case '{':
		case '}':
		case ':':
		case ';':
		case ',':
		case '=':
			p = yyp;
			CMnext( yyp );
			return( *p );	

		case '+':
			yylval.string = STalloc( ERx( "+" ) );
			CMnext( yyp );
			return( *yylval.string );

		case '-':
			yylval.string = STalloc( ERx( "-" ) );
			CMnext( yyp );
			return( *yylval.string );

		case '*':
			yylval.string = STalloc( ERx( "*" ) );
			CMnext( yyp );
			return( *yylval.string );

		case '/':
			yylval.string = STalloc( ERx( "/" ) );
			CMnext( yyp );
			return( *yylval.string );
	}

	/* check for LOGIC_OP */
	if( STbcompare( yyp, 3, ERx( "&&" ), 3, FALSE ) == 0 )
	{
		yylval.string = STalloc( ERx( "&&" ) );
		CMnext( yyp );
		CMnext( yyp );
		return( LOGIC_OP );
	}
	if( STbcompare( yyp, 3, ERx( "||" ), 3, FALSE ) == 0 )
	{
		yylval.string = STalloc( ERx( "||" ) );
		CMnext( yyp );
		CMnext( yyp );
		return( LOGIC_OP );
	}

	/* anything else is an error */
	yyerror();

}
Exemplo n.º 8
0
/*{
** Name:	RPedit_name - edit an Ingres name
**
** Description:
**	Edit an Ingres name as specified.  The edited name is placed in a
**	global buffer.
**
** Inputs:
**	edit_type	- edit type
**			  EDNM_ALPHA	- replace special chars with '_'.
**			  EDNM_DELIMIT	- Ingres delimited name.
**			  EDNM_SLITERAL	- SQL single quoted string.
**			  else		- no edit
**	name		- name to edit
**
** Outputs:
**	edited_name	- if supplied, this buffer is filled with the edited
**			  name;  if NULL, a global buffer is used and the
**			  caller should do an STcopy() upon return.
**
** Returns:
**	pointer to the edited name
**/
char *
RPedit_name(
i4	edit_type,
char	*name,
char	*edited_name)
{
	char	tmp_name[DB_MAXNAME*2+3];
	char	*t = tmp_name;
	char	*en;
	char	*n;

	if (edited_name != NULL)
		en = edited_name;
	else
		en = Edited_Name_Buf;

	switch (edit_type)
	{
	case EDNM_ALPHA:		/* alphanumeric */
		for (n = name; *n != EOS; CMnext(n))
		{
			if (CMalpha(n) || (n != name && CMdigit(n)))
				CMcpychar(n, t);
			else
				CMcpychar(ERx("_"), t);
			CMnext(t);
		}
		*t = EOS;
		break;

	case EDNM_DELIMIT:		/* delimited */
		CMcpychar(ERx("\""), t);
		CMnext(t);
		for (n = name; *n != EOS; CMnext(n))
		{
			CMcpychar(n, t);
			if (!CMcmpcase(t, ERx("\"")))
			{
				CMnext(t);
				CMcpychar(ERx("\""), t);
			}
			CMnext(t);
		}
		CMcpychar(ERx("\""), t);
		CMnext(t);
		*t = EOS;
		break;

	case EDNM_SLITERAL:		/* SQL quoted */
		CMcpychar(ERx("'"), t);
		CMnext(t);
		for (n = name; *n != EOS; CMnext(n))
		{
			if (!CMcmpcase(n, ERx("'")))
			{
				CMcpychar(ERx("'"), t);
				CMnext(t);
			}
			CMcpychar(n, t);
			CMnext(t);
		}
		CMcpychar(ERx("'"), t);
		CMnext(t);
		*t = EOS;
		break;

	default:			/* no edit */
		t = name;
		break;
	}

	STcopy(tmp_name, en);
	return (en);
}