[Openvas-commits] r3242 - trunk/winslad
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue May 5 23:49:14 CEST 2009
Author: doj
Date: 2009-05-05 23:49:13 +0200 (Tue, 05 May 2009)
New Revision: 3242
Modified:
trunk/winslad/Makefile
trunk/winslad/client.cpp
trunk/winslad/main.cpp
trunk/winslad/xml.cpp
Log:
added SLADD_VERSION macro, use \r\n
Modified: trunk/winslad/Makefile
===================================================================
--- trunk/winslad/Makefile 2009-05-05 14:00:35 UTC (rev 3241)
+++ trunk/winslad/Makefile 2009-05-05 21:49:13 UTC (rev 3242)
@@ -1,11 +1,12 @@
# This is a GNU Makefile and part of Microsoft Windows SLAD
+VERSION=1.0
EXE=sladd.exe
OBJ=main.o xml.o client.o path.o readn.o writen.o
CXX=mingw32-g++
CC=$(CXX)
-CFLAGS+=-Wall -DDOJDEBUG=1
+CFLAGS+=-Wall -DDOJDEBUG=1 -DSLADD_VERSION=\"$(VERSION)\"
CXXFLAGS=$(CFLAGS)
include config.mk
@@ -27,7 +28,7 @@
$(MAKE) -C oval $@
clean:
- $(RM) libexpat.a *~ *.o $(EXE)
+ $(RM) libexpat.a *~ *.o $(EXE) nsis.log
$(MAKE) -C expat $@
$(MAKE) -C testplugin $@
$(MAKE) -C john $@
Modified: trunk/winslad/client.cpp
===================================================================
--- trunk/winslad/client.cpp 2009-05-05 14:00:35 UTC (rev 3241)
+++ trunk/winslad/client.cpp 2009-05-05 21:49:13 UTC (rev 3242)
@@ -54,14 +54,14 @@
#if 0
CHAR szPrintBuffer[512];
wsprintf(szPrintBuffer,
- "ERROR: API = %s.\n error code = %d.\n message = %s.\n",
+ "ERROR: API = %s.\r\n error code = %d.\r\n message = %s.\r\n",
pszAPI, GetLastError(), (char *)lpvMessageBuffer);
DWORD nCharsWritten;
WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE),szPrintBuffer,
lstrlen(szPrintBuffer),&nCharsWritten,NULL);
#else
- PRINTF("ERROR: API = %s.\n error code = %d.\n message = %s.\n",
+ PRINTF("ERROR: API = %s.\r\n error code = %d.\r\n message = %s.\r\n",
pszAPI, GetLastError(), (char *)lpvMessageBuffer);
#endif
@@ -81,14 +81,14 @@
slad_plugin_t * plugin;
for (int p_num = 0; (plugin = config->plugins[p_num]); p_num++)
{
- printf ("p:%s:%s\n", plugin->name, plugin->desc);
+ printf ("p:%s:%s\r\n", plugin->name, plugin->desc);
if (plugin->sets)
{
slad_plugin_set_t * set;
for (int s_num = 0; (set = plugin->sets[s_num]); s_num++)
{
- printf ("s:%d:%s:%s:%s\n",
+ printf ("s:%d:%s:%s:%s\r\n",
set->is_default ? 1 : 0,
plugin->name,
set->name,
@@ -99,7 +99,7 @@
slad_plugin_entry_t * entry;
for (int e_num = 0; (entry = set->entries[e_num]); e_num++)
{
- printf ("e:%d:%s:%s:%s:%s\n",
+ printf ("e:%d:%s:%s:%s:%s\r\n",
entry->is_default ? 1 : 0,
plugin->name,
set->name,
@@ -177,7 +177,7 @@
fn.erase(0, resultpath.size()+1); // strip directory
const off_t fs=(fn[0]=='T') ? doj::fileSize(*f) : 0;
- printf("%s:%li at 0xDEADBEEF\n", fn.c_str(), fs);
+ printf("%s:%li at 0xDEADBEEF\r\n", fn.c_str(), fs);
}
return 0;
@@ -212,7 +212,7 @@
if(!config) return 1;
if (config->arg.empty())
{
- printf(MSG_NOCOMMAND ": No selection to --show\n");
+ printf(MSG_NOCOMMAND ": No selection to --show\r\n");
return 1;
}
@@ -240,7 +240,7 @@
}
else
{
- printf (MSG_NOCOMMAND "\n");
+ printf (MSG_NOCOMMAND "\r\n");
}
}
return 1;
@@ -265,10 +265,10 @@
const std::string pluginName=std::string(p->name)+':'+s->name+':'+e->name;
const std::string pluginPath=config->pluginpath+'\\'+p->path;
#if 0
- PRINTF("pluginName: %s\n", pluginName.c_str());
- PRINTF("path: %s\n", pluginPath.c_str());
- PRINTF("binary: %s\n", e->binary);
- PRINTF("cmdline: %s\n", e->cmdline);
+ PRINTF("pluginName: %s\r\n", pluginName.c_str());
+ PRINTF("path: %s\r\n", pluginPath.c_str());
+ PRINTF("binary: %s\r\n", e->binary);
+ PRINTF("cmdline: %s\r\n", e->cmdline);
#endif
const std::string finishedPath=config->resultpath+"\\T$"+plugin2filename(pluginName);
@@ -276,7 +276,7 @@
// check if result file already exists
if(doj::isFile(finishedPath))
{
- printf(MSG_ALREADY "\n");
+ printf(MSG_ALREADY "\r\n");
return 1;
}
@@ -302,7 +302,7 @@
);
if(nul_h == INVALID_HANDLE_VALUE)
{
- PRINTF("CreateFile(NUL) failed\n");
+ PRINTF("CreateFile(NUL) failed\r\n");
DisplayError("CreateFile");
return -1;
}
@@ -332,14 +332,14 @@
)
)
{
- PRINTF("start_plugin(%s): Created Process %i ; Thread %i\n", cmd_args.c_str(), ProcInfo.dwProcessId, ProcInfo.dwThreadId);
- printf(MSG_OK "\n");
+ PRINTF("start_plugin(%s): Created Process %i ; Thread %i\r\n", cmd_args.c_str(), ProcInfo.dwProcessId, ProcInfo.dwThreadId);
+ printf(MSG_OK "\r\n");
return 0;
}
- PRINTF("start_plugin(): %s %s\n", cmd.c_str(), cmd_args.c_str());
+ PRINTF("start_plugin(): %s %s\r\n", cmd.c_str(), cmd_args.c_str());
DisplayError("CreateProcess");
- printf(MSG_CANTQUEUE "\n");
+ printf(MSG_CANTQUEUE "\r\n");
return 1;
}
@@ -362,10 +362,10 @@
const std::string pluginName=std::string(p->name)+':'+s->name+':'+e->name;
const std::string pluginPath=config->pluginpath+'\\'+p->path;
#if 0
- PRINTF("pluginName: %s\n", pluginName.c_str());
- PRINTF("path: %s\n", pluginPath.c_str());
- PRINTF("binary: %s\n", e->binary);
- PRINTF("cmdline: %s\n", e->cmdline);
+ PRINTF("pluginName: %s\r\n", pluginName.c_str());
+ PRINTF("path: %s\r\n", pluginPath.c_str());
+ PRINTF("binary: %s\r\n", e->binary);
+ PRINTF("cmdline: %s\r\n", e->cmdline);
#endif
std::string resultFN=std::string("R$")+plugin2filename(pluginName);
@@ -401,7 +401,7 @@
strcat(lpApplicationName, "\\cmd.exe");
if(! doj::isFile(lpApplicationName))
{
- PRINTF("could not find path to cmd.exe\n");
+ PRINTF("could not find path to cmd.exe\r\n");
return -1;
}
cmd="/c ";
@@ -431,7 +431,7 @@
);
if(result_h == INVALID_HANDLE_VALUE)
{
- PRINTF("CreateFile(%s) failed\n", resultPath.c_str());
+ PRINTF("CreateFile(%s) failed\r\n", resultPath.c_str());
DisplayError("CreateFile");
return -1;
}
@@ -442,17 +442,17 @@
char *ts=asctime(localtime(&t));
ts[strlen(ts)-1]=0; // remove newline character
char buf[256];
- _snprintf(buf, sizeof(buf), "START %s = %s (%u)\r\n", pluginName.c_str(), ts, static_cast<unsigned>(t));
+ _snprintf(buf, sizeof(buf), "START %s = %s (%u)\r\r\n", pluginName.c_str(), ts, static_cast<unsigned>(t));
DWORD written;
if(!WriteFile(result_h, buf, strlen(buf), &written, NULL))
{
- PRINTF("WriteFile(%s) failed to write START\n", resultPath.c_str());
+ PRINTF("WriteFile(%s) failed to write START\r\n", resultPath.c_str());
DisplayError("WriteFile");
CloseHandle(result_h);
return -1;
}
if(written != strlen(buf))
- PRINTF("WriteFile did not write all bytes\n");
+ PRINTF("WriteFile did not write all bytes\r\n");
}
// Info on CreateProcess: http://msdn.microsoft.com/en-us/library/ms682425(VS.85).aspx
@@ -482,7 +482,7 @@
)
)
{
- PRINTF("execute_plugin(%s %s): Created Process %i ; Thread %i\n", lpApplicationName, cmd.c_str(), ProcInfo.dwProcessId, ProcInfo.dwThreadId);
+ PRINTF("execute_plugin(%s %s): Created Process %i ; Thread %i\r\n", lpApplicationName, cmd.c_str(), ProcInfo.dwProcessId, ProcInfo.dwThreadId);
// Wait until child process exits.
WaitForSingleObject( ProcInfo.hProcess, INFINITE );
@@ -491,12 +491,12 @@
CloseHandle( ProcInfo.hProcess );
CloseHandle( ProcInfo.hThread );
- PRINTF("execute_plugin(%s %s): Process %i terminated\n", lpApplicationName, cmd.c_str(), ProcInfo.dwProcessId);
+ PRINTF("execute_plugin(%s %s): Process %i terminated\r\n", lpApplicationName, cmd.c_str(), ProcInfo.dwProcessId);
runSuccess=true;
}
else
{
- PRINTF("execute_plugin(%s %s): could not create process\n", lpApplicationName, cmd.c_str());
+ PRINTF("execute_plugin(%s %s): could not create process\r\n", lpApplicationName, cmd.c_str());
DisplayError("CreateProcess");
}
@@ -506,17 +506,17 @@
char *ts=asctime(localtime(&t));
ts[strlen(ts)-1]=0; // remove newline character
char buf[256];
- _snprintf(buf, sizeof(buf), "\r\nEND %s = %s (%u)\r\n", pluginName.c_str(), ts, static_cast<unsigned>(t));
+ _snprintf(buf, sizeof(buf), "\r\r\nEND %s = %s (%u)\r\r\n", pluginName.c_str(), ts, static_cast<unsigned>(t));
DWORD written;
if(!WriteFile(result_h, buf, strlen(buf), &written, NULL))
{
- PRINTF("WriteFile(%s) failed to write END\n", resultPath.c_str());
+ PRINTF("WriteFile(%s) failed to write END\r\n", resultPath.c_str());
DisplayError("WriteFile");
CloseHandle(result_h);
return -1;
}
if(written != strlen(buf))
- PRINTF("WriteFile did not write all bytes\n");
+ PRINTF("WriteFile did not write all bytes\r\n");
}
// close result file
@@ -530,7 +530,7 @@
unlink(finishedPath.c_str());
if(!MoveFile(resultPath.c_str(), finishedPath.c_str()))
{
- PRINTF("execute_plugin(%s %s): could not rename %s to %s\n", lpApplicationName, cmd.c_str(), resultPath.c_str(), finishedPath.c_str());
+ PRINTF("execute_plugin(%s %s): could not rename %s to %s\r\n", lpApplicationName, cmd.c_str(), resultPath.c_str(), finishedPath.c_str());
DisplayError("MoveFile");
return 1;
}
@@ -566,7 +566,7 @@
if (!(config->plugins))
{
- PRINTF("findplugin(): could not find any plugins\n");
+ PRINTF("findplugin(): could not find any plugins\r\n");
return -6;
}
@@ -580,7 +580,7 @@
pname = tmpstring = strdup (pluginName.c_str());
if (!pname)
{
- PRINTF("findplugin(): could not strdup plugin name\n");
+ PRINTF("findplugin(): could not strdup plugin name\r\n");
return -7;
}
@@ -651,7 +651,7 @@
if(!config) return -1;
if(config->arg.empty())
{
- printf(MSG_CANTQUEUE ": no plugin name\n");
+ printf(MSG_CANTQUEUE ": no plugin name\r\n");
return -1;
}
@@ -664,14 +664,14 @@
if (!p)
{
- printf(MSG_NOPLUGIN ": did not find the plugin\n");
+ printf(MSG_NOPLUGIN ": did not find the plugin\r\n");
return -1;
}
if (!s)
s = (p->sets)[0];
if (!s)
{
- printf(MSG_NOPLUGIN": did not find a set\n");
+ printf(MSG_NOPLUGIN": did not find a set\r\n");
return -1;
}
@@ -681,7 +681,7 @@
if (!(s->entries)[0])
{
- printf(MSG_NOPLUGIN ": did not find entries\n");
+ printf(MSG_NOPLUGIN ": did not find entries\r\n");
return -1;
}
@@ -703,7 +703,7 @@
if(config->arg.empty())
{
- printf(MSG_CANTQUEUE ": no plugin name\n");
+ printf(MSG_CANTQUEUE ": no plugin name\r\n");
return -1;
}
@@ -716,20 +716,20 @@
if (!p)
{
- printf(MSG_NOPLUGIN ": did not find the plugin\n");
+ printf(MSG_NOPLUGIN ": did not find the plugin\r\n");
return -1;
}
if (!s)
s = (p->sets)[0];
if (!s)
{
- printf(MSG_NOPLUGIN": did not find a set\n");
+ printf(MSG_NOPLUGIN": did not find a set\r\n");
return -1;
}
if (!e)
{
- printf(MSG_NOPLUGIN": did not find the entity\n");
+ printf(MSG_NOPLUGIN": did not find the entity\r\n");
return -1;
}
@@ -752,7 +752,7 @@
case 's':
return cl_show (config);
default:
- printf(MSG_NOCOMMAND ": '%c'\n", config->command);
+ printf(MSG_NOCOMMAND ": '%c'\r\n", config->command);
return 1;
}
return 0;
Modified: trunk/winslad/main.cpp
===================================================================
--- trunk/winslad/main.cpp 2009-05-05 14:00:35 UTC (rev 3241)
+++ trunk/winslad/main.cpp 2009-05-05 21:49:13 UTC (rev 3242)
@@ -83,13 +83,14 @@
{
assert(arg0);
- printf ("Usage: %s [OPTION...]\n", basename (arg0));
- printf ("-p, --pluginpath=%-21s plug-in directory\n", SLADD_PLUGIN_PATH);
- printf ("-R, --resultpath=%-21s results directory\n", SLADD_RESULT_PATH);
- printf ("-s, --show=plugins|jobs|<resultid> display status\n"
- "-r, --run=pluginid run a job\n"
- "-h, --help display this help\n"
- "Environment variables: SLADD_PLUGIN_PATH, SLADD_RESULT_PATH\n"
+ printf ("WinSLAD %s http://openvas.org/ http://www.dn-systems.org/slad.shtml\r\n", SLADD_VERSION);
+ printf ("Usage: %s [OPTION...]\r\n", basename (arg0));
+ printf ("-p, --pluginpath=%-21s plug-in directory\r\n", SLADD_PLUGIN_PATH);
+ printf ("-R, --resultpath=%-21s results directory\r\n", SLADD_RESULT_PATH);
+ printf ("-s, --show=plugins|jobs|<resultid> display status\r\n"
+ "-r, --run=pluginid run a job\r\n"
+ "-h, --help display this help\r\n"
+ "Environment variables: SLADD_PLUGIN_PATH, SLADD_RESULT_PATH\r\n"
);
exit(EXIT_FAILURE);
@@ -193,12 +194,12 @@
struct stat statbuf;
if (stat (config->pluginpath.c_str(), &statbuf) < 0)
{
- printf("init_plugins(): stat(%s) error\n", config->pluginpath.c_str());
+ printf("init_plugins(): stat(%s) error\r\n", config->pluginpath.c_str());
return -3;
}
if (!S_ISDIR (statbuf.st_mode))
{
- printf("init_plugins(): pluginpath is not a directory\n");
+ printf("init_plugins(): pluginpath is not a directory\r\n");
return -4;
}
@@ -206,7 +207,7 @@
DIR *dir = opendir (config->pluginpath.c_str());
if (!dir)
{
- printf("can't opendir() plugin directory %s: %s\n", config->pluginpath.c_str(), strerror (errno));
+ printf("can't opendir() plugin directory %s: %s\r\n", config->pluginpath.c_str(), strerror (errno));
return -5;
}
@@ -227,7 +228,7 @@
{
if(load_plugin (tmppath.c_str(), config) < 0)
{
- printf("could not load %s\n", tmppath.c_str());
+ printf("could not load %s\r\n", tmppath.c_str());
}
}
}
@@ -250,20 +251,20 @@
sladd_config_t *config = new sladd_config_t;
if(init_cmdline (argc, argv, config) < 0)
{
- printf("could not init command line\n");
+ printf("could not init command line\r\n");
delete config;
return NULL;
}
if(init_plugins (config) < 0)
{
- printf("could not init plugins\n");
+ printf("could not init plugins\r\n");
delete config;
return NULL;
}
if(!doj::mkdir(config->resultpath))
{
- printf("could not create result directory: %s\n", config->resultpath.c_str());
+ printf("could not create result directory: %s\r\n", config->resultpath.c_str());
delete config;
return NULL;
}
@@ -291,7 +292,7 @@
sladd_config_t *config = init (argc, argv);
if (!config)
{
- printf("could not init config\n");
+ printf("could not init config\r\n");
return 1;
}
@@ -306,13 +307,13 @@
PRINTF("startup:");
for(int i=0; i<argc; ++i)
fprintf(event_log, " %s", argv[i]);
- fprintf(event_log, "\n");
+ fprintf(event_log, "\r\n");
fflush(event_log);
#endif
// run
const int ret=run_client (config);
- PRINTF("exit %s\n", (ret==EXIT_SUCCESS)?"success":"failure");
+ PRINTF("exit %s\r\n", (ret==EXIT_SUCCESS)?"success":"failure");
return ret;
} catch (std::exception& e) {
std::string err="Exception: ";
Modified: trunk/winslad/xml.cpp
===================================================================
--- trunk/winslad/xml.cpp 2009-05-05 14:00:35 UTC (rev 3241)
+++ trunk/winslad/xml.cpp 2009-05-05 21:49:13 UTC (rev 3242)
@@ -121,7 +121,7 @@
}
static void XMLCALL nullhandler (void * data, const char * s, int len) {
- // PRINTF("XML NULL handler called\n");
+ // PRINTF("XML NULL handler called\r\n");
}
static void XMLCALL stringhandler (void * data, const char * s, int len) {
@@ -134,7 +134,7 @@
text = tmp = (char*) malloc(len+1);
if (!text)
{
- PRINTF("xml stringhandler(): could not malloc text\n");
+ PRINTF("xml stringhandler(): could not malloc text\r\n");
return;
}
strncpy(text, s, len);
@@ -170,7 +170,7 @@
text = tmp = (char*) malloc(len+1);
if (!text)
{
- PRINTF("xml inihandler(): could not malloc text\n");
+ PRINTF("xml inihandler(): could not malloc text\r\n");
return;
}
strncpy(text, s, len);
@@ -225,7 +225,7 @@
entry = NULL;
if (!plugin)
{
- PRINTF("xml start(): could not calloc plugin\n");
+ PRINTF("xml start(): could not calloc plugin\r\n");
return;
}
plugin->path = strdup (basename (dirname (const_cast<char*>(config->pluginpath.c_str()))));
@@ -252,14 +252,14 @@
XML_SetCharacterDataHandler (parser, nullhandler);
XML_SetUserData (parser, NULL);
if (!plugin) {
- PRINTF("Plugin set encountered, but no plugin\n");
+ PRINTF("Plugin set encountered, but no plugin\r\n");
return;
}
set = (slad_plugin_set_t*) calloc (sizeof (slad_plugin_set_t), 1);
entry = NULL;
if (!set)
{
- PRINTF("xml start(): could not calloc set\n");
+ PRINTF("xml start(): could not calloc set\r\n");
return;
}
if (! enqueue ((void ***) &(plugin->sets), set)) {
@@ -285,13 +285,13 @@
XML_SetCharacterDataHandler (parser, nullhandler);
XML_SetUserData (parser, NULL);
if (!set) {
- PRINTF("Plugin set entry encountered, but no plugin set\n");
+ PRINTF("Plugin set entry encountered, but no plugin set\r\n");
return;
}
entry = (slad_plugin_entry_t*) calloc (sizeof (slad_plugin_entry_t), 1);
if (!entry)
{
- PRINTF("xml start(): could not calloc entry\n");
+ PRINTF("xml start(): could not calloc entry\r\n");
return;
}
if (! enqueue ((void ***) &(set->entries), entry)) {
@@ -350,10 +350,10 @@
}
break;
default:
- PRINTF("Unhandled element %s during XML parsing\n", element);
+ PRINTF("Unhandled element %s during XML parsing\r\n", element);
}
else
- PRINTF("Unknown element %s during XML parsing\n", element);
+ PRINTF("Unknown element %s during XML parsing\r\n", element);
depth++;
}
@@ -381,7 +381,7 @@
FILE *file = fopen (pluginFN, "r");
if (!file)
{
- PRINTF("could not open %s\n", pluginFN);
+ PRINTF("could not open %s\r\n", pluginFN);
return -1;
}
@@ -389,7 +389,7 @@
XML_Parser parser = XML_ParserCreate (NULL);
if (!parser)
{
- PRINTF("could not create XML parser\n");
+ PRINTF("could not create XML parser\r\n");
return -1;
}
@@ -407,7 +407,7 @@
char *buffer = (char*) XML_GetBuffer (parser, BUFSIZE);
if (!buffer)
{
- PRINTF("Got no buffer for XML parsing: %s\n", XML_ErrorString(XML_GetErrorCode(parser)));
+ PRINTF("Got no buffer for XML parsing: %s\r\n", XML_ErrorString(XML_GetErrorCode(parser)));
ret=-1;
break;
}
@@ -420,8 +420,8 @@
const int result = XML_Parse(parser, buffer, len, done);
if (result == XML_STATUS_ERROR)
{
- PRINTF("(%d) |%s|\n", len, (char *) buffer);
- PRINTF("Parse error at line %d: %s\n", (int)XML_GetCurrentLineNumber(parser), XML_ErrorString(XML_GetErrorCode(parser)));
+ PRINTF("(%d) |%s|\r\n", len, (char *) buffer);
+ PRINTF("Parse error at line %d: %s\r\n", (int)XML_GetCurrentLineNumber(parser), XML_ErrorString(XML_GetErrorCode(parser)));
ret=-1;
break;
}
More information about the Openvas-commits
mailing list