CUnixDynamicLoader::CUnixDynamicLoader(const char *libname) : module(NULL), err(NULL) { if (libname == NULL) { DoOpen(NULL); } else { CTFileName fnm = ConvertLibNameToPlatform(libname); // Always try to dlopen from inside the game dirs before trying // system libraries... if (fnm.FileDir() == "") { char buf[MAX_PATH]; _pFileSystem->GetExecutablePath(buf, sizeof (buf)); CTFileName fnmDir = CTString(buf); fnmDir = fnmDir.FileDir() + fnm; DoOpen(fnmDir); if (module != NULL) { return; } } DoOpen(fnm); } }
void ReopenEditorListView::OnReopenItems(wxCommandEvent& event) { if(m_pListControl && m_pListControl->GetItemCount() > 0) { long index = -1; if(event.GetId() == idReopenItem) { index = m_pListControl->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); if(index != -1) { DoOpen(GetFilename(index)); } } if(event.GetId() == idReopenItems) { wxArrayString list; index = m_pListControl->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); while(index != -1) { list.Add(GetFilename(index)); index = m_pListControl->GetNextItem(index, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); } if(list.GetCount() > 0) { DoOpen(list); } } } }
bool RemoteConnect( void ) { ConnRequest( CONNECT_REQUEST ); if( NameBuff[0] == BIND_ACK ) { DoOpen( &ReadHdl, READ_SUFF ); DoOpen( &WriteHdl, WRITE_SUFF ); ConnRequest( CONNECT_DONE ); return( TRUE ); } return( FALSE ); }
char *RemoteLink( char *config, bool server ) { char *msg; char *end; server=server; end = ValidName( config ); strcpy( NameBuff+1, PREFIX ); if( end == NULL ) { return( TRP_ERR_invalid_server_name_format_is ); } else { if( end == config ) { strcpy( NameBuff+1 + PREFIX_LEN, DefLinkName ); } else { memcpy( NameBuff+1 + PREFIX_LEN, config, end-config ); NameBuff[ end-config+1+PREFIX_LEN ] = '\0'; } } msg = OpenRequest(); NameEnd = NameBuff + strlen( NameBuff ); if( msg != NULL ) return( msg ); if( NameBuff[0] != BIND_ACK ) { #ifdef SERVER return( TRP_ERR_server_name_already_in_use ); #else return( TRP_ERR_server_not_found ); #endif } else { DoOpen( &ConnHdl, CONN_SUFF ); } return( NULL ); }
void COpenCVStitch2013Dlg::OnBnClickedOneshot() { DoOpen(); Mat stitched; vector<Mat> images; // for (size_t i = 0; i < camera.size(); i++) { Mat image; camera[i] >> image; if (image.empty() == false) { imshow(camera[i].GetName(), image); images.push_back(image); } } if (2 <= camera.size()) { stitcher.estimateTransform(images); if (MyStitcher::Status::OK == stitcher.composePanorama(images, stitched)) { //imageSize = Size(stitched.cols, stitched.rows); imshow(STITCHED, stitched); m_start.EnableWindow(); } else { MessageBox(L"内部処理でのエラー", L"キャリブレート"); } } else { MessageBox(L"カメラが少ないためキャリブレートできません"); } }
// BUGBUG: Arguments are reversed from as documented in April '96 MSDN! NDIS_STATUS MiniportReset(PBOOLEAN AddressingReset, NDIS_HANDLE MiniportAdapterContext) { IrDevice *dev, *thisDev = CONTEXT_TO_DEV(MiniportAdapterContext); NDIS_STATUS result = NDIS_STATUS_SUCCESS; DBGOUT(("MiniportReset(0x%x)", (UINT)MiniportAdapterContext)); /* BUGBUG: fixed; REMOVE ??? * Verify that the context is not bogus. * I've seen bad contexts getting passed in when the system gets corrupted. */ for (dev = firstIrDevice; dev && (dev != thisDev); dev = dev->next){ } if (!dev){ DBGERR(("Bad context in MiniportReset")); return NDIS_STATUS_FAILURE; } DoClose(thisDev); CloseDevice(thisDev); OpenDevice(thisDev); DoOpen(thisDev); *AddressingReset = TRUE; DBGOUT(("MiniportReset done.")); return result; }
NS_IMETHODIMP nsGnomeVFSInputStream::Read(char *aBuf, PRUint32 aCount, PRUint32 *aCountRead) { *aCountRead = 0; if (mStatus == NS_BASE_STREAM_CLOSED) return NS_OK; if (NS_FAILED(mStatus)) return mStatus; GnomeVFSResult rv = GNOME_VFS_OK; // If this is our first-time through here, then open the URI. if (!mHandle && !mDirOpen) rv = DoOpen(); if (rv == GNOME_VFS_OK) rv = DoRead(aBuf, aCount, aCountRead); if (rv != GNOME_VFS_OK) { // If we reach here, we hit some kind of error. EOF is not an error. mStatus = MapGnomeVFSResult(rv); if (mStatus == NS_BASE_STREAM_CLOSED) return NS_OK; LOG(("gnomevfs: result %d [%s] mapped to 0x%x\n", rv, gnome_vfs_result_to_string(rv), mStatus)); } return mStatus; }
bool UniStdioFile::Open(LPCTSTR filename, LPCTSTR mode) { if (!DoOpen(filename, mode)) { Close(); return false; } return true; }
f_handle QOpenRW( char *name ) /***********************************/ { tiny_ret_t h; h = DoOpen( name, TRUE, TIO_NORMAL ); if( TINY_OK( h ) ) return( (f_handle)TINY_INFO( h ) ); LnkMsg( FTL+MSG_CANT_OPEN, "12", name, QErrMsg( TINY_INFO( h ) ) ); return( NIL_HANDLE ); }
static f_handle NSOpen( char *name, unsigned mode ) /*************************************************/ { tiny_ret_t h; h = DoOpen( name, FALSE, mode ); LastResult = TINY_INFO( h ); if( TINY_OK( h ) ) return( TINY_INFO( h ) ); return( NIL_HANDLE ); }
/** @brief Open file with specified arguments */ bool UniMemFile::Open(LPCTSTR filename, DWORD dwOpenAccess, DWORD dwOpenShareMode, DWORD dwOpenCreationDispostion, DWORD dwMappingProtect, DWORD dwMapViewAccess) { // We use an internal workhorse to make it easy to close on any error if (!DoOpen(filename, dwOpenAccess, dwOpenShareMode, dwOpenCreationDispostion, dwMappingProtect, dwMapViewAccess)) { Close(); return false; } return true; }
f_handle ExeCreate( char *name ) /*************************************/ { tiny_ret_t h; h = DoOpen( name, TRUE, TIO_NORMAL ); LastResult = TINY_INFO( h ); if( TINY_OK( h ) ) return( TINY_INFO( h ) ); return( NIL_HANDLE ); }
f_handle QOpenR( char *name ) /***************************/ { int h; h = DoOpen( name, O_RDONLY, false ); if( h != -1 ) return( h ); LnkMsg( FTL+MSG_CANT_OPEN, "12", name, strerror( errno ) ); return( NIL_FHANDLE ); }
f_handle QOpenRW( char *name ) /***********************************/ { int h; h = DoOpen( name, O_RDWR | O_CREAT | O_TRUNC, FALSE ); if( h != -1 ) return( h ); LnkMsg( FTL+MSG_CANT_OPEN, "12", name, strerror( errno ) ); return( NIL_FHANDLE ); }
f_handle ExeOpen( char *name ) /***********************************/ { int h; h = DoOpen( name, O_RDWR, TRUE ); if( h != -1 ) return( h ); LnkMsg( FTL+MSG_CANT_OPEN, "12", name, strerror( errno ) ); return( NIL_FHANDLE ); }
static f_handle NSOpen( char *name, unsigned mode ) /*************************************************/ { int h; h = DoOpen( name, mode, FALSE ); LastResult = h; if( h != -1 ) return( h ); return( NIL_FHANDLE ); }
void GenericHID::onMRUSelected(const QString &sFile) { // check for changes if ( !CheckDataChanged() ) return; // Clear existing Clear(); DoOpen( sFile ); }
static RageFileObjDirect *MakeFileObjDirect( RString sPath, int iMode, int &iError ) { int iFD; if( iMode & RageFile::READ ) { iFD = DoOpen( sPath, O_BINARY|O_RDONLY, 0666 ); /* XXX: Windows returns EACCES if we try to open a file on a CDROM that isn't * ready, instead of something like ENODEV. We want to return that case as * ENOENT, but we can't distinguish it from file permission errors. */ } else { RString sOut; if( iMode & RageFile::STREAMED ) sOut = sPath; else sOut = MakeTempFilename(sPath); /* Open a temporary file for writing. */ iFD = DoOpen( sOut, O_BINARY|O_WRONLY|O_CREAT|O_TRUNC, 0666 ); } if( iFD == -1 ) { iError = errno; return NULL; } #if defined(UNIX) struct stat st; if( fstat(iFD, &st) != -1 && (st.st_mode & S_IFDIR) ) { iError = EISDIR; close( iFD ); return NULL; } #endif return new RageFileObjDirect( sPath, iFD, iMode ); }
void ReopenEditorListView::OnReopenAll(wxCommandEvent& /*event*/) { if(m_pListControl && m_pListControl->GetItemCount() > 0) { wxArrayString list; for(long i = 0; i < m_pListControl->GetItemCount(); ++i) { list.Add(GetFilename(i)); } DoOpen(list); } }
// We support loading a data file from the command line. void GenericHID::ProcessCommandline() { QStringList args = QCoreApplication::instance()->arguments(); if ( args.count() > 1 ) { QString sFile = args[1]; QFileInfo info( sFile ); if ( !info.exists() ) QMessageBox::critical( this, "File not found", QString("File '%1' does not exist").arg(sFile) ); else DoOpen( sFile ); } }
bool RageFileObjDirect::OpenInternal( const CString &sPath, int iMode, int &iError ) { m_sPath = sPath; m_iMode = iMode; if( iMode & RageFile::READ ) { m_iFD = DoOpen( sPath, O_BINARY|O_RDONLY, 0666 ); /* XXX: Windows returns EACCES if we try to open a file on a CDROM that isn't * ready, instead of something like ENODEV. We want to return that case as * ENOENT, but we can't distinguish it from file permission errors. */ } else { CString sOut; /* open a temporary file if we're not streaming */ if( iMode & RageFile::STREAMED ) sOut = sPath; else sOut = MakeTempFilename(sPath); /* Open a temporary file for writing. */ m_iFD = DoOpen( sOut, O_BINARY|O_WRONLY|O_CREAT|O_TRUNC, 0666 ); } if( m_iFD == -1 ) { iError = errno; return false; } /* enable the write buffer if we're writing data */ if( iMode & RageFile::WRITE ) this->EnableWriteBuffering( BUFFER_SIZE ); return true; }
void CProtocolExadump::DoPacket(const RMBufPacketBase &aPacket, const RMBufPktInfo &aInfo) /** * Dump the packet. * * This is called for both incoming and outgoing packets, from the * respective ApplyL methods. * * @param aPacket The packet data * @param aInfo The packet inforrmation */ { /** @code */ // Open the dump file, if not already opened (or attempted). if (iOpen == 0) DoOpen(1500); if (iOpen < 0) return; // cannot open output file. // // Build PCAP frame into iBuffer (pcap_pkthdr + snapped portion of the packet) // TPtr8 buf = iBuffer->Des(); struct pcap_pkthdr *const hdr = (struct pcap_pkthdr *)buf.Ptr(); TPtr8 ptr((TUint8 *)buf.Ptr() + sizeof(*hdr), buf.MaxLength() - sizeof(*hdr)); const TInt snap = aInfo.iLength > ptr.MaxLength() ? ptr.MaxLength() : aInfo.iLength; ptr.SetLength(snap); aPacket.CopyOut(ptr); hdr->caplen = snap; hdr->len = aInfo.iLength; TTime stamp; stamp.UniversalTime(); const TTimeIntervalMicroSeconds elapsed = stamp.MicroSecondsFrom(iBase); #ifdef I64INT hdr->ts.tv_usec = I64INT(elapsed.Int64() % 1000000); hdr->ts.tv_sec = I64INT(elapsed.Int64() / 1000000); #else hdr->ts.tv_usec = (elapsed.Int64() % 1000000).GetTInt(); hdr->ts.tv_sec = (elapsed.Int64() / 1000000).GetTInt(); #endif // // Write frame out. // iDumpFile.Write(buf, snap+sizeof(*hdr)); /** @endcode */ }
void GenericHID::onFileOpen() { // check for changes if ( !CheckDataChanged() ) return; // open file QString sFile = QFileDialog::getOpenFileName( this, "Open GenericHID device", m_sLastFile, QString("Generic HID device file (*.ghd);;All files (*)") ); if ( sFile.isNull() || sFile.isEmpty() ) return; // Clear existing Clear(); DoOpen( sFile ); }
NS_IMETHODIMP FileStream::Init(nsIFile* aFile, const nsAString& aMode, PRInt32 aFlags) { NS_ASSERTION(!mQuotaFile && !mDeferredOpen, "Already initialized!"); nsresult rv = aFile->GetPath(mFilePath); NS_ENSURE_SUCCESS(rv, rv); mMode = aMode; mFlags = aFlags; if (mFlags & nsIStandardFileStream::FLAGS_DEFER_OPEN) { mDeferredOpen = true; return NS_OK; } return DoOpen(); }
/** * Trying to read from stream. When location is not available it tries to mount it. * @param aBuf buffer to put read data * @param aCount length of aBuf * @param aCountRead number of bytes actually read */ NS_IMETHODIMP nsGIOInputStream::Read(char *aBuf, uint32_t aCount, uint32_t *aCountRead) { *aCountRead = 0; // Check if file is already opened, otherwise open it if (!mStream && !mDirOpen && mStatus == NS_OK) { mStatus = DoOpen(); if (NS_FAILED(mStatus)) { return mStatus; } } mStatus = DoRead(aBuf, aCount, aCountRead); // Check if all data has been read if (mStatus == NS_BASE_STREAM_CLOSED) return NS_OK; // Check whenever any error appears while reading return mStatus; }
// Open the document bool ctConfigToolDoc::OnOpenDocument(const wxString& filename) { wxBusyCursor cursor; bool opened = DoOpen(filename); if (opened) { SetFilename(filename); wxGetApp().GetSettings().m_lastFilename = filename; ((ctConfigToolView*)GetFirstView())->OnChangeFilename(); RefreshDependencies(); // ctConfigToolHint hint(NULL, ctFilenameChanged); ctConfigToolHint hint(NULL, ctInitialUpdate); UpdateAllViews (NULL, & hint); } SetDocumentSaved(true); // Necessary or it will pop up the Save As dialog return opened; }
/// Open the settings file bool ctConfigToolDoc::DoOpen(const wxString& filename) { wxSimpleHtmlParser parser; if (parser.ParseFile(filename)) { ctConfigToolHint hint(NULL, ctClear); UpdateAllViews (NULL, & hint); m_topItem = NULL; if (parser.GetTopLevelTag()->GetChildren()) { wxSimpleHtmlTag* settingsTag = parser.GetTopLevelTag()->GetChildren()->FindTag(wxT("settings")); if (settingsTag && settingsTag->GetChildren()) { wxSimpleHtmlTag* firstSettingTag = settingsTag->GetChildren(); if (firstSettingTag) DoOpen(firstSettingTag, NULL); return true; } return true; } } return false; }
/* * Open the decoder, returns true on success */ bool CDVDVideoCodecA10::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options) { if (getenv("NOA10")) { CLog::Log(LOGNOTICE, "A10: disabled.\n"); return false; } if (hints.software) { CLog::Log(LOGNOTICE, "A10: software decoding requested.\n"); return false; } else { m_hwrender = getenv("A10HWR") != NULL; } CLog::Log(LOGNOTICE, "A10: using %s rendering.\n", m_hwrender ? "hardware" : "software"); m_hints = hints; m_aspect = m_hints.aspect; memset(&m_info, 0, sizeof(m_info)); //m_info.frame_rate = (double)m_hints.fpsrate / m_hints.fpsscale * 1000; m_info.frame_duration = 0; m_info.video_width = m_hints.width; m_info.video_height = m_hints.height; m_info.aspect_ratio = 1000; m_info.sub_format = CEDARV_SUB_FORMAT_UNKNOW; m_info.container_format = CEDARV_CONTAINER_FORMAT_UNKNOW; m_info.init_data_len = 0; m_info.init_data = NULL; #ifdef MEDIAINFO CLog::Log(LOGDEBUG, "A10: MEDIAINFO: CodecID %d \n", m_hints.codec); CLog::Log(LOGDEBUG, "A10: MEDIAINFO: StreamType %d \n", m_hints.type); CLog::Log(LOGDEBUG, "A10: MEDIAINFO: Level %d \n", m_hints.level); CLog::Log(LOGDEBUG, "A10: MEDIAINFO: Profile %d \n", m_hints.profile); CLog::Log(LOGDEBUG, "A10: MEDIAINFO: PTS_invalid %d \n", m_hints.ptsinvalid); CLog::Log(LOGDEBUG, "A10: MEDIAINFO: Tag %d \n", m_hints.codec_tag); { u8 *pb = (u8*)&m_hints.codec_tag; if (isalnum(pb[0]) && isalnum(pb[1]) && isalnum(pb[2]) && isalnum(pb[3])) CLog::Log(LOGDEBUG, "A10: MEDIAINFO: Tag fourcc %c%c%c%c\n", pb[0], pb[1], pb[2], pb[3]); } #endif switch(m_hints.codec) { //MPEG1 #ifdef A10ENABLE_MPEG1 case CODEC_ID_MPEG1VIDEO: m_info.format = CEDARV_STREAM_FORMAT_MPEG2; m_info.sub_format = CEDARV_MPEG2_SUB_FORMAT_MPEG1; break; #endif //MPEG2 #ifdef A10ENABLE_MPEG2 case CODEC_ID_MPEG2VIDEO: m_info.format = CEDARV_STREAM_FORMAT_MPEG2; m_info.sub_format = CEDARV_MPEG2_SUB_FORMAT_MPEG2; break; #endif //H263 #ifdef A10ENABLE_H263 case CODEC_ID_H263: m_info.format = CEDARV_STREAM_FORMAT_MPEG4; m_info.sub_format = CEDARV_MPEG4_SUB_FORMAT_H263; break; #endif //H264 #ifdef A10ENABLE_H264 case CODEC_ID_H264: m_info.format = CEDARV_STREAM_FORMAT_H264; m_info.init_data_len = m_hints.extrasize; m_info.init_data = (u8*)m_hints.extradata; if(m_hints.codec_tag==27) //M2TS and TS m_info.container_format = CEDARV_CONTAINER_FORMAT_TS; break; #endif //VP6 #ifdef A10ENABLE_VP6 case CODEC_ID_VP6F: m_info.format = CEDARV_STREAM_FORMAT_MPEG4; m_info.sub_format = CEDARV_MPEG4_SUB_FORMAT_VP6; //m_info.container_format = CEDARV_CONTAINER_FORMAT_FLV; break; #endif //WMV1 #ifdef A10ENABLE_WMV1 case CODEC_ID_WMV1: m_info.format = CEDARV_STREAM_FORMAT_MPEG4; m_info.sub_format = CEDARV_MPEG4_SUB_FORMAT_WMV1; break; #endif //WMV2 #ifdef A10ENABLE_WMV2 case CODEC_ID_WMV2: m_info.format = CEDARV_STREAM_FORMAT_MPEG4; m_info.sub_format = CEDARV_MPEG4_SUB_FORMAT_WMV2; break; #endif //WMV3 #ifdef A10ENABLE_WMV3 case CODEC_ID_WMV3: m_info.format = CEDARV_STREAM_FORMAT_VC1; m_info.init_data_len = m_hints.extrasize; m_info.init_data = (u8*)m_hints.extradata; break; #endif //VC1 and WVC1 #ifdef A10ENABLE_VC1_WVC1 case CODEC_ID_VC1: m_info.format = CEDARV_STREAM_FORMAT_VC1; m_info.init_data_len = m_hints.extrasize; m_info.init_data = (u8*)m_hints.extradata; break; #endif //MJPEG #ifdef A10ENABLE_MJPEG case CODEC_ID_MJPEG: m_info.format = CEDARV_STREAM_FORMAT_MJPEG; m_info.init_data_len = m_hints.extrasize; m_info.init_data = (u8*)m_hints.extradata; break; #endif //VP8 #ifdef A10ENABLE_VP8 case CODEC_ID_VP8: m_info.format = CEDARV_STREAM_FORMAT_VP8; m_info.init_data_len = m_hints.extrasize; m_info.init_data = (u8*)m_hints.extradata; break; #endif //MSMPEG4V1 #ifdef A10ENABLE_MPEG4V1 case CODEC_ID_MSMPEG4V1: m_info.format = CEDARV_STREAM_FORMAT_MPEG4; m_info.sub_format = CEDARV_MPEG4_SUB_FORMAT_DIVX1; break; #endif //MSMPEG4V2 #ifdef A10ENABLE_MPEG4V2 case CODEC_ID_MSMPEG4V2: m_info.format = CEDARV_STREAM_FORMAT_MPEG4; m_info.sub_format = CEDARV_MPEG4_SUB_FORMAT_DIVX2; break; #endif //MSMPEG4V3 #ifdef A10ENABLE_MPEG4V3 case CODEC_ID_MSMPEG4V3: m_info.format = CEDARV_STREAM_FORMAT_MPEG4; m_info.sub_format = CEDARV_MPEG4_SUB_FORMAT_DIVX3; break; #endif //Sorensson Spark (FLV1) #ifdef A10ENABLE_FLV1 case CODEC_ID_FLV1: m_info.format = CEDARV_STREAM_FORMAT_MPEG4; m_info.sub_format = CEDARV_MPEG4_SUB_FORMAT_SORENSSON_H263; //m_info.container_format = CEDARV_CONTAINER_FORMAT_FLV; break; #endif //Detected as MPEG4 (ID 13) case CODEC_ID_MPEG4: m_info.format = CEDARV_STREAM_FORMAT_MPEG4; switch(m_hints.codec_tag) { //DX40/DIVX4, divx #ifdef A10ENABLE_DIVX4 case _4CC('D','I','V','X'): m_info.sub_format = CEDARV_MPEG4_SUB_FORMAT_DIVX4; break; #endif //DX50/DIVX5 #ifdef A10ENABLE_DIVX5 case _4CC('D','X','5','0'): case _4CC('D','I','V','5'): m_info.sub_format = CEDARV_MPEG4_SUB_FORMAT_DIVX5; break; #endif //XVID #ifdef A10ENABLE_XVID case _4CC('X','V','I','D'): case _4CC('M','P','4','V'): case _4CC('P','M','P','4'): case _4CC('F','M','P','4'): m_info.sub_format = CEDARV_MPEG4_SUB_FORMAT_XVID; break; #endif default: CLog::Log(LOGERROR, "A10: (MPEG4)Codec Tag %d is unknown.\n", m_hints.codec_tag); return false; } break; default: CLog::Log(LOGERROR, "A10: codecid %d is unknown.\n", m_hints.codec); return false; } return DoOpen(); }
/* DoFileOpen */ BOOL DoFileOpen(char* fullPathName) { HANDLE hInfo; PINFO pInfo; MDICREATESTRUCT mdicreate; CGrafPtr port; GDHandle gd; // Allocate memory for INFO to be associated with the hInfo = LocalAlloc(LHND, (WORD) sizeof(INFO)); if (hInfo) { if ((pInfo = (PINFO)LocalLock(hInfo)) == NULL) MessageBox(ghwndMain, "Failed in LocalLock", "Error", MB_OK); // if we do not have a fullPathName, display an open dialog if(fullPathName == NULL) { // Display an open dialog if( !DoOpen(pInfo)){ LocalFree(hInfo); return FALSE; } } else { // Else we open the file pInfo->ofn.lpstrFile = fullPathName; strcpy(pInfo->spec.name, fullPathName); pInfo->ofn.nMaxFile = 256; } // Can we import this file? if(!DoGraphicsImport(pInfo)){ LocalFree(hInfo); return FALSE; } else gMDICount++; pInfo->hParent = ghwndClient; mdicreate.szClass = "MDIClass"; mdicreate.szTitle = (LPTSTR)((*pInfo).ofn).lpstrFile; mdicreate.hOwner = ghModule; mdicreate.x = CW_USEDEFAULT; mdicreate.y = CW_USEDEFAULT; mdicreate.cx = pInfo->imageRect.right - pInfo->imageRect.left; mdicreate.cy = pInfo->imageRect.bottom - pInfo->imageRect.top + GetSystemMetrics(SM_CYCAPTION); mdicreate.style = 0L; // pass the handle of the per MDI child INFO to the child MDI window for storage mdicreate.lParam = (LONG) hInfo; // Create Child Window pInfo->hwndChildWindow = (HANDLE) SendMessage(ghwndClient, WM_MDICREATE, 0L, (LONG)(LPMDICREATESTRUCT)&mdicreate); if (pInfo->hwndChildWindow == NULL) { MessageBox(ghwndMain, "Failed in Creating Child Window", "Error", MB_OK); return FALSE; } // Create our port association && set the port MacSetPort(CreatePortAssociation(pInfo->hwndChildWindow, NULL, 0)); // These lines required to get the image to draw within the window GetGWorld(&port, &gd); GraphicsImportSetGWorld(pInfo->gi, port, gd); // Store our private data SetWindowLong(pInfo->hwndChildWindow, GWL_USERDATA, (LONG)hInfo); return TRUE; } else MessageBox(ghwndMain, "Failed to Allocate INFO data!", "Error", MB_OK); return FALSE; }
/* ************************************************************************* * MiniportInitialize ************************************************************************* * * * Initializes the network interface card. * * * */ NDIS_STATUS MiniportInitialize ( PNDIS_STATUS OpenErrorStatus, PUINT SelectedMediumIndex, PNDIS_MEDIUM MediumArray, UINT MediumArraySize, NDIS_HANDLE NdisAdapterHandle, NDIS_HANDLE WrapperConfigurationContext ) { UINT mediumIndex; IrDevice *thisDev = NULL; NDIS_STATUS retStat, result = NDIS_STATUS_SUCCESS; DBGOUT(("MiniportInitialize()")); /* * Search the passed-in array of supported media for the IrDA medium. */ for (mediumIndex = 0; mediumIndex < MediumArraySize; mediumIndex++){ if (MediumArray[mediumIndex] == NdisMediumIrda){ break; } } if (mediumIndex < MediumArraySize){ *SelectedMediumIndex = mediumIndex; } else { /* * Didn't see the IrDA medium */ DBGERR(("Didn't see the IRDA medium in MiniportInitialize")); result = NDIS_STATUS_UNSUPPORTED_MEDIA; goto _initDone; } /* * Allocate a new device object to represent this connection. */ thisDev = NewDevice(); if (!thisDev){ return NDIS_STATUS_NOT_ACCEPTED; } /* * Allocate resources for this connection. */ if (!OpenDevice(thisDev)){ DBGERR(("OpenDevice failed")); result = NDIS_STATUS_FAILURE; goto _initDone; } /* * Read the system registry to get parameters like COM port number, etc. */ if (!Configure(thisDev, WrapperConfigurationContext)){ result = NDIS_STATUS_FAILURE; goto _initDone; } /* * This call will associate our adapter handle with the wrapper's * adapter handle. The wrapper will then always use our handle * when calling us. We use a pointer to the device object as the context. */ NdisMSetAttributes ( NdisAdapterHandle, (NDIS_HANDLE)thisDev, FALSE, NdisInterfaceInternal ); /* * Tell NDIS about the range of IO space that we'll be using. */ retStat = NdisMRegisterIoPortRange( (PVOID)thisDev->mappedPortRange, NdisAdapterHandle, thisDev->portInfo.ioBase, 8); if (retStat != NDIS_STATUS_SUCCESS){ DBGERR(("NdisMRegisterIoPortRange failed")); result = NDIS_STATUS_FAILURE; goto _initDone; } /* * Record the NDIS wrapper's handle for this adapter, which we use * when we call up to the wrapper. * (This miniport's adapter handle is just thisDev, the pointer to the device object.). */ DBGOUT(("NDIS handle: %xh <-> IRMINI handle: %xh", (UINT)NdisAdapterHandle, (UINT)thisDev)); thisDev->ndisAdapterHandle = NdisAdapterHandle; /* * Open COMM communication channel. * This will let the dongle driver update its capabilities from their default values. */ if (!DoOpen(thisDev)){ DBGERR(("DoOpen failed")); result = NDIS_STATUS_FAILURE; goto _initDone; } /* * Register an interrupt with NDIS. */ retStat = NdisMRegisterInterrupt( (PNDIS_MINIPORT_INTERRUPT)&thisDev->interruptObj, NdisAdapterHandle, thisDev->portInfo.irq, thisDev->portInfo.irq, TRUE, // want ISR TRUE, // MUST share interrupts NdisInterruptLevelSensitive ); if (retStat != NDIS_STATUS_SUCCESS){ DBGERR(("NdisMRegisterInterrupt failed")); result = NDIS_STATUS_FAILURE; goto _initDone; } _initDone: if (result == NDIS_STATUS_SUCCESS){ /* * Add this device object to the beginning of our global list. */ thisDev->next = firstIrDevice; firstIrDevice = thisDev; DBGOUT(("MiniportInitialize succeeded")); } else { if (thisDev){ FreeDevice(thisDev); } DBGOUT(("MiniportInitialize failed")); } return result; }