NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create RDF/XML data source"); if (NS_FAILED(rv)) return rv;  nsCOMPtr<nsIRDFRemoteDataSource> remote = do_QueryInterface(ds);
nsCOMPtr<nsIRDFRemoteDataSource> remote = do_QueryInterface(ds);
main(int argc, char** argv){    nsresult rv;    if (argc < 2) {        fprintf(stderr, "usage: %s <url> [<poll-interval>]\n", argv[0]);        return 1;    }    rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);    if (NS_FAILED(rv)) {        fprintf(stderr, "NS_InitXPCOM2 failed\n");        return 1;    }    // Get netlib off the floor...    nsCOMPtr<nsIEventQueueService> theEventQueueService =              do_GetService(kEventQueueServiceCID, &rv);    if (NS_FAILED(rv)) return rv;    rv = theEventQueueService->CreateThreadEventQueue();    NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create thread event queue");    if (NS_FAILED(rv)) return rv;    // Create a stream data source and initialize it on argv[1], which    // is hopefully a "file:" URL. (Actually, we can do _any_ kind of    // URL, but only a "file:" URL will be written back to disk.)    nsCOMPtr<nsIRDFDataSource> ds;    rv = nsComponentManager::CreateInstance(kRDFXMLDataSourceCID,                                            nsnull,                                            NS_GET_IID(nsIRDFDataSource),                                            getter_AddRefs(ds));    NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create RDF/XML data source");    if (NS_FAILED(rv)) return rv;    nsCOMPtr<nsIRDFRemoteDataSource> remote        = do_QueryInterface(ds);    if (! remote)        return NS_ERROR_UNEXPECTED;    rv = remote->Init(argv[1]);    NS_ASSERTION(NS_SUCCEEDED(rv), "unable to initialize data source");    if (NS_FAILED(rv)) return rv;    // The do_QI() on the pointer is a hack to make sure that the new    // object gets AddRef()-ed.    nsCOMPtr<nsIRDFObserver> observer = do_QueryInterface(new Observer);    if (! observer)        return NS_ERROR_OUT_OF_MEMORY;    rv = ds->AddObserver(observer);    if (NS_FAILED(rv)) return rv;    while (1) {        // Okay, this should load the XML file...        rv = remote->Refresh(PR_TRUE);        NS_ASSERTION(NS_SUCCEEDED(rv), "unable to open datasource");        if (NS_FAILED(rv)) return rv;        if (argc <= 2)            break;        PRInt32 pollinterval = atol(argv[2]);        if (! pollinterval)            break;        PR_Sleep(PR_SecondsToInterval(pollinterval));    }    return NS_OK;}