Ejemplo n.º 1
0
/* extract_path()
 * ====================================================================
 *  Given an index into bufptr, immediately following the keyword that
 *  indicates a path follows, will extract a pointer to the path and
 *  return it.
 */
char
*extract_path( int *offset, int max )
{
    int j;

    /* Goes looking for the start of the path */
    while ( ( bufptr[ *offset ] != '=' ) && ( *offset < max ) )
    {
        *offset += 1;
    }

    *offset += 1;
    while ( ( kisspace(bufptr[*offset])) && ( *offset < max) )
    {
        *offset += 1;
    }

    /* Properly null terminates the path */
    j = *offset;
    while ((bufptr[j] != '\n') && (j < (max - 1)) && (bufptr[j] != '\r')) {
        ++j;
    }
    bufptr[j] = '\0';

    return ( &bufptr[*offset] );
}
Ejemplo n.º 2
0
int kvsscanf(const char *buffer, const char *format, va_list args)
{
	const char *buf = buffer;
	int count = 0;
	while (*format)
	{
		if (kisspace(*format))
		{
			while (kisspace(*buf))
				buf++;
		}
		else if (*format == '%')
		{
			format++;
			switch (*format++)
			{
			case '%':
			{
				if (*buffer++ != '%')
					return count;
			}

			case 'n':
			{
				int *out = va_arg(args, int *);
				*out = buf - buffer;
			}

			case 'd':
			{
				int32_t *out = va_arg(args, int32_t *);
				PARSE_NUM(buf, out, int32_t, uint32_t);
			}

			case 'u':
			{
				uint32_t *out = va_arg(args, uint32_t *);
				PARSE_NUM(buf, out, uint32_t, uint32_t);
			}
			}
		}
		else
		{
			if (*buffer++ != *format++)