Example #1
0
void OsmImport::finishedSlot(QNetworkReply *reply)
{
    // Reading attributes of the reply
    // e.g. the HTTP status code
    QVariant statusCodeV = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
    // Or the target URL if it was a redirect:
    QVariant redirectionTargetUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
    // see CS001432 on how to handle this
    project->numLineStrips = 0;
    // no error received?
    if (reply->error() == QNetworkReply::NoError)
    {
        // read data from QNetworkReply here
        QByteArray bytes = reply->readAll();

        QDomDocument doc;
        doc.setContent(bytes);
        parseDoc(doc);
    }
    else
    {
        // handle errors here
    }
    project->getTopviewGraph()->updateSceneSize();
    QApplication::restoreOverrideCursor();
    // We receive ownership of the reply object
    // and therefore need to handle deletion.
    reply->deleteLater();
}
Example #2
0
JLDDoc* JLDIO::parseText(std::string rawText)
{
    rawText = findAndUseMacros(stripComments(rawText));
    // std::cout << "findAndUseMacros result: \n" << rawText << "\n";
    std::istringstream iss(rawText);
    return parseDoc(iss);
}
Example #3
0
int
main(int argc, char **argv) {
        char *docname;
        if (argc <= 1) {
                printf("Usage: %s docname\n", argv[0]);
                return(0);
        }
        docname = argv[1];
        parseDoc (docname);
        return (1);
}
Example #4
0
/** \brief imports a OSM file.
*
*/
bool
OsmImport::importOSMFile(const QString &fileName)
{
    QFile file(fileName);
    if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
        return false;

    QDomDocument doc;
    if (!doc.setContent(&file)) {
        file.close();
        return false;
    }
    file.close();
    return parseDoc(doc);
}
Example #5
0
int
main(int argc, char *argv[])
{
	char *docName;

	if(argc <= 1){
		printf("usage: %s docname\n",argv[0]);
		return 0;
	}

	docName = argv[1];

	parseDoc(docName);

	return 1;
}
Example #6
0
JLDDoc* JLDIO::parseDoc(std::istringstream& iss)
{
    ignoreWhiteSpace(iss);
    char charBuffer;
    iss.get(charBuffer);
    assert(charBuffer == '{' && "Input is not a doc");
    JLDDoc* out = new JLDDoc();
    // empty list
    ignoreWhiteSpace(iss);
    if(iss.peek() == '}')
    {
        iss.get(charBuffer);
        return out;
    }
    do
    {
        auto keyObj = parseString(iss);
        std::string key = keyObj->getValue();
        delete keyObj;
        ignoreWhiteSpace(iss);
        assert(iss.peek() == ':' && ": expected after a keyword");
        iss.get(charBuffer);
        ignoreWhiteSpace(iss);
        JLDData* valueObj;
        switch (iss.peek())
        {
        case '{':
            valueObj = parseDoc(iss);
            break;
        case '[':
            valueObj = parseList(iss);
            break;
        case '\'':
        case '\"':
            valueObj = parseString(iss);
            break;
        default:
            assert(0 && "Unexpected value");
            break;
        }
        out->push_back(key, valueObj);
    } while(moreItems(iss, '}'));
    iss.get(charBuffer);
    return out;
}
Example #7
0
int filmat_parse_map(void)
{
	char *map_name=(char *)calloc(1024,1);
	int ret=0;
	sprintf(map_name,"Pre-parsing: %s%i%s%s",DATA_PREFIX,level,FILE_SEPARATOR,"level.map");
	display_gauge_only(map_name);
	sprintf(map_name,"%s%i%s%s",DATA_PREFIX,level,FILE_SEPARATOR,"level.map");
	if (!openDoc(map_name))
	{
		if (parseDoc())
			ret=-1;
	}
	else
		ret=-2;

	closeDoc();
	free(map_name);
	return ret;
}
Example #8
0
int curl_func(char citytopass[20], char urltopass[80]) {
	FILE* f;
	CURL* thehandle;
	CURLcode res; // result of retrieval / error codes - 0 = CURLE_OK

	// first initialize
	curl_global_init(CURL_GLOBAL_ALL);

	// and use the handle to capture upcoming transfer(s)
	thehandle = curl_easy_init();

	// now tell curl what to do
	curl_easy_setopt(thehandle, CURLOPT_URL, urltopass);

	// download and save xml file
	f = fopen(savefile, "wb");

	if (f == NULL) {
        	printf("xml savefile error :(\n");
        	return(1);
	}

	curl_easy_setopt(thehandle, CURLOPT_WRITEFUNCTION, &write_data);
	curl_easy_setopt(thehandle, CURLOPT_WRITEDATA, f);
	res = curl_easy_perform(thehandle);
	fclose(f);

	// now check for error
	if (res != CURLE_OK) {
		printf("xml download fail. network connected?\n");
		return(1);
	}

	// end the curl section
	curl_global_cleanup();

	// then call the xmlreader func
	if (parseDoc() == 1) 
		return(1);
	else
		return(0);
}
Example #9
0
File: test.c Project: 4179e1/misc
int
main(int argc, char **argv) {

	char *docname;
	char *keyword;
	xmlDocPtr doc;

	if (argc <= 1){
		printf("Usage: %s docname, keyword\n", argv[0]);
		return(0);
	}

	docname = argv[1];
	doc = parseDoc (docname, keyword);
	if (doc != NULL) {
		xmlSaveFormatFile (docname, doc, 1);
		xmlFreeDoc(doc);
	}
	
	return (1);
}
Example #10
0
JLDList* JLDIO::parseList(std::istringstream& iss)
{
    ignoreWhiteSpace(iss);
    char charBuffer;
    iss.get(charBuffer);
    assert(charBuffer == '[' && "Input is not a list");
    JLDList* out = new JLDList();
    // empty list
    ignoreWhiteSpace(iss);
    if(iss.peek() == ']')
    {
        iss.get(charBuffer);
        return out;
    }
    do
    {
        ignoreWhiteSpace(iss);
        JLDData* valueObj;
        switch (iss.peek())
        {
        case '{':
            valueObj = parseDoc(iss);
            break;
        case '[':
            valueObj = parseList(iss);
            break;
        case '\'':
        case '\"':
            valueObj = parseString(iss);
            break;
        default:
            assert(0 && "Unexpected value");
            break;
        }
        out->push_back(valueObj);
    } while(moreItems(iss, ']'));
    iss.get(charBuffer);
    return out;
}
bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parse()
{
    UBMetadataDcSubsetAdaptor::persist(mProxy);

    mIndent = "";
    if (!getTempFileName() || !createTempFlashPath())
        return false;

    if (mDOMdoc.isNull())
        return false;

    bool result = parseDoc();
    if (result)
        result = mProxy->pageCount() != 0;

    if (QFile::exists(mTempFilePath))
        QFile::remove(mTempFilePath);

//    if (mTmpFlashDir.exists())
//        UBFileSystemUtils::deleteDir(mTmpFlashDir.path());

    return result;
}
Example #12
0
int main (int argc, char **argv)
{
    GdkWindow *rootwindow;		 /* RootWindow of X11*/
    GMainLoop *loop;                       /* the event loop */
    char *pw_dir;
    char *xml_file;
    uid_t uid;
    struct passwd *pass;

    /* inits some gdk stuff */
    gdk_init(&argc, &argv);

#ifdef ENABLE_LIBWNCK
    screen = wnck_screen_get_default ();
    wnck_screen_force_update (screen);  
#endif
  
    parse_options(&argc, &argv);
  
    uid = getuid();
    pass = getpwuid (uid);
    pw_dir = pass->pw_dir;
  
    xml_file = (char*) malloc (sizeof (char) * (strlen (XML_FILE) + strlen (pw_dir) + 1));
    sprintf (xml_file, "%s%s", pw_dir, XML_FILE);
    
    eventlist = parseDoc (xml_file);
    if (eventlist == NULL)
    {
	g_print ("xml error or no elements in list\n");
	exit (1);
    }
    free (xml_file);

    rootwindow = gdk_window_foreign_new (gdk_x11_get_default_root_xwindow());
    /*rootwindow = gdk_window_foreign_new (0x1200002); */

    if (rootwindow == NULL)
    {
	g_print ("rootwindow == NULL\n");
	exit (1);
    }
  
    /* check if GDK_BUTTON_PRESS_MASK is available */
    gdk_error_trap_push ();

    /* ... Call the X function which may cause an error here ... */
    gdk_window_set_events (rootwindow, GDK_BUTTON_PRESS_MASK);
    gdk_window_set_events (rootwindow, GDK_SCROLL_MASK);
  
    /* Flush the X queue to catch errors now. */
    gdk_flush ();

    if (gdk_error_trap_pop ())
    {
	char error[] = "grootevent: an error occured while querying the X server.\n"
	    "A window manager or an application is already grapping\n"
	    "the buttons from the root window.\n\n"
	    "Please read the documentation to get more help about this.\n";
	g_print (error);
	exit (1);
    }
    
    gdk_event_handler_set (event_func, NULL, NULL);

    loop = g_main_loop_new (NULL, FALSE);
    g_main_loop_run (loop);
   
    return 0;
}