Showing the changes to src/scripts (4 of 158 files). Show all
Unified · Split
| @@ -0,0 +1,104 @@ | |||
| 1 | use Data::Dumper; | ||
| 2 | my %seen; | ||
| 3 | my @source; | ||
| 4 | |||
| 5 | my $output = $ARGV[0]; | ||
| 6 | |||
| 7 | my @fileList = `ls *.c *.h`; | ||
| 8 | foreach $_ (@fileList) | ||
| 9 | { | ||
| 10 | chomp; | ||
| 11 | if( $_ =~ /$output/ || $_ =~ /test/ ) {} | ||
| 12 | elsif( $_ =~ /\.h/ ) { $seen{$_} = 0; } | ||
| 13 | elsif( $_ =~ /\.c/ ) { push @source, $_ } | ||
| 14 | } | ||
| 15 | |||
| 16 | close DOTH; | ||
| 17 | close DOTC; | ||
| 18 | open DOTH, ">" . $output . ".h" or die; | ||
| 19 | open DOTC, ">" . $output . ".c" or die; | ||
| 20 | my @list; | ||
| 21 | $seen{'config.h'} = 1; | ||
| 22 | push @list, "config.h"; | ||
| 23 | $seen{'sndfile.h'} = 1; | ||
| 24 | push @list, "sndfile.h"; | ||
| 25 | $seen{'common.h'} = 1; | ||
| 26 | push @list, "common.h"; | ||
| 27 | $seen{'G72x.h'} = 1; | ||
| 28 | push @list, "G72x.h"; | ||
| 29 | |||
| 30 | sub depend | ||
| 31 | { | ||
| 32 | my $file = shift; | ||
| 33 | my $handle; | ||
| 34 | open $handle, "<$file"; | ||
| 35 | while(<$handle>) | ||
| 36 | { | ||
| 37 | if( my $include = /#include[ \t]*[<"]([\w\d]+\.h)[>"]/ ) | ||
| 38 | { | ||
| 39 | if( defined( $seen{$include} && $seen{$include} == 0 ) ) | ||
| 40 | { | ||
| 41 | depend( $include ); | ||
| 42 | } | ||
| 43 | } | ||
| 44 | } | ||
| 45 | close $handle; | ||
| 46 | $seen{$file} = 1; | ||
| 47 | push @list, $file; | ||
| 48 | } | ||
| 49 | |||
| 50 | foreach my $key ( keys %seen ) | ||
| 51 | { | ||
| 52 | if( $seen{$key} == 0 ) { depend($key); } | ||
| 53 | } | ||
| 54 | |||
| 55 | print DOTH '#include <stdio.h>' . "\n\n"; | ||
| 56 | print DOTH '#include <stdlib.h>' . "\n\n"; | ||
| 57 | foreach my $file (@list) | ||
| 58 | { | ||
| 59 | open F, "<$file"; | ||
| 60 | while(<F>) | ||
| 61 | { | ||
| 62 | if( $_ !~ /#include[ \t]*[<"](\w+\.h)[>"]/ ) | ||
| 63 | { | ||
| 64 | print DOTH $_; | ||
| 65 | } | ||
| 66 | } | ||
| 67 | close F; | ||
| 68 | } | ||
| 69 | |||
| 70 | |||
| 71 | |||
| 72 | |||
| 73 | |||
| 74 | close FILE; | ||
| 75 | |||
| 76 | print DOTC '#include ' . "\"$output.h\"\n"; | ||
| 77 | print DOTC '#include <stdio.h>' . "\n\n"; | ||
| 78 | print DOTC '#include <stdlib.h>' . "\n\n"; | ||
| 79 | foreach my $file (@source) | ||
| 80 | { | ||
| 81 | open FILE, $file; | ||
| 82 | $file =~ s/\.[ch]//g; | ||
| 83 | while( my $line = <FILE> ) | ||
| 84 | { | ||
| 85 | if( $line !~ /#include[ \t]*("[\w\d]+\.[ch]")|<CoreServices.h>/ ) | ||
| 86 | { | ||
| 87 | $line =~ s/(f2d_array)/$file$1/g; | ||
| 88 | $line =~ s/(d2f_array)/$file$1/g; | ||
| 89 | $line =~ s/(_\w+tab)/$file$1/g; | ||
| 90 | $line =~ s/(STEP)/$file$1/g; | ||
| 91 | $line =~ s/(HAVE_[^D]\w+)/$file$1/g; | ||
| 92 | print DOTC $line; | ||
| 93 | } | ||
| 94 | } | ||
| 95 | close FILE; | ||
| 96 | } | ||
| 97 | |||
| 98 | |||
| 99 | |||
| 100 | close DOTH; | ||
| 101 | close DOTC; | ||
| 102 | |||
| 103 | |||
| 104 | |||
| @@ -0,0 +1,61 @@ | |||
| 1 | //----------------------------------------------------------------------------- | ||
| 2 | // name: hex2cpp.cpp | ||
| 3 | // desc: hexdump to cpp | ||
| 4 | // | ||
| 5 | // author: Ge Wang (gewang@cs.princeton.edu) | ||
| 6 | // data: Summer 2004 | ||
| 7 | //----------------------------------------------------------------------------- | ||
| 8 | #include <iostream> | ||
| 9 | #include <sstream> | ||
| 10 | #include <stdio.h> | ||
| 11 | #include <limits.h> | ||
| 12 | using namespace std; | ||
| 13 | |||
| 14 | |||
| 15 | // one of these days i will learn perl, or awk, or sed | ||
| 16 | int main( int argc, char ** argv ) | ||
| 17 | { | ||
| 18 | if( argc < 2 ) | ||
| 19 | { | ||
| 20 | cerr << "hex2cpp: too few arguments..." << endl; | ||
| 21 | exit( 1 ); | ||
| 22 | } | ||
| 23 | |||
| 24 | string line; | ||
| 25 | int count = 0; | ||
| 26 | cout << "// data for " << argv[1] << ".raw..." << endl; | ||
| 27 | cout << "SAMPLE " << argv[1] << "_data[] = {" << endl; | ||
| 28 | |||
| 29 | while( getline( cin, line ) ) | ||
| 30 | { | ||
| 31 | istringstream sin( line ); | ||
| 32 | string token, token2; | ||
| 33 | int c = 0; | ||
| 34 | short x = 0; | ||
| 35 | |||
| 36 | // get rid of offset | ||
| 37 | sin >> token; | ||
| 38 | cout << " "; | ||
| 39 | |||
| 40 | while( sin >> token >> token2 ) | ||
| 41 | { | ||
| 42 | x = (token2[0]-'0')*64 + (token2[1]-'0')*8 + (token2[2]-'0'); | ||
| 43 | x <<= 8; | ||
| 44 | x += (token[0]-'0')*64 + (token[1]-'0')*8 + (token[2]-'0'); | ||
| 45 | printf( "%.1ff,", (float)x ); | ||
| 46 | count++; | ||
| 47 | c++; | ||
| 48 | } | ||
| 49 | |||
| 50 | if( c ) | ||
| 51 | cout << endl; | ||
| 52 | } | ||
| 53 | |||
| 54 | cout << "0" << endl; | ||
| 55 | cout << "}; "; | ||
| 56 | cout << argv[1] << "_size = " << count << ";"; | ||
| 57 | cout << endl << endl; | ||
| 58 | |||
| 59 | return 0; | ||
| 60 | } | ||
| 61 | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | // name: platform.cpp | ||
| 2 | // desc: finds sizes | ||
| 3 | // author: Ge Wang (gewang@cs.princeton.edu) | ||
| 4 | |||
| 5 | #include <iostream> | ||
| 6 | using namespace std; | ||
| 7 | |||
| 8 | // union | ||
| 9 | union X | ||
| 10 | { | ||
| 11 | short s; | ||
| 12 | char b[2]; | ||
| 13 | }; | ||
| 14 | |||
| 15 | // entry point | ||
| 16 | int main( int argc, char ** argv ) | ||
| 17 | { | ||
| 18 | X x; | ||
| 19 | x.s = 0x0100; | ||
| 20 | |||
| 21 | // go | ||
| 22 | cout << "char: " << sizeof(char) << endl; | ||
| 23 | cout << "short: " << sizeof(short) << endl; | ||
| 24 | cout << "int: " << sizeof(int) << endl; | ||
| 25 | cout << "long: " << sizeof(long) << endl; | ||
| 26 | cout << "float: " << sizeof(float) << endl; | ||
| 27 | cout << "double: " << sizeof(double) << endl; | ||
| 28 | cout << "void *: " << sizeof(void *) << endl; | ||
| 29 | cout << "endian: " << ( x.b[1] ? "small" : "big" ) << endl; | ||
| 30 | |||
| 31 | return 0; | ||
| 32 | } | ||
| @@ -0,0 +1,22 @@ | |||
| 1 | #include <string> | ||
| 2 | #include <iostream> | ||
| 3 | #include <sstream> | ||
| 4 | #include <stdio.h> | ||
| 5 | #include <stdlib.h> | ||
| 6 | #include <string.h> | ||
| 7 | using namespace std; | ||
| 8 | |||
| 9 | |||
| 10 | int main( int argc, char ** argv ) | ||
| 11 | { | ||
| 12 | for( int i = 1; i < argc; i++ ) | ||
| 13 | { | ||
| 14 | ostringstream sout; | ||
| 15 | |||
| 16 | argv[i][strlen(argv[i])-4] = '\0'; | ||
| 17 | sout << "hexdump -bv " << argv[i] << ".raw | hex2cpp " << argv[i] << " > " << argv[i] << ".c++"; | ||
| 18 | system( sout.str().c_str() ); | ||
| 19 | cout << sout.str() << endl; | ||
| 20 | } | ||
| 21 | } | ||
| 22 | |||