#include <stdio.h>
Go to the source code of this file.
Functions | |
| void | score_add_args (const char *arg1, const char *arg2) |
| Adds the given argument(s) from the command-line to the score array such that no arguments are duplicated. | |
| void | info_db_write (FILE *file) |
| Writes info line to specified CDD file. | |
| void | info_db_read (char **line) |
| Reads info line from specified line and stores information. | |
| void | args_db_read (char **line) |
| Reads score args line from specified line and stores information. | |
| void | message_db_read (char **line) |
| Reads user-specified message from specified line and stores information. | |
| void | merged_cdd_db_read (char **line) |
| Reads merged CDD information from specified line and stores information. | |
| void | info_dealloc () |
| Deallocates all memory associated with the information section of a database file. | |
|
|
Reads score args line from specified line and stores information.
00291 { PROFILE(ARGS_DB_READ);
00292
00293 int chars_read; /* Number of characters scanned in from this line */
00294 char tmp1[4096]; /* Temporary string */
00295 char tmp2[4096]; /* Temporary string */
00296 int arg_num;
00297
00298 if( sscanf( *line, "%s%n", score_run_path, &chars_read ) == 1 ) {
00299
00300 *line = *line + chars_read;
00301
00302 /* Store score command-line arguments */
00303 while( sscanf( *line, "%d%n", &arg_num, &chars_read ) == 1 ) {
00304 *line = *line + chars_read;
00305 if( (arg_num == 1) && (sscanf( *line, "%s%n", tmp1, &chars_read ) == 1) ) {
00306 score_add_args( tmp1, NULL );
00307 } else if( (arg_num == 2) && (sscanf( *line, "%s (%[^)])%n", tmp1, tmp2, &chars_read ) == 2) ) {
00308 score_add_args( tmp1, tmp2 );
00309 }
00310 *line = *line + chars_read;
00311 }
00312
00313 } else {
00314
00315 print_output( "CDD file being read is incompatible with this version of Covered", FATAL, __FILE__, __LINE__ );
00316 Throw 0;
00317
00318 }
00319
00320 PROFILE_END;
00321
00322 }
|
|
|
Reads info line from specified line and stores information.
00226 { PROFILE(INFO_DB_READ);
00227
00228 int chars_read; /* Number of characters scanned in from this line */
00229 uint32 scored; /* Indicates if this file contains scored data */
00230 unsigned int version; /* Contains CDD version from file */
00231 char tmp[4096]; /* Temporary string */
00232
00233 /* Save off original scored value */
00234 scored = info_suppl.part.scored;
00235
00236 if( sscanf( *line, "%x%n", &version, &chars_read ) == 1 ) {
00237
00238 *line = *line + chars_read;
00239
00240 if( version != CDD_VERSION ) {
00241 print_output( "CDD file being read is incompatible with this version of Covered", FATAL, __FILE__, __LINE__ );
00242 Throw 0;
00243 }
00244
00245 /*@-formattype -duplicatequals@*/
00246 if( sscanf( *line, "%x %llu %s%n", &(info_suppl.all), &num_timesteps, tmp, &chars_read ) == 3 ) {
00247 /*@=formattype =duplicatequals@*/
00248
00249 *line = *line + chars_read;
00250
00251 /* Set leading_hiers_differ to TRUE if this is not the first hierarchy and it differs from the first */
00252 if( (db_list[curr_db]->leading_hier_num > 0) && (strcmp( db_list[curr_db]->leading_hierarchies[0], tmp ) != 0) ) {
00253 db_list[curr_db]->leading_hiers_differ = TRUE;
00254 }
00255
00256 /* Assign this hierarchy to the leading hierarchies array */
00257 db_list[curr_db]->leading_hierarchies = (char**)realloc_safe( db_list[curr_db]->leading_hierarchies, (sizeof( char* ) * db_list[curr_db]->leading_hier_num), (sizeof( char* ) * (db_list[curr_db]->leading_hier_num + 1)) );
00258 db_list[curr_db]->leading_hierarchies[db_list[curr_db]->leading_hier_num] = strdup_safe( tmp );
00259 db_list[curr_db]->leading_hier_num++;
00260
00261 /* Set scored flag to correct value */
00262 if( info_suppl.part.scored == 0 ) {
00263 info_suppl.part.scored = scored;
00264 }
00265
00266 } else {
00267
00268 print_output( "CDD file being read is incompatible with this version of Covered", FATAL, __FILE__, __LINE__ );
00269 Throw 0;
00270
00271 }
00272
00273 } else {
00274
00275 print_output( "CDD file being read is incompatible with this version of Covered", FATAL, __FILE__, __LINE__ );
00276 Throw 0;
00277
00278 }
00279
00280 PROFILE_END;
00281
00282 }
|
|
|
Writes info line to specified CDD file. Writes information line to specified file.
00151 { PROFILE(INFO_DB_WRITE);
00152
00153 str_link* arg;
00154
00155 assert( db_list[curr_db]->leading_hier_num > 0 );
00156
00157 /* Calculate vector element size */
00158 info_set_vector_elem_size();
00159
00160 /*@-formattype -duplicatequals@*/
00161 fprintf( file, "%d %x %x %llu %s\n",
00162 DB_TYPE_INFO,
00163 CDD_VERSION,
00164 info_suppl.all,
00165 num_timesteps,
00166 db_list[curr_db]->leading_hierarchies[0] );
00167 /*@=formattype =duplicatequals@*/
00168
00169 /* Display score arguments */
00170 fprintf( file, "%d %s", DB_TYPE_SCORE_ARGS, score_run_path );
00171
00172 arg = score_args_head;
00173 while( arg != NULL ) {
00174 if( arg->str2 != NULL ) {
00175 fprintf( file, " 2 %s (%s)", arg->str, arg->str2 );
00176 } else {
00177 fprintf( file, " 1 %s", arg->str );
00178 }
00179 arg = arg->next;
00180 }
00181
00182 fprintf( file, "\n" );
00183
00184 /* Display the CDD message, if there is one */
00185 if( cdd_message != NULL ) {
00186 fprintf( file, "%d %s\n", DB_TYPE_MESSAGE, cdd_message );
00187 }
00188
00189 /* Display the merged CDD information, if there are any */
00190 if( db_list[curr_db]->leading_hier_num == merge_in_num ) {
00191 str_link* strl = merge_in_head;
00192 unsigned int i = 0;
00193 while( strl != NULL ) {
00194 if( (strcmp( strl->str, merged_file ) != 0) && (strl->suppl == 1) ) {
00195 fprintf( file, "%d %s %s\n", DB_TYPE_MERGED_CDD, strl->str, db_list[curr_db]->leading_hierarchies[i++] );
00196 } else {
00197 i++;
00198 }
00199 strl = strl->next;
00200 }
00201 } else {
00202 str_link* strl = merge_in_head;
00203 unsigned int i = 1;
00204 assert( (db_list[curr_db]->leading_hier_num - 1) == merge_in_num );
00205 while( strl != NULL ) {
00206 if( (strcmp( strl->str, merged_file ) != 0) && (strl->suppl == 1) ) {
00207 fprintf( file, "%d %s %s\n", DB_TYPE_MERGED_CDD, strl->str, db_list[curr_db]->leading_hierarchies[i++] );
00208 } else {
00209 i++;
00210 }
00211 strl = strl->next;
00212 }
00213 }
00214
00215 PROFILE_END;
00216
00217 }
|
|
|
Deallocates all memory associated with the information section of a database file. Deallocates all memory associated with the database information section. Needs to be called when the database is closed.
00400 { PROFILE(INFO_DEALLOC);
00401
00402 str_link_delete_list( score_args_head );
00403 score_args_head = NULL;
00404 score_args_tail = NULL;
00405
00406 /* Free merged arguments */
00407 str_link_delete_list( merge_in_head );
00408 merge_in_head = NULL;
00409 merge_in_tail = NULL;
00410 merge_in_num = 0;
00411
00412 /* Free user message */
00413 free_safe( cdd_message, (strlen( cdd_message ) + 1) );
00414 cdd_message = NULL;
00415
00416 PROFILE_END;
00417
00418 }
|
|
|
Reads merged CDD information from specified line and stores information. Parses given line for merged CDD information and stores this information in the appropriate global variables.
00345 { PROFILE(MERGED_CDD_DB_READ);
00346
00347 char tmp1[4096]; /* Temporary string */
00348 char tmp2[4096]; /* Temporary string */
00349 int chars_read; /* Number of characters read */
00350
00351 if( sscanf( *line, "%s %s%n", tmp1, tmp2, &chars_read ) == 2 ) {
00352
00353 str_link* strl;
00354
00355 *line = *line + chars_read;
00356
00357 /* Add merged file */
00358 if( (strl = str_link_find( tmp1, merge_in_head)) == NULL ) {
00359
00360 strl = str_link_add( strdup_safe( tmp1 ), &merge_in_head, &merge_in_tail );
00361 strl->suppl = 1;
00362 merge_in_num++;
00363
00364 /* Set leading_hiers_differ to TRUE if this is not the first hierarchy and it differs from the first */
00365 if( strcmp( db_list[curr_db]->leading_hierarchies[0], tmp2 ) != 0 ) {
00366 db_list[curr_db]->leading_hiers_differ = TRUE;
00367 }
00368
00369 /* Add its hierarchy */
00370 db_list[curr_db]->leading_hierarchies = (char**)realloc_safe( db_list[curr_db]->leading_hierarchies, (sizeof( char* ) * db_list[curr_db]->leading_hier_num), (sizeof( char* ) * (db_list[curr_db]->leading_hier_num + 1)) );
00371 db_list[curr_db]->leading_hierarchies[db_list[curr_db]->leading_hier_num] = strdup_safe( tmp2 );
00372 db_list[curr_db]->leading_hier_num++;
00373
00374 } else if( merge_in_num > 0 ) {
00375
00376 char* file = get_relative_path( tmp1 );
00377 unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "File %s in CDD file has been specified on the command-line", file );
00378 assert( rv < USER_MSG_LENGTH );
00379 free_safe( file, (strlen( file ) + 1) );
00380 print_output( user_msg, FATAL, __FILE__, __LINE__ );
00381 Throw 0;
00382
00383 }
00384
00385 } else {
00386
00387 print_output( "CDD file being read is incompatible with this version of Covered", FATAL, __FILE__, __LINE__ );
00388 Throw 0;
00389
00390 }
00391
00392 PROFILE_END;
00393
00394 }
|
|
|
Reads user-specified message from specified line and stores information. Read user-specified message from specified string and stores its information.
00329 { PROFILE(MESSAGE_DB_READ);
00330
00331 /* All we need to do is copy the message */
00332 if( (cdd_message == NULL) && (strlen( *line + 1 ) > 0) ) {
00333 cdd_message = strdup_safe( *line + 1 );
00334 }
00335
00336 PROFILE_END;
00337
00338 }
|
|
||||||||||||
|
Adds the given argument(s) from the command-line to the score array such that no arguments are duplicated. Adds the specified argument to the list of score arguments that will be written to the CDD file.
00084 { PROFILE(SCORE_ADD_ARGS);
00085
00086 str_link* arg = score_args_head;
00087 bool done = FALSE;
00088 bool nondup = ((strncmp( arg1, "-vpi", 4 ) == 0) ||
00089 (strncmp( arg1, "-lxt", 4 ) == 0) ||
00090 (strncmp( arg1, "-vcd", 4 ) == 0) ||
00091 (strncmp( arg1, "-t", 2 ) == 0) ||
00092 (strncmp( arg1, "-i", 2 ) == 0) ||
00093 (strncmp( arg1, "-o", 2 ) == 0));
00094
00095 while( !done ) {
00096
00097 /* Check to see if the specified arguments already exist */
00098 while( (arg != NULL) && (strcmp( arg->str, arg1 ) != 0) ) {
00099 arg = arg->next;
00100 }
00101
00102 /* If the argument doesn't exist, just add it and be done */
00103 if( arg == NULL ) {
00104 arg = str_link_add( strdup_safe( arg1 ), &score_args_head, &score_args_tail );
00105 if( arg2 != NULL ) {
00106 arg->str2 = strdup_safe( arg2 );
00107 }
00108 done = TRUE;
00109
00110 /* If the first option exists and its either a non-duplicatible option or it already exists, be done */
00111 } else if( nondup || ((arg2 != NULL) && (strcmp( arg2, arg->str2 ) == 0)) ) {
00112 done = TRUE;
00113
00114 /* Otherwise, advance the arg pointer */
00115 } else {
00116 arg = arg->next;
00117 }
00118
00119 }
00120
00121 }
|
1.3.4