Changeset 14662 for trunk


Ignore:
Timestamp:
11/19/12 18:28:38 (12 years ago)
Author:
tbretz
Message:
Added the possibility to get resource values from the dimctrl to the JavaScripts (on the dimctrl server)
Location:
trunk/FACT++/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/StateMachineDimControl.cc

    r14561 r14662  
    9797
    9898    const map<string,string> data = Tools::Split(opt, true);
    99 
    10099    if (imp.GetSize()==0 || opt.size()==0 || opt[0]==0)
    101100    {
     
    119118    }
    120119
    121     Readline::SetExternalInput(cmd+imp.GetString());
     120    string emit = cmd+imp.GetString();
     121    if (cmd==".js ")
     122        emit += fArgumentsJS;
     123
     124    Readline::SetExternalInput(emit);
    122125    return 1;
    123126}
     
    490493    fScriptUser = fUser;
    491494
     495    const map<string, string> &js = conf.GetOptions<string>("JavaScript.");
     496    for (auto it=js.begin(); it!=js.end(); it++)
     497    {
     498        string key = it->first;
     499        string val = it->second;
     500
     501        // Escape key
     502        boost::replace_all(key, "\\", "\\\\");
     503        boost::replace_all(key, "'", "\\'");
     504        boost::replace_all(key, "\"", "\\\"");
     505
     506        // Escape value
     507        boost::replace_all(val, "\\", "\\\\");
     508        boost::replace_all(val, "'", "\\'");
     509        boost::replace_all(val, "\"", "\\\"");
     510
     511        fArgumentsJS += " '"+key +"'='"+val+"'";
     512    }
     513
    492514    // fVerbosity = 40;
    493515
  • trunk/FACT++/src/StateMachineDimControl.h

    r14551 r14662  
    3232    std::string fUser;
    3333    std::string fScriptUser;
     34
     35    /// Default arguments provided to very java script
     36    std::string fArgumentsJS;
    3437
    3538    std::string Line(const std::string &txt, char fill);
  • trunk/FACT++/src/dimctrl.cc

    r14621 r14662  
    2121        ("server",       po_bool(false),  "Start dimctrl as a dim server (console mode switched off)")
    2222        ("force-console",po_switch(),     "Forces console mode in server-mode.")
    23         // ("verbosity,v",  var<uint32_t>()->implicit_value(0), "Set a new verbosity level (see MessageImp)")
    24         // ("quiet,q",      po_bool(false),  "Suppress all output except comments (log-level>=90)")
    2523        ("debug",        po_bool(false),  "Print the labels for debugging purpose")
    2624        ("start",        var<string>(),   "Start a java script with the given name on the dimctrl-server")
     
    2927        ("msg",          var<string>(),   "Send a message to the chat server.")
    3028        ("user,u",       var<string>(""), "A user name - just for logging purposes (default is ${USER})")
     29        ("JavaScript.*", var<string>(""), "Additional arguments which are provided to JavaScripts started in a dimctrl server via the START command")
    3130        ;
    3231
Note: See TracChangeset for help on using the changeset viewer.