int main(int argc, char *argv[]) { FILE *fp = NULL; int fi = -1; int i; int len; unsigned char *p; struct bursts *cb; struct stat bufstat; if( argc < 3 ) { printf( "Usage: inp.file out.file\n" ); return( 1 ); } fi = open( argv[1], O_BINARY ); fp = fopen( argv[2], "w" ); stat( argv[1], &bufstat ); buff = malloc( bufstat.st_size ); read( fi, buff, bufstat.st_size ); close( fi ); cb = (struct bursts *) Xptr( *(short*)buff ); for( ;; ) { p = Xptr(cb->defs); if( p == buff ) break; for(;;) { fprintf( fp, "%s\n", p ); while( *p != '\0' ) ++p; ++p; if( *p == '\0' ) break; } p = Xptr(cb->burst); len = *p++; fprintf( fp, "static struct STRUCT_byte_seq( %d ) %s = { %d, FALSE, {\n ", len, Xptr(cb->name), len ); i = 0; for(;;) { fprintf( fp, "0x%2.2X", *p++ ); --len; if( len == 0 ) break; fprintf( fp, "," ); i++; if( i == 10 ) { fprintf( fp, "\n " ); i = 0; } } fprintf( fp, "\n} };\n\n" ); cb++; } fclose( fp ); free( buff ); return( 0 ); }
void merge_inplace(const t_index i, const t_index j) const { for(t_index k=0; k<dim; ++k) { *(Xptr(j,k)) = (X(i,k)*members[i] + X(j,k)*members[j]) / (members[i]+members[j]); } members[j] += members[i]; }
int main(int argc, char *argv[]) { FILE *fp; int i; int len; unsigned char *p; struct bursts *cb; struct stat bufstat; if( argc < 3 ) { printf( "Usage: inp.file out.file\n" ); return( 1 ); } stat( argv[1], &bufstat ); fp = fopen( argv[1], "rb" ); buff = malloc( bufstat.st_size ); fread( buff, bufstat.st_size, 1, fp ); fclose( fp ); cb = (struct bursts *)Xptr( *(short *)buff ); fp = fopen( argv[2], "wt" ); if( fp == NULL ) { free( buff ); printf( "Error: can not open out.file\n" ); return( 1 ); } for( ;; ) { p = Xptr( cb->defs ); if( p == buff ) break; for( ;; ) { fprintf( fp, "%s\n", p ); while( *p != '\0' ) ++p; ++p; if( *p == '\0' ) { break; } } p = Xptr( cb->burst ); len = *p++; fprintf( fp, "static struct STRUCT_BYTE_SEQ( %d ) %s = { %d, false, {\n ", len, Xptr( cb->name ), len ); i = 0; for( ;; ) { fprintf( fp, "0x%2.2X", *p++ ); --len; if( len == 0 ) break; fprintf( fp, "," ); i++; if( i == 10 ) { fprintf( fp, "\n " ); i = 0; } } fprintf( fp, "\n} };\n\n" ); cb++; } fclose( fp ); free( buff ); return( 0 ); }