//=============================================================================================== // FUNCTION: Read // PURPOSE: Reads the complete protocol from the data file. // BOOL CABF2ProtocolReader::Read( UINT fFlags ) { MEMBERASSERT(); BOOL bOK = TRUE; bOK &= m_pFI->Seek( 0L, FILE_BEGIN); if( !bOK ) return FALSE; bOK &= m_pFI->Read( &m_FileInfo, sizeof( m_FileInfo ) ); if( m_FileInfo.StringsSection.uBlockIndex ) { // Read the protocol strings into the cache. UINT uSeekPos = m_FileInfo.StringsSection.uBlockIndex * ABF_BLOCKSIZE; if( !m_Strings.Read( m_pFI->GetFileHandle(), uSeekPos ) ) return FALSE; //SetLastError( ABF_ENOSTRINGS ); } bOK &= ReadFileInfo(); bOK &= ReadProtocolInfo(); bOK &= ReadADCInfo(); bOK &= ReadDACInfo(); bOK &= ReadEpochs(); bOK &= ReadStats(); bOK &= ReadUserList(); bOK &= ReadMathInfo(); RemoveExtraChannels( m_pFH, fFlags ); FlattenGearShift( m_pFH ); return bOK; }
void ObjReadFiles (FILE* F, unsigned long Pos, ObjData* O) /* Read the files list from a file at the given position */ { unsigned I; /* Seek to the correct position */ FileSetPos (F, Pos); /* Read the data */ O->FileCount = ReadVar (F); O->Files = xmalloc (O->FileCount * sizeof (O->Files[0])); for (I = 0; I < O->FileCount; ++I) { O->Files[I] = ReadFileInfo (F, O); } }
int main( int argc, char** argv) { int retval; char* cfg_dir = (char *)malloc(FILENAME_MAX); char* prod_table_filename = "product_attr_table"; retval = Read_options(argc, argv); if (retval < 0) { Print_usage(argv); } /* We need the product attribute table in order to do decompression on compressed products. If no product_tables file is given on the command line, we try to use the one located in RPG_LEVEL/cfg. If that's not available, we will not attempt to decompress any products. */ if ( Prod_table_flag == 0 ) { /* attempt to use default prod table file */ cfg_dir = getenv("RPG_LEVEL"); if ( cfg_dir == NULL ) { cfg_dir = getenv("HOME"); } if ( cfg_dir != NULL ) { strcat(cfg_dir, "/cfg/"); strcpy(Prod_table, cfg_dir); strcat(Prod_table, prod_table_filename); } } if (Init_attr_tbl (Prod_table, 1) <= 0) { fprintf(stderr, "Failure initializing product attrib table %s.\n", Prod_table); } else { /* print product table being used */ fprintf(stdout, "Using product attribute table: %s\n", Prod_table); } retval = ReadFileInfo(); if (retval < 0) { fprintf(stderr, "Problem reading file\n"); return (-1); } retval = DecompressProd(); if (retval < 0) { fprintf(stderr, "Error decompressing product\n"); return (-1); } retval = WriteDecompProd(); if (retval < 0) { fprintf(stderr, "Error writing product\n"); return (-1); } return (0); } /* end main() */
// Edit database dialog LRESULT CDataBase::WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { switch (msg) { case WM_INITDIALOG: { // Create database list m_listview.Create(hWnd, *m_pOption); // Create various buttons m_DelButton.Create(hWnd, _T("Edit"), ID_DB_BUTTON1); m_UndoButton.Create(hWnd, _T("Undo"), ID_DB_BUTTON2); m_AllSelButton.Create(hWnd, _T("Select all"), ID_DB_BUTTON3); m_EndButton.Create(hWnd, _T("Finish"), ID_DB_BUTTON4); // Seek the coordinates displayed in the center of the parent window RECT rc; GetWindowRect(GetParent(hWnd), (LPRECT)&rc); int width = 600; int height = 400; int left = rc.left + ((rc.right - rc.left) - width) / 2; int top = rc.top + ((rc.bottom - rc.top) - height) / 2; // Window position and size settings //SaveLoadIni slini(hWnd); //slini.LoadWindowPlacement(idsDataBaseWindow, left, top, width, height); //slini.LoadListView(idsDataBaseList, &sort_param, 1); // Read database file ReadFileInfo(); // Sort m_listview.Sort(); SetFocus(hWnd); return FALSE; } case WM_COMMAND: { switch (LOWORD(wp)) { case ID_DB_BUTTON1: // Edit //case IDM_DEL: DelFileInfo(); m_listview.SetFocus(); return FALSE; case ID_DB_BUTTON2: // Undo //case IDM_UNDO: SetUndo(); m_listview.SetFocus(); return FALSE; case ID_DB_BUTTON3: // Select all //case IDM_SELECTALL: m_listview.SetAllItemSelect(); m_listview.SetFocus(); return FALSE; case ID_DB_BUTTON4: // Finish SaveFileInfo(); case IDCANCEL: // Cancel m_EndButton.SetFocus(); // Prevent lack of focus //SaveLoadIni slini(hWnd); //slini.SaveWindowPlacement(idsDataBaseWindow); //slini.SaveListView(idsDataBaseList, m_DataBaseList, sort_param); EndDialog(hWnd, IDOK); return TRUE; } return FALSE; } case WM_PAINT: { PAINTSTRUCT ps; BeginPaint(hWnd, &ps); m_listview.SetFocus(); EndPaint(hWnd, &ps); return FALSE; } case WM_NOTIFY: { if (wp == ID_LISTVIEW2) // ID check { LPNMLISTVIEW pNM = (LPNMLISTVIEW)lp; switch (pNM->hdr.code) { case LVN_COLUMNCLICK: m_listview.Sort(pNM->iSubItem); return FALSE; case LVN_GETDISPINFO: { NMLVDISPINFO* pDispInfo = (NMLVDISPINFO*)lp; if (pDispInfo->item.mask & LVIF_TEXT) m_listview.Show(pDispInfo); return FALSE; } } } return FALSE; } case WM_SIZE: m_listview.SetWindowPos(20, 20, LOWORD(lp) - 130, HIWORD(lp) - 40); m_DelButton.SetWindowPos(LOWORD(lp) - 95, 70, 80, 20); m_UndoButton.SetWindowPos(LOWORD(lp) - 95, 110, 80, 20); m_AllSelButton.SetWindowPos(LOWORD(lp) - 95, 150, 80, 20); m_EndButton.SetWindowPos(LOWORD(lp) - 95, 190, 80, 20); return FALSE; } return FALSE; }
int CEQUFile::LoadEQUFile( char* filename ) { int ret; m_mode = EQUFILE_LOAD; m_hfile = CreateFile( (LPCTSTR)filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL ); if( m_hfile == INVALID_HANDLE_VALUE ){ DbgOut( "EQUFile : LoadEQUFile : CreateFile : INVALID_HANDLE_VALUE error !!!\n" ); //return D3DAPPERR_MEDIANOTFOUND;//!!!!!!!! return 1; } ret = SetBuffer(); if( ret ){ DbgOut( "EQUFile : LoadEQUFile : SetBuffer error !!!\n" ); _ASSERT( 0 ); return 1; } ret = ReadFileInfo(); if( ret ){ DbgOut( "EQUFile : LoadEQUFile : ReadFileInfo error !!!\n" ); _ASSERT( 0 ); return 1; } ret = Read_Int( &m_equbuf, "<AnimNum>", "</AnimNum>", &m_animnum ); if( ret ){ DbgOut( "EQUFile : LoadEQUFile : Read_Int animnum error !!!\n" ); _ASSERT( 0 ); return 1; } if( m_animnum <= 0 ){ return 0; } m_animdat = (ANIMDAT*)malloc( sizeof( ANIMDAT ) * m_animnum ); if( !m_animdat ){ DbgOut( "EQUFile : LoadEQUFile : animdat alloc error !!!\n" ); _ASSERT( 0 ); return 1; } ZeroMemory( m_animdat, sizeof( ANIMDAT ) * m_animnum ); int animcnt; for( animcnt = 0; animcnt < m_animnum; animcnt++ ){ if( m_equbuf.pos >= m_equbuf.bufleng ){ DbgOut( "EQUFile : LoadEQUFile : pos overflow error !!!\n" ); _ASSERT( 0 ); return 1; } char* startptr = 0; char* endptr = 0; startptr = strstr( m_equbuf.buf + m_equbuf.pos, "<Animation>" ); if( startptr ){ startptr += (int)strlen( "<Animation>" ); } endptr = strstr( m_equbuf.buf + m_equbuf.pos, "</Animation>" ); if( endptr ){ endptr += (int)strlen( "</Animation>" ); } if( !startptr || !endptr ){ DbgOut( "EQUFile : LoadEQUFile : Animation pattern not found skip !!!\n" ); _ASSERT( 0 ); return 1; } int chkendpos; chkendpos = (int)( endptr - m_equbuf.buf ); if( (chkendpos >= (int)m_equbuf.bufleng) || (endptr < startptr) ){ DbgOut( "EQUFile : LoadEQUFile : Animation endmark error !!!\n" ); _ASSERT( 0 ); return 1; } EQUBUF animbuf; ZeroMemory( &animbuf, sizeof( EQUBUF ) ); animbuf.buf = startptr; animbuf.pos = 0; animbuf.bufleng = (int)( endptr - startptr ); animbuf.isend = 0; ret = ReadAnimation( &animbuf, animcnt ); if( ret ){ DbgOut( "EQUFile : LoadEQUFile : ReadAnimation error !!!\n" ); _ASSERT( 0 ); return 1; } m_equbuf.pos = chkendpos; } return 0; }