Exemplo n.º 1
0
BOOL jam_get_note_value
(
    char *statement_buffer,
    long *value_begin,
    long *value_end
)

/*																			*/
/*	Description:	Finds the value field of a NOTE.  Could be enclosed in	*/
/*					quotation marks, or could not be.  Must be followed by	*/
/*					a semicolon.											*/
/*																			*/
/*	Returns:		TRUE for success, FALSE for failure						*/
/*																			*/
/****************************************************************************/
{
    int index = 0;
    BOOL quoted_string = FALSE;
    BOOL status = FALSE;

    /* skip over white space */
    while ((statement_buffer[index] != JAMC_NULL_CHAR) &&
            (jam_isspace(statement_buffer[index])) &&
            (index < JAMC_MAX_STATEMENT_LENGTH))
    {
        ++index;
    }

    /*
    *	Check if value string has quotes
    */
    if ((statement_buffer[index] == JAMC_QUOTE_CHAR) &&
            (index < JAMC_MAX_STATEMENT_LENGTH))
    {
        quoted_string = TRUE;
        ++index;
    }

    /*
    *	Mark the beginning of the value string
    */
    *value_begin = index;

    /*
    *	Now find the end of the value string
    */
    if (quoted_string)
    {
        /* look for matching quote */
        while ((statement_buffer[index] != JAMC_NULL_CHAR) &&
                (statement_buffer[index] != JAMC_QUOTE_CHAR) &&
                (index < JAMC_MAX_STATEMENT_LENGTH))
        {
            ++index;
        }

        if (statement_buffer[index] == JAMC_QUOTE_CHAR)
        {
            *value_end = index;
            status = TRUE;
            ++index;
        }
    }
    else
    {
        /* look for white space or semicolon */
        while ((statement_buffer[index] != JAMC_NULL_CHAR) &&
                (statement_buffer[index] != JAMC_SEMICOLON_CHAR) &&
                (!jam_isspace(statement_buffer[index])) &&
                (index < JAMC_MAX_STATEMENT_LENGTH))
        {
            ++index;	/* skip over non-white space */
        }

        if ((statement_buffer[index] == JAMC_SEMICOLON_CHAR) ||
                (jam_isspace(statement_buffer[index])))
        {
            *value_end = index;
            status = TRUE;
        }
    }

    if (status)
    {
        while ((statement_buffer[index] != JAMC_NULL_CHAR) &&
                (jam_isspace(statement_buffer[index])) &&
                (index < JAMC_MAX_STATEMENT_LENGTH))
        {
            ++index;	/* skip over white space */
        }

        /*
        *	Next character must be semicolon
        */
        if (statement_buffer[index] != JAMC_SEMICOLON_CHAR)
        {
            status = FALSE;
        }
    }

    return (status);
}
Exemplo n.º 2
0
BOOL jam_check_init_list
(
	char *name,
	long *value
)

/*																			*/
/*	Description:	Compares variable name to names in initialization list	*/
/*					and, if name is found, returns the corresponding		*/
/*					initialization value for the variable.					*/
/*																			*/
/*	Returns:		TRUE if variable was found, else FALSE					*/
/*																			*/
/****************************************************************************/
{
	char r, l;
	int ch_index = 0;
	int init_entry = 0;
	char *init_string = NULL;
	long val;
	BOOL match = FALSE;
	BOOL negate = FALSE;
	BOOL status = FALSE;

	if (jam_init_list != NULL)
	{
		while ((!match) && (jam_init_list[init_entry] != NULL))
		{
			init_string = jam_init_list[init_entry];
			match = TRUE;
			ch_index = 0;
			do
			{
				r = jam_toupper(init_string[ch_index]);
				if (!jam_is_name_char(r)) r = '\0';
				l = name[ch_index];
				match = (r == l);
				++ch_index;
			}
			while (match && (r != '\0') && (l != '\0'));

			if (match)
			{
				--ch_index;
				while (jam_isspace(init_string[ch_index])) ++ch_index;
				if (init_string[ch_index] == JAMC_EQUAL_CHAR)
				{
					++ch_index;
					while (jam_isspace(init_string[ch_index])) ++ch_index;

					if (init_string[ch_index] == JAMC_MINUS_CHAR)
					{
						++ch_index;
						negate = TRUE;
					}

					if (jam_isdigit(init_string[ch_index]))
					{
						val = jam_atol(&init_string[ch_index]);

						if (negate) val = 0L - val;

						if (value != NULL) *value = val;

						status = TRUE;
					}
				}
			}
			else
			{
				++init_entry;
			}
		}
	}

	return (status);
}
Exemplo n.º 3
0
BOOL jam_get_note_key
(
    char *statement_buffer,
    long *key_begin,
    long *key_end
)

/*																			*/
/*	Description:	This function finds the note key name in the statement	*/
/*					buffer and returns the start and end offsets			*/
/*																			*/
/*	Returns:		TRUE for success, FALSE if key not found				*/
/*																			*/
/****************************************************************************/
{
    int index = 0;
    BOOL quoted_string = FALSE;

    index = jam_skip_instruction_name(statement_buffer);

    /*
    *	Check if key string has quotes
    */
    if ((statement_buffer[index] == JAMC_QUOTE_CHAR) &&
            (index < JAMC_MAX_STATEMENT_LENGTH))
    {
        quoted_string = TRUE;
        ++index;
    }

    /*
    *	Mark the beginning of the key string
    */
    *key_begin = index;

    /*
    *	Now find the end of the key string
    */
    if (quoted_string)
    {
        /* look for matching quote */
        while ((statement_buffer[index] != JAMC_NULL_CHAR) &&
                (statement_buffer[index] != JAMC_QUOTE_CHAR) &&
                (index < JAMC_MAX_STATEMENT_LENGTH))
        {
            ++index;
        }

        if (statement_buffer[index] == JAMC_QUOTE_CHAR)
        {
            *key_end = index;
        }
    }
    else
    {
        /* look for white space */
        while ((statement_buffer[index] != JAMC_NULL_CHAR) &&
                (!jam_isspace(statement_buffer[index])) &&
                (index < JAMC_MAX_STATEMENT_LENGTH))
        {
            ++index;	/* skip over white space */
        }

        if (jam_isspace(statement_buffer[index]))
        {
            *key_end = index;
        }
    }

    return ((*key_end > *key_begin) ? TRUE : FALSE);
}