Example #1
0
		    virtual bool read( Serialize::Client & ph )
			{
			    if ( ! prefs ) 
			    {
			        return 0;
			    }
			    if ( feof( prefs ) ) 
			    {
			        return 0;
			    }

			    char buf[500];
			    char key[200];
			    char value[400];
				char *line;
				while ( fgets( buf, 499, prefs ) )
			    {
					line = buf;
					while ( line[0] == ' ' || line[0] == '\t'  )
						line ++;

			        if ( line[0] == '\n' ) 
			        {
						ph.read( *this );
						params.clear();
						return 1;
			        } 

					if ( line[0] == '#' ) 
			        {
			            continue;
			        } 

					// nuke whitespace at end of line:
					size_t l = strlen(line);
					while (--l)
					{
						if ( line[l] == '\n' || line[l] == '\r' || line[l] == '\t' || line[l] == ' ' )
						{
							line[l] = 0;
							continue;
						}
						break;
					}

					if ( char * end = strchr( line, '=') )
			        {
			            *end = 0;
			            strcpy( key, line );
			            strcpy( value , (end+1) );
			            push(  key , value );
			        }
			    }
			    return 0;
			}
Example #2
0
bool name_is_valid()
{
    nsol = 0;

    sol.clear();
    for (int i = 0; i < R; ++i)
        for (int j = 0; j < C; ++j)
            dfs(i, j, 0);

    return nsol < 2;
}