Ejemplo n.º 1
0
static inline bool __xuuid_parse(struct xuuid *uuid, const char *in,
				 bool req_nul)
{
	return (in[8] == '-') && (in[13] == '-') &&
	       (in[18] == '-') && (in[23] == '-') &&
	       (!req_nul || (in[36] == '\0')) &&
	       parse_part(&uuid->raw[0], &in[0], 4) &&
	       parse_part(&uuid->raw[4], &in[9], 2) &&
	       parse_part(&uuid->raw[6], &in[14], 2) &&
	       parse_part(&uuid->raw[8], &in[19], 2) &&
	       parse_part(&uuid->raw[10], &in[24], 6);
}
Ejemplo n.º 2
0
/** Scan a C string for an IPv4 address.

\return \c NULL if parsing failed, otherwise a pointer to the
first character after the end of the address.
*/
const char* ipv4_scan(const char* start, ipv4addr* addr)
{
  const char* s;
  if ((s = parse_part(start, &addr->addr[0])) == 0) return 0;
  if (*s != '.' && addr->addr[0] == 0) {
    /* Special case -- The number "0" represents 0.0.0.0 */
    memset(addr, 0, sizeof *addr);
    return s;
  }
  if ((s = parse_part(s+1, &addr->addr[1])) == 0 || *s != '.') return 0;
  if ((s = parse_part(s+1, &addr->addr[2])) == 0 || *s != '.') return 0;
  if ((s = parse_part(s+1, &addr->addr[3])) == 0) return 0;
  return s;
}
Ejemplo n.º 3
0
bool MainWindow::loadFile(const QString &fileName) {
	char buf[1024];
	char localFileName[800];
	QByteArray pstr;
	
	// convert fileName to localFileName
	// copy localFileName to Dataname
	pstr = fileName.toLatin1();						//possible alt .toAscii().data()
	strncpy(localFileName, pstr.data(), 800-1);
	strncpy(Dataname, localFileName, 800-1);
	parse_part();
	visualize_part();
	display_complete_graph();
	update_zoom_status();
	canvas->viewport()->update();
	_snprintf(buf, sizeof(buf), "WinGraph32 - %s", localFileName);
	setWindowTitle(buf);
	statistics();
	_snprintf(buf, sizeof(buf), "%d nodes, %d edge segments, %d crossings",
            st_nr_vis_nodes,
            st_nr_vis_edges,
            nr_crossings);
	setNodesValue(buf);

	resize(800, 600);
	return true;
}
Ejemplo n.º 4
0
Archivo: c_cmd.cpp Proyecto: pouba/os
int parse_line(char* line, run_params* par) {
	char* cmd = (char*)malloc(sizeof(char) * MAX_CMD_LEN);
	int pos_line = 0, pos_cmd = 0;
	int c;
	int in_q = 0;
	while (true) {
		c = line[pos_line];

		if (c == '"') in_q = 1 - in_q;

		if (((c == CMD_END_CHAR) && (!in_q)) || (c == '\0')) {
			cmd[pos_cmd] = '\0';
			pos_line++;
			int ret = parse_part(cmd, par);
			if (ret == 1) return 1;
			pos_cmd = 0;
			if (c == '\0') return 0;
		}
		else {
			cmd[pos_cmd] = line[pos_line];
			pos_cmd++;
			pos_line++;
		}
	}

	free(cmd);
}
Ejemplo n.º 5
0
static void parse_message(struct ws_parser_info *parser_info, struct evbuffer *buf, u_char *message)
{
    parse_part_n(parser_info, buf, "\x00", 1);

    parse_part(parser_info, buf, message);

    parse_part_n(parser_info, buf, "\xff", 1);
}
Ejemplo n.º 6
0
END_TEST

START_TEST(test_ws_error_0)
{
	parse_part(__parser_info, __buf, "HET");

    __waiting_call_count = 1;
    __waiting_call_info = ERROR_CALL;
}
Ejemplo n.º 7
0
END_TEST

START_TEST(test_ws_error_1)
{
    parse_message(__parser_info, __buf, MESSAGE);

    parse_part(__parser_info, __buf, "cdcd");

    __waiting_call_count = 2;
    __waiting_call_info = ERROR_CALL | MESSAGE_CALL;
}
Ejemplo n.º 8
0
xml_dayf *
parse_dayf (xmlNode *cur_node)
{
    xml_dayf *ret;  
    gchar *value;

    if ((ret = g_new0(xml_dayf, 1)) == NULL)
        return NULL;

    ret->day  = (gchar *) xmlGetProp (cur_node, (const xmlChar *) "t");
    ret->date = (gchar *) xmlGetProp (cur_node, (const xmlChar *) "dt");

    for (cur_node = cur_node->children; cur_node; cur_node = cur_node->next)
    {
        if (cur_node->type != XML_ELEMENT_NODE)
            continue;

        if (NODE_IS_TYPE (cur_node, "hi"))
        {
            ret->hi = DATA(cur_node); 
            g_assert(ret->hi != NULL);
        }
        else if (NODE_IS_TYPE (cur_node, "low"))
        {
            ret->low = DATA(cur_node);
        }
        else if (NODE_IS_TYPE (cur_node, "part"))
        {
            value = (gchar *)  xmlGetProp (cur_node, (const xmlChar *) "p");
            
            if (xmlStrEqual ((const xmlChar *)value, (const xmlChar *)"d"))
                ret->part[0] = parse_part(cur_node);
            else if (xmlStrEqual ((const xmlChar *)value, (const xmlChar *)"n"))
                ret->part[1] = parse_part(cur_node);
            
            g_free(value);
        }
    }

    return ret;
}
Ejemplo n.º 9
0
Archivo: parser.c Proyecto: rju/slp
/* Main parser function
 */
