DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T w

⟦d33764b13⟧ TextFile

    Length: 2349 (0x92d)
    Types: TextFile
    Names: »wr_q2drsubmit.c«

Derivation

└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0
    └─⟦dc59850a2⟧ »EurOpenD22/pp5.0/pp-5.tar.Z« 
        └─⟦e5a54fb17⟧ 
            └─⟦this⟧ »pp-5.0/Lib/io/wr_q2drsubmit.c« 

TextFile

/* wr_q2drsubmit.c: write out a Delivery Notification struct 
	from the info held in the queue and address structures of submit
*/

# ifndef lint
static char Rcsid[] = "@(#)$Header: /cs/research/pp/hubris/pp-beta/Lib/io/RCS/wr_q2drsubmit.c,v 5.0 90/09/20 16:07:23 pp Exp Locker: pp $";
# endif

/*
 * $Header: /cs/research/pp/hubris/pp-beta/Lib/io/RCS/wr_q2drsubmit.c,v 5.0 90/09/20 16:07:23 pp Exp Locker: pp $
 *
 * $Log:	wr_q2drsubmit.c,v $
 * Revision 5.0  90/09/20  16:07:23  pp
 * rcsforce : 5.0 public release
 * 
 */



#include        "head.h"
#include        "q.h"
#include        "dr.h"
#include        <sys/file.h>
#include        "list_bpt.h"
#include        <sys/time.h>

extern char     *dr_file;


/* ---------------------  Begin  Routines  -------------------------------- */


int wr_q2drsubmit (qp, path)
register Q_struct       *qp;
char			*path;
{
	FILE            *fp;
	ADDR            *ap;
	char            *fname = NULL,
			buf[FILNSIZE],
			odir[FILNSIZE];
	int             retval=NOTOK,
			dr_file_no = -1,
			dr_required = FALSE;
	extern char     *mquedir;

	(void) strcpy (odir, path);

	PP_DBG (("Lib/io/wr_q2drsubmit (dir=%s)", odir));


	/* open a DR file (dr.999) name is determined by recip */

	for (ap=qp->Raddress, retval=OK;
		ap != NULLADDR && retval == OK; ap=ap->ad_next)

		if (ap->ad_status == AD_STAT_DRREQUIRED) {

			dr_required = TRUE;

			dr_file_no = ap->ad_no;
			PP_DBG(("ap->ad_no = %d",ap->ad_no));
			(void) sprintf (&buf[0], "%s%d", dr_file, dr_file_no);

			fname = multcat (odir, "/", &buf[0], NULLCP);

			if (access (fname, F_OK) == NOTOK)
				break;


			retval = NOTOK;
			PP_LOG (LLOG_EXCEPTIONS,
			      ("Lib/io/wr_q2drsubmit (file %s exists)",
				fname));
		}

	if (ap == NULLADDR && dr_required == FALSE) return (RP_OK);

	if (retval == NOTOK) {
		PP_LOG (LLOG_FATAL,
		("Lib/io/wr_q2drsubmit (dr required but first file in use)"));
		return (RP_BAD);
	}

	PP_DBG (("Lib/io/wr_q2drsubmit (opening %s)", fname));

	if ((fp = fopen (fname, "w")) == NULLFILE) {
		PP_LOG (LLOG_FATAL,
			("Lib/io/wr_q2drsubmit (unable to open %s)", fname));
		return (RP_FIO);
	}


	retval = wr_dr_info (fp, qp, dr_file_no, TRUE);

	(void) fclose(fp);

	if (chmod(fname, 0666) != 0)
		PP_SLOG(LLOG_EXCEPTIONS, fname,
			("chmod failed"));

	if (retval == NOTOK)    return (RP_FIO);

	return (RP_OK);
}