Previous 15994 Revisions Next

r2260 Saturday 5th April, 2008 at 01:50:02 UTC by Nathan Woods
[Windows GUI] Coding standards
[src/mess/osd/winui]softwarepicker.c

src/mess/osd/winui/softwarepicker.c
r2259r2260
3131
3232
3333
34struct FileInfo
34//============================================================
35//  TYPE DEFINITIONS
36//============================================================
37
38typedef struct _file_info file_info;
39struct _file_info
3540{
3641   mess_device_class devclass;
3742
r2259r2260
4550   char szFilename[1];
4651};
4752
48struct DirectorySearchInfo
53typedef struct _directory_search_info directory_search_info;
54struct _directory_search_info
4955{
50   struct DirectorySearchInfo *pNext;
56   directory_search_info *pNext;
5157   HANDLE hFind;
5258   WIN32_FIND_DATA fd;
5359   char szDirectory[1];
5460};
5561
56struct SoftwarePickerInfo
62typedef struct _software_picker_info software_picker_info;
63struct _software_picker_info
5764{
5865   WNDPROC pfnOldWndProc;
59   struct FileInfo **ppIndex;
66   file_info **ppIndex;
6067   int nIndexLength;
6168   int nHashesRealized;
6269   int nCurrentPosition;
63   struct DirectorySearchInfo *pFirstSearchInfo;
64   struct DirectorySearchInfo *pLastSearchInfo;
70   directory_search_info *pFirstSearchInfo;
71   directory_search_info *pLastSearchInfo;
6572   const game_driver *pDriver;
6673   machine_config *pConfig;
6774   hash_file *pHashFile;
r2259r2260
7077
7178
7279
80//============================================================
81//  CONSTANTS
82//============================================================
83
7384static const TCHAR s_szSoftwarePickerProp[] = TEXT("SWPICKER");
7485
7586
7687
88//============================================================
89
7790static LPCSTR NormalizePath(LPCSTR pszPath, LPSTR pszBuffer, size_t nBufferSize)
7891{
7992   BOOL bChanged = FALSE;
r2259r2260
115128
116129
117130
118static struct SoftwarePickerInfo *GetSoftwarePickerInfo(HWND hwndPicker)
131static software_picker_info *GetSoftwarePickerInfo(HWND hwndPicker)
119132{
120133   HANDLE h;
121134   h = GetProp(hwndPicker, s_szSoftwarePickerProp);
122135   assert(h);
123   return (struct SoftwarePickerInfo *) h;
136   return (software_picker_info *) h;
124137}
125138
126139
127140
128141LPCSTR SoftwarePicker_LookupFilename(HWND hwndPicker, int nIndex)
129142{
130   struct SoftwarePickerInfo *pPickerInfo;
143   software_picker_info *pPickerInfo;
131144   pPickerInfo = GetSoftwarePickerInfo(hwndPicker);
132145   if ((nIndex < 0) || (nIndex >= pPickerInfo->nIndexLength))
133146      return NULL;
r2259r2260
138151
139152mess_device_class SoftwarePicker_LookupDevice(HWND hwndPicker, int nIndex)
140153{
141   struct SoftwarePickerInfo *pPickerInfo;
154   software_picker_info *pPickerInfo;
142155   pPickerInfo = GetSoftwarePickerInfo(hwndPicker);
143156   if ((nIndex < 0) || (nIndex >= pPickerInfo->nIndexLength))
144157   {
r2259r2260
153166
154167int SoftwarePicker_LookupIndex(HWND hwndPicker, LPCSTR pszFilename)
155168{
156   struct SoftwarePickerInfo *pPickerInfo;
169   software_picker_info *pPickerInfo;
157170   int i;
158171
159172   pPickerInfo = GetSoftwarePickerInfo(hwndPicker);
r2259r2260
169182
170183iodevice_t SoftwarePicker_GetImageType(HWND hwndPicker, int nIndex)
171184{
172   struct SoftwarePickerInfo *pPickerInfo;
185   software_picker_info *pPickerInfo;
173186   const mess_device_class *devclass;
174187
175188   pPickerInfo = GetSoftwarePickerInfo(hwndPicker);
r2259r2260
186199
187200void SoftwarePicker_SetDriver(HWND hwndPicker, const game_driver *pDriver)
188201{
189   struct SoftwarePickerInfo *pPickerInfo;
202   software_picker_info *pPickerInfo;
190203   int i;
191204
192205   pPickerInfo = GetSoftwarePickerInfo(hwndPicker);
r2259r2260
241254
242255void SoftwarePicker_SetErrorProc(HWND hwndPicker, void (*pfnErrorProc)(const char *message))
243256{
244   struct SoftwarePickerInfo *pPickerInfo;
257   software_picker_info *pPickerInfo;
245258   pPickerInfo = GetSoftwarePickerInfo(hwndPicker);
246259   pPickerInfo->pfnErrorProc = pfnErrorProc;
247260}
248261
249262
250263
251static void ComputeFileHash(struct SoftwarePickerInfo *pPickerInfo,
252   struct FileInfo *pFileInfo, const unsigned char *pBuffer, unsigned int nLength)
264static void ComputeFileHash(software_picker_info *pPickerInfo,
265   file_info *pFileInfo, const unsigned char *pBuffer, unsigned int nLength)
253266{
254267   unsigned int nFunctions;
255268   iodevice_t type;
r2259r2260
274287
275288static BOOL SoftwarePicker_CalculateHash(HWND hwndPicker, int nIndex)
276289{
277   struct SoftwarePickerInfo *pPickerInfo;
278   struct FileInfo *pFileInfo;
290   software_picker_info *pPickerInfo;
291   file_info *pFileInfo;
279292   LPSTR pszZipName;
280293   BOOL rc = FALSE;
281294   unsigned char *pBuffer;
r2259r2260
367380
368381static void SoftwarePicker_RealizeHash(HWND hwndPicker, int nIndex)
369382{
370   struct SoftwarePickerInfo *pPickerInfo;
371   struct FileInfo *pFileInfo;
383   software_picker_info *pPickerInfo;
384   file_info *pFileInfo;
372385   unsigned int nHashFunctionsUsed = 0;
373386   unsigned int nCalculatedHashes = 0;
374387   iodevice_t type;
r2259r2260
407420static BOOL SoftwarePicker_AddFileEntry(HWND hwndPicker, LPCSTR pszFilename,
408421   UINT nZipEntryNameLength, UINT32 nCrc, BOOL bForce)
409422{
410   struct SoftwarePickerInfo *pPickerInfo;
411   struct FileInfo **ppNewIndex;
412   struct FileInfo *pInfo;
423   software_picker_info *pPickerInfo;
424   file_info **ppNewIndex;
425   file_info *pInfo;
413426   int nIndex, nSize;
414427   LPCSTR pszExtension = NULL, s;
415428   mess_device_class devclass = {0,};
r2259r2260
452465      return TRUE;
453466
454467   // create the FileInfo structure
455   nSize = sizeof(struct FileInfo) + strlen(pszFilename);
456   pInfo = (struct FileInfo *) malloc(nSize);
468   nSize = sizeof(file_info) + strlen(pszFilename);
469   pInfo = (file_info *) malloc(nSize);
457470   if (!pInfo)
458471      goto error;
459472   memset(pInfo, 0, nSize);
r2259r2260
575588
576589BOOL SoftwarePicker_AddDirectory(HWND hwndPicker, LPCSTR pszDirectory)
577590{
578   struct SoftwarePickerInfo *pPickerInfo;
579   struct DirectorySearchInfo *pSearchInfo;
580   struct DirectorySearchInfo **ppLast;
591   software_picker_info *pPickerInfo;
592   directory_search_info *pSearchInfo;
593   directory_search_info **ppLast;
581594   size_t nSearchInfoSize;
582595   char szBuffer[MAX_PATH];
583596
r2259r2260
587600   Picker_ResetIdle(hwndPicker);
588601   pPickerInfo = GetSoftwarePickerInfo(hwndPicker);
589602
590   nSearchInfoSize = sizeof(struct DirectorySearchInfo) + strlen(pszDirectory);
603   nSearchInfoSize = sizeof(directory_search_info) + strlen(pszDirectory);
591604   pSearchInfo = malloc(nSearchInfoSize);
592605   if (!pSearchInfo)
593606      return FALSE;
r2259r2260
608621
609622
610623
611static void SoftwarePicker_FreeSearchInfo(struct DirectorySearchInfo *pSearchInfo)
624static void SoftwarePicker_FreeSearchInfo(directory_search_info *pSearchInfo)
612625{
613626   if (pSearchInfo->hFind != INVALID_HANDLE_VALUE)
614627      FindClose(pSearchInfo->hFind);
r2259r2260
617630
618631
619632
620static void SoftwarePicker_InternalClear(struct SoftwarePickerInfo *pPickerInfo)
633static void SoftwarePicker_InternalClear(software_picker_info *pPickerInfo)
621634{
622   struct DirectorySearchInfo *p;
635   directory_search_info *p;
623636   int i;
624637
625638   for (i = 0; i < pPickerInfo->nIndexLength; i++)
r2259r2260
642655
643656void SoftwarePicker_Clear(HWND hwndPicker)
644657{
645   struct SoftwarePickerInfo *pPickerInfo;
658   software_picker_info *pPickerInfo;
646659   pPickerInfo = GetSoftwarePickerInfo(hwndPicker);
647660   SoftwarePicker_InternalClear(pPickerInfo);
648661   ListView_DeleteAllItems(hwndPicker);
r2259r2260
651664
652665
653666static BOOL SoftwarePicker_AddEntry(HWND hwndPicker,
654   struct DirectorySearchInfo *pSearchInfo)
667   directory_search_info *pSearchInfo)
655668{
656   struct SoftwarePickerInfo *pPickerInfo;
669   software_picker_info *pPickerInfo;
657670   LPSTR pszFilename;
658671   BOOL rc;
659672   char* utf8_FileName;
r2259r2260
687700
688701BOOL SoftwarePicker_Idle(HWND hwndPicker)
689702{
690   struct SoftwarePickerInfo *pPickerInfo;
691   struct FileInfo *pFileInfo;
703   software_picker_info *pPickerInfo;
704   file_info *pFileInfo;
692705   static const char szWildcards[] = "\\*.*";
693   struct DirectorySearchInfo *pSearchInfo;
706   directory_search_info *pSearchInfo;
694707   LPSTR pszFilter;
695708   BOOL bSuccess;
696709   int nCount;
r2259r2260
777790LPCTSTR SoftwarePicker_GetItemString(HWND hwndPicker, int nRow, int nColumn,
778791   TCHAR *pszBuffer, UINT nBufferLength)
779792{
780   struct SoftwarePickerInfo *pPickerInfo;
781   const struct FileInfo *pFileInfo;
793   software_picker_info *pPickerInfo;
794   const file_info *pFileInfo;
782795   LPCTSTR s = NULL;
783796   const char *pszUtf8 = NULL;
784797   unsigned int nHashFunction = 0;
r2259r2260
863876static LRESULT CALLBACK SoftwarePicker_WndProc(HWND hwndPicker, UINT nMessage,
864877   WPARAM wParam, LPARAM lParam)
865878{
866   struct SoftwarePickerInfo *pPickerInfo;
879   software_picker_info *pPickerInfo;
867880   LRESULT rc;
868881
869882   pPickerInfo = GetSoftwarePickerInfo(hwndPicker);
r2259r2260
883896
884897BOOL SetupSoftwarePicker(HWND hwndPicker, const struct PickerOptions *pOptions)
885898{
886   struct SoftwarePickerInfo *pPickerInfo = NULL;
899   software_picker_info *pPickerInfo = NULL;
887900   LONG_PTR l;
888901
889902   if (!SetupPicker(hwndPicker, pOptions))

Previous 15994 Revisions Next


© 1998-2018 The MESS Team