int parse() {
	token = yylex();
	do {
		switch (token) {
		case TITLE:
			if (!parse_title()) return 0;
			break;
		case AUTHOR:
			if (!parse_author()) return 0;
			break;
		case DATE:
			if (!parse_date()) return 0;
			break;
		case SECTION:
			if (!parse_section()) return 0;
			break;
		case FRAME:
			if (!parse_frame()) return 0;
			break;
		case PART:
			if (!parse_part()) return 0;
			break;
		case EOF:
		case ZERO:
			return 1;
		case NEWLINE:
			token = yylex();
			break;
		case IMAGE:
			fprintf(stderr, "[%d] Top mode: figure not allowed in top mode.\n",yylineno);
			return 0;
		case ANIMATION:
			fprintf(stderr, "[%d] Top mode: figure not allowed in top mode.\n",yylineno);
			return 0;
		case LISTING:
			fprintf(stderr, "[%d] Top mode: listing not allowed in top mode.\n", yylineno);
			return 0;
		case STRUCT:
			fprintf(stderr, "[%d] Top mode: structure not allowed in top mode.\n", yylineno);
			return 0;
		case ITEM:
			fprintf(stderr, "[%d] Top mode: item not allowed in top mode.\n", yylineno);
			return 0;
		default:
			fprintf(stderr, "[%d] Top mode: %s \"%s\" not allowed in top mode.\n", yylineno,
					get_token_name(token), yytext);
			return 0;
		}
	} while (token != EOF);

	return 1;
}
Ejemplo n.º 10
0
void Project::parse()
{
    QFile f( filename );
    if ( !f.exists() || !f.open( IO_ReadOnly ) )
	return;
    QTextStream ts( &f );
    QString contents = ts.read();
    f.close();

    proName = QFileInfo( filename ).baseName();

    QStringList::ConstIterator it;

    int i = contents.find( "LANGUAGE" );
    if ( i != -1 ) {
	lang = "";
	is_cpp = FALSE;
	QString part = contents.mid( i + QString( "LANGUAGE" ).length() );
	lang = parse_part( part );
	is_cpp = lang == "C++";
    }

    i = contents.find( "DBFILE" );
    if ( i != -1 ) {
	dbFile = "";
	QString part = contents.mid( i + QString( "DBFILE" ).length() );
	dbFile = parse_part( part );
    }

    QStringList uifiles = parse_multiline_part( contents, "FORMS" );
    uifiles += parse_multiline_part( contents, "INTERFACES" ); // compatibility
    for ( it = uifiles.begin(); it != uifiles.end(); ++it ) {
	if ( (*it).startsWith( "__APPOBJ" ) )
	    continue;
	(void) new FormFile( *it, FALSE, this );
    }


    i = contents.find( "TEMPLATE" );
    if ( i != -1 ) {
	templ = "";
	QString part = contents.mid( i + QString( "TEMPLATE" ).length() );
	templ = parse_part( part );
    }

    readPlatformSettings( contents, "CONFIG", cfg );
    readPlatformSettings( contents, "LIBS", lbs );
    readPlatformSettings( contents, "INCLUDEPATH", inclPath );
    readPlatformSettings( contents, "DEFINES", defs );
    readPlatformSettings( contents, "SOURCES", sources );
    readPlatformSettings( contents, "HEADERS", headers );

    LanguageInterface *iface = MetaDataBase::languageInterface( lang );
    if ( iface ) {
	QStringList sourceKeys;
	iface->sourceProjectKeys( sourceKeys );
	for ( QStringList::Iterator it = sourceKeys.begin(); it != sourceKeys.end(); ++it ) {
	    QStringList lst = parse_multiline_part( contents, *it );
	    for ( QStringList::Iterator it = lst.begin(); it != lst.end(); ++it )
		(void) new SourceFile( *it, FALSE, this );
	}
    }

    updateCustomSettings();

    for ( it = csList.begin(); it != csList.end(); ++it ) {
	i = contents.find( *it );
	if ( i != -1 ) {
	    QString val = "";
	    QString part = contents.mid( i + QString( *it ).length() );
	    val = parse_part( part );
	    customSettings.replace( *it, val );
	}
    }

    loadConnections();

    QStringList images = parse_multiline_part( contents, "IMAGES" );

    // ### remove that for the final - this is beta-compatibility
    if ( images.isEmpty() && QDir( QFileInfo( filename ).dirPath( TRUE ) + "/images" ).exists() ) {
	    images = QDir( QFileInfo( filename ).dirPath( TRUE ) + "/images" ).entryList();
	    for ( int i = 0; i < (int)images.count(); ++i )
		images[ i ].prepend( "images/" );
	    modified = TRUE;
    }

    for ( QStringList::ConstIterator pit = images.begin(); pit != images.end(); ++pit )
	pixCollection->load( *pit );
}