NAMD
Macros | Typedefs | Functions
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.

Macros

#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[])
 

Macro Definition Documentation

#define MAP_FILE   0

Definition at line 18 of file dumpdcd.c.

Referenced by main().

#define READINT (   X)
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]; } }
#define X
Definition: msm_defn.h:29
#define SKIP (   X)    {d+=(X);n-=(X);}
#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 MAP_FILE, and SKIPFOUR.

27  {
28 
29 int fd;
30 struct stat statbuf;
31 int i, j, isbig, itmp;
32 off_t n;
33 double delta;
34 float delta4;
35 int32 icntrl[20];
36 char *ccntrl;
37 char b[8];
38 char *d;
39 
40 if ( argc != 2 ) {
41  fprintf(stderr,"This program reads the ICNTRL array from DCD files.\n");
42  fprintf(stderr,"Usage: %s <filename> > <data>\n",argv[0]);
43  exit(-1);
44 }
45 
46 if ( ( fd = open(argv[1], O_RDONLY) ) < 0 ) {
47  fprintf(stderr,"Can't open %s for reading.\n",argv[1]);
48  exit(-1);
49 }
50 
51 if ( fstat(fd,&statbuf) < 0 ) {
52  fprintf(stderr,"Can't stat %s.\n",argv[1]);
53  exit(-1);
54 }
55 
56 n = statbuf.st_size;
57 
58 if ( n <= 104 ) {
59  fprintf(stderr,"%s is not in DCD format.\n",argv[1]);
60  exit(-1);
61 }
62 
63 if ( n % 4 ) {
64  fprintf(stderr,"%s is not in DCD format.\n",argv[1]);
65  exit(-1);
66 }
67 
68 if ( ( d = mmap(0,n,PROT_READ,MAP_FILE|MAP_SHARED,fd,0) )
69  == (caddr_t) -1 ) {
70  fprintf(stderr,"Can't mmap %s.\n",argv[1]);
71  exit(-1);
72 }
73 
74 #define SKIPFOUR {d+=4;n-=4;}
75 #define SKIP(X) {d+=(X);n-=(X);}
76 #define READINT(X) { X=0; if (isbig) { for(j=0;j<4;++j,X<<8) X+=d[j]; } \
77  else { for(j=3;j>=0;--j,X<<8) X+=d[j]; } }
78 
79 SKIPFOUR; /* 84 */
80 SKIPFOUR; /* "CORD" */
81 
82 ccntrl = (char*)(&(icntrl[0]));
83 
84 for(j=0;j<80;++j) {
85  ccntrl[j] = d[j];
86 }
87 
88 for(j=0;j<9;++j) {
89  itmp = icntrl[j];
90  printf("%d\n",itmp);
91 }
92 
93 printf("%f\n",*((float*)(icntrl+9)));
94 
95 for(j=10;j<20;++j) {
96  itmp = icntrl[j];
97  printf("%d\n",itmp);
98 }
99 
100 }
short int32
Definition: dumpdcd.c:24
#define SKIPFOUR
#define MAP_FILE
Definition: dumpdcd.c:18