alerts.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 1997 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.17 */
/* EMACS_MODES: !fill, lnumb, !overwrite, !nodelete, !picture */
#include "stdio.h"
#include "string.h"
#include "errno.h"
#include "limits.h"
#include "unistd.h"
#include "lp.h"
extern char **environ;
static void envlist(int, char **);
/*
* We recognize the following key phrases in the alert prototype
* file, and replace them with appropriate values.
*/
#define NALRT_KEYS 7
# define ALRT_ENV 0
# define ALRT_PWD 1
# define ALRT_ULIMIT 2
# define ALRT_UMASK 3
# define ALRT_INTERVAL 4
# define ALRT_CMD 5
# define ALRT_USER 6
static struct {
char *v;
short len;
} shell_keys[NALRT_KEYS] = {
#define ENTRY(X) X, sizeof(X)-1
ENTRY("-ENVIRONMENT-"),
ENTRY("-PWD-"),
ENTRY("-ULIMIT-"),
ENTRY("-UMASK-"),
ENTRY("-INTERVAL-"),
ENTRY("-CMD-"),
ENTRY("-USER-"),
};
/*
* These are used to bracket the administrator's command, so that
* we can find it easily. We're out of luck if the administrator
* includes an identical phrase in his or her command.
*/
#define ALRT_CMDSTART "## YOUR COMMAND STARTS HERE -- DON'T TOUCH ABOVE!!"
#define ALRT_CMDEND "## YOUR COMMAND ENDS HERE -- DON'T TOUCH BELOW!!"
/**
** putalert() - WRITE ALERT TO FILES
**/
int
{
char *path,
int cur_umask;
return (-1);
}
return (-1);
}
/*
* See if the form/printer/print-wheel exists.
*/
return (-1);
return (-1);
}
/*
* First, the shell command file.
*/
return (-1);
return (-1);
}
/*
* We use a prototype file to build the shell command,
* so that the alerts are easily customized. The shell
* is expected to handle repeat alerts and failed alerts,
* because the Spooler doesn't. Also, the Spooler runs
* each alert with the UID and GID of the administrator
* who defined the alert. Otherwise, anything goes.
*/
if (!Lp_Bin) {
getpaths ();
if (!Lp_Bin)
return (-1);
}
return (-1);
return (-1);
}
errno = 0;
int key;
char *cp,
*dash;
*dash = 0;
if (STRNEQU(
cp,
shell_keys[key].v,
)) {
register char *newline =
switch (key) {
case ALRT_ENV:
break;
case ALRT_PWD:
break;
case ALRT_ULIMIT:
break;
case ALRT_UMASK:
break;
case ALRT_INTERVAL:
break;
case ALRT_CMD:
break;
case ALRT_USER:
break;
}
break;
}
if (key >= NALRT_KEYS)
}
}
if (errno != 0) {
int save_errno = errno;
errno = save_errno;
return (-1);
}
/*
* Next, the variables file.
*/
return (-1);
return (-1);
}
return (0);
}
/**
** getalert() - EXTRACT ALERT FROM FILES
**/
FALERT *
{
int fd;
char *tmp;
register char *path;
int len;
return (0);
}
/*
* See if the form/printer/print-wheel exists.
*/
return (0);
return (0);
}
/*
* First, the shell command file.
*/
return (0);
return (0);
}
/*
* Skip over environment setting stuff, while loop, etc.,
* to find the beginning of the command.
*/
errno = 0;
;
int save_errno = errno;
errno = save_errno;
return (0);
}
return (0);
/*
* Drop terminating newline.
*/
/*
* Next, the variables file.
*/
return (0);
return (0);
}
errno = 0;
if (errno != 0) {
int save_errno = errno;
errno = save_errno;
return (0);
}
if (errno != 0) {
int save_errno = errno;
errno = save_errno;
return (0);
}
return (&alert);
}
/**
** delalert() - DELETE ALERT FILES
**/
int
{
char *path;
return (-1);
}
/*
* See if the form/printer/print-wheel exists.
*/
return (-1);
return (-1);
}
/*
* Remove the two files.
*/
return (-1);
return (-1);
}
return (-1);
return (-1);
}
return (0);
}
/**
** envlist() - PRINT OUT ENVIRONMENT LIST SAFELY
**/
static void
{
register char *env,
*value;
return;
continue;
*value++ = 0;
*--value = '=';
}
}
/*
* printalert() - PRINT ALERT DESCRIPTION
*
* This is not used in the scheduler, so we don't need to switch to using
* file descriptors for scalability.
*/
void
{
if (isfault)
else
} else {
*cp;
if (isfault)
else
if (alertp->Q > 1)
(void)fprintf (
fp,
(char *)gettext("When %d are queued: "),
alertp->Q
);
else
while (*cp == ' ')
*cp++ = 0;
if (
&& (
)
)
else
if (alertp->W > 0)
else
}
return;
}