diff options
author | deva <deva> | 2010-08-03 12:29:39 +0000 |
---|---|---|
committer | deva <deva> | 2010-08-03 12:29:39 +0000 |
commit | d285c1bdb79752ef23a7252c9c2d9f408f0c9f49 (patch) | |
tree | 7c65185cdddb37dc99cccca6c5b89a9799add6a9 /server/src/resumeparser.cc | |
parent | 726742e53bcbb3fa31bcd55e6e7fe305da225455 (diff) |
New script-tag attribute that includes lua code from a file.
Diffstat (limited to 'server/src/resumeparser.cc')
-rw-r--r-- | server/src/resumeparser.cc | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/server/src/resumeparser.cc b/server/src/resumeparser.cc index 4d514ac..37b36f4 100644 --- a/server/src/resumeparser.cc +++ b/server/src/resumeparser.cc @@ -29,6 +29,7 @@ #include <string.h> #include "luaresume.h" +#include "configuration.h" static std::string resume_parser_format(Resume &r, Commit &commit) { @@ -100,18 +101,40 @@ static std::string resume_parser_format(Resume &r, Commit &commit) return resume; } -static std::string resume_parser_lua(Resume &resume, Commit &commit) +static std::string resume_parser_lua(Macro ¯o, Commit &commit) { LUAResume luaresume(commit); - - return luaresume.run(resume.attributes["format"]); + std::string lua; + /* + std::vector< ScriptInclude >::iterator spii = + macro.script_includes.begin(); + while(spii != macro.script_includes.end()) { + std::string file = + Conf::xml_basedir + "/include/" + spii->attributes["file"]; + FILE *fp = fopen(file.c_str(), "r"); + if(fp) { + char buf[64]; + size_t sz; + std::string inc; + while((sz = fread(buf, 1, sizeof(buf), fp)) != 0) { + lua.append(buf, sz); + } + fclose(fp); + } + spii++; + } + */ + lua += macro.resume.attributes["format"]; + + return luaresume.run(lua); } -std::string resume_parser(Resume &resume, Commit &commit) +std::string resume_parser(Macro ¯o, Commit &commit) { - if(resume.attributes["language"] == "lua") - return resume_parser_lua(resume, commit); + if(macro.resume.attributes["language"] == "lua") { + return resume_parser_lua(macro, commit); + } // Default to pracro format language. - return resume_parser_format(resume, commit); + return resume_parser_format(macro.resume, commit); } |