Staticified a function that was forgotten. Added support for multiple PSRs in one app.

This commit is contained in:
n-a-c-h
2006-02-24 01:08:02 +00:00
parent 248613f346
commit 3161cb06aa

View File

@@ -322,6 +322,8 @@ Structures used to store config data
*/ */
string family_name = "cfg";
set<string> defines; set<string> defines;
stack<bool> ifs; stack<bool> ifs;
@@ -618,7 +620,7 @@ void output_parser_start(ostream& c_stream)
<< " return(pos); \n" << " return(pos); \n"
<< "}\n" << "}\n"
<< "\n" << "\n"
<< "char *get_token(char *str, char *delim)\n" << "static char *get_token(char *str, char *delim)\n"
<< "{\n" << "{\n"
<< " static char *pos = 0;\n" << " static char *pos = 0;\n"
<< " char *token = 0;\n" << " char *token = 0;\n"
@@ -763,8 +765,8 @@ void output_cheader_start(ostream& cheader_stream)
<< " extern \"C\" {\n" << " extern \"C\" {\n"
<< "#endif\n" << "#endif\n"
<< "\n" << "\n"
<< "unsigned char read_cfg_vars(const char *);\n" << "unsigned char read_" << family_name << "_vars(const char *);\n"
<< "unsigned char write_cfg_vars(const char *);\n" << "unsigned char write_" << family_name << "_vars(const char *);\n"
<< "\n"; << "\n";
} }
@@ -781,7 +783,7 @@ void output_cheader_end(ostream& cheader_stream)
void output_init_var(ostream& c_stream) void output_init_var(ostream& c_stream)
{ {
c_stream << "\n" c_stream << "\n"
<< "static void init_cfg_vars()\n" << "static void init_" << family_name << "_vars()\n"
<< "{\n" << "{\n"
<< " static unsigned char init_done = 0;\n" << " static unsigned char init_done = 0;\n"
<< " if (!init_done)\n" << " if (!init_done)\n"
@@ -828,11 +830,11 @@ void output_write_var(ostream& c_stream)
output_array_write(c_stream, variable::SD); output_array_write(c_stream, variable::SD);
c_stream << "\n" c_stream << "\n"
<< "unsigned char write_cfg_vars(const char *file)\n" << "unsigned char write_" << family_name << "_vars(const char *file)\n"
<< "{\n" << "{\n"
<< " FILE *fp = 0;\n" << " FILE *fp = 0;\n"
<< "\n" << "\n"
<< " init_cfg_vars();\n" << " init_" << family_name << "_vars();\n"
<< "\n" << "\n"
<< " if ((fp = fopen(file, \"w\")))\n" << " if ((fp = fopen(file, \"w\")))\n"
<< " {\n"; << " {\n";
@@ -902,15 +904,15 @@ void output_read_var(ostream& c_stream)
output_array_read(c_stream, variable::SD); output_array_read(c_stream, variable::SD);
c_stream << "\n" c_stream << "\n"
<< "unsigned char read_cfg_vars(const char *file)\n" << "unsigned char read_" << family_name << "_vars(const char *file)\n"
<< "{\n" << "{\n"
<< " FILE *fp = 0;\n" << " FILE *fp = 0;\n"
<< "\n" << "\n"
<< " init_cfg_vars();\n" << " init_" << family_name << "_vars();\n"
<< "\n" << "\n"
<< " if (!(fp = fopen(file, \"r\")))\n" << " if (!(fp = fopen(file, \"r\")))\n"
<< " {\n" << " {\n"
<< " write_cfg_vars(file);\n" << " write_" << family_name << "_vars(file);\n"
<< " return(0);\n" << " return(0);\n"
<< " }\n" << " }\n"
<< "\n" << "\n"
@@ -965,7 +967,7 @@ void output_read_var(ostream& c_stream)
c_stream << " }\n" c_stream << " }\n"
<< "\n" << "\n"
<< " fclose(fp);\n" << " fclose(fp);\n"
<< " write_cfg_vars(file);\n" << " write_" << family_name << "_vars(file);\n"
<< " return(1);\n" << " return(1);\n"
<< "}\n"; << "}\n";
} }
@@ -1365,6 +1367,11 @@ int main(size_t argc, const char **argv)
{ {
compile = true; compile = true;
} }
else if (!strcmp(argv[param_pos], "-fname"))
{
param_pos++;
family_name = argv[param_pos];
}
else else
{ {
break; break;
@@ -1386,6 +1393,12 @@ int main(size_t argc, const char **argv)
<< "\n" << "\n"
<< " -cheader Create a C/C++ header with the following name.\n" << " -cheader Create a C/C++ header with the following name.\n"
<< " Example -cheader cfgvars.h\n" << " Example -cheader cfgvars.h\n"
<< "\n"
<< " -fname Use the following name for the main functions.\n"
<< " Example -fname math\n"
<< " Would make init_cfg_vars become init_math_vars the\n"
<< " happens to write_cfg_vars and read_cfg_vars.\n"
<< "\n"
<< endl; << endl;
return(1); return(1);