Skip to content

Commit

Permalink
Pass specifications file when call PCx.
Browse files Browse the repository at this point in the history
Now you can pass the specification file when call PCx using

    $ ./PCx -s specification_file mpsfile

It is very usefull when you have to change the specifications a lot.
  • Loading branch information
Raniere Silva committed May 23, 2013
1 parent 40cb4aa commit 911f58e
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 6 deletions.
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@

# Doc
DOC/_build
DOC/_doxygen
xml

# ctags
*tags

# dev
debug
mps-test/

# C/C++ Object files
*.o
*.slo
Expand All @@ -32,6 +38,13 @@ DOC/_build
*.out
*.app

# Configuration
*Makefile
aclocal.m4
autom4te.cache
config.status
ltmain.sh

# Test problem
mps/*

Expand All @@ -40,3 +53,6 @@ PCx

# Log files
*.log

# Benchmark
__pycache__/*
30 changes: 26 additions & 4 deletions SRC/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,15 @@
#include "pre.h"

char infile[200];
char sinfile[200];
char P_name[100];

void usage(char *argv[]) {
printf("Usage:\n");
printf("\t%s mpsfile\n", argv[0]);
printf("\t%s -s specification_file mpsfile\n", argv[0]);
}

main(argc, argv)
int argc;
char *argv[];
Expand All @@ -39,6 +46,7 @@ main(argc, argv)
double UserTime, OldSysTime, OldUserTime;

extern char infile[200];
extern char sinfile[200];

/********************************************************************
* *
Expand Down Expand Up @@ -73,20 +81,34 @@ main(argc, argv)

if (argc < 2)
{
printf("Usage:\n\t%s mpsfile\n", argv[0]);
usage(argv);
exit(INVOCATION_ERROR);
}
/* Create the parameter data structure, insert the parameter values into
* it, and check their validity. */

strcpy(infile, argv[1]);

if (argc == 2) {
strcpy(infile, argv[1]);
sinfile[0] = '\0';
}
else {
if (argc == 4)
if (strcmp("-s", argv[1]) == 0) {
strcpy(sinfile, argv[2]);
strcpy(infile, argv[3]);
}
else {
usage(argv);
exit(INVOCATION_ERROR);
}
}


/* load the default parameters */
Inputs = NewParameters();

/* read modified parameters (if any) from specs file */
ParseSpecsFile(Inputs, infile);
ParseSpecsFile(Inputs, infile, sinfile);

/* check for errors */
if (CheckParameters(Inputs))
Expand Down
10 changes: 8 additions & 2 deletions SRC/parameters.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void FreeParameters(Parameters *Inputs);
int CheckParameters(Parameters *ptr);
int ParseSpecsFile(Parameters *parameters, char *infile);
int ParseSpecsFile(Parameters *parameters, char *infile char *sinfile);
*/
/***************************************************************************/

Expand Down Expand Up @@ -212,9 +212,10 @@ CheckParameters(ptr)
/***************************************************************************/

int
ParseSpecsFile(parameters, infile)
ParseSpecsFile(parameters, infile, sinfile)
Parameters *parameters;
char *infile;
char *sinfile;
{
int match, key;
char line[200], rootfilename[200], filename[200];
Expand Down Expand Up @@ -266,6 +267,11 @@ ParseSpecsFile(parameters, infile)
strcat(filename, ".specs");
fp = fopen(filename, "r");
}
if (fp == NULL && sinfile[0] != '\0')
{
strcpy(filename, sinfile);
fp = fopen(filename, "r");
}
if (fp == NULL)
{
strcpy(filename, "spc");
Expand Down

0 comments on commit 911f58e

Please sign in to comment.