Hello community, here is the log from the commit of package konkretcmpi for openSUSE:Factory checked in at 2013-10-25 11:10:13 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/konkretcmpi (Old) and /work/SRC/openSUSE:Factory/.konkretcmpi.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "konkretcmpi" Changes: -------- --- /work/SRC/openSUSE:Factory/konkretcmpi/konkretcmpi.changes 2013-08-01 15:37:24.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.konkretcmpi.new/konkretcmpi.changes 2013-10-25 11:10:14.000000000 +0200 @@ -1,0 +2,13 @@ +Thu Oct 17 12:50:28 UTC 2013 - [email protected] + +- Update to 0.9.2 + * Modifiable templates for method stubs. + * Stub substitutions for method name, method type. + * Generated code for method input arguments name and type. + * Also generated code for output arguments. + * Bugfix possible integer overflow. + * Name collision avoidance for status variable in generated + * Modifiable template for enumeration stub. + * Plenty of bugfixes not announced in silent 0.9.1 release. + +------------------------------------------------------------------- @@ -5,5 +18,5 @@ - - Add support for embedded instances - - Support varlist in KReturn2 - - Fix return type for generated indication functions - - Enable direct calls - - Fix method arguments that are both input and output + * Add support for embedded instances + * Support varlist in KReturn2 + * Fix return type for generated indication functions + * Enable direct calls + * Fix method arguments that are both input and output Old: ---- konkretcmpi-0.9.1.tar.gz New: ---- konkretcmpi-0.9.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ konkretcmpi.spec ++++++ --- /var/tmp/diff_new_pack.o4Abez/_old 2013-10-25 11:10:15.000000000 +0200 +++ /var/tmp/diff_new_pack.o4Abez/_new 2013-10-25 11:10:15.000000000 +0200 @@ -17,7 +17,7 @@ Name: konkretcmpi -Version: 0.9.1 +Version: 0.9.2 Release: 0 BuildRequires: cmake BuildRequires: gcc ++++++ konkretcmpi-0.9.1.tar.gz -> konkretcmpi-0.9.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/konkretcmpi-0.9.1/CMakeLists.txt new/konkretcmpi-0.9.2/CMakeLists.txt --- old/konkretcmpi-0.9.1/CMakeLists.txt 2013-07-12 08:32:32.000000000 +0200 +++ new/konkretcmpi-0.9.2/CMakeLists.txt 2013-09-25 14:36:56.000000000 +0200 @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 2.6) set(CMAKE_C_FLAGS "-std=c99 -Wall -pedantic -g -Wextra -Wno-unused-parameter -Wformat -Wparentheses -Wl,--no-undefined ${CMAKE_C_FLAGS}") -set(CMAKE_CXX_FLAGS "-std=c++98 -Wall -pedantic -Wno-long-long -g -Wextra -Wno-unused-parameter -Wformat -Wparentheses -Wl,--no-undefined ${CMAKE_CXX_FLAGS}") +set(CMAKE_CXX_FLAGS "-std=c++98 -Wall -pedantic -Wno-long-long -g -Wextra -Wno-unused-parameter -Wformat -Wparentheses -Wl,--no-undefined -Wno-variadic-macros ${CMAKE_CXX_FLAGS}") # Set path to custom cmake modules set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH}) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/konkretcmpi-0.9.1/src/konkret/konkret.h new/konkretcmpi-0.9.2/src/konkret/konkret.h --- old/konkretcmpi-0.9.1/src/konkret/konkret.h 2013-07-12 08:32:32.000000000 +0200 +++ new/konkretcmpi-0.9.2/src/konkret/konkret.h 2013-09-25 14:36:56.000000000 +0200 @@ -205,8 +205,9 @@ fprintf(stderr, "CMPIStatus{%u, %s}\n", st->rc, KChars(st->msg)); } +__attribute__((format(printf, 3, 4))) KINLINE CMPIStatus __KReturn2( - const CMPIBroker* cb, + const CMPIBroker* cb, CMPIrc rc, const char* format, ...) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/konkretcmpi-0.9.1/src/mof/MOF_Buffer.cpp new/konkretcmpi-0.9.2/src/mof/MOF_Buffer.cpp --- old/konkretcmpi-0.9.1/src/mof/MOF_Buffer.cpp 2013-07-12 08:32:32.000000000 +0200 +++ new/konkretcmpi-0.9.2/src/mof/MOF_Buffer.cpp 2013-09-25 14:36:56.000000000 +0200 @@ -26,10 +26,11 @@ */ #include "MOF_Buffer.h" +#include "MOF_Error.h" -inline MOF_uint32 _next_pow_2(MOF_uint32 x) +inline size_t _next_pow_2(size_t x) { - MOF_uint32 r = 1; + size_t r = 1; while (r < x) r <<= 1; @@ -37,7 +38,7 @@ return r; } -inline MOF_uint32 _round_capacity(MOF_uint32 capacity) +inline size_t _round_capacity(size_t capacity) { return capacity < 16 ? 16 : _next_pow_2(capacity); } @@ -54,6 +55,12 @@ void MOF_Buffer::append(const char* data, size_t size) { + if (_size + size < _size) { + // It would overflow, because both size and _size are unsigned + // and their sum can't be lower than any of them + MOF_error_printf("Integer overflow detected"); + return; + } reserve(_size + size); memcpy(_data + _size, data, size); _size += size; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/konkretcmpi-0.9.1/src/mof/MOF_Data_Type.cpp new/konkretcmpi-0.9.2/src/mof/MOF_Data_Type.cpp --- old/konkretcmpi-0.9.1/src/mof/MOF_Data_Type.cpp 2013-07-12 08:32:32.000000000 +0200 +++ new/konkretcmpi-0.9.2/src/mof/MOF_Data_Type.cpp 2013-09-25 14:36:56.000000000 +0200 @@ -76,6 +76,9 @@ case TOK_DATETIME: return "datetime"; + case TOK_INSTANCE: + return "instance"; + default: MOF_ASSERT(false); return 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/konkretcmpi-0.9.1/src/program/main.cpp new/konkretcmpi-0.9.2/src/program/main.cpp --- old/konkretcmpi-0.9.1/src/program/main.cpp 2013-07-12 08:32:32.000000000 +0200 +++ new/konkretcmpi-0.9.2/src/program/main.cpp 2013-09-25 14:36:56.000000000 +0200 @@ -54,13 +54,17 @@ vector<char> torder; vector<pair<string,string> > rall; vector<pair<string,map<string,string> > > pall; -vector<map<string,string> > mall; +vector<pair<string,map<string,string> > > oall; +vector<pair<string,map<string,string> > > iall; +vector<map<string,string> > aall; -string eta, eti, etn; +string eta, eti, etn, etm; string ofile; bool around = false; +static void transform(string &text, const MOF_Class_Decl* cd, const MOF_Method_Decl* md); + static void substitute( string& text, const string& pattern, @@ -929,67 +933,13 @@ return buf; } -static void exmethod(FILE* os, const MOF_Class_Decl* cd, const MOF_Method_Decl* md) -{ - - string append; -/* if (md->qual_mask & MOF_QT_STATIC) - put(os, STATIC_HEADER, sn, mn, ktn, NULL); - else - put(os, HEADER, sn, mn, ktn, NULL); -*/ - for (MOF_Parameter* p = md->parameters; p; p = (MOF_Parameter*)p->next) - { -/* const char* mod = (p->qual_mask & MOF_QT_OUT) ? "" : "const ";*/ - - string type; - string name; - if (p->data_type == TOK_REF) - { - if (p->array_index) - type = string("KrefA"); - else - - type = string("Kref"); - } - else - { - const char* ktn = _ktype_name(p->data_type); - - if (p->array_index) - type = string(ktn)+string("A"); /* p->name */ - else - type = string(ktn); - } - name = p->name; - - for (vector<map<string,string> >::iterator mi = mall.begin(); mi != mall.end(); mi++) - { - map<string,string> mrules = (*mi); - if (mrules.find(type) != mrules.end()){ - append = mrules[type]; - printf("\nTo be appended to method %s\n", append.c_str()); - substitute(append, "<MTYPE>", type); - substitute(append, "<MNAME>", name); - printf("\nTransformed method appendix %s\n", append.c_str()); - put(os, append.c_str(), NULL); - - } - - } - - } - - - return; - -} - static void gen_meth_stub( FILE* os, const MOF_Class_Decl* cd, const MOF_Method_Decl* md) { + const char* sn = alias(cd->name); + const char* mn = md->name; const char* ktn = _ktype_name(md->data_type); char buf[1024]; @@ -1005,13 +955,38 @@ " $0 result = $1_INIT;\n" "\n"; + string text; if (around) - put(os, BODY_LEAD_AROUND, ktn, to_upper(buf, ktn), NULL); + text = BODY_LEAD_AROUND; +/* put(os, BODY_LEAD_AROUND, ktn, to_upper(buf, ktn), NULL);*/ else - put(os, BODY_LEAD, ktn, to_upper(buf, ktn), NULL); + text = BODY_LEAD; +/* put(os, BODY_LEAD, ktn, to_upper(buf, ktn), NULL);*/ - exmethod(os, cd, md); + if (!etm.empty()) { + text += etm; +/* put(os, etm.c_str(), ktn, to_upper(buf, ktn), NULL);*/ + } + + /* Replacements, including output arguments */ + transform(text, cd, md); + + /* Method credentials */ + substitute(text, "<MNAME>", mn); + substitute(text, "<MTYPE>", ktn); + substitute(text, "<ALIAS>", sn); + substitute(text, "<CLASS>", cd->name); + + /* Write */ + put(os, text.c_str(), ktn, to_upper(buf, ktn), NULL); + +/* transform(text, cd, md); + substitute(text, "<ALIAS>", sn); + substitute(text, "<CLASS>", cd->name); + fprintf(os, "%s", text.c_str()); + exmethod(os, cd, md); +*/ const char BODY_OUT[] = " KSetStatus(status, ERR_NOT_SUPPORTED);\n" " return result;\n" @@ -2345,7 +2320,6 @@ { string append; - printf("Properties of %s\n", cd->name); for (MOF_Feature_Info* p = cd->all_features; p; p = (MOF_Feature_Info*)p->next) { @@ -2372,27 +2346,13 @@ type = string(_ktype_name(pd->data_type))+string("A"); } - // XXX may need to extend by property name, class name, subclass name, superclass name rules - printf("Lookup %s\n", type.c_str()); - for (map<string,string>::iterator pi = prules.begin(); pi!=prules.end(); pi++) { - printf(" among %s\n", (*pi).first.c_str()); - } if (prules.find(type) != prules.end()) { // type has mapping rule append = prules[type]; - printf("\nTo be appended %s\n", append.c_str()); substitute(append, "<PTYPE>", type); substitute(append, "<PNAME>", pd->name); - printf("\nTransformed appendix %s\n", append.c_str()); chunk+=append; - printf("\nMerged chunk %s\n", chunk.c_str()); } - - if (pd->array_index == 0) { - printf(" const %s %s;\n", ktn, pn); - } else { - printf(" const %sA %s;\n", ktn, pn); - } } } return; @@ -2402,7 +2362,6 @@ { if (cd->super_class) { expropers_recursive(chunk, prules, cd->super_class); - printf("Nested chunk =======\n%s=======\n", chunk.c_str()); } expropers_decls(chunk, prules, cd); return; @@ -2410,14 +2369,83 @@ static void expropers(string &text, const pair<string,map<string,string> > pset, const MOF_Class_Decl* cd) { - printf("Property pattern %s\n",pset.first.c_str()); string chunk; expropers_recursive(chunk, pset.second, cd); - printf("Finished properties ==========\n%s==========\n", chunk.c_str()); substitute(text, pset.first, chunk); return; } +static void exoutputarg(string &text, const pair<string,map<string,string> > oset, const MOF_Class_Decl* cd, const MOF_Method_Decl* md) +{ + string chunk; + + const char* ktn = _ktype_name(md->data_type); + map<string,string> orules = oset.second; + + for (MOF_Parameter* p = md->parameters; p; p = (MOF_Parameter*)p->next) + { + string append; + bool out = p->qual_mask & MOF_QT_OUT; + if (!out) continue; + + string type; + if (p->array_index == 0) { + // is not array + type = string(_ktype_name(p->data_type)); + } else { + // is array + type = string(_ktype_name(p->data_type))+string("A"); + } + + if (orules.find(type) != orules.end()) { + // type has mapping rule + append = orules[type]; + substitute(append, "<MOTYPE>", type); + substitute(append, "<MONAME>", p->name); + chunk+=append; + } + } + + substitute(text, oset.first, chunk); + return; +} + +static void exinputarg(string &text, const pair<string,map<string,string> > iset, const MOF_Class_Decl* cd, const MOF_Method_Decl* md) +{ + string chunk; + + const char* ktn = _ktype_name(md->data_type); + map<string,string> irules = iset.second; + + for (MOF_Parameter* p = md->parameters; p; p = (MOF_Parameter*)p->next) + { + string append; + bool in = p->qual_mask & MOF_QT_IN; + if (!in) continue; + + string type; + if (p->array_index == 0) { + // is not array + type = string(_ktype_name(p->data_type)); + } else { + // is array + type = string(_ktype_name(p->data_type))+string("A"); + } + + if (irules.find(type) != irules.end()) { + // type has mapping rule + append = irules[type]; + substitute(append, "<MITYPE>", type); + substitute(append, "<MINAME>", p->name); + chunk+=append; + } + } + + substitute(text, iset.first, chunk); + return; +} + + static void exreplace(string &text, const pair<string,string> rrule) { ifstream rchunk(rrule.second.c_str(), ios::in|ios::ate|ios::binary); @@ -2436,11 +2464,13 @@ return; } -static void transform(string &text, const MOF_Class_Decl* cd) +static void transform(string &text, const MOF_Class_Decl* cd, const MOF_Method_Decl* md) { vector<pair<string,string> >::iterator ri = rall.begin(); vector<pair<string,map<string,string> > >::iterator pi = pall.begin(); + vector<pair<string,map<string,string> > >::iterator oi = oall.begin(); + vector<pair<string,map<string,string> > >::iterator ii = iall.begin(); for (vector<char>::iterator t = torder.begin(); t != torder.end(); t++) { switch (*t) { case 'R': @@ -2453,6 +2483,19 @@ expropers(text, *pi, cd); pi++; break; + case 'O': + if (NULL == md) break; /* Run only with valid method declaration */ + printf("%s transformed to method output arguments.\n", (*oi).first.c_str()); + exoutputarg(text, *oi, cd, md); + oi++; + break; + case 'i': + if (NULL == md) break; /* Run only with valid method declaration */ + printf("%s transformed to method input arguments.\n", (*ii).first.c_str()); + exinputarg(text, *ii, cd, md); + ii++; + break; + } } return; @@ -2498,7 +2541,7 @@ } else { text = eta; } - transform(text, cd); + transform(text, cd, NULL); substitute(text, "<ALIAS>", sn); substitute(text, "<CLASS>", cd->name); fprintf(os, "%s", text.c_str()); @@ -2513,7 +2556,7 @@ } else { text = etn; } - transform(text, cd); + transform(text, cd, NULL); substitute(text, "<ALIAS>", sn); substitute(text, "<CLASS>", cd->name); fprintf(os, "%s", text.c_str()); @@ -2528,7 +2571,7 @@ } else { text = eti; } - transform(text, cd); + transform(text, cd, NULL); substitute(text, "<ALIAS>", sn); substitute(text, "<CLASS>", cd->name); fprintf(os, "%s", text.c_str()); @@ -2759,18 +2802,21 @@ "OPTIONS:\n" " -P STR=FILE Replace STR with properties. With property rules in FILE\n" " -R STR=FILE Replace STR for contents of FILE\n" - " -M FILE Method argument type processing rules in FILE\n" + " -O STR=FILE Replace STR with method output arguments.\n" + " -i STR=FILE Replace STR with method input arguments.\n" " -I DIR Search for included MOF files in this directory\n" " -m FILE Add MOF file to list of MOFs to parse\n" " -v Print the version\n" " -s CLASS Write provider skeleton for CLASS to <ALIAS>Provider.c\n" " (or use CLASS=ALIAS! form instead).\n" " -o FILE Write main skeleton to custom FILE.\n" + " -k Use __status instead of status for result reporting.\n" " -f FILE Read CLASS=ALIAS[!] argumetns the given file.\n" " -h Print this help message\n" " -a FILE Template for association provider\n" " -c FILE Template for class instance provider\n" " -n FILE Template for indication provider\n" + " -M FILE Template for method provider\n" "\n" "ENVIRONMENT VARIABLES:\n" " KONKRET_SCHEMA_DIR -- searched for schema MOF files\n" @@ -2841,7 +2887,7 @@ vector<string> args; - for (int opt; (opt = getopt(argc, argv, "P:R:I:m:vhs:pf:a:c:n:o:kM:")) != -1; ) + for (int opt; (opt = getopt(argc, argv, "P:R:I:m:vhs:f:a:c:n:o:kM:O:i:")) != -1; ) { switch (opt) { @@ -2867,14 +2913,11 @@ ifstream pmap(pfilename.c_str(), ios::in|ios::binary); if (!pmap) { err("Property replacement file %s missing or unreadable.", pfilename.c_str()); - } else { - printf("Processing %s\n", pfilename.c_str()); } string line; map <string,string> tlist; while (getline(pmap, line)) { - printf("-P line: %s\n", line.c_str()); string ptype = line.substr(0, line.find('=')); string pfile = line.substr(line.find('=') + 1); @@ -2885,7 +2928,6 @@ codefile.close(); string pcode = extemplate(pfile.c_str()); tlist[ptype] = pcode; - printf("Property type %s for %s\n", ptype.c_str(), pcode.c_str()); } pmap.close(); @@ -2905,7 +2947,7 @@ if (tmpfile.size() == 0) { - err("Invalid -P option %s. Use -P PATTERN=FILENAME", optarg); + err("Invalid -R option %s. Use -R PATTERN=FILENAME", optarg); } ifstream ifile(tmpfile.c_str(), ios::in|ios::ate|ios::binary); @@ -2919,7 +2961,87 @@ break; } - case 'M': + case 'O': + { + torder.push_back('O'); + string replace; + replace.assign(optarg); + + string token = replace.substr(0, replace.find('=')); + string ofilename = replace.substr(replace.find('=') + 1); + + if (ofilename.size() == 0) + { + err("Invalid -O option %s. Use -O PATTERN=FILENAME", optarg); + } + + ifstream omap(ofilename.c_str(), ios::in|ios::binary); + if (!omap) { + err("Output argument replacement file %s missing or unreadable.", ofilename.c_str()); + } + + string line; + map <string,string> tlist; + while (getline(omap, line)) { + string otype = line.substr(0, line.find('=')); + string ofile = line.substr(line.find('=') + 1); + + ifstream codefile(ofile.c_str(), ios::in|ios::ate|ios::binary); + if (!codefile) { + err("Output argument type %s replacement file %s missing or unreadable.", otype.c_str(), ofile.c_str()); + } + codefile.close(); + string ocode = extemplate(ofile.c_str()); + tlist[otype] = ocode; + } + omap.close(); + + oall.push_back(pair<string,map<string, string> >(token, tlist)); + + break; + } + + case 'i': + { + torder.push_back('i'); + string replace; + replace.assign(optarg); + + string token = replace.substr(0, replace.find('=')); + string ifilename = replace.substr(replace.find('=') + 1); + + if (ifilename.size() == 0) + { + err("Invalid -i option %s. Use -i PATTERN=FILENAME", optarg); + } + + ifstream imap(ifilename.c_str(), ios::in|ios::binary); + if (!imap) { + err("Input argument replacement file %s missing or unreadable.", ifilename.c_str()); + } + + string line; + map <string,string> tlist; + while (getline(imap, line)) { + string itype = line.substr(0, line.find('=')); + string ifile = line.substr(line.find('=') + 1); + + ifstream codefile(ifile.c_str(), ios::in|ios::ate|ios::binary); + if (!codefile) { + err("Input argument type %s replacement file %s missing or unreadable.", itype.c_str(), ifile.c_str()); + } + codefile.close(); + string icode = extemplate(ifile.c_str()); + tlist[itype] = icode; + } + imap.close(); + + iall.push_back(pair<string,map<string, string> >(token, tlist)); + + break; + } + + case 'A': { string mfilename; mfilename.assign(optarg); @@ -2932,14 +3054,11 @@ ifstream imamap(mfilename.c_str(), ios::in|ios::binary); if (!imamap) { err("Method argument replacement file %s missing or unreadable.", mfilename.c_str()); - } else { - printf("Processing %s\n", mfilename.c_str()); } string line; map <string,string> tlist; while (getline(imamap, line)) { - printf("-M line: %s\n", line.c_str()); string mtype = line.substr(0, line.find('=')); string mfile = line.substr(line.find('=') + 1); @@ -2950,11 +3069,10 @@ codefile.close(); string mcode = extemplate(mfile.c_str()); tlist[mtype] = mcode; - printf("Method argument type %s for %s\n", mtype.c_str(), mcode.c_str()); } imamap.close(); - mall.push_back(map<string, string>(tlist)); + aall.push_back(map<string, string>(tlist)); break; } @@ -3033,6 +3151,9 @@ case 'n': etn = extemplate(optarg); break; + case 'M': + etm = extemplate(optarg); + break; case 'k': around = true; break; -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
