예제 #1
0
static VOID
eqck_idschar(char *idname )
{
    register char	*cp = idname;

    if (*cp == '_')		/* Check if first char is an underscore */ 
    {
	er_write (E_EQ0515_FIPS_IDCHAR, EQ_WARN, 1, idname);
	return;
    }

    /* Check for special characters anywhere in the identifier */
    while (*cp)
    {
	/*
	** Check for special characters anywhere or for an underscore as
	** the last character.
	*/
	if (*cp == '$' || *cp == '@' || *cp == '#'
	    || (*cp == '_' && *(cp+1) == '\0'))
	{
	    er_write (E_EQ0515_FIPS_IDCHAR, EQ_WARN, 1, idname);
	    break;
	}
	CMnext(cp);
    }		
}
예제 #2
0
bool
eqck_tgt(short action, short value)
{
    static short	tgt_list[DB_MAX_COLS];
    static short	tgt_num = 0;

    switch (action)
    {
	case 0:				/* clear */
	    for (tgt_num = 0; tgt_num < DB_MAX_COLS; tgt_num++)
		tgt_list[tgt_num] = 0;
	    tgt_num = 0;
	    return FALSE;
	case 1:				/* reset */
	    tgt_num = 0;
	    if (tgt_list[0] == 0)	/* list is empty */
		return TRUE;
	    else
		return FALSE;
	case 2:				/* fill */
	    tgt_list[tgt_num++] = value;
	    return FALSE;
	case 3:				/* check and flag */
	    if ((tgt_list[0] != 0) && (tgt_list[tgt_num++] != value))
		er_write( E_EQ051D_FIPS_UNIONSEL, EQ_WARN, 0 );
	    return FALSE;
    }
}
예제 #3
0
static VOID
eqck_idkeywd(char *idname )
{
    char	*cp = idname;

    /* Look at ANSI SQL2 table to see if identifier is a keyword */
    if (sc_ansikey(tok_sql2key, tok_sql2num, idname) == OK)	
	er_write (E_EQ0516_FIPS_IDSQL2, EQ_WARN, 1, idname);
}
예제 #4
0
static VOID
eqck_idlen(char *idname )
{
    i4	idlen;

    /* Get length of id */	
    idlen = STlength(idname);

    /*	
    ** If identifier is too long, then this is not a valid FIPS id so give
    ** a FIPS warning.
    */
    if (idlen > FIPS_MAX_IDLEN)
	er_write( E_EQ0514_FIPS_IDLEN, EQ_WARN, 1, idname );
}
예제 #5
0
/*{
** Name:	g4_check - Check request name for INQUIRE_4GL or SET_4GL
**
** Description:
**	The code for the request name is returned, if the request is valid.
**	Otherwise an error is emitted and -1 returned.
**
** Inputs:
**	id		i4	SET or INQUIRE
**	request		char *	request name
**	isobject	bool	Was an object provided	
**
** Returns:
**	i4	code number
**
** Side Effects:
**	An error may be emitted, which will cause the proprocessor to return
**	failure.
**
** History:
**	11/92 (Mike S) Initial version
*/
i4
g4_check(i4 id, char *request, bool isobject)
{
    REQUESTS *requests;
    i4  bot;
    i4  top;
    i4  size;
    i4  probe;

    if (id == IIINQ4GL)
    {
	requests = inq_requests;
	size = sizeof(inq_requests) / sizeof(REQUESTS);
    }
    else
    {
	requests = set_requests;
	size = sizeof(set_requests) / sizeof(REQUESTS);
    }

    bot = 0;
    top = size - 1;
    do
    {
	i4 comp;

	probe = (top + bot) / 2;
	comp = STbcompare(request, 0, requests[probe].request_name, 0, TRUE);
	if (comp == 0)
	    break;
	else if (comp < 0)
	    top = probe - 1;
	else
	    bot = probe + 1;
    } while (bot <= top);

    if (bot > top)
    {
	/* Search failed */
	er_write(E_EQ0081_TL_ATTR_UNKNOWN, EQ_ERROR, 1, request);
    }
    else
    {
	/* We found a keyword match */
	if (requests[probe].need_object && !isobject)
	{
	    er_write(E_EQ0153_fsREQOBJ, EQ_ERROR, 1, request);
	}
	else if (!requests[probe].need_object && isobject)
	{
	    er_write(E_EQ0154_fsNOTOBJ, EQ_ERROR, 1, request);
	}
	else
	{
	    /* We're OK */
	    return requests[probe].code;
	}
    }

    /* Something was wrong */
    return -1;
}