#include <sys/types.h>#include <sys/stat.h>#include <sys/mman.h>#include <fcntl.h>#include <stdio.h>#include <limits.h>Go to the source code of this file.
Defines | |
| #define | MAP_FILE 0 |
| #define | SKIPFOUR {d+=4;n-=4;} |
| #define | SKIP(X) {d+=(X);n-=(X);} |
| #define | READINT(X) |
Typedefs | |
| typedef short | int32 |
Functions | |
| int | main (int argc, char *argv[]) |
|
|
Definition at line 15 of file dumpdcd.c. Referenced by main(). |
|
|
Value: { X=0; if (isbig) { for(j=0;j<4;++j,X<<8) X+=d[j]; } \
else { for(j=3;j>=0;--j,X<<8) X+=d[j]; } }
Referenced by main(). |
|
|
Referenced by main(). |
|
|
|
|
|
||||||||||||
|
Definition at line 24 of file dumpdcd.c. References int32, and MAP_FILE. 00024 {
00025
00026 int fd;
00027 struct stat statbuf;
00028 int i, j, n, isbig, itmp;
00029 double delta;
00030 float delta4;
00031 int32 icntrl[20];
00032 char *ccntrl;
00033 char b[8];
00034 char *d;
00035
00036 if ( argc != 2 ) {
00037 fprintf(stderr,"This program reads the ICNTRL array from DCD files.\n");
00038 fprintf(stderr,"Usage: %s <filename> > <data>\n",argv[0]);
00039 exit(-1);
00040 }
00041
00042 if ( ( fd = open(argv[1], O_RDONLY) ) < 0 ) {
00043 fprintf(stderr,"Can't open %s for reading.\n",argv[1]);
00044 exit(-1);
00045 }
00046
00047 if ( fstat(fd,&statbuf) < 0 ) {
00048 fprintf(stderr,"Can't stat %s.\n",argv[1]);
00049 exit(-1);
00050 }
00051
00052 n = statbuf.st_size;
00053
00054 if ( n <= 104 ) {
00055 fprintf(stderr,"%s is not in DCD format.\n",argv[1]);
00056 exit(-1);
00057 }
00058
00059 if ( n % 4 ) {
00060 fprintf(stderr,"%s is not in DCD format.\n",argv[1]);
00061 exit(-1);
00062 }
00063
00064 if ( ( d = mmap(0,n,PROT_READ,MAP_FILE|MAP_SHARED,fd,0) )
00065 == (caddr_t) -1 ) {
00066 fprintf(stderr,"Can't mmap %s.\n",argv[1]);
00067 exit(-1);
00068 }
00069
00070 #define SKIPFOUR {d+=4;n-=4;}
00071 #define SKIP(X) {d+=(X);n-=(X);}
00072 #define READINT(X) { X=0; if (isbig) { for(j=0;j<4;++j,X<<8) X+=d[j]; } \
00073 else { for(j=3;j>=0;--j,X<<8) X+=d[j]; } }
00074
00075 SKIPFOUR; /* 84 */
00076 SKIPFOUR; /* "CORD" */
00077
00078 ccntrl = (char*)(&(icntrl[0]));
00079
00080 for(j=0;j<80;++j) {
00081 ccntrl[j] = d[j];
00082 }
00083
00084 for(j=0;j<9;++j) {
00085 itmp = icntrl[j];
00086 printf("%d\n",itmp);
00087 }
00088
00089 printf("%f\n",*((float*)(icntrl+9)));
00090
00091 for(j=10;j<20;++j) {
00092 itmp = icntrl[j];
00093 printf("%d\n",itmp);
00094 }
00095
00096 }
|
1.3.9.1