Could someone help me understand what is happening with this code below. I am having trouble understanding stdout, stdin, and stderr. Are they buffers where data sits until told what to do?
Code:
/* send to standard output */
if (strcmp(logfile,"stdout") == 0) – compares the strings (file pointers
{
fprintf(stdout,"%s %4.4d %d %d %s\n",cur_dt_tm,jnl.blk,jnl.val1,
jnl.val2, jnl.mesg);
fflush(stdout);
}
/* send to standard error */
else if (strcmp(logfile,"stderr") == 0)
{
fprintf(stderr,"%s %4.4d %d %d %s\n",cur_dt_tm,jnl.blk,jnl.val1,
jnl.val2, jnl.mesg);
fflush(stderr);
}
/* append message to logfile */
else if (strcmp(logfile,"") != 0)
{
logfp = fopen(logfile,"a");
if (!logfp)
{
sprintf(jnlmsg,"Unable to open logfile: |%s|\n",logfile);
ssw_jnlreq(0,"PS",0,jnl.mod,jnl.blk,jnlmsg,0,0);
return -1;