Improved a bit the folder browsing implementation.
[wine.git] / dlls / msacm / internal.c
blob9eb235d9abb3d074df2b5ba9e761308ea5a9f6e9
1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
3 /*
4 * MSACM32 library
6 * Copyright 1998 Patrik Stridvall
7 * 1999 Eric Pouech
8 */
10 #include <string.h>
12 #include "winbase.h"
13 #include "windef.h"
14 #include "wingdi.h"
15 #include "winuser.h"
16 #include "winerror.h"
17 #include "heap.h"
18 #include "mmsystem.h"
19 #include "msacm.h"
20 #include "msacmdrv.h"
21 #include "wineacm.h"
22 #include "debugtools.h"
24 DEFAULT_DEBUG_CHANNEL(msacm)
26 /**********************************************************************/
28 HANDLE MSACM_hHeap = (HANDLE) NULL;
29 PWINE_ACMDRIVERID MSACM_pFirstACMDriverID = NULL;
30 PWINE_ACMDRIVERID MSACM_pLastACMDriverID = NULL;
32 /***********************************************************************
33 * MSACM_RegisterDriver32()
35 PWINE_ACMDRIVERID MSACM_RegisterDriver(LPSTR pszDriverAlias, LPSTR pszFileName,
36 HINSTANCE hinstModule)
38 PWINE_ACMDRIVERID padid;
40 TRACE("('%s', '%s', 0x%08x)\n", pszDriverAlias, pszFileName, hinstModule);
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->pACMDriverList = NULL;
48 padid->pNextACMDriverID = NULL;
49 padid->pPrevACMDriverID = MSACM_pLastACMDriverID;
50 if (MSACM_pLastACMDriverID)
51 MSACM_pLastACMDriverID->pNextACMDriverID = padid;
52 MSACM_pLastACMDriverID = padid;
53 if (!MSACM_pFirstACMDriverID)
54 MSACM_pFirstACMDriverID = padid;
56 return padid;
59 /***********************************************************************
60 * MSACM_RegisterAllDrivers32()
62 void MSACM_RegisterAllDrivers(void)
64 LPSTR pszBuffer;
65 DWORD dwBufferLength;
67 /* FIXME
68 * What if the user edits system.ini while the program is running?
69 * Does Windows handle that?
71 if (MSACM_pFirstACMDriverID)
72 return;
74 /* FIXME: Do not work! How do I determine the section length? */
75 dwBufferLength = 1024;
76 /* EPP GetPrivateProfileSectionA("drivers32", NULL, 0, "system.ini"); */
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);
90 s += strlen(s) + 1; /* Either next char or \0 */
94 HeapFree(MSACM_hHeap, 0, pszBuffer);
97 /***********************************************************************
98 * MSACM_UnregisterDriver32()
100 PWINE_ACMDRIVERID MSACM_UnregisterDriver(PWINE_ACMDRIVERID p)
102 PWINE_ACMDRIVERID pNextACMDriverID;
104 while (p->pACMDriverList)
105 acmDriverClose((HACMDRIVER) p->pACMDriverList, 0);
107 if (p->pszDriverAlias)
108 HeapFree(MSACM_hHeap, 0, p->pszDriverAlias);
109 if (p->pszFileName)
110 HeapFree(MSACM_hHeap, 0, p->pszFileName);
112 if (p == MSACM_pFirstACMDriverID)
113 MSACM_pFirstACMDriverID = p->pNextACMDriverID;
114 if (p == MSACM_pLastACMDriverID)
115 MSACM_pLastACMDriverID = p->pPrevACMDriverID;
117 if (p->pPrevACMDriverID)
118 p->pPrevACMDriverID->pNextACMDriverID = p->pNextACMDriverID;
119 if (p->pNextACMDriverID)
120 p->pNextACMDriverID->pPrevACMDriverID = p->pPrevACMDriverID;
122 pNextACMDriverID = p->pNextACMDriverID;
124 HeapFree(MSACM_hHeap, 0, p);
126 return pNextACMDriverID;
129 /***********************************************************************
130 * MSACM_UnregisterAllDrivers32()
131 * FIXME
132 * Where should this function be called?
134 void MSACM_UnregisterAllDrivers(void)
136 PWINE_ACMDRIVERID p;
138 for (p = MSACM_pFirstACMDriverID; p; p = MSACM_UnregisterDriver(p));
141 /***********************************************************************
142 * MSACM_GetDriverID32()
144 PWINE_ACMDRIVERID MSACM_GetDriverID(HACMDRIVERID hDriverID)
146 return (PWINE_ACMDRIVERID)hDriverID;
149 /***********************************************************************
150 * MSACM_GetDriver32()
152 PWINE_ACMDRIVER MSACM_GetDriver(HACMDRIVER hDriver)
154 return (PWINE_ACMDRIVER)hDriver;
157 /***********************************************************************
158 * MSACM_GetObj32()
160 PWINE_ACMOBJ MSACM_GetObj(HACMOBJ hObj)
162 return (PWINE_ACMOBJ)hObj;