File:  [CSRG BSD Unix] / 43BSD / contrib / notes / src / nfcomment.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 16:12:54 2018 UTC (8 years, 1 month ago) by root
Branches: MAIN, BSD
CVS tags: HEAD, BSD43
BSD 4.3

#include "parms.h"
#include "structs.h"

#ifdef	RCSIDENT
static char rcsid[] = "$Header: /var/lib/cvsd/repos/CSRG/43BSD/contrib/notes/src/nfcomment.c,v 1.1.1.1 2018/04/24 16:12:54 root Exp $";
#endif	RCSIDENT

/*
 *	nfcomment(nfname, text, title, dirflag, anonflag)
 *	char *nfname, *text, *title;
 *
 *	Allows the user to insert notes into notesfiles from his programs.
 *	The text is inserted into the notesfile 'nfname' with the 
 *	title specified. If dirflag or anonflag are non-null the
 *	director or anonymous bits are enabled, provided the user has
 *	permission.
 *	If text is NULL, the text for the note will be taken from
 *	standard input.
 *
 *	Original Coding:	Ray Essick	April 1982
 */

FILE * popen ();

nfcomment (nfname, text, title, dirflag, anonflag)
char   *nfname;
char   *text;
char   *title;
{

    FILE * zpipe;
    char    cmdline[CMDLEN];

    if (nfname == NULL)
    {
	fprintf (stderr, "nfcomment: No notesfile specified\n");
	return (-1);
    }
    if (title == NULL)
	title = "From nfcomment";

    sprintf (cmdline, "%s/nfpipe %s -t \"%s\" %s %s",
	    BIN,					/* where nfpipe lives */
	    nfname,
	    title,
	    dirflag ? "-d" : " ",
	    anonflag ? "-a" : " ");

    if (text == NULL)
    {
	system (cmdline);
	fprintf (stderr, "EOT\n");			/* let him know he hit EOT */
    }
    else
    {
	if ((zpipe = popen (cmdline, "w")) == NULL)
	    return (-1);
	while (*text)
	    putc (*text++, zpipe);
	pclose (zpipe);
    }
    return 0;
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.