Changeset 5735dda in nscp for modules/CheckExternalScripts


Ignore:
Timestamp:
06/13/10 22:02:07 (3 years ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2
Children:
f0607c4
Parents:
5cd6bcf (diff), f1d6990 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merged back all (some?) of the new changes from 0.3.8

Location:
modules/CheckExternalScripts
Files:
1 added
3 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • modules/CheckExternalScripts/CheckExternalScripts.cpp

    rcad08fb r5735dda  
    5656    } 
    5757  } 
     58} 
     59 
     60 
     61std::wstring CheckExternalScripts::getWrapping(std::wstring val) { 
     62  strEx::token tok = strEx::getToken(val, ' ', true); 
     63  std::wstring::size_type pos = tok.first.find_last_of(_T(".")); 
     64  if (pos == std::wstring::npos) 
     65    return _T(""); 
     66  return tok.first.substr(pos+1); 
     67} 
     68 
     69void CheckExternalScripts::addWrappedCommand(std::wstring key, std::wstring tpl, std::wstring command ) { 
     70  strEx::token tok = strEx::getToken(command, ' ', true); 
     71  strEx::replace(tpl, _T("%SCRIPT%"), tok.first); 
     72  strEx::replace(tpl, _T("%ARGS%"), tok.second); 
     73  tok = strEx::getToken(tpl, ' ', true); 
     74  addCommand(key.c_str(),tok.first, tok.second); 
    5875} 
    5976 
     
    99116  } 
    100117 
     118  std::map<std::wstring,std::wstring> wrappers; 
     119  std::list<std::wstring> wrappings = GET_CORE()->getSettingsSection(setting_keys::external_scripts::WRAPPINGS_SECTION_PATH); 
     120  for (it = wrappings.begin(); it != wrappings.end(); ++it) { 
     121    std::wstring val = GET_CORE()->getSettingsString(setting_keys::external_scripts::WRAPPINGS_SECTION_PATH, *it, _T("")); 
     122    if (!(*it).empty() && !val.empty()) { 
     123      wrappers[(*it)] = val; 
     124    } 
     125  } 
     126  std::list<std::wstring> wscript = GET_CORE()->getSettingsSection(setting_keys::external_scripts::WRAPPED_SCRIPT_PATH); 
     127  for (it = wscript.begin(); it != wscript.end(); ++it) { 
     128    std::wstring val = GET_CORE()->getSettingsString(setting_keys::external_scripts::WRAPPED_SCRIPT_PATH, *it, _T("")); 
     129    if (!(*it).empty() && !val.empty()) { 
     130      std::wstring type = getWrapping(val); 
     131      std::map<std::wstring,std::wstring>::const_iterator cit = wrappers.find(type); 
     132      if (cit == wrappers.end()) { 
     133        NSC_LOG_ERROR_STD(_T("Failed to find wrappings for: ") + type + _T(" (" + (*it) + _T(")"))); 
     134      } else { 
     135        addWrappedCommand((*it), (*cit).second, val); 
     136      } 
     137    } 
     138  } 
     139 
    101140  if (!scriptDirectory_.empty()) { 
    102141    addAllScriptsFrom(scriptDirectory_); 
  • modules/CheckExternalScripts/CheckExternalScripts.h

    rcad08fb r5735dda  
    9696    GET_CORE()->registerCommand(key, _T("Alias for: ") + cd.to_string()); 
    9797  } 
     98  std::wstring getWrapping( std::wstring val ); 
     99  void addWrappedCommand( std::wstring key, std::wstring tpl, std::wstring command ); 
    98100}; 
    99101 
  • modules/CheckExternalScripts/CheckExternalScripts.def

    rc1d545e rcad08fb  
    1111  NSHandleCommand 
    1212  NSUnloadModule 
    13   NSGetConfigurationMeta 
    1413  NSGetModuleDescription 
     14  NSDeleteBuffer 
  • modules/CheckExternalScripts/stdafx.h

    rc1d545e rcad08fb  
    2121#pragma once 
    2222 
    23 #define WIN32_LEAN_AND_MEAN   // Exclude rarely-used stuff from Windows headers 
    24 // Windows Header Files: 
    25 #include <windows.h> 
    26  
    2723#include <string> 
    2824#include <functional> 
    29  
    30 #include <config.h> 
    3125#include <utils.h> 
    3226 
     27#include <boost/lexical_cast.hpp> 
     28 
     29#include <types.hpp> 
    3330#include <NSCAPI.h> 
    34 #include <NSCHelper.h> 
     31#include <nscapi/plugin.hpp> 
    3532 
    3633#ifdef MEMCHECK 
Note: See TracChangeset for help on using the changeset viewer.