int main(int argc, char* argv[]) { nsresult rv; { nsCOMPtr<nsIServiceManager> servMan; NS_InitXPCOM2(getter_AddRefs(servMan), nullptr, nullptr); nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan); NS_ASSERTION(registrar, "Null nsIComponentRegistrar"); if (registrar) registrar->AutoRegister(nullptr); NS_ASSERTION(NS_SUCCEEDED(rv), "AutoregisterComponents failed"); if (argc < 2) { printf("usage: %s resource://foo/<path-to-resolve>\n", argv[0]); return -1; } rv = SetupMapping(); NS_ASSERTION(NS_SUCCEEDED(rv), "SetupMapping failed"); if (NS_FAILED(rv)) return rv; rv = TestOpenInputStream(argv[1]); NS_ASSERTION(NS_SUCCEEDED(rv), "TestOpenInputStream failed"); rv = TestAsyncRead(argv[1]); NS_ASSERTION(NS_SUCCEEDED(rv), "TestAsyncRead failed"); } // this scopes the nsCOMPtrs // no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM rv = NS_ShutdownXPCOM(nullptr); NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed"); return rv; }
void GOrgueMidiRecorder::SendMidiRecorderMessage(GOrgueMidiEvent& e) { if (!m_OutputDevice && !IsRecording()) return; if (!SetupMapping(e.GetDevice(), e.GetMidiType() == MIDI_NRPN)) return; e.SetTime(wxGetLocalTimeMillis()); e.SetChannel(m_Mappings[e.GetDevice()].channel); if (e.GetMidiType() == MIDI_NRPN) e.SetKey(m_Mappings[e.GetDevice()].key); SendEvent(e); }
vtLULCFile::vtLULCFile(const char *fname) { char buf[80]; uint i; m_pNext = NULL; m_iError = 0; FILE *fp = vtFileOpen(fname, "rb"); if (!fp) { m_iError = LULC_ERR_FILE; return; } // subfile A - header if (!GetRecord(fp, buf)) return; geti10(buf+0); // iNumArcs geti10(buf+10); // iNumCoords geti10(buf+20); // iNumPolys m_iNumSections = geti5(buf+40); geti5(buf+45); // iMapType, 1 = LULC geti5(buf+50); // iSubfileLength geti5(buf+55); // iProjectionCode geti10(buf+60); // iScaleDenominator geti10(buf+70); // iMapDate // extent of control points, in local coordinates if (!GetRecord(fp, buf)) return; m_cMin.x = (short) geti5(buf+0); m_cMin.y = (short) geti5(buf+5); m_cMax.x = (short) geti5(buf+10); m_cMax.y = (short) geti5(buf+15); // local coordinates of control points for (i = 0; i < 6; i++) { m_cCorners[i].x = (short) geti5(buf+20+i*10); m_cCorners[i].y = (short) geti5(buf+20+i*10+5); } // latitude and longitude of control points if (!GetRecord(fp, buf)) return; m_Corners[0].y = getdegree(buf+0); m_Corners[0].x = getdegree(buf+10); m_Corners[1].y = getdegree(buf+20); m_Corners[1].x = getdegree(buf+30); m_Corners[2].y = getdegree(buf+40); m_Corners[2].x = getdegree(buf+50); m_Corners[3].y = getdegree(buf+60); m_Corners[3].x = getdegree(buf+70); if (!GetRecord(fp, buf)) return; m_Corners[4].y = getdegree(buf+0); m_Corners[4].x = getdegree(buf+10); m_Corners[5].y = getdegree(buf+20); m_Corners[5].x = getdegree(buf+30); // try to determine the mapping from local to latlon SetupMapping(); geti5(buf+40); // iNad int iNumCharTitle = geti5(buf+45); if (iNumCharTitle > 64) iNumCharTitle = 64; geti5(buf+50); // iLengthOfFAP geti10(buf+60); // CreationDate if (!GetRecord(fp, buf)) return; char title[65]; strncpy(title, buf, iNumCharTitle); // allocate sections m_pSection = new LULCSection[m_iNumSections]; for (i = 0; i < m_iNumSections; i++) ReadSection(m_pSection + i, fp); fclose(fp); }