1 #ifndef __XLOCK_XLOCK_H__ 2 #define __XLOCK_XLOCK_H__ 3 4 #if !defined( lint ) && !defined( SABER ) 5 /* #ident "@(#)xlock.h 5.34 2011/05/23 xlockmore" */ 6 7 #endif 8 9 /*- 10 * @(#)xlock.h 4.00 97/01/01 xlockmore 11 * 12 * External interfaces for new modes and SYSV OS defines. 13 * 14 * Copyright (c) 1988-1991 by Patrick J. Naughton 15 * Copyright (c) 1993-2011 by David A. Bagley 16 * 17 * xscreensaver code, Copyright (c) 1997 Jamie Zawinski <jwz AT jwz.org> 18 * 19 * Permission to use, copy, modify, and distribute this software and its 20 * documentation for any purpose and without fee is hereby granted, 21 * provided that the above copyright notice appear in all copies and that 22 * both that copyright notice and this permission notice appear in 23 * supporting documentation. 24 * 25 * This file is provided AS IS with no warranties of any kind. The author 26 * shall have no liability with respect to the infringement of copyrights, 27 * trade secrets or any patents by this file or any part thereof. In no 28 * event will the author be liable for any lost revenue or profits or 29 * other special, indirect and consequential damages. 30 * 31 * Revision History: 32 * 33 * Changes maintained by David Bagley <bagleyd AT verizon.net> 34 * 23-Apr-98: Merged in xlockmore.h from xscreensaver, not much in common yet. 35 * 12-May-95: Added defines for SunOS's Adjunct password file 36 * Dale A. Harris <rodmur@ecst.csuchico.edu> 37 * 18-Nov-94: Modified for QNX 4.2 w/ Metrolink X server from Brian Campbell 38 * <brianc@qnx.com>. 39 * 11-Jul-94: added Bool flag: inwindow, which tells xlock to run in a 40 * window from Greg Bowering <greg@cs.adelaide.edu.au> 41 * 11-Jul-94: patch for Solaris SYR4 from Chris P. Ross <cross@eng.umd.edu> 42 * 28-Jun-94: Reorganized shadow stuff 43 * 24-Jun-94: Reorganized 44 * 22-Jun-94: Modified for VMS 45 * <Anthony.D.Clarke@Support.Hatfield.Raytheon.bae.eurokom.ie> 46 * 17-Jun-94: patched shadow passwords and bcopy and bzero for SYSV from 47 * <reggers@julian.uwo.ca> 48 * 21-Mar-94: patched the patch for AIXV3 and HP from 49 * <R.K.Lloyd@csc.liv.ac.uk>. 50 * 01-Dec-93: added patch for AIXV3 from Tom McConnell 51 * <tmcconne@sedona.intel.com> also added a patch for HP-UX 8.0. 52 * 53 */ 54 55 #ifdef STANDALONE 56 /* xscreensaver compatibility layer for xlockmore modules. */ 57 58 /*- 59 * xscreensaver, Copyright (c) 1997, 1998 Jamie Zawinski <jwz AT jwz.org> 60 * 61 * Permission to use, copy, modify, distribute, and sell this software and its 62 * documentation for any purpose is hereby granted without fee, provided that 63 * the above copyright notice appear in all copies and that both that 64 * copyright notice and this permission notice appear in supporting 65 * documentation. No representations are made about the suitability of this 66 * software for any purpose. It is provided "as is" without express or 67 * implied warranty. 68 * 69 * The definitions in this file make it possible to compile an xlockmore 70 * module into a standalone program, and thus use it with xscreensaver. 71 * By Jamie Zawinski <jwz AT jwz.org> on 10-May-97; based on the ideas 72 * in the older xlock.h by Charles Hannum <mycroft@ai.mit.edu>. (I had 73 * to redo it, since xlockmore has diverged so far from xlock...) 74 */ 75 76 #if !defined(PROGCLASS) || !defined(HACK_INIT) || !defined(HACK_DRAW) 77 ERROR ! Define PROGCLASS, HACK_INIT, and HACK_DRAW before including xlockmore.h 78 #endif 79 80 #include "config.h" 81 82 #include <stdio.h> 83 #include <math.h> 84 #include "mode.h" 85 86 #ifdef USE_GL 87 #include "visgl.h" 88 #define FreeAllGL(dpy) /* */ 89 #endif 90 91 /*- 92 * Sun version of OpenGL needs to have the constant 93 * SUN_OGL_NO_VERTEX_MACROS defined in order to compile modes that 94 * use glNormal3f (the number of arguments to the macro changes...) 95 */ 96 #ifndef HAVE_MESA_GL 97 #if defined(__sun) && defined(__SVR4) /* Solaris */ 98 #define SUN_OGL_NO_VERTEX_MACROS 1 99 #endif /* Solaris */ 100 #endif /* !HAVE_MESA_GL */ 101 102 103 /* Some other utility macros. 104 */ 105 #define SINF(n) ((float)sin((double)(n))) 106 #define COSF(n) ((float)cos((double)(n))) 107 #define FABSF(n) ((float)fabs((double)(n))) 108 109 #undef MAX 110 #undef MIN 111 #undef ABS 112 #define MAX(a,b)((a)>(b)?(a):(b)) 113 #define MIN(a,b)((a)<(b)?(a):(b)) 114 #define ABS(a)((a)<0 ? -(a) : (a)) 115 116 /* The globals that screenhack.c expects (initialized by xlockmore.c). 117 */ 118 #ifdef __cplusplus 119 extern "C" { 120 #endif 121 char *defaults[100]; 122 XrmOptionDescRec options[100]; 123 #ifdef __cplusplus 124 } 125 #endif 126 127 #define XSCREENSAVER_PREF 1 /* Disagreements handled with this :) */ 128 #define ENTRYPOINT static 129 130 #else /* !STANDALONE */ 131 132 #ifdef HAVE_CONFIG_H 133 #include "config.h" 134 #ifdef USE_MB 135 #ifdef __linux__ 136 /*#define X_LOCALE*/ 137 #endif 138 #include <X11/Xlocale.h> 139 #endif 140 #else /* HAVE_CONFIG_H */ 141 142 #ifdef WIN32 143 #define HAVE_FCNTL_H 1 144 #define HAVE_LIMITS_H 1 145 #define HAVE_SYSLOG_H 1 146 #define HAVE_MEMORY_H 1 147 #define HAVE_STRDUP 1 148 #else /* !WIN32 */ 149 150 /* THIS MAY SOON BE DEFUNCT, SHOULD WORK NOW THOUGH FOR IMAKE */ 151 #define HAVE_GLBINDTEXTURE 1 152 #if !defined(__cplusplus) && !defined(c_plusplus) 153 #ifdef inline 154 #undef inline 155 #endif 156 #define inline 157 #endif 158 #ifdef AIXV3 159 #define HAVE_SYS_SELECT_H 1 160 #else 161 #define HAVE_SYS_TIME_H 1 162 #endif 163 #if !defined( __hpux ) && !defined( apollo ) && !defined( VMS ) 164 #define HAVE_SETEUID 165 #endif 166 #define HAVE_FCNTL_H 1 167 #define HAVE_LIMITS_H 1 168 #define HAVE_SYSLOG_H 1 169 #define HAVE_GETHOSTNAME 1 170 #define HAVE_UNISTD_H 1 171 #ifdef VMS 172 #ifdef USE_MB 173 #include <X11/Xlocale.h> 174 #endif 175 #if ( __VMS_VER < 70000000 ) 176 #ifdef USE_XVMSUTILS 177 #define HAVE_DIRENT_H 1 178 #define HAVE_GETTIMEOFDAY 1 179 #define GETTIMEOFDAY_TWO_ARGS 1 180 #else /* !USE_XVMSUTILS */ 181 #ifndef USE_OLD_EVENT_LOOP 182 #define USE_OLD_EVENT_LOOP 183 #endif /* USE_OLD_EVENT_LOOP */ 184 #define HAVE_DIRENT_H 0 185 #define HAVE_GETTIMEOFDAY 0 186 #endif /* !USE_XVMSUTILS */ 187 #define HAVE_STRDUP 0 188 #else /* __VMS_VER >= 70000000 */ 189 #define HAVE_DIRENT_H 1 190 #define HAVE_GETTIMEOFDAY 1 191 #define GETTIMEOFDAY_TWO_ARGS 1 192 #define HAVE_STRDUP 1 193 #endif /* __VMS_VER >= 70000000 */ 194 #else /* !VMS */ 195 #define HAVE_DIRENT_H 1 196 #define HAVE_MEMORY_H 1 197 #define HAVE_GETTIMEOFDAY 1 198 #define GETTIMEOFDAY_TWO_ARGS 1 199 #ifdef ultrix 200 #define HAVE_STRDUP 0 201 #else /* !ultrix */ 202 #define HAVE_STRDUP 1 203 #endif /* !ultrix */ 204 #endif /* !VMS */ 205 #endif /* !WIN32 */ 206 #endif /* !HAVE_CONF_H */ 207 208 #ifdef USE_MB 209 #include <sys/types.h> 210 #else 211 #include <sys/types.h> 212 #ifdef USE_MB 213 /* Something weird happening here on Cygwin */ 214 #undef USE_MB 215 #endif 216 #endif 217 #ifndef WIN32 218 #ifdef __NetBSD__ 219 #include <signal.h> 220 #else /* !__NetBSD__ */ 221 #include <sys/signal.h> 222 #endif /* __NetBSD__ */ 223 #endif /* !WIN32 */ 224 #if defined( VMS ) && defined( __cplusplus ) 225 /* Xlib.h for VMS is not (yet) compatible with C++ * 226 * The resulting warnings are switched off here */ 227 #pragma message disable nosimpint 228 #endif 229 #ifdef VMS 230 #include "vms_x_fix.h" 231 #ifdef USE_MB 232 #undef XTextWidth 233 #undef XDrawString 234 #undef XDrawImageString 235 #endif 236 #endif 237 #ifndef WIN32 238 #include <X11/Xlib.h> 239 #include <X11/Xutil.h> 240 #include <X11/Xos.h> 241 #include <X11/Xresource.h> 242 /* Maximum possible number of colors (*not* default number of colors.) */ 243 #define NUMCOLORS 256 244 #else 245 #include "Xapi.h" 246 extern int usleep(unsigned long usec); 247 /* wingdi.h also defines NUMCOLORS but to 24 */ 248 #undef NUMCOLORS 249 #define NUMCOLORS 256 250 #endif /* WIN32 */ 251 #if defined( VMS ) && defined( __cplusplus ) 252 #pragma message enable nosimpint 253 #endif 254 #include <math.h> 255 256 /* I use this for testing SunCplusplus 257 I still get this in the link: 258 Undefined first referenced 259 symbol in file 260 gethostbyname(const char*) ../xlock/resource.o 261 kill(long, int) ../xlock/logout.o 262 signal(int, void (*)(int)) ../xlock/logout.o 263 264 */ 265 #ifdef SunCplusplus 266 #ifndef HAVE_USLEEP 267 #define HAVE_USLEEP 1 268 #endif 269 #ifndef SUN_OGL_NO_VERTEX_MACROS 270 #define SUN_OGL_NO_VERTEX_MACROS 1 271 #endif 272 #endif 273 #ifndef TEXTLINES 274 #define TEXTLINES 40 275 #endif 276 #define PASSLENGTH 120 277 #define ERROR_BUF 2048 278 #define ERROR_LINE 80 279 280 #ifdef HAVE_SYS_PARAM_H 281 #include <sys/param.h> 282 #endif 283 #ifndef MAXPATHLEN 284 #define MAXPATHLEN 1024 285 #endif 286 287 #ifndef DEF_NONE3D 288 #define DEF_NONE3D "Black" 289 #endif 290 #ifndef DEF_RIGHT3D 291 #define DEF_RIGHT3D "Blue" 292 #endif 293 #ifndef DEF_LEFT3D 294 #define DEF_LEFT3D "Red" 295 #endif 296 #ifndef DEF_BOTH3D 297 #define DEF_BOTH3D "Magenta" 298 #endif 299 300 #ifndef DEF_ICONW 301 #define DEF_ICONW 64 /* Age old default */ 302 #endif 303 #ifndef DEF_ICONH 304 #define DEF_ICONH 64 305 #endif 306 307 #ifndef DEF_GLW 308 #define DEF_GLW 640 309 #endif 310 #ifndef DEF_GLH 311 #define DEF_GLH 480 312 #endif 313 314 #define MINICONW 1 /* Will not see much */ 315 #define MINICONH 1 316 317 #ifndef MAXICONW 318 #define MAXICONW 256 /* Want users to know the screen is locked */ 319 #endif 320 #ifndef MAXICONH 321 #define MAXICONH 256 /* by a particular user */ 322 #endif 323 324 #ifndef MIN 325 #define MIN(a,b) (((a)<(b))?(a):(b)) 326 #endif 327 328 #ifndef MAX 329 #define MAX(a,b) (((a)>(b))?(a):(b)) 330 #endif 331 332 #ifndef ABS 333 #define ABS(a) ((a<0)?(-(a)):(a)) 334 #endif 335 336 #ifndef M_E 337 #define M_E 2.7182818284590452354 /* e */ 338 #endif 339 #ifndef M_LOG2E 340 #define M_LOG2E 1.4426950408889634074 /* */ 341 #endif 342 #ifndef M_LN2 343 #define M_LN2 0.69314718055994530942 /* log e2 */ 344 #endif 345 #ifndef M_PI 346 #define M_PI 3.14159265358979323846 /* pi */ 347 #endif 348 #ifndef M_PI_2 349 #define M_PI_2 1.57079632679489661923 /* pi/2 */ 350 #endif 351 #ifdef MATHF 352 #define SINF(n) sinf(n) 353 #define COSF(n) cosf(n) 354 #define FABSF(n) fabsf(n) 355 #else 356 #define SINF(n) ((float)sin((double)(n))) 357 #define COSF(n) ((float)cos((double)(n))) 358 #define FABSF(n) ((float)fabs((double)(n))) 359 #endif 360 361 #if VMS 362 #include <unixlib.h> 363 #endif 364 #if 0 365 #ifndef uid_t 366 #define uid_t int 367 #endif 368 #ifndef gid_t 369 #define gid_t int 370 #endif 371 #ifndef pid_t 372 #define pid_t int 373 #endif 374 #ifndef size_t 375 #define size_t unsigned 376 #endif 377 #ifndef caddr_t 378 #define caddr_t char * 379 #endif 380 #endif 381 #if HAVE_UNISTD_H 382 #include <unistd.h> 383 #endif 384 #if HAVE_MEMORY_H 385 #include <memory.h> 386 #endif 387 #include <stdio.h> 388 #include <string.h> 389 #include <stdlib.h> 390 #if (defined( SYSV ) || defined( SVR4 )) && defined( SOLARIS2 ) && !defined( LESS_THAN_SOLARIS2_5 ) 391 #ifdef __cplusplus 392 extern "C" { 393 #endif 394 struct hostent { 395 char *h_name; /* official name of host */ 396 char **h_aliases; /* alias list */ 397 int h_addrtype; /* host address type */ 398 int h_length; /* length of address */ 399 char **h_addr_list; /* list of addresses from name server */ 400 }; 401 #ifdef __cplusplus 402 } 403 #endif 404 405 #else 406 #ifndef WIN32 407 #include <netdb.h> /* Gives problems on Solaris 2.6 with gcc */ 408 #endif /* !WIN32 */ 409 #endif 410 #include <ctype.h> 411 #if HAVE_DIRENT_H 412 #ifdef USE_XVMSUTILS 413 #if 0 414 #include "../xvmsutils/unix_types.h" 415 #include "../xvmsutils/dirent.h" 416 #else 417 #include <X11/unix_types.h> 418 #include <X11/dirent.h> 419 #endif 420 #else /* !USE_XVMSUTILS */ 421 #include <dirent.h> 422 #endif /* !USE_XVMSUTILS */ 423 #else 424 #define dirent direct 425 #define NAMELEN(dirent) (dirent)->d_namelen 426 #if HAVE_SYS_NDIR_H 427 #include <sys/ndir.h> 428 #endif 429 #if HAVE_SYS_DIR_H 430 #include <sys/dir.h> 431 #endif 432 #if HAVE_NDIR_H 433 #include <ndir.h> 434 #endif 435 #endif 436 #if defined(_SYSTYPE_SVR4) && !defined(SVR4) /* For SGI */ 437 #define SVR4 438 #endif 439 440 #ifndef MAXHOSTNAMELEN 441 #define MAXHOSTNAMELEN 64 /* SunOS 3.5 does not define this */ 442 #endif 443 444 #ifndef MAXNAMLEN 445 #define MAXNAMLEN 256 /* maximum filename length */ 446 #endif 447 #ifndef DIRBUF 448 #define DIRBUF 512 /* buffer size for fs-indep. dirs */ 449 #endif 450 451 #if defined(__cplusplus) || defined(c_plusplus) 452 #define CLASS c_class 453 #else 454 #define CLASS class 455 #endif 456 457 #if (!defined( AFS ) && !defined( SIA ) && defined( HAVE_SHADOW ) && !defined( OSF1_ENH_SEC ) && !defined( HP_PASSWDETC ) && !defined( VMS ) && !defined( USE_PAM ) && !defined( PASSWD_HELPER_PROGRAM )) 458 #define FALLBACK_XLOCKRC 459 #endif 460 461 #define t_String 0 462 #define t_Float 1 463 #define t_Int 2 464 #define t_Bool 3 465 466 #ifdef __cplusplus 467 extern "C" { 468 #endif 469 typedef struct { 470 void *var; 471 char *name; 472 char *classname; 473 char *def; 474 int type; 475 } argtype; 476 477 typedef struct { 478 char *opt; 479 char *desc; 480 } OptionStruct; 481 482 typedef struct { 483 int numopts; 484 XrmOptionDescRec *opts; 485 int numvarsdesc; 486 argtype *vars; 487 OptionStruct *desc; 488 } ModeSpecOpt; 489 490 #ifdef USE_MODULES 491 typedef struct { 492 const char *cmdline_arg; /* mode name */ 493 const char *init_name; /* name of init a mode */ 494 const char *callback_name; /* name of run (tick) a mode */ 495 const char *release_name; /* name of shutdown of a mode */ 496 const char *refresh_name; /* name of mode to repaint */ 497 const char *change_name; /* name of mode to change */ 498 const char *unused_name; /* name for future expansion */ 499 ModeSpecOpt *msopt; /* this mode's def resources */ 500 int def_delay; /* default delay for mode */ 501 int def_count; 502 int def_cycles; 503 int def_size; 504 int def_ncolors; 505 float def_saturation; 506 const char *def_bitmap; 507 const char *desc; /* text description of mode */ 508 unsigned int flags; /* state flags for this mode */ 509 void *userdata; /* for use by the mode */ 510 } ModStruct; 511 512 #endif 513 #ifdef __cplusplus 514 } 515 #endif 516 517 /* this must follow definition of ModeSpecOpt */ 518 #include "mode.h" 519 520 #define CHECK_OLD_ARGS /* check deprecated args */ 521 522 #ifdef OPENGL_MESA_INCLUDES 523 /* Allow OPEN GL using MESA includes */ 524 #undef MESA 525 #endif 526 527 #ifdef __cplusplus 528 extern "C" { 529 #endif 530 extern char * ProgramName; 531 extern void getResources(Display ** displayp, int argc, char **argv); 532 extern void finish(Display * display, Bool closeDisplay); 533 #ifdef HAS_MMOV 534 #define error xlock_error 535 #endif 536 extern void error(const char *buf); 537 #ifndef DECLARED_GETENV 538 extern char * getenv(const char *); 539 #endif 540 #ifdef __cplusplus 541 } 542 #endif 543 544 #ifdef VMS 545 #define FORK vfork 546 #else 547 #define FORK fork 548 #endif 549 550 #ifdef LESS_THAN_AIX3_2 551 #undef NULL 552 #define NULL 0 553 #endif /* LESS_THAN_AIX3_2 */ 554 555 #ifndef SYSLOG_WARNING 556 #define SYSLOG_WARNING LOG_WARNING 557 #endif 558 #ifndef SYSLOG_NOTICE 559 #define SYSLOG_NOTICE LOG_NOTICE 560 #endif 561 #ifndef SYSLOG_INFO 562 #define SYSLOG_INFO LOG_INFO 563 #endif 564 565 #if (defined( USE_RPLAY ) || defined( USE_NAS ) || defined( USE_VMSPLAY ) || \ 566 defined( HAS_MMOV ) || defined( USE_ESOUND ) || defined( DEF_PLAY )) 567 #define USE_SOUND 568 #endif 569 570 #ifdef USE_MB 571 #ifdef __cplusplus 572 extern "C" { 573 #endif 574 extern XFontSet fontset; 575 #ifdef __cplusplus 576 } 577 #endif 578 579 #define XTextWidth(font,string,length) \ 580 XmbTextEscapement(fontset,string,length) 581 #define XDrawString(display,window,gc,x,y,string,length) \ 582 XmbDrawString(display,window,fontset,gc,x,y,string,length) 583 #define XDrawImageString(display,window,gc,x,y,string,length) \ 584 XmbDrawImageString(display,window,fontset,gc,x,y,string,length) 585 #endif 586 587 #endif /* STANDALONE */ 588 589 /* COMMON STUFF */ 590 #if HAVE_GETTIMEOFDAY 591 #ifdef GETTIMEOFDAY_TWO_ARGS 592 #ifdef SunCplusplus 593 #define GETTIMEOFDAY(t) (void)gettimeofday(t,(struct timezone *) NULL); 594 #else 595 #define GETTIMEOFDAY(t) (void)gettimeofday(t,NULL); 596 #endif 597 #else 598 #define GETTIMEOFDAY(t) (void)gettimeofday(t); 599 #endif 600 #endif 601 602 #ifndef CLOCKS_PER_SEC 603 #define CLOCKS_PER_SEC 1000000 604 #endif 605 606 607 /* There is some overlap so it can be made more efficient */ 608 #define ERASE_IMAGE(d,w,g,x,y,xl,yl,xs,ys) \ 609 if (yl<y) \ 610 (y<(yl+ys))?XFillRectangle(d,w,g,xl,yl,xs,y-(yl)): \ 611 XFillRectangle(d,w,g,xl,yl,xs,ys); \ 612 else if (yl>y) \ 613 (y>(yl-(ys)))?XFillRectangle(d,w,g,xl,y+ys,xs,yl-(y)): \ 614 XFillRectangle(d,w,g,xl,yl,xs,ys); \ 615 if (xl<x) \ 616 (x<(xl+xs))?XFillRectangle(d,w,g,xl,yl,x-(xl),ys): \ 617 XFillRectangle(d,w,g,xl,yl,xs,ys); \ 618 else if (xl>x) \ 619 (x>(xl-(xs)))?XFillRectangle(d,w,g,x+xs,yl,xl-(x),ys): \ 620 XFillRectangle(d,w,g,xl,yl,xs,ys) 621 622 #include "random.h" 623 624 #ifdef WIN32 625 void xlockmore_win32_text(int xloc, int yloc, char *text); 626 void xlockmore_set_debug(char *text); 627 #endif 628 629 #define DEFAULT_NAME "xlock" 630 #define ENTRYPOINT 631 632 #endif /* __XLOCK_XLOCK_H__ */ 633