Beispiel #1
0
	void Parser::scan()
	{
        if (!scan_char())
            return;

		for(; !src->eof();)
		{
			if (current_char == L_SECTION)
			{
				scan_section();

				//we'll skip everything after R_SECTION
				// put your comments there or w/e
				//Also
				// let's skip all empty lines
				do
                    skip_until_after(NEWLINE);
                while (current_char == NEWLINE);
			}

			else
            {
                scan_line();

                do
                    skip_until_after(NEWLINE);
                while (current_char == NEWLINE);
            }
		}
	};
Beispiel #2
0
static void
phase_one(void){
#line 1463 "ctangle.w"
phase= 1;
section_count= 0;
reset_input();
skip_limbo();
while(!input_has_ended)scan_section();
check_complete();
phase= 2;
}
Beispiel #3
0
void
#line 350 "./cwebdir/ctang-w2c.ch"
 phase_one P1H(void){
#line 1463 "./cwebdir/ctangle.w"
phase= 1;
section_count= 0;
reset_input();
skip_limbo();
while(!input_has_ended)scan_section();
check_complete();
phase= 2;
}
Beispiel #4
0
static enum save_type detect_save_type(const uint8_t* data, unsigned size)
{
    if (size == 512)
        return EEPROM_512B;
    if (size == 0x2000)
        return EEPROM_8K;
    if (size == 0x10000)
        return FLASH_64K;
    if (size == 0x20000)
        return FLASH_128K;

    if (size == (0x20000 + 0x2000)) {
        if (scan_section(data, 0x10000) && !scan_section(data + 0x10000, 0x10000))
            return FLASH_64K;
        if (scan_section(data, 0x20000))
            return FLASH_128K;

        if (scan_section(data + 0x20000, 512) && !scan_section(data + 0x20000 + 512, 0x20000 - 512))
            return EEPROM_512B;
        if (scan_section(data + 0x20000, 0x2000))
            return EEPROM_8K;
    }

    return SAVE_UNKNOWN;
}
Beispiel #5
0
/*
 * Processes a single man section.
 */
static void
process_section(char *mandir, char *section)
{
	char *cat_section;

	if (already_visited(mandir, section, 1))
		return;
	if (verbose)
		fprintf(stderr, "  section %s\n", section);
	cat_section = get_cat_section(section);
	if (make_writable_dir(mandir, cat_section))
		scan_section(mandir, section, cat_section);
	free(cat_section);
}
Beispiel #6
0
bool Config::load(const char* fname) {
	E_ASSERT(fname != NULL);

	clear();

	FILE *f = fopen(fname, "r");
	if (!f) {
		errcode = CONF_ERR_FILE;
		return false;
	}

	// set default return values
	errcode = CONF_SUCCESS;
	bool status = true;

	// we must have at least one section
	bool sect_found = false;

	// use fixed sizes for sections and keys
	char section[ESECT_MAX];
	char keybuf[EKEY_MAX];

	// line and value can grow
	int buflen = ELINE_SIZE_START;
	char* buf = new char[buflen];

	// use the same size as for line
	int valbuflen = buflen;
	char* valbuf = new char[valbuflen];

	char *bufp;
	ConfigSection* tsect = NULL;

	while(config_getline(&buf, &buflen, f) != -1) {
		++linenum;

		bufp = buf;
		EAT_SPACES(bufp);

		// comment or empty line
		if (*bufp == COMMENT || *bufp == '\0')
			continue;

		// we found an section
		if (*bufp == SECT_OPEN) {
			sect_found = true;
			bufp++;
			if (!scan_section(bufp, section, sizeof(section))) {
				errcode = CONF_ERR_BAD;
				status = false;
				break;
			} else {
				// first check if section exists, or create if not
				tsect = find_section(section);
				if (!tsect) {
					++sectnum;
					tsect = new ConfigSection(section);
					section_list.push_back(tsect);
				}
			}
		}
		// data part
		else {
			// file without sections
			if (!sect_found) {
				errcode = CONF_ERR_SECTION;
				status = false;
				break;
			}

			/*
			 * check if size of valbuf is less than buflen;
			 * in that case make it size as buflen (better would be to use 
			 * buflen - EKEY_MAX - '=' - <spaces>, but that would complicate thing,
			 * also more size does not hurts :P)
			 */
			if(valbuflen < buflen) {
				valbuflen = buflen;
				delete [] valbuf;
				valbuf = new char[valbuflen];
			}

			if (!scan_keyvalues(bufp, keybuf, valbuf, buflen, EKEY_MAX, valbuflen)) {
				errcode = CONF_ERR_BAD;
				status = false;
				break;
			}

			E_ASSERT(tsect != NULL && "Entry without a section ?!");
			tsect->add_entry(keybuf, valbuf);
		}
	}

	fclose(f);
	delete [] buf;
	delete [] valbuf;

	return status;
}