File: printlog.c

package info (click to toggle)
mpich 1.1.0-3
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 22,116 kB
  • ctags: 27,349
  • sloc: ansic: 193,435; sh: 11,172; fortran: 6,545; makefile: 5,801; cpp: 5,020; tcl: 3,548; asm: 3,536; csh: 1,079; java: 614; perl: 183; awk: 168; sed: 70; f90: 62
file content (35 lines) | stat: -rw-r--r-- 688 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "clogimpl.h"
#include <unistd.h>
#include <fcntl.h>


int main( argc, argv )
int argc;
char *argv[];
{
    int logfd;			/* logfile */
    int n;
    double buf[ CLOG_BLOCK_SIZE / sizeof( double ) ];

    if (argc < 2) {
	fprintf(stderr,"usage:  printlog <logfile>\n");
	exit(-1);
    }

    if ((logfd = open(argv[1], O_RDONLY, 0)) == -1)
    {
	printf("could not open file %s for reading\n",argv[1]);
	exit(-2);
    }

    n = read(logfd, buf, CLOG_BLOCK_SIZE);
    while (n) {
	if (n != CLOG_BLOCK_SIZE) {
	    fprintf(stderr,"could not read %d bytes\n", CLOG_BLOCK_SIZE);
	    exit(-3);
	}
	CLOG_dumpblock(buf);
	n = read(logfd, buf, CLOG_BLOCK_SIZE);
    }	
    return(0);
}