/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
*/
#include "prof_int.h"
#include <stdio.h>
#include <string.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <errno.h>
#include <ctype.h>
struct parse_state {
int state;
int group_level;
};
{
cp++;
return cp;
}
{
*p-- = 0;
}
{
if (*from == '\\') {
from++;
switch (*from) {
case 'n':
*to = '\n';
break;
case 't':
*to = '\t';
break;
case 'b':
*to = '\b';
break;
default:
}
continue;
}
}
*to = '\0';
}
{
state->group_level = 0;
}
{
char *p;
int do_subsection = 0;
void *iter = 0;
if (*line == 0)
return 0;
return 0;
strip_line(cp);
if (ch == 0)
return 0;
if (ch == '[') {
if (state->group_level > 0)
return PROF_SECTION_NOTOP;
cp++;
if (p == NULL)
return PROF_SECTION_SYNTAX;
*p = '\0';
&state->current_section);
if (retval == PROF_NO_SECTION) {
cp, 0,
&state->current_section);
if (retval)
return retval;
} else if (retval)
return retval;
/*
* Finish off the rest of the line.
*/
cp = p+1;
if (*cp == '*') {
cp++;
}
/*
* A space after ']' should not be fatal
*/
if (*cp)
return PROF_SECTION_SYNTAX;
return 0;
}
if (ch == '}') {
if (state->group_level == 0)
return PROF_EXTRA_CBRACE;
&state->current_section);
if (retval)
return retval;
state->group_level--;
return 0;
}
/*
* Parse the relations
*/
if (!cp)
return PROF_RELATION_SYNTAX;
return PROF_RELATION_SYNTAX;
*cp = '\0';
p = tag;
/* Look for whitespace on left-hand side. */
p++;
if (p < cp) {
/* Found some sort of whitespace. */
*p++ = 0;
/* If we have more non-whitespace, it's an error. */
while (p < cp) {
if (!isspace((int)*p))
return PROF_RELATION_SYNTAX;
p++;
}
}
if (value[0] == '"') {
value++;
} else if (value[0] == 0) {
else {
*cp-- = 0;
}
if (do_subsection) {
if (p)
*p = '\0';
if (retval)
return retval;
if (p)
state->group_level++;
return 0;
}
if (p)
*p = '\0';
if (p)
return 0;
}
{
char *cp;
case STATE_INIT_COMMENT:
if (line[0] != '[')
return 0;
case STATE_STD_LINE:
case STATE_GET_OBRACE:
if (*cp != '{')
return PROF_MISSING_OBRACE;
}
return 0;
}
{
char *bptr;
if (!bptr)
return ENOMEM;
if (retval) {
return retval;
}
while (!feof(f)) {
break;
if (retval) {
/* Solaris Kerberos: check if an unconfigured file */
return retval;
}
#else
{
char *p, *end;
/* The string may have foreign newlines and
gotten chopped off on a non-newline
boundary. Seek backwards to the last known
newline. */
long offset;
if (*c == '\r' || *c == '\n') {
*c = '\0';
break;
}
c--;
}
}
/* First change all newlines to \n */
for (p = bptr; *p != '\0'; p++) {
if (*p == '\r')
*p = '\n';
}
/* Then parse all lines */
p = bptr;
while (p < end) {
char* newline;
char* newp;
*newline = '\0';
/* parse_line modifies contents of p */
if (retval) {
return retval;
}
p = newp;
}
}
#endif
}
return 0;
}
/*
* Return TRUE if the string begins or ends with whitespace
*/
{
if (!str)
return 0;
if (str[0] == '\0')
return 1;
return 1;
return 1;
return 0;
}
/*
* Output a string with double quotes, doing appropriate backquoting
* of characters as necessary.
*/
void *data)
{
char ch;
if (!str) {
return;
}
buf[1] = 0;
switch (ch) {
case '\\':
break;
case '\n':
break;
case '\t':
break;
case '\b':
break;
default:
/* This would be a lot faster if we scanned
forward for the next "interesting"
character. */
break;
}
}
}
#if defined(_WIN32)
#endif
#ifndef EOL
#endif
/* Errors should be returned, not ignored! */
{
int i;
struct profile_node *p;
void *iter;
long retval;
iter = 0;
do {
if (retval)
break;
for (i=0; i < level; i++)
if (need_double_quotes(value)) {
} else {
}
} while (iter != 0);
iter = 0;
do {
&name, &p);
if (retval)
break;
if (level == 0) { /* [xxx] */
} else { /* xxx = { ... } */
for (i=0; i < level; i++)
for (i=0; i < level; i++)
}
} while (iter != 0);
}
{
}
{
return 0;
}
struct prof_buf {
char *base;
int err;
};
{
if (b->err)
return;
char *newptr;
b->err = 1;
return;
}
}
}
{
}
char **buf)
{
return ENOMEM;
}
if (newptr)
}
return 0;
}