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 <stdlib.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 18 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 24 of file dumpdcd.c.


Function Documentation

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

Definition at line 27 of file dumpdcd.c.

References j, MAP_FILE, and SKIPFOUR.

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


Generated on 12 Nov 2019 for NAMD by  doxygen 1.6.1