Changeset 1607 for trunk/src/msacm32/internal.cpp
- Timestamp:
- Nov 5, 1999, 10:19:27 AM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/msacm32/internal.cpp
r972 r1607 1 /* $Id: internal.cpp,v 1.2 1999-09-18 15:57:10 sandervl Exp $ */ 1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */ 2 2 3 /* 3 4 * MSACM32 library 4 5 * 5 6 * Copyright 1998 Patrik Stridvall 6 * Copyright 1999 Jens Wiessner7 * 1999 Eric Pouech 7 8 */ 8 9 9 10 #include <os2win.h> 10 #include <stdio.h>11 #include <stdlib.h>12 11 #include <string.h> 13 #include <odinwrap.h>14 12 15 13 #include "winbase.h" … … 21 19 #include "msacm.h" 22 20 #include "msacmdrv.h" 21 #include "wineacm.h" 23 22 #include "debugtools.h" 23 24 DEFAULT_DEBUG_CHANNEL(msacm) 24 25 25 26 /**********************************************************************/ … … 28 29 PWINE_ACMDRIVERID MSACM_pFirstACMDriverID = NULL; 29 30 PWINE_ACMDRIVERID MSACM_pLastACMDriverID = NULL; 30 INT WINAPI lstrncmpiA(LPCSTR,LPCSTR,INT);31 32 31 33 32 /*********************************************************************** 34 33 * MSACM_RegisterDriver32() 35 34 */ 36 PWINE_ACMDRIVERID MSACM_RegisterDriver( 37 LPSTR pszDriverAlias, LPSTR pszFileName, 38 PWINE_ACMLOCALDRIVER pLocalDriver) 39 { 40 PWINE_ACMDRIVERID padid; 41 padid = (PWINE_ACMDRIVERID) HeapAlloc( 42 MSACM_hHeap, 0, sizeof(WINE_ACMDRIVERID) 43 ); 44 padid->pszDriverAlias = 45 HEAP_strdupA(MSACM_hHeap, 0, pszDriverAlias); 46 padid->pszFileName = 47 HEAP_strdupA(MSACM_hHeap, 0, pszFileName); 48 padid->pACMLocalDriver = pLocalDriver; 49 padid->bEnabled = TRUE; 50 padid->pACMDriver = NULL; 51 padid->pNextACMDriverID = NULL; 52 padid->pPreviousACMDriverID = 53 MSACM_pLastACMDriverID; 54 MSACM_pLastACMDriverID = padid; 55 if(!MSACM_pFirstACMDriverID) 56 MSACM_pFirstACMDriverID = padid; 35 PWINE_ACMDRIVERID MSACM_RegisterDriver(LPSTR pszDriverAlias, LPSTR pszFileName, 36 HINSTANCE hinstModule) 37 { 38 PWINE_ACMDRIVERID padid; 57 39 58 return padid; 40 TRACE("('%s', '%s', 0x%08x)\n", pszDriverAlias, pszFileName, hinstModule); 41 42 padid = (PWINE_ACMDRIVERID) HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMDRIVERID)); 43 padid->pszDriverAlias = HEAP_strdupA(MSACM_hHeap, 0, pszDriverAlias); 44 padid->pszFileName = HEAP_strdupA(MSACM_hHeap, 0, pszFileName); 45 padid->hInstModule = hinstModule; 46 padid->bEnabled = TRUE; 47 padid->pACMDriver = NULL; 48 padid->pNextACMDriverID = NULL; 49 padid->pPreviousACMDriverID = MSACM_pLastACMDriverID; 50 if (MSACM_pLastACMDriverID) 51 MSACM_pLastACMDriverID->pNextACMDriverID = padid; 52 MSACM_pLastACMDriverID = padid; 53 if (!MSACM_pFirstACMDriverID) 54 MSACM_pFirstACMDriverID = padid; 55 56 return padid; 59 57 } 60 58 … … 62 60 * MSACM_RegisterAllDrivers32() 63 61 */ 64 void MSACM_RegisterAllDrivers( )62 void MSACM_RegisterAllDrivers(void) 65 63 { 66 PWINE_ACMBUILTINDRIVER pbd; 67 LPSTR pszBuffer; 68 DWORD dwBufferLength; 69 70 /* FIXME 71 * What if the user edits system.ini while the program is running? 72 * Does Windows handle that? 73 */ 74 if(!MSACM_pFirstACMDriverID) 75 return; 76 77 /* FIXME: Do not work! How do I determine the section length? */ 78 dwBufferLength = 79 GetPrivateProfileSectionA("drivers32", NULL, 0, "system.ini"); 80 81 pszBuffer = (LPSTR) HeapAlloc( 82 MSACM_hHeap, 0, dwBufferLength 83 ); 84 if(GetPrivateProfileSectionA( 85 "drivers32", pszBuffer, dwBufferLength, "system.ini")) 86 { 87 char *s = pszBuffer; 88 while(*s) 89 { 90 if(!lstrncmpiA("MSACM.", s, 6)) 91 { 92 char *s2 = s; 93 while(*s2 != '\0' && *s2 != '=') s2++; 94 if(*s2) 95 { 96 *s2++='\0'; 97 MSACM_RegisterDriver(s, s2, NULL); 64 LPSTR pszBuffer; 65 DWORD dwBufferLength; 66 67 /* FIXME 68 * What if the user edits system.ini while the program is running? 69 * Does Windows handle that? 70 */ 71 if (MSACM_pFirstACMDriverID) 72 return; 73 74 /* FIXME: Do not work! How do I determine the section length? */ 75 dwBufferLength = 1024; 76 /* EPP GetPrivateProfileSectionA("drivers32", NULL, 0, "system.ini"); */ 77 78 pszBuffer = (LPSTR) HeapAlloc(MSACM_hHeap, 0, dwBufferLength); 79 if (GetPrivateProfileSectionA("drivers32", pszBuffer, dwBufferLength, "system.ini")) { 80 char* s = pszBuffer; 81 while (*s) { 82 if (!lstrncmpiA("MSACM.", s, 6)) { 83 char *s2 = s; 84 while (*s2 != '\0' && *s2 != '=') s2++; 85 if (*s2) { 86 *s2++ = '\0'; 87 MSACM_RegisterDriver(s, s2, 0); 98 88 } 99 89 } 100 s += lstrlenA(s) + 1; /* Either next char or \0 */90 s += lstrlenA(s) + 1; /* Either next char or \0 */ 101 91 } 102 92 } 103 104 /* FIXME 105 * Check if any of the builtin driver was added 106 * when the external drivers was. 107 */ 108 109 pbd = MSACM_BuiltinDrivers; 110 while(pbd->pszDriverAlias) 111 { 112 PWINE_ACMLOCALDRIVER pld; 113 pld = (PWINE_ACMLOCALDRIVER) HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMLOCALDRIVER)); 114 pld->pfnDriverProc = pbd->pfnDriverProc; 115 MSACM_RegisterDriver(pbd->pszDriverAlias, NULL, pld); 116 pbd++; 117 } 118 HeapFree(MSACM_hHeap, 0, pszBuffer); 93 94 HeapFree(MSACM_hHeap, 0, pszBuffer); 119 95 } 120 96 … … 124 100 PWINE_ACMDRIVERID MSACM_UnregisterDriver(PWINE_ACMDRIVERID p) 125 101 { 126 PWINE_ACMDRIVERID pNextACMDriverID; 102 PWINE_ACMDRIVERID pNextACMDriverID; 103 104 if (p->pACMDriver) 105 acmDriverClose((HACMDRIVER) p->pACMDriver, 0); 106 107 if (p->pszDriverAlias) 108 HeapFree(MSACM_hHeap, 0, p->pszDriverAlias); 109 if (p->pszFileName) 110 HeapFree(MSACM_hHeap, 0, p->pszFileName); 111 112 if (p == MSACM_pFirstACMDriverID) 113 MSACM_pFirstACMDriverID = p->pNextACMDriverID; 114 if (p == MSACM_pLastACMDriverID) 115 MSACM_pLastACMDriverID = p->pPreviousACMDriverID; 127 116 128 if(p->pACMDriver) 129 acmDriverClose((HACMDRIVER) p->pACMDriver, 0); 130 131 if(p->pszDriverAlias) 132 HeapFree(MSACM_hHeap, 0, p->pszDriverAlias); 133 if(p->pszFileName) 134 HeapFree(MSACM_hHeap, 0, p->pszFileName); 135 if(p->pACMLocalDriver) 136 HeapFree(MSACM_hHeap, 0, p->pACMLocalDriver); 137 138 if(p->pPreviousACMDriverID) 139 p->pPreviousACMDriverID->pNextACMDriverID = p->pNextACMDriverID; 140 if(p->pNextACMDriverID) 141 p->pNextACMDriverID->pPreviousACMDriverID = p->pPreviousACMDriverID; 142 143 pNextACMDriverID = p->pNextACMDriverID; 144 145 HeapFree(MSACM_hHeap, 0, p); 146 147 return pNextACMDriverID; 117 if (p->pPreviousACMDriverID) 118 p->pPreviousACMDriverID->pNextACMDriverID = p->pNextACMDriverID; 119 if (p->pNextACMDriverID) 120 p->pNextACMDriverID->pPreviousACMDriverID = p->pPreviousACMDriverID; 121 122 pNextACMDriverID = p->pNextACMDriverID; 123 124 HeapFree(MSACM_hHeap, 0, p); 125 126 return pNextACMDriverID; 148 127 } 149 128 … … 153 132 * Where should this function be called? 154 133 */ 155 void MSACM_UnregisterAllDrivers( )134 void MSACM_UnregisterAllDrivers(void) 156 135 { 157 PWINE_ACMDRIVERID p = MSACM_pFirstACMDriverID; 158 while(p) p = MSACM_UnregisterDriver(p); 136 PWINE_ACMDRIVERID p; 137 138 for (p = MSACM_pFirstACMDriverID; p; p = MSACM_UnregisterDriver(p)); 159 139 } 160 140 … … 164 144 PWINE_ACMDRIVERID MSACM_GetDriverID(HACMDRIVERID hDriverID) 165 145 { 166 return (PWINE_ACMDRIVERID)hDriverID;146 return (PWINE_ACMDRIVERID)hDriverID; 167 147 } 168 148 … … 172 152 PWINE_ACMDRIVER MSACM_GetDriver(HACMDRIVER hDriver) 173 153 { 174 return (PWINE_ACMDRIVER)hDriver;154 return (PWINE_ACMDRIVER)hDriver; 175 155 } 176 156 … … 180 160 PWINE_ACMOBJ MSACM_GetObj(HACMOBJ hObj) 181 161 { 182 return (PWINE_ACMOBJ) hObj; 183 } 184 185 /*********************************************************************** 186 * MSACM_OpenDriverProc32 187 * FIXME 188 * This function should be integrated with OpenDriver, 189 * renamed and moved there. 190 */ 191 HDRVR MSACM_OpenDriverProc(DRIVERPROC pfnDriverProc) 192 { 193 #if 0 194 LPDRIVERITEMA pDrvr; 195 196 /* FIXME: This is a very bad solution */ 197 pDrvr = (LPDRIVERITEMA) HeapAlloc(MSACM_hHeap, HEAP_ZERO_MEMORY, sizeof(DRIVERITEMA)); 198 pDrvr->count = 1; 199 pDrvr->driverproc = pfnDriverProc; 200 201 /* FIXME: Send DRV_OPEN among others to DriverProc */ 202 203 return (HDRVR) pDrvr; 204 #else 205 return (HDRVR) 0; 206 #endif 162 return (PWINE_ACMOBJ)hObj; 207 163 } 208 164
Note:
See TracChangeset
for help on using the changeset viewer.