[Wine] Want to use Digital Oszilloscope DSO-2100 at parport LPT1

Martin Gregorie martin at gregorie.org
Thu Feb 4 13:41:09 CST 2010


On Thu, 2010-02-04 at 19:46 +0200, Gert van den Berg wrote:
> Fixed code: /* Hopefully... Wrapping WILL %#$% it up... */
>
Here's a version that compiles and runs. I've added a couple of extra
capabilities too:

- it passes the environment variables to its child process, so it runs
  wine with execve() rather than execlp()

- the abandon() function reports errors, showing what the program
  was doing, the error code that was returned and its meaning.

- Wine runs its command line arguments for added flexibility, so
 
      testw winefile

  runs Wine's Windows Explorer workalike. You'll see that it fiddles
  with the argument list, substituting "wine" for the first argument
  and adding a after the last argument null to terminate the array.
  Both are necessary.

=========================testw.c============================
#include <sys/io.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>

void abandon(char *text)
{
   fprintf(stderr, 
           "Error: %s: err %d,%s\n", 
           text, errno, strerror(errno));
   exit(1);
}

int main(int argc, char *argv[], char *envp[])
{
   char **args;
   int  i;

   args = (char**)malloc((argc + 1) * sizeof(char*));
   if (!args)
      abandon("malloc() failed");

   for (i = 1; i < argc; i++)
      args[i] = argv[i];

   args[0] = "wine";
   args[i] = 0;
   ioperm(0,0x3ff,1); /* Allows access to all ports: poss. dangerous */
   setuid(geteuid()); /* set effective uid */
   if (execve("/usr/bin/wine", args, envp) == -1)
      abandon("Failed to run wine");

   free(args);
   return 0;
}
=====================end of testw.c=========================


Martin





More information about the wine-users mailing list