Files
Arquivotheca.Solaris-2.5/lib/libadm/puthelp.c
seta75D 7c4988eac0 Init
2021-10-11 19:38:01 -03:00

58 lines
1.3 KiB
C
Executable File

/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */
/*LINTLIBRARY*/
#ident "@(#)puthelp.c 1.4 92/07/14 SMI" /* SVr4.0 1.1 */
#include <stdio.h>
#include <string.h>
extern int ckwidth;
extern int ckindent;
extern int ckquit;
extern int puttext();
extern void *calloc(),
free();
void
puthelp(fp, defmesg, help)
FILE *fp;
char *defmesg, *help;
{
char *tmp;
int n;
tmp = NULL;
if(help == NULL) {
/* use default message since no help was provided */
help = defmesg ? defmesg : "No help available.";
} else if(defmesg != NULL) {
n = strlen(help);
if(help[0] == '~') {
/* prepend default message */
tmp = calloc(n+strlen(defmesg)+1, sizeof(char));
(void) strcpy(tmp, defmesg);
(void) strcat(tmp, "\n");
(void) strcat(tmp, ++help);
help = tmp;
} else if(n && (help[n-1] == '~')) {
/* append default message */
tmp = calloc(n+strlen(defmesg)+2, sizeof(char));
(void) strcpy(tmp, help);
tmp[n-1] = '\0';
(void) strcat(tmp, "\n");
(void) strcat(tmp, defmesg);
help = tmp;
}
}
(void) puttext(fp, help, ckindent, ckwidth);
(void) fputc('\n', fp);
if(tmp)
free(tmp);
}