I am having the last_word: Print the full hostname.
This commit is contained in:
parent
69949f29e0
commit
cc31744fc2
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: do_command.c,v 1.6 2014/09/05 21:32:37 christos Exp $ */
|
||||
/* $NetBSD: do_command.c,v 1.7 2015/12/17 22:36:48 christos Exp $ */
|
||||
|
||||
/* Copyright 1988,1990,1993,1994 by Paul Vixie
|
||||
* All rights reserved
|
||||
|
@ -25,7 +25,7 @@
|
|||
#if 0
|
||||
static char rcsid[] = "Id: do_command.c,v 1.9 2004/01/23 18:56:42 vixie Exp";
|
||||
#else
|
||||
__RCSID("$NetBSD: do_command.c,v 1.6 2014/09/05 21:32:37 christos Exp $");
|
||||
__RCSID("$NetBSD: do_command.c,v 1.7 2015/12/17 22:36:48 christos Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -454,7 +454,7 @@ child_process(entry *e) {
|
|||
(void)fprintf(mail, "To: %s\n", mailto);
|
||||
(void)fprintf(mail,
|
||||
"Subject: Cron <%s@%s> %s\n",
|
||||
usernm, first_word(hostname, "."), e->cmd);
|
||||
usernm, hostname, e->cmd);
|
||||
(void)fprintf(mail,
|
||||
"Auto-Submitted: auto-generated\n");
|
||||
#ifdef MAIL_DATE
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: funcs.h,v 1.2 2010/05/06 18:53:17 christos Exp $ */
|
||||
/* $NetBSD: funcs.h,v 1.3 2015/12/17 22:36:48 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Id: funcs.h,v 1.9 2004/01/23 18:56:42 vixie Exp
|
||||
|
@ -59,7 +59,6 @@ size_t strlens(const char *, ...);
|
|||
char *env_get(const char *, char **),
|
||||
*arpadate(time_t *),
|
||||
*mkprints(char *, size_t),
|
||||
*first_word(char *, const char *),
|
||||
**env_init(void),
|
||||
**env_copy(char **),
|
||||
**env_set(char **, char *);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: misc.c,v 1.2 2010/05/06 18:53:17 christos Exp $ */
|
||||
/* $NetBSD: misc.c,v 1.3 2015/12/17 22:36:48 christos Exp $ */
|
||||
|
||||
/* Copyright 1988,1990,1993,1994 by Paul Vixie
|
||||
* All rights reserved
|
||||
|
@ -25,7 +25,7 @@
|
|||
#if 0
|
||||
static char rcsid[] = "Id: misc.c,v 1.16 2004/01/23 18:56:43 vixie Exp";
|
||||
#else
|
||||
__RCSID("$NetBSD: misc.c,v 1.2 2010/05/06 18:53:17 christos Exp $");
|
||||
__RCSID("$NetBSD: misc.c,v 1.3 2015/12/17 22:36:48 christos Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -497,41 +497,6 @@ log_close(void) {
|
|||
#endif /*SYSLOG*/
|
||||
}
|
||||
|
||||
/* char *first_word(char *s, char *t)
|
||||
* return pointer to first word
|
||||
* parameters:
|
||||
* s - string we want the first word of
|
||||
* t - terminators, implicitly including \0
|
||||
* warnings:
|
||||
* (1) this routine is fairly slow
|
||||
* (2) it returns a pointer to static storage
|
||||
*/
|
||||
char *
|
||||
first_word(char *s, const char *t) {
|
||||
static char retbuf[2][MAX_TEMPSTR + 1]; /* sure wish C had GC */
|
||||
static int retsel = 0;
|
||||
char *rb, *rp;
|
||||
|
||||
/* select a return buffer */
|
||||
retsel = 1-retsel;
|
||||
rb = &retbuf[retsel][0];
|
||||
rp = rb;
|
||||
|
||||
/* skip any leading terminators */
|
||||
while (*s && (NULL != strchr(t, *s))) {
|
||||
s++;
|
||||
}
|
||||
|
||||
/* copy until next terminator or full buffer */
|
||||
while (*s && (NULL == strchr(t, *s)) && (rp < &rb[MAX_TEMPSTR])) {
|
||||
*rp++ = *s++;
|
||||
}
|
||||
|
||||
/* finish the return-string and return it */
|
||||
*rp = '\0';
|
||||
return (rb);
|
||||
}
|
||||
|
||||
/* warning:
|
||||
* heavily ascii-dependent.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue