|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T g
Length: 2802 (0xaf2)
Types: TextFile
Names: »gen_io2dr.c«
└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0
└─⟦dc59850a2⟧ »EurOpenD22/pp5.0/pp-5.tar.Z«
└─⟦e5a54fb17⟧
└─⟦this⟧ »pp-5.0/Src/submit/gen_io2dr.c«
/* gen_io2dr.c: write a DR submitted by an X400 incomming channel */
# ifndef lint
static char Rcsid[] = "@(#)$Header: /cs/research/pp/hubris/pp-beta/Src/submit/RCS/gen_io2dr.c,v 5.0 90/09/20 16:22:59 pp Exp Locker: pp $";
# endif
/*
* $Header: /cs/research/pp/hubris/pp-beta/Src/submit/RCS/gen_io2dr.c,v 5.0 90/09/20 16:22:59 pp Exp Locker: pp $
*
* $Log: gen_io2dr.c,v $
* Revision 5.0 90/09/20 16:22:59 pp
* rcsforce : 5.0 public release
*
*/
#include <sys/types.h>
#include <sys/stat.h>
#include "head.h"
#include "dr.h"
extern char msg_fullpath[];
extern long msg_size;
extern char *dr_file;
extern int errno,
end_of_file,
protocol_mode;
/* -- local routines -- */
int gen_io2dr();
static void reset_protocol_mode();
static void unset_protocol_mode();
/* --------------------- Begin Routines -------------------------------- */
int gen_io2dr()
{
struct stat st_rec;
FILE *fp;
DRmpdu DeliveryReport, *dr;
char *fname,
buf[FILNSIZE];
int retval;
Trace *temp;
PP_TRACE (("gen_io2dr (protocol_mode=%d)", protocol_mode));
dr_init (dr = &DeliveryReport);
/* -- read the DR from stdin -- */
if (rp_isbad (retval = rd_dr (dr, stdin))) {
switch (retval) {
case RP_EOF:
end_of_file = TRUE;
return (RP_EOF);
case RP_PARM:
PP_LOG (LLOG_EXCEPTIONS, ("gen_io2dr Invalid param"));
return (RP_PARM);
default:
PP_LOG (LLOG_EXCEPTIONS,
("gen_io2dr read error %d", retval));
return (retval);
}
}
check_dr_crits (dr);
temp = trace_new();
temp -> trace_next = dr -> dr_trace;
dr -> dr_trace = temp;
/* -- write the DR into the PP queue -- */
(void) sprintf (buf, "%s/%s%d", msg_fullpath, dr_file,
DR_FILENO_DEFAULT);
fname = strdup (buf);
if ((fp = fopen (fname, "w")) == NULLFILE) {
PP_LOG (LLOG_FATAL, ("gen_io2dr (unable to open %s)", fname));
return (RP_FIO);
}
unset_protocol_mode();
retval = wr_dr (dr, fp);
reset_protocol_mode();
if (rp_isbad (retval)) {
PP_TRACE (("gen_io2dr Unable to write"));
(void) fclose (fp);
return (RP_PARM);
}
(void) fclose (fp);
if (stat (fname, &st_rec) == NOTOK)
PP_LOG (LLOG_EXCEPTIONS,
("gen_io2dr: Unable to stat %s %d", fname, errno));
msg_size = st_rec.st_size;
dr_free (dr);
PP_TRACE (("gen_io2dr returns (%d)", retval));
return (retval);
}
/* --------------------- Static Routines ------------------------------- */
static void unset_protocol_mode ()
{
reset_protocol_mode();
protocol_mode = 0;
return;
}
static void reset_protocol_mode ()
{
static int save = -1;
if (save == -1)
save = protocol_mode;
else {
protocol_mode = save;
save = -1;
}
}