dumpdcd.c File Reference

#include "largefiles.h"
#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[])


Define Documentation

#define MAP_FILE   0

Definition at line 17 of file dumpdcd.c.

Referenced by main().

#define READINT (  ) 

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().

#define SKIP (  )     {d+=(X);n-=(X);}

Referenced by main().

#define SKIPFOUR   {d+=4;n-=4;}

Referenced by main().


Typedef Documentation

typedef short int32

Definition at line 23 of file dumpdcd.c.


Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 26 of file dumpdcd.c.

References j, MAP_FILE, and SKIPFOUR.

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


Generated on Tue Nov 21 01:17:16 2017 for NAMD by  doxygen 1.4.7