Commit 4af813fb authored by Claes Sjofors's avatar Claes Sjofors

Wb history to html conversion added

parent 84066f3b
......@@ -298,6 +298,7 @@ void WNavGtk::logw_new( char *item, wlog_eCategory *categories, int show_item)
char title[300];
pwr_tStatus sts;
if ( categories) {
for ( unsigned int i = 0; i < sizeof(categories_str)/sizeof(categories_str[0]); i++) {
if ( categories[i] == wlog_eCategory_) {
strcpy( categories_str[i], "");
......@@ -306,13 +307,19 @@ void WNavGtk::logw_new( char *item, wlog_eCategory *categories, int show_item)
else
wb_log::category_to_string( categories[i], categories_str[i]);
}
}
strcpy( title, "History ");
if ( item)
strcat( title, item);
if ( title[strlen(title)-1] == '*')
title[strlen(title)-1] = 0;
CoLogWGtk *logw = new CoLogWGtk( this, parent_wid, title, show_item, &sts);
if ( categories)
logw->show( categories_str, item);
else
logw->show( 0, item);
}
void WNavGtk::sel_convert_cb( GtkWidget *w, GtkSelectionData *selection_data,
......
......@@ -1115,6 +1115,12 @@ void wb_build::webhandler( pwr_tOid oid)
MsgWindow::message( 'I', msg, msgw_ePop_No, oid);
m_sts = PWRB__SUCCESS;
}
// Generate wb history html file
pwr_tCmd cmd;
strcpy( cmd, "generate history");
m_wnav->command( cmd);
}
void wb_build::application( pwr_tOid oid)
......
......@@ -45,7 +45,13 @@
#include "co_time.h"
#include "wb_session.h"
#include "wb_object.h"
#include "wb_utl_api.h"
#include "wb_log.h"
#include "wb_wnav_msg.h"
typedef struct {
vector<string> v;
} log_sCbCtx;
void wb_log::log( wlog_eCategory category, const char *str, const char *comment, unsigned int opt)
......@@ -167,3 +173,50 @@ void wb_log::string_to_category( char *str, wlog_eCategory *category)
*category = wlog_eCategory_;
}
void wb_log::generate_html( char *filename, pwr_tStatus *sts)
{
log_sCbCtx cbctx;
pwr_tFileName fname;
FILE *fp;
char timstr[24];
char pname[80];
time_AtoAscii( 0, time_eFormat_DateAndTime, timstr, sizeof(timstr));
utl_get_projectname( pname);
CoLog::dget( 0, 0, gen_cb, &cbctx);
dcli_translate_filename( fname, filename);
fp = fopen( fname, "w");
if ( !fp) {
*sts = WNAV__NOFILE;
return;
}
fprintf( fp, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"\"http://www.w3.org/TR/REC-html40/loose.dtd>\n\
<!-- Generated by wb_log %s -->\n", timstr);
fprintf( fp, "<HTML>\n<HEAD>\n<META http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">\n\
<TITLE>\nWorkbench History\n</TITLE>\n</HEAD>\n<BODY BGCOLOR=\"white\"><XMP>\n");
fprintf( fp, "Workbench History %s %s\n\n", pname, timstr);
fprintf( fp, "%-20s %-10s %-20s %-20s %s\n", "Date", "User", "Action", "Item", "Comment");
fprintf( fp, "----------------------------------------------------------------------------------------------\n");
for ( int i = cbctx.v.size() - 1; i >= 0; i--)
fprintf( fp, "%s\n", cbctx.v[i].c_str());
fprintf( fp, "</XMP>\n</BODY>\n</HTML>\n");
fclose( fp);
}
void wb_log::gen_cb( void *ctx, pwr_tTime time, char *s1, char *s2, char *s3, char *s4)
{
log_sCbCtx *cbctx = (log_sCbCtx *)ctx;
char timstr[21];
char str[200];
time_AtoAscii( &time, time_eFormat_DateAndTime, timstr, sizeof(timstr));
snprintf( str, sizeof(str), "%-20s %-10s %-20s %-20s %s", timstr, s2, s1, s3, s4 ? s4 : "");
string s(str);
cbctx->v.push_back(s);
}
......@@ -77,6 +77,9 @@ class wb_log
static void string_to_category( char *str, wlog_eCategory *category);
static void push() { CoLog::dpush();}
static void pull() { CoLog::dpull();}
static void generate_html( char *filename, pwr_tStatus *sts);
static void gen_cb( void *ctx, pwr_tTime time, char *s1, char *s2, char *s3, char *s4);
};
#endif
......
......@@ -41,10 +41,11 @@
#include "flow_std.h"
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <string>
#include "pwr_class.h"
#include "pwr_version.h"
......@@ -430,7 +431,7 @@ dcli_tCmdTable wnav_command_table[] = {
{
"GENERATE",
&wnav_generate_func,
{ "dcli_arg1", ""}
{ "dcli_arg1", "/FILE", ""}
},
{
"CROSSREFERENCE",
......@@ -2574,8 +2575,7 @@ static int wnav_generate_func( void *client_data,
return WNAV__SYNTAX;
}
if ( cdh_NoCaseStrncmp( arg1_str, "WEB", strlen( arg1_str)) == 0)
{
if ( cdh_NoCaseStrncmp( arg1_str, "WEB", strlen( arg1_str)) == 0) {
int sts;
sts = wnav_wccm_get_ldhsession_cb( wnav, &wnav->ldhses);
......@@ -2588,6 +2588,27 @@ static int wnav_generate_func( void *client_data,
return sts;
}
}
else if ( cdh_NoCaseStrncmp( arg1_str, "HISTORY", strlen( arg1_str)) == 0) {
pwr_tFileName filestr;
pwr_tStatus sts;
if ( EVEN( dcli_get_qualifier( "/FILE", filestr, sizeof(filestr)))) {
strcpy( filestr, "$pwrp_web/wb_history.html");
}
else {
wnav->message('E', "File is missing");
return WNAV__SYNTAX;
}
wb_log::generate_html( filestr, &sts);
if ( EVEN(sts))
wnav->message(' ', wnav_get_message(sts));
else {
char msg[200];
sprintf( msg, "History html file generated, %s", filestr);
wnav->message('I', msg);
}
}
else {
wnav->message('E', "Syntax error");
return WNAV__SYNTAX;
......@@ -3747,26 +3768,24 @@ static int wnav_open_func( void *client_data,
{
char categoriesstr[80];
pwr_tAName itemstr;
char *itemp = itemstr;
int showitem;
char cvect[10][20];
wlog_eCategory categories[10];
wlog_eCategory *catp = categories;
int nr;
// Command is "OPEN HISTORY"
if ( EVEN( dcli_get_qualifier( "/ITEM", itemstr, sizeof(itemstr)))) {
wnav->message('E', "Item is missing");
return WNAV__SYNTAX;
}
if ( EVEN( dcli_get_qualifier( "/ITEM", itemstr, sizeof(itemstr))))
itemp = 0;
showitem = ODD( dcli_get_qualifier( "/SHOWITEM", 0, 0));
if ( EVEN( dcli_get_qualifier( "/CATEGORIES", categoriesstr, sizeof(categoriesstr)))) {
wnav->message('E', "Categories are missing");
return WNAV__SYNTAX;
}
if ( EVEN( dcli_get_qualifier( "/CATEGORIES", categoriesstr, sizeof(categoriesstr))))
catp = 0;
if ( catp) {
nr = dcli_parse( categoriesstr, ",", "", (char *)cvect,
sizeof( cvect) / sizeof( cvect[0]), sizeof( cvect[0]), 0);
if ( nr == 0) {
......@@ -3780,8 +3799,9 @@ static int wnav_open_func( void *client_data,
wb_log::string_to_category( cvect[i], &categories[i]);
}
categories[nr] = wlog_eCategory_;
}
wnav->logw_new( itemstr, categories, showitem);
wnav->logw_new( itemp, catp, showitem);
}
else
{
......
......@@ -132,12 +132,17 @@ void CoLog::get( char categories[][20], char *item,
continue;
int found = 0;
if ( categories) {
for ( int i = 0; strcmp( categories[i], "") != 0; i++) {
if ( strcmp( categories[i], line_array[4]) == 0) {
found = 1;
break;
}
}
}
else
found = 1;
if ( !found)
continue;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment