| 241 | |
| 242 | |
| 243 | unsigned short instanceCheck(Display *dpy) |
| 244 | { |
| 245 | Atom atom = None; unsigned short p = 0; |
| 246 | if((atom = XInternAtom(dpy, "_VGLCLIENT_PORT", True)) != None) |
| 247 | { |
| 248 | unsigned char *prop = NULL; unsigned long n = 0, bytesLeft = 0; |
| 249 | int actualFormat = 0; Atom actualType = None; |
| 250 | if(XGetWindowProperty(dpy, DefaultRootWindow(dpy), atom, 0, 1, False, |
| 251 | XA_INTEGER, &actualType, &actualFormat, &n, &bytesLeft, |
| 252 | &prop) == Success |
| 253 | && n >= 1 && actualFormat == 16 && actualType == XA_INTEGER && prop) |
| 254 | p = *(unsigned short *)prop; |
| 255 | if(prop) XFree(prop); |
| 256 | if(p != 0) |
| 257 | { |
| 258 | vglout.println("vglclient is already running on this X display and accepting connections on"); |
| 259 | vglout.println(" port %d.", p); |
| 260 | } |
| 261 | } |
| 262 | return p; |
| 263 | } |
| 264 | |
| 265 | |
| 266 | void getEnvironment(void) |