summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBastian Wissler2009-03-09 19:51:09 +0100
committerBastian Wissler2009-03-09 19:51:09 +0100
commitfb90986c3928d2ba98d6cb6a18c122de78b8b0c7 (patch)
tree09ed78f654bb3173a2e8ec39cbced7786cf7bcbf
parentvmchooser source: (diff)
downloadvmchooser-fb90986c3928d2ba98d6cb6a18c122de78b8b0c7.tar.gz
vmchooser-fb90986c3928d2ba98d6cb6a18c122de78b8b0c7.tar.xz
vmchooser-fb90986c3928d2ba98d6cb6a18c122de78b8b0c7.zip
vmchooser source:
* added support for starting xml with argument * version: 0.0.8 git-svn-id: http://svn.openslx.org/svn/openslx/openslx-src-tools/vmchooser/trunk@2703 95ad53e4-c205-0410-b2fa-d234c58c8868
-rw-r--r--vmchooser/addInfo.cxx15
-rw-r--r--vmchooser/inc/functions.h2
-rw-r--r--vmchooser/main.cxx43
-rw-r--r--vmchooser/runImage.cxx5
4 files changed, 37 insertions, 28 deletions
diff --git a/vmchooser/addInfo.cxx b/vmchooser/addInfo.cxx
index 5d1301d..d470ebd 100644
--- a/vmchooser/addInfo.cxx
+++ b/vmchooser/addInfo.cxx
@@ -115,6 +115,7 @@ void addInfo(xmlNode* node, DataEntry* dat) {
if(dat->xml_name.empty()) return;
bfs::path path(dat->xml_name);
std::string folder = path.branch_path().string();
+ folder.append("/");
cout << "XML folder name: " << folder << endl;
@@ -130,25 +131,17 @@ void addInfo(xmlNode* node, DataEntry* dat) {
cur = cur->next;
}
if(! filenamenode) {
- //filenamenode = xmlNewNode(NULL, (const xmlChar*) "xmlpath");
- //if(filenamenode != NULL ) {
- // xmlNewProp(filenamenode, (const xmlChar*) "param", (const xmlChar*) folder.c_str());
- // xmlAddChild(node, filenamenode);
- //}
- //else {
- // cerr << "<xmlpath> node could not be created!" << endl;
- //}
cerr << "There is no node called 'image_name'. " << endl;
}
else {
- // add param value to existant hostname-nodea
- xmlChar* bla = xmlGetProp(filenamenode, "param");
+ // add param value to existant hostname-node
+ xmlChar* bla = xmlGetProp(filenamenode, (const xmlChar*) "param");
if(!bla) {
cerr << "Could not read Attribute 'param' in 'image_name' node." << endl;
return;
}
else {
- xmlSetProp(filenamenode, (const xmlChar*) "param", (xmlChar*) folder.append(bla).c_str());
+ xmlSetProp(filenamenode, (const xmlChar*)"param", (const xmlChar*)folder.append((char*)bla).c_str());
}
}
diff --git a/vmchooser/inc/functions.h b/vmchooser/inc/functions.h
index 1ec76f4..9a10329 100644
--- a/vmchooser/inc/functions.h
+++ b/vmchooser/inc/functions.h
@@ -15,7 +15,7 @@ DataEntry** readLinSess(char* path);
void runImage(fltk::Widget* , void* p);
/* building & executing command for different Virtualizer */
-string runImage(DataEntry&, string confxml);
+void runImage(DataEntry&, string confxml);
/* Globs for a specific filetype (2. argument) */
glob_t* globber(char* path, char* filetype);
diff --git a/vmchooser/main.cxx b/vmchooser/main.cxx
index 4f91117..b388eb2 100644
--- a/vmchooser/main.cxx
+++ b/vmchooser/main.cxx
@@ -8,9 +8,16 @@
#include "inc/functions.h"
#include "inc/anyoption.h"
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+#include <libxml/xpath.h>
+
using namespace std;
using namespace fltk;
+// defined in readXmlDir.h
+extern DataEntry* get_entry(xmlDoc * doc);
+
SWindow* mainwin;
/**
* MAIN
@@ -25,22 +32,22 @@ SWindow* mainwin;
int main(int argc, char** argv) {
AnyOption* opt = new AnyOption();
char* xmlpath = NULL;
- bool version = false;
char* lsesspath = NULL;
int width=0, height=0;
- opt->setVerbose();
- opt->autoUsagePrint(true);
+ //opt->setVerbose();
+ opt->autoUsagePrint(false);
opt->addUsage("");
- opt->addUsage("SessionChooser Usage:");
+ opt->addUsage("SessionChooser Usage: vmchooser [OPTS|image.xml]");
opt->addUsage("\t{-p |--path=} path to vmware (.xml) files");
opt->addUsage("\t{-l |--lpath=} path to linux session (.desktop) files");
opt->addUsage("\t{-s |--size=} [widthxheight]");
opt->addUsage("\t{-v |--version} print out version");
opt->addUsage("\t{-h |--help} prints help");
opt->addUsage("");
-
+ opt->addUsage("Run with xml-file as additional argument to start image at once.");
+
opt->setFlag("help",'h');
opt->setFlag("version",'v');
opt->setOption("path", 'p');
@@ -70,7 +77,11 @@ int main(int argc, char** argv) {
/* VERSION */
if(opt->getFlag('v') || opt->getFlag("version")) {
- version = true;
+ // just print out version information - helps testing
+ cout << "virtual machine chooser 0.0.7"<< endl;
+ delete opt;
+ return 0;
+
}
/** LINUX SESSION PATH */
@@ -108,14 +119,22 @@ int main(int argc, char** argv) {
height = atoi(size.substr(i+1).c_str());
width = atoi(size.substr(0, size.size()-i).c_str());
}
+
+
+ // additional xml argument -> start image directly
+ if(opt->getArgc() > 0) {
+ // read xml image
+ xmlDoc* doc = xmlReadFile(opt->getArgv(0), NULL, XML_PARSE_RECOVER);
+ if (doc == NULL) {
+ fprintf(stderr, "error: could not parse file %s\n", opt->getArgv(0));
+ return 1;
+ }
+
+ DataEntry* result = get_entry(doc);
+ runImage(*result, opt->getArgv(0));
+ }
delete opt;
-
- // just print out version information - helps testing
- cout << "virtual machine chooser 0.0.7"<< endl;
- if(version) {
- exit(1);
- }
/* read xml files */
diff --git a/vmchooser/runImage.cxx b/vmchooser/runImage.cxx
index bed42ac..750d408 100644
--- a/vmchooser/runImage.cxx
+++ b/vmchooser/runImage.cxx
@@ -83,7 +83,7 @@ void runImage(fltk::Widget*, void* p)
* Helper-function for runImage(Widget, void)
* - runs the chosen virtualizer image
**/
-string runImage(DataEntry& dat, string confxml)
+void runImage(DataEntry& dat, string confxml)
{
if(! dat.command.empty() ) {
char* arg[] = { (char*) dat.command.c_str(), '\0' };
@@ -94,9 +94,6 @@ string runImage(DataEntry& dat, string confxml)
NULL };
execvp("/var/X11R6/bin/run-virt.sh", arg);
-
- // not reachable - but for compiling issues
- return string();
}