Intial commit
[profile/ivi/w3m.git] / w3mimg / w3mimg.c
1 /* $Id: w3mimg.c,v 1.5 2002/11/06 03:50:49 ukai Exp $ */
2
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <sys/types.h>
6 #include <unistd.h>
7 #include "w3mimg/w3mimg.h"
8
9 w3mimg_op *
10 w3mimg_open()
11 {
12     w3mimg_op *w_op = NULL;
13 #ifdef W3MIMGDISPLAY_SETUID
14     uid_t runner_uid = getuid();
15     uid_t owner_uid = geteuid();
16 #endif
17 #ifdef USE_W3MIMG_X11
18 #ifdef W3MIMGDISPLAY_SETUID
19     /* run in user privileges */
20     setreuid(owner_uid, runner_uid);
21 #endif
22     if (w_op == NULL)
23         w_op = w3mimg_x11open();
24 #ifdef W3MIMGDISPLAY_SETUID
25     setreuid(runner_uid, owner_uid);
26 #endif
27 #endif
28 #ifdef USE_W3MIMG_FB
29     /* run in setuid privileges */
30     if (w_op == NULL)
31         w_op = w3mimg_fbopen();
32 #endif
33     return w_op;
34 }