#include <afs/param.h>
#include <roken.h>
+#include <opr/softsig.h>
#undef IN
#include <afs/gtxwindows.h> /*Generic window package */
#include <afs/fsprobe.h> /*Interface for fsprobe module */
#include <afs/afsutil.h>
+#include <string.h>
+
/*
* Command line parameter indicies.
*/
#define P_SERVER 0
#define P_BASE 1
-#if 0
-#define P_PACKAGE 2
-#endif /* 0 */
#define P_FREQ 2
#define P_HOST 3
#define P_ATTENTION 4
struct onode *newlightp; /*Ptr to new light onode */
/*We only support curses right now */
struct gator_light_crparams light_crparams; /*Light creation params */
- char *truncname; /*Truncated name, if needed */
int name_len; /*True length of name */
if (scout_debug) {
if (scout_debug)
fprintf(scout_debugfd, "[%s] Name '%s' has %d chars\n", rn, a_name,
name_len);
- if (name_len <= a_width)
- sprintf(light_crparams.onode_params.cr_name, "%s", a_name);
- else {
- /*
- * We need to truncate the given name, leaving a `*' at the end to
- * show us it's been truncated.
- */
- truncname = light_crparams.onode_params.cr_name;
- strncpy(truncname, a_name, a_width - 1);
- truncname[a_width - 1] = '*';
- truncname[a_width] = 0;
- }
+
+ if (a_width >= sizeof(light_crparams.onode_params.cr_name))
+ a_width = sizeof(light_crparams.onode_params.cr_name) - 1;
+
+ if (strlcpy(light_crparams.onode_params.cr_name, a_name, a_width + 1) >= a_width + 1)
+ /* The name is truncated, put a '*' at the end to note */
+ light_crparams.onode_params.cr_name[a_width - 1] = '*';
+
light_crparams.onode_params.cr_x = a_x;
light_crparams.onode_params.cr_y = a_y;
light_crparams.onode_params.cr_width = a_width;
curr_disk->prev = i - 1;
curr_disk->next = i + 1;
curr_disk->active = 0;
- curr_disk->name = '\0';
+ curr_disk->name = "";
/*
* Bump up to the next disk structure.
* mark all used disk objects for this server as inactive and fix
* their line numbers if needed.
*/
- sc_disk = a_srvline->disks;
used_disk_idx = a_srvline->used_head;
while (used_disk_idx != SCOUT_NIL) {
if (scout_debug) {
curr_probeOK = fsprobe_Results.probeOK;
curr_line_num = curr_line->base_line;
- setting = 0;
for (curr_srvidx = 0; curr_srvidx < scout_screen.numServers;
curr_srvidx++) {
/*
sprintf(sp, "%d", curr_stats->CurrentConnections);
} else
sp = sblank;
- code = mini_justify(sp, /*Src buffer */
- lightdata->label, /*Dest buffer */
- scout_col_width[COL_CONN], /*Dest's width */
- SCOUT_RIGHT_JUSTIFY, /*Right-justify */
- SCOUT_LEFT_TRUNC, /*Left-truncate */
- SCOUT_ISNT_LDISK); /*Not a labeled disk */
+ mini_justify(sp, /*Src buffer */
+ lightdata->label, /*Dest buffer */
+ scout_col_width[COL_CONN], /*Dest's width */
+ SCOUT_RIGHT_JUSTIFY, /*Right-justify */
+ SCOUT_LEFT_TRUNC, /*Left-truncate */
+ SCOUT_ISNT_LDISK); /*Not a labeled disk */
if (scout_attn_conn != SCOUT_ATTN_NOTUSED
&& curr_stats->CurrentConnections >= scout_attn_conn)
setting = 1;
else
setting = 0;
- code = gator_light_set(curr_line->currConns_lp, setting);
+ gator_light_set(curr_line->currConns_lp, setting);
lightdata = (struct gator_lightobj *)(curr_line->fetches_lp->o_data);
if (*curr_probeOK == 0) {
sprintf(sp, "%u", curr_stats->TotalFetchs);
} else
sp = sblank;
- code = mini_justify(sp, /*Src buffer */
- lightdata->label, /*Dest buffer */
- scout_col_width[COL_FETCH], /*Dest's width */
- SCOUT_RIGHT_JUSTIFY, /*Right-justify */
- SCOUT_LEFT_TRUNC, /*Left-truncate */
- SCOUT_ISNT_LDISK); /*Not a labeled disk */
+ mini_justify(sp, /*Src buffer */
+ lightdata->label, /*Dest buffer */
+ scout_col_width[COL_FETCH], /*Dest's width */
+ SCOUT_RIGHT_JUSTIFY, /*Right-justify */
+ SCOUT_LEFT_TRUNC, /*Left-truncate */
+ SCOUT_ISNT_LDISK); /*Not a labeled disk */
if (scout_attn_fetch != SCOUT_ATTN_NOTUSED
&& curr_stats->TotalFetchs >= scout_attn_fetch)
setting = 1;
else
setting = 0;
- code = gator_light_set(curr_line->fetches_lp, setting);
+ gator_light_set(curr_line->fetches_lp, setting);
lightdata = (struct gator_lightobj *)(curr_line->stores_lp->o_data);
if (*curr_probeOK == 0) {
sprintf(sp, "%u", curr_stats->TotalStores);
} else
sp = sblank;
- code = mini_justify(sp, /*Src buffer */
- lightdata->label, /*Dest buffer */
- scout_col_width[COL_STORE], /*Dest's width */
- SCOUT_RIGHT_JUSTIFY, /*Right-justify */
- SCOUT_LEFT_TRUNC, /*Left-truncate */
- SCOUT_ISNT_LDISK); /*Not a labeled disk */
+ mini_justify(sp, /*Src buffer */
+ lightdata->label, /*Dest buffer */
+ scout_col_width[COL_STORE], /*Dest's width */
+ SCOUT_RIGHT_JUSTIFY, /*Right-justify */
+ SCOUT_LEFT_TRUNC, /*Left-truncate */
+ SCOUT_ISNT_LDISK); /*Not a labeled disk */
if (scout_attn_store != SCOUT_ATTN_NOTUSED
&& curr_stats->TotalStores >= scout_attn_store)
setting = 1;
else
setting = 0;
- code = gator_light_set(curr_line->stores_lp, setting);
+ gator_light_set(curr_line->stores_lp, setting);
lightdata =
(struct gator_lightobj *)(curr_line->workstations_lp->o_data);
sprintf(sp, "%d", curr_stats->WorkStations);
} else
sp = sblank;
- code = mini_justify(sp, /*Src buffer */
- lightdata->label, /*Dest buffer */
- scout_col_width[COL_WK], /*Dest's width */
- SCOUT_RIGHT_JUSTIFY, /*Right-justify */
- SCOUT_LEFT_TRUNC, /*Left-truncate */
- SCOUT_ISNT_LDISK); /*Not a labeled disk */
+ mini_justify(sp, /*Src buffer */
+ lightdata->label, /*Dest buffer */
+ scout_col_width[COL_WK], /*Dest's width */
+ SCOUT_RIGHT_JUSTIFY, /*Right-justify */
+ SCOUT_LEFT_TRUNC, /*Left-truncate */
+ SCOUT_ISNT_LDISK); /*Not a labeled disk */
if (scout_attn_workstations != SCOUT_ATTN_NOTUSED
&& curr_stats->WorkStations >= scout_attn_workstations)
setting = 1;
else
setting = 0;
- code = gator_light_set(curr_line->workstations_lp, setting);
+ gator_light_set(curr_line->workstations_lp, setting);
/*
* We turn the server light on if there was an error in the
* (Don't forget to fix the light's line if it needs it).
*/
setting = (*curr_probeOK) ? 1 : 0;
- code = gator_light_set(curr_line->srvName_lp, setting);
+ gator_light_set(curr_line->srvName_lp, setting);
/*
* Print out the disk statistics. The value returned is the
"[%s] Can't center server name inside of light object\n", rn);
return (code);
}
- curr_x += scout_col_width[COL_SRVNAME] + 1;
if (scout_initDiskLightObjects(a_line, scout_frame->window)) {
fprintf(stderr, "[%s:%s] Can't create disk light objects\n", pn, rn);
struct mini_line *curr_line; /*Ptr to current line */
int i; /*Generic loop variable */
int mini_line_bytes; /*Num bytes in mini_lines */
- struct timeval tv; /*Time structure */
int linenum; /*Current mini-line number */
-#if 0
- PROCESS pid; /*Main LWP process ID */
- PROCESS gxlistener_ID; /*Input Server LWP process ID */
-#endif /* 0 */
struct gator_lightobj *lightdata; /*Private light data */
if (scout_debug) {
}
/*
- * We have to initialize LWP support before we start up any of
+ * We have to initialize thread support before we start up any of
* our packages.
*/
-#if 0
- code = LWP_InitializeProcessSupport(LWP_NORMAL_PRIORITY, &pid);
- if (code) {
- fprintf(stderr, "[%s:%s] Can't initialize LWP\n", pn, rn);
- scout_CleanExit(code);
- }
-#endif /* 0 */
+ opr_softsig_Init();
/*
* Initialize the gtx package.
*/
-#if 0
- fprintf(stderr, "[%s:%s] Starting up gtx package\n", pn, rn);
-#endif /* 0 */
scout_gwin = gtx_Init(0, /*Don't start up InputServer yet */
-1); /*Type of window package */
if (scout_gwin == NULL) {
scout_gwin); /*Window */
if (scout_banner0_lp != NULL) {
lightdata = (struct gator_lightobj *)(scout_banner0_lp->o_data);
- code =
- mini_justify(scout_Banner, lightdata->label, scout_frameDims.maxx,
- SCOUT_CENTER, SCOUT_RIGHT_TRUNC, SCOUT_ISNT_LDISK);
- code = gator_light_set(scout_banner0_lp, 1);
- code = gtxframe_AddToList(scout_frame, scout_banner0_lp);
+ mini_justify(scout_Banner, lightdata->label, scout_frameDims.maxx,
+ SCOUT_CENTER, SCOUT_RIGHT_TRUNC, SCOUT_ISNT_LDISK);
+ gator_light_set(scout_banner0_lp, 1);
+ gtxframe_AddToList(scout_frame, scout_banner0_lp);
/*Debugging */
if (scout_debug)
snprintf(attn_label, sizeof(attn_label), "%s: < %d blocks free",
scout_label[5], scout_attn_disk_minfree);
}
- snprintf(scout_Banner, sizeof(scout_Banner),
- "%*s %*s %*s %*s %*s %s",
- scout_col_width[0], scout_label[0],
- scout_col_width[1], scout_label[1],
- scout_col_width[2], scout_label[2],
- scout_col_width[3], scout_label[3],
- scout_col_width[4], scout_label[4],
- attn_label);
+ code = snprintf(scout_Banner, sizeof(scout_Banner),
+ "%*s %*s %*s %*s %*s %s",
+ scout_col_width[0], scout_label[0],
+ scout_col_width[1], scout_label[1],
+ scout_col_width[2], scout_label[2],
+ scout_col_width[3], scout_label[3],
+ scout_col_width[4], scout_label[4],
+ attn_label);
+ if (code < 0 || code >= sizeof(scout_Banner)) {
+ fprintf(stderr, "[%s] Truncation while generating banner\n", rn);
+ return -1;
+ }
lightdata = (struct gator_lightobj *)(scout_banner1_lp->o_data);
- code =
- mini_justify(scout_Banner, lightdata->label, scout_frameDims.maxx,
- SCOUT_LEFT_JUSTIFY, SCOUT_RIGHT_TRUNC,
- SCOUT_ISNT_LDISK);
+ mini_justify(scout_Banner, lightdata->label, scout_frameDims.maxx,
+ SCOUT_LEFT_JUSTIFY, SCOUT_RIGHT_TRUNC,
+ SCOUT_ISNT_LDISK);
- code = gtxframe_AddToList(scout_frame, scout_banner1_lp);
+ gtxframe_AddToList(scout_frame, scout_banner1_lp);
}
scout_banner2_lp = mini_initLightObject("Banner 2", /*Light name */
scout_underline[5]);
lightdata = (struct gator_lightobj *)(scout_banner2_lp->o_data);
- code =
- mini_justify(scout_Banner, lightdata->label,
- scout_frameDims.maxx, SCOUT_LEFT_JUSTIFY,
- SCOUT_RIGHT_TRUNC, SCOUT_ISNT_LDISK);
- code = gtxframe_AddToList(scout_frame, scout_banner2_lp);
+ mini_justify(scout_Banner, lightdata->label,
+ scout_frameDims.maxx, SCOUT_LEFT_JUSTIFY,
+ SCOUT_RIGHT_TRUNC, SCOUT_ISNT_LDISK);
+ gtxframe_AddToList(scout_frame, scout_banner2_lp);
}
for (i = 0; i < a_numservers; i++) {
} /*Add lights in server records to display list */
-#if 0
- /*
- * Set up the minimal keymap.
- */
- code = keymap_BindToString(scout_frame->keymap, /*Ptr to keymap */
- "e", /*Key to bind */
- ExitCmd, /*Cmd to execute */
- NULL, /*Name */
- NULL); /*Ptr to rock */
- if (code) {
- fprintf(stderr, "[%s] Can't bind key `e', code is %d\n", rn, code);
- return (code);
- }
-#endif /* 0 */
-
/*
* Finish setting up the overall mini_screen structure.
*/
scout_probefreq, /*Probe frequency */
FS_Handler, /*Handler routine */
0); /*Turn debugging output off */
-#if 0
- scout_debug); /*Turn debugging output off */
-#endif /* 0 */
if (code) {
fprintf(stderr, "[%s] Error returned by fsprobe_Init: %d\n", rn,
code);
return (-1);
}
-
- /*
- * Start up the input server LWP for our window.
- */
-#if 0
- code = LWP_CreateProcess(gtx_InputServer, /*Fcn to start up */
- 8192, /*Stack size in bytes */
- LWP_NORMAL_PRIORITY, /*Priority */
- (void *)scout_gwin, /*Params: Ptr to window */
- "gx-listener", /*Name to use */
- &gxlistener_ID); /*Returned LWP process ID */
-#endif /* 0 */
-
code = (int)(intptr_t)gtx_InputServer(scout_gwin);
if (code) {
fprintf(stderr,
scout_CleanExit(code);
}
- /*
- * We fall into a loop, sleeping forever.
- */
- while (1) {
- tv.tv_sec = 60 * 60; /*Sleep for an hour at a time */
- tv.tv_usec = 0;
- code = select(0, /*Num fds */
- 0, /*Descriptors ready for reading */
- 0, /*Descriptors ready for writing */
- 0, /*Descriptors with exceptional conditions */
- &tv); /*Timeout structure */
- } /*Sleep forever */
-
-#if 0
- /*
- * How did we get here? Oh, well, clean up our windows and
- * return sweetness and light anyway.
- */
- WOP_CLEANUP(&scout_gwin);
- return (0);
-#endif /* 0 */
-
+ fsprobe_Wait(0); /* sleep forever */
+ return 0;
} /*execute_scout */
/*------------------------------------------------------------------------
fprintf(scout_debugfd, "[%s] Writing to Scout debugging file '%s'\n",
rn, debug_filename);
}
-#if 0
- wpkg_to_use = atoi(as->parms[P_PACKAGE].items->data);
-#endif /* 0 */
wpkg_to_use = 2; /*Always use curses for now */
-#if 0
- fprintf(stderr, "[%s:%s] Using graphics package %d: ", pn, rn,
- wpkg_to_use);
- switch (wpkg_to_use) {
- case GATOR_WIN_CURSES:
- fprintf(stderr, "curses\n");
- break;
- case GATOR_WIN_DUMB:
- fprintf(stderr, "dumb terminal\n");
- break;
- case GATOR_WIN_X11:
- fprintf(stderr, "X11\n");
- break;
- default:
- fprintf(stderr, "Illegal graphics package: %d\n", wpkg_to_use);
- scout_CleanExit(-1);
- } /*end switch (wpkg_to_use) */
-#endif /* 0 */
-
if (as->parms[P_FREQ].items != 0)
scout_probefreq = atoi(as->parms[P_FREQ].items->data);
else
/*
* Set up the commands we understand.
*/
- ts = cmd_CreateSyntax("initcmd", scoutInit, NULL, "initialize the program");
+ ts = cmd_CreateSyntax("initcmd", scoutInit, NULL, 0, "initialize the program");
cmd_AddParm(ts, "-server", CMD_LIST, CMD_REQUIRED,
"FileServer name(s) to monitor");
cmd_AddParm(ts, "-basename", CMD_SINGLE, CMD_OPTIONAL,
"base server name");
-#if 0
- cmd_AddParm(ts, "-package", CMD_SINGLE, CMD_REQUIRED,
- "Graphics package to use");
-#endif /* 0 */
cmd_AddParm(ts, "-frequency", CMD_SINGLE, CMD_OPTIONAL,
"poll frequency, in seconds");
cmd_AddParm(ts, "-host", CMD_FLAG, CMD_OPTIONAL,
*/
code = cmd_Dispatch(argc, argv);
if (code) {
-#if 0
- fprintf(stderr, "[%s:%s] Call to cmd_Dispatch() failed; code is %d\n",
- pn, rn, code);
-#endif /* 0 */
scout_CleanExit(1);
} else
scout_CleanExit(0);