Changeset 38
- Timestamp:
- 11/09/07 17:22:02 (10 months ago)
- Files:
-
- vowfsc/Makefile (modified) (2 diffs)
- vowfsc/db.c (modified) (5 diffs)
- vowfsc/db.h (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
vowfsc/Makefile
r37 r38 2 2 @echo made $@ 3 3 4 db: db. c db.h file.db dir.db stream.db5 gcc db. c-o db4 db: db.o 5 gcc db.o -o db 6 6 7 7 xdelta: xdelta.o xdelta3.o 8 8 gcc xdelta.o xdelta3.o -o xdelta 9 10 db.o: db.c db.h file.db dir.db stream.db 11 gcc db.c -c 9 12 10 13 xdelta3.o: xdelta3.c xdelta3.h xdelta3-cfgs.h xdelta3-list.h xdelta3-decode.h … … 13 16 xdelta.o: xdelta.c 14 17 gcc xdelta.c -c 18 19 clean: 20 rm *.o vowfsc/db.c
r34 r38 149 149 150 150 151 file db_get_file( int file_id ){152 file stat;151 file_t db_get_file( int file_id ){ 152 file_t stat; 153 153 154 154 char *pq_request[BUFFER_SIZE]; … … 189 189 190 190 191 file db_get_file( int file_id, int revision ){192 file stat;191 file_t db_get_file( int file_id, int revision ){ 192 file_t stat; 193 193 194 194 char *pq_request[BUFFER_SIZE]; … … 341 341 342 342 343 dir db_get_dir( int dir_id ){344 dir stat;343 dir_t db_get_dir( int dir_id ){ 344 dir_t stat; 345 345 346 346 char *pq_request[BUFFER_SIZE]; … … 381 381 382 382 383 dir db_get_dir( int dir_id, int revision ){384 dir stat;383 dir_t db_get_dir( int dir_id, int revision ){ 384 dir_t stat; 385 385 386 386 char *pq_request[BUFFER_SIZE]; … … 459 459 460 460 461 stream_t db_get_stream( int stream_id ){ 462 stream_t stat; 463 464 char *pq_request[BUFFER_SIZE]; 465 sprintf(pq_request,"SELECT * " 466 "FROM streamectory " 467 "WHERE streamectory_id = \'%i\'", 468 stream_id); 469 PGresult *res=PQexec(pq_conn,pq_request); 470 471 if( NUM_FILE_FIELDS ){ 472 NUM_FILE_FIELDS = sizeof(stream_format)/4; 473 474 if( PQnfields(pq_data) != NUM_FILE_FIELDS ){ 475 NUM_FILE_FIELDS = 0; 476 return NULL; 477 } 478 479 // Fill stream_format with column numbers 480 #define db(type, name) stream_format.name = PQfnumber(pq_data, #name ); 481 #define db_string(name) stream_format.name = PQfnumber(pq_data, #name ); 482 #include "stream.db" 483 } 484 485 if( PQresultStatus(res) != PGRES_TUPLES_OK ) return NULL; 486 487 if( PQnfields(pq_data) != NUM_FILE_FIELDS ) return NULL; 488 489 // Fill stat 490 #define db(type, name) stat.name = *(type*)PQgetvalue(pq_data, /*row*/, stream_format.name ); 491 #define db_string(name) stat.name = strdup(PQgetvalue(pq_data, /*row*/, stream_format.name )); 492 #include "stream.db" 493 494 // Free the result 495 PQfreemem(res); 496 497 return stat; 498 } 499 500 501 stream_t db_get_stream( int stream_id, int revision ){ 502 stream_t stat; 503 504 char *pq_request[BUFFER_SIZE]; 505 sprintf(pq_request,"SELECT * " 506 "FROM streamectory " 507 "WHERE streamectory_id = \'%i\' " 508 "AND revision_id = \'%i\'", 509 stream_id, revision); 510 PGresult *res=PQexec(pq_conn,pq_request); 511 512 if( NUM_FILE_FIELDS ){ 513 NUM_FILE_FIELDS = sizeof(stream_format)/4; 514 515 if( PQnfields(pq_data) != NUM_FILE_FIELDS ){ 516 NUM_FILE_FIELDS = 0; 517 return NULL; 518 } 519 520 // Fill stream_format with column numbers 521 #define db(type, name) stream_format.name = PQfnumber(pq_data, #name ); 522 #define db_string(name) stream_format.name = PQfnumber(pq_data, #name ); 523 #include "stream.db" 524 } 525 526 if( PQresultStatus(res) != PGRES_TUPLES_OK ) return NULL; 527 528 if( PQnfields(pq_data) != NUM_FILE_FIELDS ) return NULL; 529 530 // Fill stat 531 #define db(type, name) stat.name = *(type*)PQgetvalue(pq_data, 0, stream_format.name ); 532 #define db_string(name) stat.name = strdup(PQgetvalue(pq_data, 0, stream_format.name )); 533 #include "stream.db" 534 535 // Free the result 536 PQfreemem(res); 537 538 return stat; 539 } 540 541 vowfsc/db.h
r37 r38 13 13 #define false 0 14 14 15 typedef struct file file ;15 typedef struct file file_t; 16 16 struct file{ 17 17 #define db( type, name) type name; … … 21 21 22 22 23 typedef struct dir dir ;24 struct dir {23 typedef struct dir dir_t; 24 struct dir_t{ 25 25 #define db( type, name ) type name; 26 26 #define db_string( name ) char *name; … … 28 28 }; 29 29 30 typedef struct stream stream ;30 typedef struct stream stream_t; 31 31 struct stream{ 32 32 #define db( type, name ) type name; … … 34 34 #include "stream.db" 35 35 }; 36 36 37 37 38 /* Given a file path, db_get_file_id splits it into … … 54 55 * look at the file.db file. 55 56 */ 56 file db_get_file( int file_id );57 file db_get_file( int file_id, int revision );57 file_t db_get_file( int file_id ); 58 file_t db_get_file( int file_id, int revision ); 58 59 59 60 /* db_get_file_data returns the undiffed data from … … 69 70 * db_get_file_data 70 71 */ 71 char *db_get_file_stream( int file_id ); // TODO72 char *db_get_file_stream( int file_id, int revision ); // TODO72 char *db_get_file_stream( int file_id ); 73 char *db_get_file_stream( int file_id, int revision ); 73 74 74 75 /* Looks first to see if the given stream exists, and … … 87 88 * revisions it. 88 89 */ 89 int db_create_file(char *file_name, char *file_path, stream data); // TODO90 int db_create_file(char *file_name, char *file_path, stream_t stream); // TODO 90 91 91 92 … … 113 114 * file_id. 114 115 */ 115 int db_modify_file_stream(int file_id, stream data); // TODO116 int db_modify_file_stream(int file_id, stream_t stream); // TODO 116 117 117 118 … … 134 135 * struct, look at the dir.db file. 135 136 */ 136 dir db_get_dir( int dir_id );137 dir db_get_dir( int dir_id, int revision );137 dir_t db_get_dir( int dir_id ); 138 dir_t db_get_dir( int dir_id, int revision ); 138 139 139 140
