git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@126 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Björn Groenvall
1995-09-28 17:04:46 +00:00
parent b789954d34
commit 9862e8b890

View File

@@ -6,8 +6,11 @@
* "xnlock" is the X11 version of the program. * "xnlock" is the X11 version of the program.
* Original sunview version written by Dan Heller 1985 (not included here). * Original sunview version written by Dan Heller 1985 (not included here).
*/ */
#define random rand #ifdef HAVE_CONFIG_H
#define srandom srand #include "config.h"
#include "protos.h"
#endif
#include <stdio.h> #include <stdio.h>
#include <X11/StringDefs.h> #include <X11/StringDefs.h>
#include <X11/Intrinsic.h> #include <X11/Intrinsic.h>
@@ -17,10 +20,9 @@
#include <ctype.h> #include <ctype.h>
#include <pwd.h> #include <pwd.h>
#define KERBEROS
#ifdef KERBEROS #ifdef KERBEROS
#include <krb.h> #include <krb.h>
#include <kafs.h>
#endif #endif
char STRING[] = "****************"; char STRING[] = "****************";
@@ -110,6 +112,7 @@ static XrmOptionDescRec options[] = {
{ "-noar", "acceptRootPasswd", XrmoptionNoArg, "False" }, { "-noar", "acceptRootPasswd", XrmoptionNoArg, "False" },
}; };
int
main (argc, argv) main (argc, argv)
int argc; int argc;
char *argv[]; char *argv[];
@@ -120,7 +123,7 @@ char *argv[];
XGCValues gcvalues; XGCValues gcvalues;
char **list; char **list;
if (ProgName = rindex(*argv, '/')) if ((ProgName = rindex(*argv, '/')) != 0)
ProgName++; ProgName++;
else else
ProgName = *argv; ProgName = *argv;
@@ -169,7 +172,7 @@ char *argv[];
if (!(font = Resrcs.font)) { if (!(font = Resrcs.font)) {
list = XListFonts(dpy, FONT_NAME, 32767, &foo); list = XListFonts(dpy, FONT_NAME, 32767, &foo);
for (i = 0; i < foo; i++) for (i = 0; i < foo; i++)
if (font = XLoadQueryFont(dpy, list[i])) if ((font = XLoadQueryFont(dpy, list[i])) != 0)
break; break;
if (!font) if (!font)
{ {
@@ -188,7 +191,7 @@ char *argv[];
x = Width / 2; x = Width / 2;
y = Height / 2; y = Height / 2;
srandom (time(0)); srand (time(0));
state = IS_MOVING; state = IS_MOVING;
{ {
@@ -215,8 +218,10 @@ char *argv[];
#endif #endif
ScreenSaver(1); ScreenSaver(1);
XtAppMainLoop(app); XtAppMainLoop(app);
exit(0);
} }
static void
leave() leave()
{ {
#if 0 #if 0
@@ -229,6 +234,7 @@ leave()
exit(0); exit(0);
} }
static void
ScreenSaver(save) ScreenSaver(save)
{ {
static int timeout, interval, prefer_blank, allow_exp; static int timeout, interval, prefer_blank, allow_exp;
@@ -240,7 +246,7 @@ ScreenSaver(save)
XSetScreenSaver(dpy, timeout, interval, prefer_blank, allow_exp); XSetScreenSaver(dpy, timeout, interval, prefer_blank, allow_exp);
} }
void static void
ClearWindow(w, event) ClearWindow(w, event)
Widget w; Widget w;
XExposeEvent *event; XExposeEvent *event;
@@ -264,7 +270,7 @@ XExposeEvent *event;
} }
} }
void static void
Visibility(w, client_data, event) Visibility(w, client_data, event)
Widget w; Widget w;
XtPointer client_data; XtPointer client_data;
@@ -273,6 +279,7 @@ XVisibilityEvent *event;
XRaiseWindow(dpy, XtWindow(w)); XRaiseWindow(dpy, XtWindow(w));
} }
static void
init_words (argc, argv) init_words (argc, argv)
int argc; int argc;
char *argv[]; char *argv[];
@@ -324,7 +331,7 @@ char *argv[];
words = get_words(argv); /* if getwordsfrom != FROM_ARGV, argv is a nop */ words = get_words(argv); /* if getwordsfrom != FROM_ARGV, argv is a nop */
} }
char * static char *
get_words(argv) get_words(argv)
char **argv; char **argv;
{ {
@@ -372,7 +379,7 @@ char **argv;
#define PROMPT "Password: " #define PROMPT "Password: "
#define FAIL_MSG "Sorry, try again" #define FAIL_MSG "Sorry, try again"
void static void
GetPasswd(w, event) GetPasswd(w, event)
Widget w; Widget w;
XKeyEvent *event; XKeyEvent *event;
@@ -403,7 +410,6 @@ XKeyEvent *event;
if (!XLookupString(event, &c, 1, &keysym, 0)) if (!XLookupString(event, &c, 1, &keysym, 0))
return; return;
if (keysym == XK_Return || keysym == XK_Linefeed) { if (keysym == XK_Return || keysym == XK_Linefeed) {
XExposeEvent event;
passwd[cnt] = 0; passwd[cnt] = 0;
XtRemoveTimeOut(timeout_id); XtRemoveTimeOut(timeout_id);
/* /*
@@ -472,11 +478,11 @@ XKeyEvent *event;
prompt_y, " ", 11-cnt); prompt_y, " ", 11-cnt);
} }
void static void
post_prompt_box(window) post_prompt_box(window)
Window window; Window window;
{ {
char *pass = NULL, s[32]; char s[32];
int width = (Width / 3); int width = (Width / 3);
int height = font_height(font) * 6; int height = font_height(font) * 6;
int box_x, box_y; int box_x, box_y;
@@ -517,7 +523,7 @@ Window window;
time_y += 2*font_height(font); time_y += 2*font_height(font);
} }
void static void
countdown(timeout) countdown(timeout)
int *timeout; int *timeout;
{ {
@@ -548,7 +554,7 @@ int *timeout;
#include "nose.front" #include "nose.front"
#include "nose.down" #include "nose.down"
void static void
init_images() init_images()
{ {
static Pixmap *images[] = { static Pixmap *images[] = {
@@ -577,7 +583,7 @@ init_images()
#define X_INCR 3 #define X_INCR 3
#define Y_INCR 2 #define Y_INCR 2
void static void
move() move()
{ {
static int length, dir; static int length, dir;
@@ -585,21 +591,21 @@ move()
if (!length) { if (!length) {
register int tries = 0; register int tries = 0;
dir = 0; dir = 0;
if ((random() & 1) && think()) { if ((rand() & 1) && think()) {
talk(0); /* sets timeout to itself */ talk(0); /* sets timeout to itself */
return; return;
} }
if (!(random() % 3) && (interval = look())) { if (!(rand() % 3) && (interval = look())) {
timeout_id = XtAppAddTimeOut(app, interval, move, NULL); timeout_id = XtAppAddTimeOut(app, interval, move, NULL);
return; return;
} }
interval = 20 + random() % 100; interval = 20 + rand() % 100;
do { do {
if (!tries) if (!tries)
length = Width/100 + random() % 90, tries = 8; length = Width/100 + rand() % 90, tries = 8;
else else
tries--; tries--;
switch (random() % 8) { switch (rand() % 8) {
case 0: case 0:
if (x - X_INCR*length >= 5) if (x - X_INCR*length >= 5)
dir = LEFT; dir = LEFT;
@@ -635,6 +641,7 @@ move()
timeout_id = XtAppAddTimeOut(app, interval, move, NULL); timeout_id = XtAppAddTimeOut(app, interval, move, NULL);
} }
static void
walk(dir) walk(dir)
register int dir; register int dir;
{ {
@@ -698,11 +705,12 @@ register int dir;
lastdir = dir; lastdir = dir;
} }
static int
think() think()
{ {
if (random() & 1) if (rand() & 1)
walk(FRONT); walk(FRONT);
if (random() & 1) { if (rand() & 1) {
if (getwordsfrom > 1) if (getwordsfrom > 1)
words = get_words((char **)NULL); words = get_words((char **)NULL);
return 1; return 1;
@@ -711,6 +719,7 @@ think()
} }
#define MAXLINES 40 #define MAXLINES 40
static void
talk(force_erase) talk(force_erase)
int force_erase; int force_erase;
{ {
@@ -828,24 +837,24 @@ int force_erase;
(XtTimerCallbackProc)talk, NULL); (XtTimerCallbackProc)talk, NULL);
} }
unsigned long static unsigned long
look() look()
{ {
if (random() % 3) { if (rand() % 3) {
XCopyPlane(dpy, (random() & 1)? down : front, XtWindow(widget), gc, XCopyPlane(dpy, (rand() & 1)? down : front, XtWindow(widget), gc,
0, 0, 64,64, x, y, 1L); 0, 0, 64,64, x, y, 1L);
return 1000L; return 1000L;
} }
if (!(random() % 5)) if (!(rand() % 5))
return 0; return 0;
if (random() % 3) { if (rand() % 3) {
XCopyPlane(dpy, (random() & 1)? left_front : right_front, XCopyPlane(dpy, (rand() & 1)? left_front : right_front,
XtWindow(widget), gc, 0, 0, 64,64, x, y, 1L); XtWindow(widget), gc, 0, 0, 64,64, x, y, 1L);
return 1000L; return 1000L;
} }
if (!(random() % 5)) if (!(rand() % 5))
return 0; return 0;
XCopyPlane(dpy, (random() & 1)? left0 : right0, XtWindow(widget), gc, XCopyPlane(dpy, (rand() & 1)? left0 : right0, XtWindow(widget), gc,
0, 0, 64,64, x, y, 1L); 0, 0, 64,64, x, y, 1L);
return 1000L; return 1000L;
} }