|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T m
Length: 4938 (0x134a) Types: TextFile Names: »misc.c«
└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0 └─⟦dc59850a2⟧ »EurOpenD22/pp5.0/pp-5.tar.Z« └─⟦e5a54fb17⟧ └─⟦this⟧ »pp-5.0/Src/MTAconsole/misc.c«
/* misc.c : routines that wouldn't fit anywhere else */ # ifndef lint static char Rcsid[] = "@(#)$Header: /cs/research/pp/hubris/pp-beta/Src/MTAconsole/RCS/misc.c,v 5.0 90/09/20 16:19:56 pp Exp Locker: pp $"; # endif /* * $Header: /cs/research/pp/hubris/pp-beta/Src/MTAconsole/RCS/misc.c,v 5.0 90/09/20 16:19:56 pp Exp Locker: pp $ * * $Log: misc.c,v $ * Revision 5.0 90/09/20 16:19:56 pp * rcsforce : 5.0 public release * */ #include "console.h" #include <X11/cursorfont.h> #include "back.bit" Pixmap backpixmap; struct color_item *colors = NULL; XColor white, exact_white, black, exact_black; Pixel fg, bg; create_pixmaps(disp) Display *disp; { Window root; root = XDefaultRootWindow(disp); backpixmap = XCreatePixmapFromBitmapData(disp, root, back_bits, back_width, back_height, fg, bg, XDefaultDepth(disp,XDefaultScreen(disp))); } static Colormap color_map; extern int num_colors; extern Widget quit_command; #define MAX_COLOR_VALUE 65535 /* setup the colours used */ /* ARGSUSED */ SetColours(disp, win) Display *disp; Window win; { int i, badness; Colormap cmap2; double fract; WidgetGet (quit_command, XtNbackground, &bg, XtNforeground, &fg, NULL); color_map = DefaultColormap(disp, XDefaultScreen(disp)); XAllocNamedColor(disp, color_map, "white", &white, &exact_white); XAllocNamedColor(disp, color_map, "black", &black, &exact_black); colors = (struct color_item *) calloc((unsigned) num_colors, sizeof(struct color_item)); if (num_colors == 1) { colors[0].badness = 0; colors[0].colour.pixel = fg; } else { for (i = 0; i < num_colors; i++) { badness = (i * max_bad_channel/num_colors); colors[i].badness = badness; colors[i].colour.pixel = 0; colors[i].colour.blue = 0; if (badness > max_bad_channel/2) colors[i].colour.red = MAX_COLOR_VALUE; else { fract = (double) badness * 2.0 / (double) max_bad_channel; colors[i].colour.red = fract * MAX_COLOR_VALUE; } if (colors[i].colour.red > MAX_COLOR_VALUE) colors[i].colour.red = MAX_COLOR_VALUE; if (max_bad_channel - badness > max_bad_channel/2) colors[i].colour.green = MAX_COLOR_VALUE; else { fract = ((double) (max_bad_channel - badness) * 2.0) / (double) max_bad_channel; colors[i].colour.green = fract * MAX_COLOR_VALUE; } if (colors[i].colour.green > MAX_COLOR_VALUE) colors[i].colour.green = MAX_COLOR_VALUE; colors[i].colour.flags = DoRed | DoGreen | DoBlue; } for (i = 0; i < num_colors; i++) { if (XAllocColor(disp, color_map, &(colors[i].colour)) == 0) { cmap2 = XCopyColormapAndFree(disp, color_map); for (; i < num_colors; i++) XAllocColor(disp, cmap2, &(colors[i].colour)); color_map = cmap2; break; } } XSetWindowColormap(disp, win, color_map); } create_pixmaps(disp); } char *stripstr(str) char *str; { char *ret, *ix; ix = str; while (*ix != '\0' && isspace(*ix)) ix++; ret = ix; while(*ix != '\0' && *ix != '\n') ix++; if (*ix == '\n') *ix = '\0'; return ret; } int is_loc_chan(chan) struct chan_struct *chan; { if (chan->chantype == int_Qmgr_chantype_mts && chan->outbound > 0) return TRUE; else return FALSE; } extern Display *disp; extern Widget top; Window waitWindow = NULL; StartWait() { if (waitWindow == (Window)NULL) { XSetWindowAttributes attributes; attributes.cursor = XCreateFontCursor(disp, XC_watch); attributes.do_not_propagate_mask = (KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask); waitWindow = XCreateWindow(disp, XtWindow(top), 0, 0, XDisplayWidth(disp, XDefaultScreen(disp)), XDisplayHeight(disp, XDefaultScreen(disp)), (unsigned int) 0, CopyFromParent, InputOnly, CopyFromParent, (CWDontPropagate | CWCursor), &attributes); } (void) XMapRaised(disp, waitWindow); (void) XFlush(disp); } EndWait() { (void) XUnmapWindow(disp, waitWindow); } extern Widget time_label; undisplay_time_label() { XtSetMappedWhenManaged(time_label, False); } display_time_label() { update_time_label(); XtSetMappedWhenManaged(time_label, True); } extern time_t currentTime; extern char *time_t2RFC(); extern int currchans, maxchans; update_time_label() { char *str, buf[BUFSIZ]; time(¤tTime); str = time_t2RFC(currentTime); (void) sprintf(buf, "%d channel%s running (max %d) at %s", currchans, (currchans == 1) ? "" : "s", maxchans, str); free(str); WidgetSet(time_label, XtNlabel, buf, NULL); } extern State connectState; /* ARGSUSED */ void setLoad (w, ptr_load, load) Widget w; double *ptr_load; double *load; { if (connectState == connected) *load = *ptr_load / 100; else *load = 0; }