On Wed, Jun 25, 2008 at 12:12 PM, Juan Lang juan.lang@gmail.com wrote:
Hi Austin, at the risk of getting flamed for discussing elementary C here I'll give some feedback.
Appreciate the help. I don't have any C experience, so this testcase was hacked together by looking at a few other testcases in the testsuite + msdn.
LPRASDEVINFO = sizeof(RASDEVINFO);
This is a little confused. You've named a type (LPRASDEVINFO) but not a variable. The naive fix would be to something like the following:
LPRASDEVINFO pRDV = sizeof(RASDEVINFO);
This at least declares a variable (pRDV) of type LPRASDEVINFO. It might even compile, but it'll certainly crash: The first parameter to RasEnumDeviceA is a pointer, and a pointer must point to a valid memory location, or have the special value NULL.
What you most likely want is something like this: RASDEVINFOA rasDevInfo;
rasDevInfo.dwSize = sizeof(rasDevInfo);
result = RasEnumDevicesA(LPRASDEVINFOA, NULL, LPDWORD lpcDevices);
Here you're passing a type (LPRASDEVINFOA) as the first parameter. If you use what I gave above, you'd want &rasDevInfo to be the first parameter instead.
The third parameter is also bogus. You want to declare a DWORD cDevices, and pass &cDevices instead.
result = RasEnumDevicesA(NULL, LPDWORD lpcb, LPDWORD lpcDevices);
Again you've got something that won't compile. You need to declare a DWORD cb, and pass &cb as the second parameter. For good measure you should probably initialize it to something (maybe 0?), since MSDN says the second parameter is an in/out parameter.
Feel free to whip up another one for review. --Juan
I made these changes, but still not compiling: austin@SERVER1:~/wine-git/dlls/rasapi32/tests$ make crosstest i586-mingw32msvc-gcc -c -I. -I. -I../../../include -I../../../include -D_REENTRANT -fPIC -Wall -pipe -fno-strict-aliasing -Wdeclaration-after-statement -Wwrite-strings -Wpointer-arith -g -O2 -o rasapi.cross.o rasapi.c rasapi.c:1: warning: -fPIC ignored for target (all code is position independent) rasapi.c: In function `test_rasenum': rasapi.c:36: error: request for member `dwSize' in something not a structure or union rasapi.c:37: warning: ISO C90 forbids mixed declarations and code rasapi.c:40: warning: passing arg 1 of `RasEnumDevicesA' from incompatible pointer type rasapi.c:40: warning: passing arg 3 of `RasEnumDevicesA' from incompatible pointer type rasapi.c:41: warning: implicit declaration of function `ok' rasapi.c:44: warning: passing arg 2 of `RasEnumDevicesA' from incompatible pointer type rasapi.c:44: warning: passing arg 3 of `RasEnumDevicesA' from incompatible pointer type rasapi.c: At top level: rasapi.c:51: warning: return type defaults to `int' make: *** [rasapi.cross.o] Error 1
I've tried assigning those args different types, but none seem to be working (int,float,etc.).
I've found a C guide that I'm going through now, but don't know how long that'll take. If someone has a few minutes to kill and a penchant for guiding C programming, please contact me off list...I don't want to flood -devel with elementary C questions.
Or if someone wants to take my patch and fix it up, have at it. I'm just trying to get a bug fixed ;-).
-Austin