Commit 5d3a4e05 authored by claes's avatar claes

Major redesign, conversion to postscript and xml

parent 6edd27e6
/* cnv_content.cpp --
PROVIEW/R
Copyright (C) 1996-98 by Mandator AB.
Table of content ist. */
/*_Include files_________________________________________________________*/
#include <iostream.h>
#include <fstream.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
extern "C" {
#include "co_cdh.h"
#include "co_dcli.h"
}
#include "cnv_content.h"
int CnvContent::find_link( char *subject, char *text, int *page)
{
char key_part[4][40];
char subject_part[4][40];
int i, j;
int subject_nr;
int key_nr;
int hit = 0;
subject_nr = dcli_parse( subject, " ", "", (char *)subject_part,
sizeof( subject_part) / sizeof( subject_part[0]),
sizeof( subject_part[0]), 0);
for ( j = 0; j < (int)tab.size(); j++) {
key_nr = dcli_parse( tab[j].subject, " ", "", (char *)key_part,
sizeof( key_part) / sizeof( key_part[0]),
sizeof( key_part[0]), 0);
if ( key_nr == subject_nr ) {
for ( i = 0; i < key_nr; i++) {
if ( cdh_NoCaseStrcmp( subject_part[i], key_part[i]) == 0) {
if ( i == key_nr - 1) {
hit = 1;
break;
}
}
else
break;
}
}
if ( hit)
break;
}
if ( !hit)
return 0;
strcpy( text, tab[j].text);
*page = tab[j].page_number;
return 1;
}
void CnvContent::add( CnvContentElem& elem)
{
tab.push_back( elem);
}
#ifndef cnv_content_h
#define cnv_content_h
/* cnv_content.h -- Table of content list
PROVIEW/R
Copyright (C) 1996 by Comator Process AB.
<Description>. */
using namespace std;
#include <iostream.h>
#include <vector.h>
#include <string>
#include "pwr.h"
#include "cnv_style.h"
class CnvContentElem {
public:
int page_number;
int header_level;
char header_number[40];
char subject[80];
char text[80];
};
class CnvContent {
public:
CnvContent() {}
vector<CnvContentElem> tab;
void add( CnvContentElem& elem);
int find_link( char *subject, char *text, int *page);
};
#endif
#include <stdio.h>
#include <float.h>
#include <string.h>
#include <stdlib.h>
#include <iostream.h>
#include <fstream.h>
extern "C" {
#include "pwr.h"
#include "co_dcli.h"
#include "co_cdh.h"
}
#include "cnv_ctx.h"
char *CnvCtx::low( char *in)
{
static char str[400];
cdh_ToLower( str, in);
return str;
}
int CnvCtx::remove_spaces(
char *in,
char *out)
{
char *s;
for ( s = in; !((*s == 0) || ((*s != ' ') && (*s != 9))); s++);
strcpy( out, s);
s = out;
if ( strlen(s) != 0) {
for ( s += strlen(s) - 1;
!((s == out) || ((*s != ' ') && (*s != 9))); s--) ;
s++;
*s = 0;
}
return 1;
}
int CnvCtx::read_line(
char *line,
int maxsize,
FILE *file)
{
char *s;
if (fgets( line, maxsize, file) == NULL)
return 0;
line[maxsize-1] = 0;
s = strchr( line, 10);
if ( s != 0)
*s = 0;
s = strchr( line, 13);
if ( s != 0)
*s = 0;
return 1;
}
#ifndef co_convert_h
#define co_convert_h
/* co_convert.h -- Setup
PROVIEW/R
Copyright (C) 1996 by Comator Process AB.
<Description>. */
#if defined __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include "pwr.h"
#include "cnv_setup.h"
class CnvWblTo;
class CnvReadWbl;
class CnvReadXtthelp;
class CnvCtx {
public:
CnvCtx() : generate_html(0), generate_xtthelp(0), generate_src(0),
generate_struct(0), generate_ps(0), common_structfile_only(0), hpp(0),
verbose(0), first_class(1), setup(0), wblto(0), rw(0), rx(0)
{
strcpy( dir, "");
strcpy( setup_filename, "");
}
char dir[120];
int generate_html;
int generate_xtthelp;
int generate_src;
int generate_struct;
int generate_ps;
int common_structfile_only;
int hpp;
int verbose;
char setup_filename[120];
int first_class;
CnvSetup *setup;
CnvWblTo *wblto;
CnvReadWbl *rw;
CnvReadXtthelp *rx;
static int read_line( char *line, int maxsize, FILE *file);
static int remove_spaces( char *in, char *out);
static char *low( char *in);
};
#if defined __cplusplus
}
#endif
#endif
#include <iostream.h>
#include <float.h>
#include <math.h>
#include <stdlib.h>
#include "cnv_image.h"
static ImlibData *imlib = 0;
static Display *display = 0;
int cnv_get_image( char *fname, ImlibImage **image, Pixmap *pixmap)
{
#if defined IMLIB
if ( !imlib) {
display = XOpenDisplay(NULL);
imlib = Imlib_init( display);
}
#endif
*image = Imlib_load_image( imlib, fname);
if ( !*image)
return 0;
*pixmap = Imlib_move_image( imlib, *image);
return 1;
}
void cnv_free_image( ImlibImage *image, Pixmap pixmap)
{
Imlib_free_pixmap( imlib, pixmap);
Imlib_destroy_image( imlib, image);
}
#ifndef cnv_image_h
#define cnv_image_h
#include <stdlib.h>
#include <Xm/Xm.h>
#include <Mrm/MrmPublic.h>
#ifndef _XtIntrinsic_h
#include <X11/Intrinsic.h>
#endif
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#if defined OS_LINUX
#define IMLIB 1
#endif
#if defined IMLIB
# if defined OS_LYNX
# define __NO_INCLUDE_WARN__ 1
# endif
# include <X11/extensions/shape.h>
# include <Imlib.h>
# if defined OS_LYNX
# undef __NO_INCLUDE_WARN__
# endif
#else
typedef void *ImlibData;
typedef void *ImlibImage;
#endif
int cnv_get_image( char *fname, ImlibImage **image, Pixmap *pixmap);
void cnv_free_image( ImlibImage *image, Pixmap pixmap);
#endif
......@@ -10,15 +10,18 @@ extern "C" {
#include "co_dcli.h"
#include "co_cdh.h"
}
#include "cnv_classread.h"
#include "cnv_ctx.h"
#include "cnv_readsrc.h"
#include "cnv_wblto.h"
int ClassRead::src_read( char *filename)
int CnvReadSrc::read_src( char *filename)
{
int sts;
char orig_line[400];
char line[400];
char line_part[4][80];
int nr;
FILE *fp;
fp = fopen( filename, "r");
if ( !fp)
......@@ -27,23 +30,23 @@ int ClassRead::src_read( char *filename)
state = 0;
doc_fresh = 0;
src_html_init( filename);
html_init( filename);
while( 1)
{
sts = read_line( orig_line, sizeof(orig_line), fp);
sts = CnvCtx::read_line( orig_line, sizeof(orig_line), fp);
if ( !sts)
linetype = cread_eLine_EOF;
else
{
remove_spaces( orig_line, line);
CnvCtx::remove_spaces( orig_line, line);
if ( strcmp( line, "") == 0)
continue;
if ( strncmp( line, "/*_*", 4) != 0 &&
!(state & cread_mState_Doc))
{
src_html_line( orig_line);
html_line( orig_line);
continue;
}
......@@ -81,7 +84,7 @@ int ClassRead::src_read( char *filename)
strcpy( src_aref, line_part[1]);
if ( nr > 2)
strcpy( src_aref_text, line_part[2]);
src_html_aref();
html_aref();
}
if ( strstr( line, "*/"))
state &= ~cread_mState_Doc;
......@@ -91,23 +94,23 @@ int ClassRead::src_read( char *filename)
break;
}
if ( generate_html && html_class_open)
html_class_close();
if ( generate_xtthelp && xtthelp_index_open)
xtthelp_class_close();
if ( ctx->generate_html && ctx->wblto && ctx->wblto->class_open())
ctx->wblto->class_close();
if ( ctx->generate_xtthelp && ctx->wblto && ctx->wblto->index_open())
ctx->wblto->class_close();
fclose(fp);
src_html_close();
html_close();
return 1;
}
int ClassRead::src_html_init( char *filename)
int CnvReadSrc::html_init( char *filename)
{
char fname[200];
char dir_fname[200];
src_filename_to_html( fname, filename);
strcpy( dir_fname, dir);
filename_to_html( fname, filename);
strcpy( dir_fname, ctx->dir);
strcat( dir_fname, fname);
// Open html file
......@@ -135,7 +138,7 @@ filename << endl <<
return 1;
}
int ClassRead::src_html_close()
int CnvReadSrc::html_close()
{
fp_src_html <<
"</XMP></CODE>" << endl <<
......@@ -146,14 +149,14 @@ int ClassRead::src_html_close()
return 1;
}
int ClassRead::src_html_line( char *line)
int CnvReadSrc::html_line( char *line)
{
fp_src_html << line << endl;
return 1;
}
int ClassRead::src_html_aref()
int CnvReadSrc::html_aref()
{
fp_src_html <<
"</XMP></CODE>" << endl <<
......@@ -164,7 +167,7 @@ int ClassRead::src_html_aref()
return 1;
}
void ClassRead::src_filename_to_html( char *fname, char *filename)
void CnvReadSrc::filename_to_html( char *fname, char *filename)
{
char *s;
......@@ -186,3 +189,11 @@ void ClassRead::src_filename_to_html( char *fname, char *filename)
*s = '_';
strcat( fname, ".html");
}
char *CnvReadSrc::low( char *in)
{
static char str[400];
cdh_ToLower( str, in);
return str;
}
#ifndef cnv_readsrc_h
#define cnv_readsrc_h
/* cnv_readsrc.h -- Read source files
PROVIEW/R
Copyright (C) 1996 by Comator Process AB.
<Description>. */
#if defined __cplusplus
extern "C" {
#endif
#include "pwr.h"
#include "cnv_ctx.h"
#include "cnv_readwbl.h"
using namespace std;
class CnvReadSrc {
public:
CnvReadSrc( CnvCtx *cnv_ctx) :
ctx(cnv_ctx), state(0), linetype(cread_eLine_No), doc_fresh(0),
html_class_open(0)
{}
CnvCtx *ctx;
int state;
char src_aref[80];
char src_aref_text[200];
ofstream fp_src_html;
cread_eLine linetype;
int doc_fresh;
int html_class_open;
int read_src( char *filename);
int html_init( char *filename);
int html_close();
int html_line( char *line);
int html_aref();
static void filename_to_html( char *fname, char *filename);
char *low( char *in);
};
#if defined __cplusplus
}
#endif
#endif
......@@ -10,13 +10,16 @@ extern "C" {
#include "co_dcli.h"
#include "co_cdh.h"
}
#include "cnv_classread.h"
#include "cnv_ctx.h"
#include "cnv_readwbl.h"
#include "cnv_wblto.h"
#include "cnv_ctx.h"
#define CNV__UNKNOWN_LINETYPE 2
static int tlog = 0;
int ClassRead::read( char *filename)
int CnvReadWbl::read_wbl( char *filename)
{
int sts;
int return_sts = 1;
......@@ -50,15 +53,13 @@ int ClassRead::read( char *filename)
state = 0;
doc_fresh = 0;
while( 1)
{
sts = read_line( line, sizeof(line), fp);
while( 1) {
sts = CnvCtx::read_line( line, sizeof(line), fp);
if ( !sts)
linetype = cread_eLine_EOF;
else
{
else {
line_cnt++;
remove_spaces( line, line);
CnvCtx::remove_spaces( line, line);
if ( strcmp( line, "") == 0)
continue;
......@@ -223,8 +224,7 @@ int ClassRead::read( char *filename)
linetype = cread_eLine_Unknown;
sts = 1;
switch( linetype)
{
switch( linetype) {
case cread_eLine_Doc:
state |= cread_mState_Doc;
sts = object_close();
......@@ -385,39 +385,38 @@ int ClassRead::read( char *filename)
state &= ~cread_mState_ObjXRef;
else if ( state & cread_mState_Buffer)
state &= ~cread_mState_Buffer;
else if ( state & cread_mState_ObjBodyDef)
{
else if ( state & cread_mState_ObjBodyDef) {
state &= ~cread_mState_ObjBodyDef;
if ( generate_html)
html_body_close();
if ( generate_struct)
struct_body_close();
if ( wblto->type() == Cnv_eWblToType_Html ||
wblto->type() == Cnv_eWblToType_H)
wblto->body_close();
}
else if ( state & cread_mState_GraphPlcNode)
{
else if ( state & cread_mState_GraphPlcNode) {
state &= ~cread_mState_GraphPlcNode;
if ( generate_html)
html_body_close();
if ( wblto->type() == Cnv_eWblToType_Html)
wblto->body_close();
}
else if ( state & cread_mState_GraphPlcCon)
{
else if ( state & cread_mState_GraphPlcCon) {
state &= ~cread_mState_GraphPlcCon;
if ( generate_html)
html_body_close();
if ( wblto->type() == Cnv_eWblToType_Html)
wblto->body_close();
}
else if ( state & cread_mState_Template)
{
else if ( state & cread_mState_Template) {
state &= ~cread_mState_Template;
if ( generate_html)
html_body_close();
if ( wblto->type() == Cnv_eWblToType_Html)
wblto->body_close();
}
else if ( state & cread_mState_ClassDef && classdef_level == object_level) {
if (tlog) printf( "Cd %7d %3d %s\n", line_cnt, object_level, line);
state &= ~cread_mState_ClassDef;
if ( generate_html && html_class_open && classdef_level == object_level)
html_class_close();
if ( generate_struct && struct_class_open && classdef_level == object_level)
struct_class_close();
if ( wblto->type() == Cnv_eWblToType_Html &&
wblto->class_open() &&
classdef_level == object_level)
wblto->class_close();
if ( wblto->type() == Cnv_eWblToType_H &&
wblto->class_open() &&
classdef_level == object_level)
wblto->class_close();
}
else if ( state & cread_mState_Bit) {
state &= ~cread_mState_Bit;
......@@ -429,14 +428,16 @@ int ClassRead::read( char *filename)
// object_state = cread_mState_TypeDef;
object_level--;
}
else if ( state & cread_mState_TypeDef && classdef_level == object_level) {
else if ( state & cread_mState_TypeDef && classdef_level == object_level) {
state &= ~cread_mState_TypeDef;
if ( generate_html && html_class_open)
html_typedef_close();
if ( generate_struct && struct_class_open)
struct_typedef_close();
if ( wblto->type() == Cnv_eWblToType_Html &&
wblto->class_open())
wblto->typedef_close();
if ( wblto->type() == Cnv_eWblToType_H &&
wblto->class_open())
wblto->typedef_close();
}
else if ( state & cread_mState_Type) {
else if ( state & cread_mState_Type) {
state &= ~cread_mState_Type;
#if 0
if ( generate_html && html_class_open)
......@@ -445,8 +446,7 @@ int ClassRead::read( char *filename)
struct_class_close();
#endif
}
else if ( state & cread_mState_Object)
{
else if ( state & cread_mState_Object) {
object_level--;
if ( object_level <= 0)
state &= ~cread_mState_Object;
......@@ -456,22 +456,19 @@ int ClassRead::read( char *filename)
printf( "Error: mismatch in Object-Endobject nesting, at line %d\n",
line_cnt);
break;
case cread_eLine_Attr:
{
case cread_eLine_Attr: {
char attr_name[80];
char attr_value[100];
int oreq = 0;
if ( strcmp( line_part[2], "|") == 0)
{
if ( strcmp( line_part[2], "|") == 0) {
strcpy( line_part[2], line_part[3]);
oreq = 1;
}
strcpy( attr_name, line_part[1]);
strcpy( attr_value, line_part[2]);
switch ( object_state)
{
switch ( object_state) {
case cread_mState_Input:
case cread_mState_Output:
case cread_mState_Intern:
......@@ -520,22 +517,19 @@ int ClassRead::read( char *filename)
break;
}
case cread_eLine_DAttr:
{
case cread_eLine_DAttr: {
char attr_name[80];
char attr_value[100];
int oreq = 0;
if ( strcmp( line_part[3], "|") == 0)
{
if ( strcmp( line_part[3], "|") == 0) {
strcpy( line_part[3], line_part[4]);
oreq = 1;
}
strcpy( attr_name, line_part[1]);
strcpy( attr_value, line_part[3]);
switch ( object_state)
{
switch ( object_state) {
case cread_mState_DParam:
case cread_mState_Input:
case cread_mState_Output:
......@@ -569,8 +563,7 @@ int ClassRead::read( char *filename)
}
break;
}
case cread_eLine_Buffer:
{
case cread_eLine_Buffer: {
sts = object_close();
state |= cread_mState_Buffer;
object_state = cread_mState_Buffer;
......@@ -579,8 +572,7 @@ int ClassRead::read( char *filename)
attribute_init();
break;
}
case cread_eLine_GraphPlcNode:
{
case cread_eLine_GraphPlcNode: {
sts = object_close();
state |= cread_mState_GraphPlcNode;
object_state = cread_mState_GraphPlcNode;
......@@ -588,8 +580,7 @@ int ClassRead::read( char *filename)
strcpy( graphplcnode_name, line_part[1]);
break;
}
case cread_eLine_GraphPlcCon:
{
case cread_eLine_GraphPlcCon: {
sts = object_close();
state |= cread_mState_GraphPlcCon;
object_state = cread_mState_GraphPlcCon;
......@@ -597,8 +588,7 @@ int ClassRead::read( char *filename)
strcpy( graphplccon_name, line_part[1]);
break;
}
case cread_eLine_Object:
{
case cread_eLine_Object: {
sts = object_close();
state |= cread_mState_Object;
object_state = cread_mState_Object;
......@@ -606,14 +596,12 @@ int ClassRead::read( char *filename)
if (tlog) printf( "Oo %7d %3d %s\n", line_cnt, object_level, line);
break;
}
case cread_eLine_Volume:
{
case cread_eLine_Volume: {
state |= cread_mState_Volume;
strcpy( volume_name, line_part[1]);
break;
}
case cread_eLine_EndVolume:
{
case cread_eLine_EndVolume: {
if ( state & cread_mState_Volume)
state &= ~cread_mState_Volume;
break;
......@@ -630,8 +618,7 @@ int ClassRead::read( char *filename)
printf( "Error, unknown linetype, %s, at line %d\n", filename, line_cnt);
return sts = CNV__UNKNOWN_LINETYPE;
}
if ( EVEN(sts))
{
if ( EVEN(sts)) {
printf( ", at line %d\n", line_cnt);
return_sts = sts;
}
......@@ -641,19 +628,24 @@ int ClassRead::read( char *filename)
break;
}
if ( generate_html && html_class_open)
html_class_close();
if ( generate_xtthelp && xtthelp_index_open)
xtthelp_class_close();
if ( generate_struct && html_class_open)
struct_class_close();
if ( wblto->type() == Cnv_eWblToType_Html &&
wblto->class_open())
wblto->class_close();
if ( wblto->type() == Cnv_eWblToType_H &&
wblto->class_open())
wblto->class_close();
if ( wblto->type() == Cnv_eWblToType_Xtthelp &&
wblto->index_open())
wblto->class_close();
if ( wblto->type() == Cnv_eWblToType_Ps)
wblto->class_close();
fclose(fp);
return return_sts;
}
void ClassRead::attribute_init()
void CnvReadWbl::attribute_init()
{
strcpy( attr_flags, "");
strcpy( attr_typeref, "");
......@@ -667,15 +659,13 @@ void ClassRead::attribute_init()
attr_isclass = 0;
}
int ClassRead::attribute_attr( char *name, char *value)
int CnvReadWbl::attribute_attr( char *name, char *value)
{
char *s;
int nr;
if ( strcmp( low( name), "typeref") == 0)
{
if ((s = strrchr( value, '-')))
{
if ( strcmp( low( name), "typeref") == 0) {
if ((s = strrchr( value, '-'))) {
s++;
if ( *s == '$')
s++;
......@@ -689,8 +679,7 @@ int ClassRead::attribute_attr( char *name, char *value)
else
strcpy( attr_typeref, value);
}
else if ( strcmp( low( name), "flags") == 0)
{
else if ( strcmp( low( name), "flags") == 0) {
if ( strncmp( value, "PWR_MASK_", 9) == 0) {
if ( strcmp( attr_flags, "") != 0)
strcat( attr_flags, " | ");
......@@ -726,55 +715,42 @@ int ClassRead::attribute_attr( char *name, char *value)
attr_isclass = 1;
}
}
else if ( strcmp( low( name), "elements") == 0)
{
else if ( strcmp( low( name), "elements") == 0) {
strcpy( attr_elements, value);
nr = sscanf( attr_elements, "%d", &attr_elem);
if ( nr == 0)
attr_elem = 0;
}
else if ( strcmp( low( name), "class") == 0)
{
else if ( strcmp( low( name), "class") == 0) {
strcpy( attr_typeref, value);
}
else if ( strcmp( low( name), "pgmname") == 0)
{
else if ( strcmp( low( name), "pgmname") == 0) {
strcpy( attr_pgmname, value);
}
return 1;
}
int ClassRead::attribute_close()
int CnvReadWbl::attribute_close()
{
int sts;
if ( generate_html)
sts = html_attribute();
if ( generate_xtthelp)
sts = xtthelp_attribute();
if ( generate_struct)
sts = struct_attribute();
sts = wblto->attribute_exec();
doc_fresh = 0;
return sts;
}
int ClassRead::bit_close()
int CnvReadWbl::bit_close()
{
int sts;
if ( generate_html)
sts = html_bit();
if ( generate_xtthelp)
sts = xtthelp_bit();
if ( generate_struct)
sts = struct_bit();
sts = wblto->bit_exec();
doc_fresh = 0;
return sts;
}
void ClassRead::class_init()
void CnvReadWbl::class_init()
{
strcpy( class_name, "");
strcpy( class_editor, "");
......@@ -784,30 +760,26 @@ void ClassRead::class_init()
class_devonly = 0;
}
int ClassRead::class_attr( char *name, char *value)
int CnvReadWbl::class_attr( char *name, char *value)
{
if ( strcmp( low( name), "editor") == 0)
{
if ( strcmp( low( name), "editor") == 0) {
if ( strncmp( value, "pwr_eEditor_", 12) == 0)
strcpy( class_editor, &value[12]);
else
strcpy( class_editor, value);
}
else if ( strcmp( low( name), "method") == 0)
{
else if ( strcmp( low( name), "method") == 0) {
if ( strncmp( value, "pwr_eMethod_", 12) == 0)
strcpy( class_method, &value[12]);
else
strcpy( class_method, value);
}
else if ( strcmp( low( name), "popeditor") == 0)
{
else if ( strcmp( low( name), "popeditor") == 0) {
strcpy( class_method, value);
}
else if ( strcmp( low( name), "flags") == 0)
{
else if ( strcmp( low( name), "flags") == 0) {
if ( strcmp( class_flags, "") != 0)
strcat( class_flags, " | ");
if ( strncmp( value, "pwr_mClassDef_", 14) == 0)
......@@ -821,32 +793,21 @@ int ClassRead::class_attr( char *name, char *value)
return 1;
}
int ClassRead::class_close()
int CnvReadWbl::class_close()
{
if ( first_class)
{
if ( generate_html)
html_init( class_name);
if ( generate_xtthelp)
xtthelp_init();
if ( generate_struct)
struct_init();
first_class = 0;
if ( ctx->first_class) {
wblto->init( class_name);
ctx->first_class = 0;
}
if ( generate_html)
html_class();
if ( generate_xtthelp)
xtthelp_class();
if ( generate_struct)
struct_class();
wblto->class_exec();
doc_fresh = 0;
return 1;
}
void ClassRead::body_init()
void CnvReadWbl::body_init()
{
strcpy( body_name, "");
strcpy( body_structname, "");
......@@ -854,14 +815,12 @@ void ClassRead::body_init()
body_rtvirtual = 0;
}
int ClassRead::body_attr( char *name, char *value)
int CnvReadWbl::body_attr( char *name, char *value)
{
if ( strcmp( low( name), "structname") == 0)
{
if ( strcmp( low( name), "structname") == 0) {
strcpy( body_structname, value);
}
else if ( strcmp( low( name), "flags") == 0)
{
else if ( strcmp( low( name), "flags") == 0) {
if ( strcmp( body_flags, "") != 0)
strcat( body_flags, " | ");
if ( strncmp( value, "pwr_mObjBodyDef_", 16) == 0)
......@@ -875,36 +834,33 @@ int ClassRead::body_attr( char *name, char *value)
return 1;
}
int ClassRead::body_close()
int CnvReadWbl::body_close()
{
int sts;
if ( generate_html)
html_body();
if ( generate_xtthelp)
xtthelp_body();
if ( generate_struct)
{
sts = struct_body();
if ( wblto->type() == Cnv_eWblToType_H) {
sts = wblto->body_exec();
if ( EVEN(sts)) return sts;
}
else
wblto->body_exec();
doc_fresh = 0;
return 1;
}
void ClassRead::graphplcnode_init()
void CnvReadWbl::graphplcnode_init()
{
doc_cnt = 0;
}
int ClassRead::graphplcnode_attr( char *name, char *value)
int CnvReadWbl::graphplcnode_attr( char *name, char *value)
{
strcpy( doc_text[doc_cnt++], name);
strcpy( doc_text[doc_cnt++], value);
// Description of methods
if ( strcmp( low( name), "graphmethod") == 0)
{
if ( strcmp( low( name), "graphmethod") == 0) {
if ( strcmp( value, "0") == 0)
strcat( doc_text[doc_cnt-1], " (standard, individual attributes)");
else if ( strcmp( value, "1") == 0)
......@@ -931,20 +887,19 @@ int ClassRead::graphplcnode_attr( char *name, char *value)
return 1;
}
int ClassRead::graphplcnode_close()
int CnvReadWbl::graphplcnode_close()
{
if ( generate_html)
html_graphplcnode();
wblto->graphplcnode();
doc_fresh = 0;
return 1;
}
void ClassRead::graphplccon_init()
void CnvReadWbl::graphplccon_init()
{
doc_cnt = 0;
}
int ClassRead::graphplccon_attr( char *name, char *value)
int CnvReadWbl::graphplccon_attr( char *name, char *value)
{
strcpy( doc_text[doc_cnt++], name);
strcpy( doc_text[doc_cnt++], value);
......@@ -961,35 +916,33 @@ int ClassRead::graphplccon_attr( char *name, char *value)
return 1;
}
int ClassRead::graphplccon_close()
int CnvReadWbl::graphplccon_close()
{
if ( generate_html)
html_graphplccon();
wblto->graphplccon();
doc_fresh = 0;
return 1;
}
void ClassRead::template_init()
void CnvReadWbl::template_init()
{
doc_cnt = 0;
}
int ClassRead::template_attr( char *name, char *value)
int CnvReadWbl::template_attr( char *name, char *value)
{
strcpy( doc_text[doc_cnt++], name);
strcpy( doc_text[doc_cnt++], value);
return 1;
}
int ClassRead::template_close()
int CnvReadWbl::template_close()
{
if ( generate_html)
html_template();
wblto->template_exec();
doc_fresh = 0;
return 1;
}
void ClassRead::volume_init()
void CnvReadWbl::volume_init()
{
char *s;
......@@ -999,7 +952,7 @@ void ClassRead::volume_init()
}
void ClassRead::doc_init()
void CnvReadWbl::doc_init()
{
doc_cnt = 0;
strcpy( doc_author, "");
......@@ -1016,7 +969,7 @@ void ClassRead::doc_init()
doc_group_cnt = 0;
}
int ClassRead::doc_add( char *line)
int CnvReadWbl::doc_add( char *line)
{
char line_part[4][80];
int nr;
......@@ -1043,8 +996,8 @@ int ClassRead::doc_add( char *line)
else if ( strcmp( low(line_part[1]), "@group") == 0) {
char str[400];
remove_spaces( line, str);
remove_spaces( &str[6], str);
CnvCtx::remove_spaces( line, str);
CnvCtx::remove_spaces( &str[6], str);
doc_group_cnt = dcli_parse( str, " ,", "", (char *)doc_groups,
sizeof( doc_groups) / sizeof( doc_groups[0]),
sizeof( doc_groups[0]), 0);
......@@ -1105,18 +1058,17 @@ int ClassRead::doc_add( char *line)
return 1;
}
int ClassRead::doc_close()
int CnvReadWbl::doc_close()
{
doc_fresh = 1;
return 1;
}
int ClassRead::object_close()
int CnvReadWbl::object_close()
{
int sts;
switch ( object_state)
{
switch ( object_state) {
case 0:
break;
case cread_mState_Input:
......@@ -1162,7 +1114,7 @@ int ClassRead::object_close()
return 1;
}
void ClassRead::typedef_init()
void CnvReadWbl::typedef_init()
{
strcpy( typedef_name, "");
strcpy( typedef_typeref, "");
......@@ -1170,35 +1122,32 @@ void ClassRead::typedef_init()
typedef_elements = 0;
}
void ClassRead::bit_init()
void CnvReadWbl::bit_init()
{
strcpy( bit_text, "");
strcpy( bit_pgmname, "");
bit_value = 0;
}
int ClassRead::typedef_attr( char *name, char *value)
int CnvReadWbl::typedef_attr( char *name, char *value)
{
if ( strcmp( low( name), "typeref") == 0)
{
if ( strcmp( low( name), "typeref") == 0) {
if ( strncmp( value, "pwrs:Type-$", 11) == 0)
strcpy( typedef_typeref, &value[11]);
else
strcpy( typedef_typeref, value);
}
if ( strcmp( low( name), "pgmname") == 0)
{
if ( strcmp( low( name), "pgmname") == 0) {
strcpy( typedef_pgmname, value);
}
else if ( strcmp( low( name), "elements") == 0)
{
else if ( strcmp( low( name), "elements") == 0) {
sscanf( value, "%d", &typedef_elements);
}
return 1;
}
int ClassRead::bit_attr( char *name, char *value)
int CnvReadWbl::bit_attr( char *name, char *value)
{
if ( strcmp( low( name), "text") == 0) {
strcpy( bit_text, value);
......@@ -1212,32 +1161,28 @@ int ClassRead::bit_attr( char *name, char *value)
return 1;
}
int ClassRead::typedef_close()
int CnvReadWbl::typedef_close()
{
if ( first_class) {
if ( generate_html)
html_init( typedef_name);
if ( generate_struct)
struct_init();
if ( generate_xtthelp)
xtthelp_init();
if ( ctx->first_class) {
wblto->init( typedef_name);
first_class = 0;
ctx->first_class = 0;
}
if ( generate_html)
html_typedef();
if ( generate_struct &&
if ( wblto->type() == Cnv_eWblToType_Html ||
wblto->type() == Cnv_eWblToType_Ps)
wblto->typedef_exec();
if ( wblto->type() == Cnv_eWblToType_H &&
object_state == cread_mState_TypeDef)
struct_typedef();
wblto->typedef_exec();
doc_fresh = 0;
return 1;
}
char *ClassRead::low( char *in)
char *CnvReadWbl::low( char *in)
{
static char str[400];
......@@ -1245,49 +1190,7 @@ char *ClassRead::low( char *in)
return str;
}
int ClassRead::remove_spaces(
char *in,
char *out)
{
char *s;
for ( s = in; !((*s == 0) || ((*s != ' ') && (*s != 9))); s++);
strcpy( out, s);
s = out;
if ( strlen(s) != 0)
{
for ( s += strlen(s) - 1;
!((s == out) || ((*s != ' ') && (*s != 9))); s--) ;
s++;
*s = 0;
}
return 1;
}
int ClassRead::read_line(
char *line,
int maxsize,
FILE *file)
{
char *s;
if (fgets( line, maxsize, file) == NULL)
return 0;
line[maxsize-1] = 0;
s = strchr( line, 10);
if ( s != 0)
*s = 0;
s = strchr( line, 13);
if ( s != 0)
*s = 0;
return 1;
}
int ClassRead::copy_tmp_file( char *tmpfilename, ofstream& fp_to)
int CnvReadWbl::copy_tmp_file( char *tmpfilename, ofstream& fp_to)
{
FILE *fp;
char c;
......@@ -1310,7 +1213,7 @@ int ClassRead::copy_tmp_file( char *tmpfilename, ofstream& fp_to)
return 1;
}
char *ClassRead::flags_to_string( int value)
char *CnvReadWbl::flags_to_string( int value)
{
static char str[40];
......
#ifndef cnv_readwbl_h
#define cnv_readwbl_h
/* cnv_readwbl.h -- Documentation
PROVIEW/R
Copyright (C) 1996 by Comator Process AB.
<Description>. */
#if defined __cplusplus
extern "C" {
#endif
#include "pwr.h"
using namespace std;
class CnvCtx;
class CnvWblTo;
#define MAX_GROUPS 100
typedef enum {
cread_eLine_No,
cread_eLine_EOF,
cread_eLine_SObject,
cread_eLine_EndSObject,
cread_eLine_ClassDef,
cread_eLine_ObjBodyDef,
cread_eLine_SysBody,
cread_eLine_RtBody,
cread_eLine_DevBody,
cread_eLine_EndBody,
cread_eLine_Input,
cread_eLine_Output,
cread_eLine_Intern,
cread_eLine_Attribute,
cread_eLine_ObjXRef,
cread_eLine_Attr,
cread_eLine_GraphPlcNode,
cread_eLine_GraphPlcCon,
cread_eLine_Buffer,
cread_eLine_Object,
cread_eLine_EndObject,
cread_eLine_Doc,
cread_eLine_DocEnd,
cread_eLine_Template,
cread_eLine_Comment,
cread_eLine_Volume,
cread_eLine_EndVolume,
cread_eLine_DParam,
cread_eLine_DAttr,
cread_eLine_Buff,
cread_eLine_EndBuff,
cread_eLine_Range,
cread_eLine_TypeDef,
cread_eLine_Type,
cread_eLine_Bit,
cread_eLine_Value,
cread_eLine_Unknown
} cread_eLine;
typedef enum {
cread_mState_SObject = 1 << 0,
cread_mState_ClassDef = 1 << 1,
cread_mState_ObjBodyDef = 1 << 2,
cread_mState_SysBody = 1 << 3,
cread_mState_RtBody = 1 << 4,
cread_mState_DevBody = 1 << 5,
cread_mState_Input = 1 << 6,
cread_mState_Output = 1 << 7,
cread_mState_Intern = 1 << 8,
cread_mState_Attribute = 1 << 9,
cread_mState_ObjXRef = 1 << 10,
cread_mState_GraphPlcNode = 1 << 11,
cread_mState_GraphPlcCon = 1 << 12,
cread_mState_Buffer = 1 << 13,
cread_mState_Object = 1 << 14,
cread_mState_Doc = 1 << 15,
cread_mState_Template = 1 << 16,
cread_mState_Volume = 1 << 17,
cread_mState_DParam = 1 << 18,
cread_mState_TypeDef = 1 << 19,
cread_mState_Type = 1 << 20,
cread_mState_StringAttr = 1 << 21,
cread_mState_Bit = 1 << 22,
cread_mState_Value = 1 << 23
} cread_mState;
#define cread_cTmpFile1 "classread1.tmp"
#define cread_cTmpFile2 "classread2.tmp"
#define cread_cTmpFile3 "classread3.tmp"
class CnvFile {
public:
ofstream f;
};
class CnvReadWbl {
public:
CnvReadWbl( CnvCtx *cnv_ctx, CnvWblTo *cnv_wblto) :
ctx(cnv_ctx), wblto(cnv_wblto)
{}
~CnvReadWbl() {}
CnvCtx *ctx;
CnvWblTo *wblto;
FILE *fp;
cread_eLine linetype;
int verbose;
int state;
int object_state;
char source_dir[200];
char current_file[200];
char attr_name[80];
char attr_flags[200];
char attr_type[80];
char attr_typeref[80];
char attr_typeref_volume[80];
int attr_pointer;
int attr_array;
int attr_rtvirtual;
int attr_isclass;
char attr_elements[80];
int attr_elem;
char attr_pgmname[80];
char volume_name[80];
char class_id[80];
char class_name[80];
char class_editor[80];
char class_method[80];
char class_popeditor[80];
char class_flags[200];
int class_devonly;
char body_name[80];
char body_structname[80];
char body_flags[200];
int body_rtvirtual;
char graphplcnode_name[80];
char graphplccon_name[20];
char typedef_name[80];
char typedef_typeref[80];
int typedef_elements;
char typedef_pgmname[32];
char bit_name[80];
char bit_type[80];
int bit_value;
char bit_text[80];
char bit_pgmname[80];
char doc_author[200];
char doc_version[80];
char doc_groups[10][40];
int doc_group_cnt;
char doc_code[200];
char doc_link_ref[20][80];
char doc_link_text[20][200];
int doc_link_cnt;
char doc_clink_ref[20][80];
char doc_clink_text[20][200];
int doc_clink_cnt;
char doc_summary[400];
char doc_text[1000][200];
int doc_cnt;
int doc_fresh;
char sobject_name[80];
char dir[120];
char ClassDef[80];
char ObjBodyDef[80];
char GraphPlcNode[80];
char GraphPlcCon[80];
char Attribute[80];
int read_wbl( char *filename);
int read_line( char *line, int maxsize, FILE *file);
int remove_spaces( char *in, char *out);
void attribute_init();
int attribute_attr( char *name, char *value);
int attribute_close();
void class_init();
int class_attr( char *name, char *value);
int class_close();
void typedef_init();
int typedef_attr( char *name, char *value);
int typedef_close();
void bit_init();
int bit_attr( char *name, char *value);
int bit_close();
void body_init();
int body_attr( char *name, char *value);
int body_close();
void graphplcnode_init();
int graphplcnode_attr( char *name, char *value);
int graphplcnode_close();
void graphplccon_init();
int graphplccon_attr( char *name, char *value);
int graphplccon_close();
void template_init();
int template_attr( char *name, char *value);
int template_close();
void doc_init();
int doc_add( char *line);
int doc_close();
void volume_init();
int object_close();
char *low( char *in);
int copy_tmp_file( char *tmpfilename, ofstream& fp_to);
char *flags_to_string( int value);
};
#if defined __cplusplus
}
#endif
#endif
/* cnv_readxtthelp.cpp --
PROVIEW/R
Copyright (C) 1996-98 by Mandator AB.
Convert xtt help file to html. */
/*_Include files_________________________________________________________*/
#include <iostream.h>
#include <fstream.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
extern "C" {
#include "co_cdh.h"
#include "co_dcli.h"
}
#include "co_nav_help.h"
#include "cnv_readxtthelp.h"
#include "cnv_xtthelpto.h"
#define CNV_TAB 18
/* Nice functions */
#define ODD(a) (((int)(a) & 1) != 0)
#define EVEN(a) (((int)(a) & 1) == 0)
#define max(Dragon,Eagle) ((Dragon) > (Eagle) ? (Dragon) : (Eagle))
#define min(Dragon,Eagle) ((Dragon) < (Eagle) ? (Dragon) : (Eagle))
#ifndef __ALPHA
#define abs(Dragon) ((Dragon) >= 0 ? (Dragon) : (-(Dragon)))
#endif
CnvReadXtthelp::CnvReadXtthelp( char *x_name, char *x_directory,
CnvXtthelpTo *to) :
xtthelpto(to)
{
char *s;
strcpy( filename, x_name);
if ( (s = strrchr(x_name,'/')))
strcpy( name, s+1);
else
strcpy( name, x_name);
if ((s = strrchr( name, '.')))
*s = 0;
strcpy( directory, x_directory);
}
void *help_insert_cb( void *ctx, navh_eItemType item_type, char *text1,
char *text2, char *text3, char *link,
char *link_bookmark, char *file_name,
navh_eHelpFile file_type, int help_index,
char *bookmark)
{
CnvReadXtthelp *xh = (CnvReadXtthelp *)ctx;
return xh->xtthelpto->insert( item_type, text1, text2, text3, link,
link_bookmark, file_name, file_type, help_index,
bookmark);
}
int CnvReadXtthelp::read_xtthelp()
{
int sts;
void *bookmark_node;
if ( xtthelpto->confpass()) {
xtthelpto->set_confpass( true);
NavHelp *navhelp = new NavHelp( (void *)this, "$pwr_exe/wtt_help.dat",
"$pwrp_exe/xtt_help.dat");
navhelp->insert_cb = help_insert_cb;
navhelp->set_propagate(0); // Don't print include files
sts = navhelp->help( NULL, "", navh_eHelpFile_Other,
filename, &bookmark_node);
if ( EVEN(sts)) return sts;
delete navhelp;
xtthelpto->set_confpass( false);
}
NavHelp *navhelp = new NavHelp( (void *)this, "$pwr_exe/wtt_help.dat",
"$pwrp_exe/xtt_help.dat");
navhelp->insert_cb = help_insert_cb;
navhelp->set_propagate(0); // Don't print include files
sts = navhelp->help( NULL, "", navh_eHelpFile_Other,
filename, &bookmark_node);
if ( EVEN(sts)) return sts;
delete navhelp;
return 1;
}
#ifndef cnv_help_h
#define cnv_help_h
#ifndef cnv_xtthelpread_h
#define cnv_xtthelpread_h
/* cnv_help.h -- Documentation
/* cnv_xtthelpread.h -- Documentation
PROVIEW/R
Copyright (C) 1996 by Comator Process AB.
......@@ -13,16 +13,19 @@
extern "C" {
#endif
class XhelpToHtml {
class CnvXtthelpTo;
class CnvReadXtthelp {
public:
XhelpToHtml( char *x_name, char *x_directory);
CnvReadXtthelp( char *x_name, char *x_directory,
CnvXtthelpTo *to);
ofstream fp;
char directory[80];
char name[80];
char filename[120];
CnvXtthelpTo *xtthelpto;
void subject_to_fname( char *fname, char *subject, int path);
int generate();
int read_xtthelp();
};
......
......@@ -10,27 +10,29 @@ extern "C" {
#include "co_dcli.h"
#include "co_cdh.h"
}
#include "cnv_classread.h"
#include "cnv_ctx.h"
#include "cnv_setup.h"
int ClassRead::setup()
int CnvSetup::setup( char *filename)
{
int sts;
char line[400];
char line_part[4][80];
int nr;
char line_cnt = 0;
FILE *fp;
fp = fopen( setup_filename, "r");
fp = fopen( filename, "r");
if ( !fp)
return 0;
while( 1) {
sts = read_line( line, sizeof(line), fp);
sts = CnvCtx::read_line( line, sizeof(line), fp);
if ( !sts)
break;
else {
line_cnt++;
remove_spaces( line, line);
CnvCtx::remove_spaces( line, line);
if ( strcmp( line, "") == 0)
continue;
......@@ -41,21 +43,21 @@ int ClassRead::setup()
sizeof( line_part) / sizeof( line_part[0]),
sizeof( line_part[0]), 0);
if ( strcmp( low( line_part[0]), "group") == 0){
if ( strcmp( CnvCtx::low( line_part[0]), "group") == 0){
if ( nr < 2) {
printf("** Setup syntax error in file %s, line %d\n", setup_filename, line_cnt);
printf("** Setup syntax error in file %s, line %d\n", filename, line_cnt);
continue;
}
if ( setup_group_cnt >= (int)(sizeof(setup_groups)/sizeof(setup_groups[0]))) {
printf("** Max number of groups exceeded in file %s, line %d\n", setup_filename, line_cnt);
if ( group_cnt >= (int)(sizeof(groups)/sizeof(groups[0]))) {
printf("** Max number of groups exceeded in file %s, line %d\n", filename, line_cnt);
continue;
}
strcpy( setup_groups[setup_group_cnt], line_part[1]);
strcpy( groups[group_cnt], line_part[1]);
if ( nr >= 3)
strcpy( setup_groups_startpage[setup_group_cnt], line_part[2]);
strcpy( groups_startpage[group_cnt], line_part[2]);
else
strcpy( setup_groups_startpage[setup_group_cnt], "");
setup_group_cnt++;
strcpy( groups_startpage[group_cnt], "");
group_cnt++;
}
}
}
......
#ifndef cnv_setup_h
#define cnv_setup_h
/* cnv_setup.h -- Setup
PROVIEW/R
Copyright (C) 1996 by Comator Process AB.
<Description>. */
#if defined __cplusplus
extern "C" {
#endif
#include "pwr.h"
#define MAX_GROUPS 100
class CnvSetup {
public:
int group_cnt;
char groups[MAX_GROUPS][40];
char groups_startpage[MAX_GROUPS][80];
int setup( char *filename);
};
#if defined __cplusplus
}
#endif
#endif
#ifndef cnv_style_h
#define cnv_style_h
/* cnv_style.h -- Convert style
PROVIEW/R
Copyright (C) 1996 by Comator Process AB.
<Description>. */
using namespace std;
#include <iostream.h>
#include <vector.h>
#include <string>
#include "pwr.h"
typedef enum {
cnv_eAlignment_Left,
cnv_eAlignment_Center
} cnv_eAlignment;
class CnvStyle {
public:
CnvStyle() {}
CnvStyle( string s_font, int s_font_size, int s_indentation,
int s_top_offset, int s_bottom_offset, int s_alignment,
int s_pagebreak, int s_sidebreak, int s_display_number) :
font(s_font), font_size(s_font_size), indentation(s_indentation),
top_offset(s_top_offset), bottom_offset(s_bottom_offset),
alignment(s_alignment), pagebreak(s_pagebreak), sidebreak(s_sidebreak),
display_number(s_display_number)
{}
string font;
int font_size;
int indentation;
int top_offset;
int bottom_offset;
int alignment;
int pagebreak;
int sidebreak;
int display_number;
};
class CnvIdStyle {
public:
CnvIdStyle() {
h1 = CnvStyle( "Helvetica-Bold-ISOLatin1", 14, 0, 30, 25, cnv_eAlignment_Left, 0, 0, 1);
h2 = CnvStyle( "Helvetica-Bold-ISOLatin1", 12, 0, 25, 20, cnv_eAlignment_Left, 0, 0, 1);
h3 = CnvStyle( "Helvetica-Bold-ISOLatin1", 10, 0, 15, 10, cnv_eAlignment_Left, 0, 0, 1);
text = CnvStyle( "Helvetica-ISOLatin1", 10, 0, 11, 2, cnv_eAlignment_Left, 0, 0, 0);
boldtext = CnvStyle( "Helvetica-Bold-ISOLatin1", 10, 0, 11, 2, cnv_eAlignment_Left, 0, 0, 0);
link = CnvStyle( "Helvetica-Oblique-ISOLatin1", 8, 0, 11, 2, cnv_eAlignment_Left, 0, 0, 0);
image = CnvStyle( "Helvetica-Oblique-ISOLatin1", 10, 0, 10, 0, cnv_eAlignment_Left, 0, 0, 0);
code = CnvStyle( "Courier-ISOLatin1", 10, 0, 11, 2, cnv_eAlignment_Left, 0, 0, 0);
}
CnvStyle h1;
CnvStyle h2;
CnvStyle h3;
CnvStyle text;
CnvStyle boldtext;
CnvStyle link;
CnvStyle image;
CnvStyle code;
};
#endif
/* cnv_tops.cpp --
PROVIEW/R
Copyright (C) 1996-98 by Mandator AB.
Convert xtt help file to postscript. */
/*_Include files_________________________________________________________*/
#include <iostream.h>
#include <fstream.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
extern "C" {
#include "co_cdh.h"
#include "co_dcli.h"
}
#include "cnv_tops.h"
#include "co_lng.h"
#include "cnv_image.h"
#define CNV_TAB 18
#define ps_cHead "%!PS-Adobe-2.0 EPSF-1.2\n\
%%Creator: Proview co_convert\n\
%%EndComments\n\
\n\
/Helvetica findfont\n\
dup length dict begin\n\
{ 1 index /FID ne\n\
{def}\n\
{pop pop}\n\
ifelse\n\
} forall\n\
/Encoding ISOLatin1Encoding def\n\
currentdict\n\
end\n\
/Helvetica-ISOLatin1 exch definefont pop\n\
/Helvetica-Bold findfont\n\
dup length dict begin\n\
{ 1 index /FID ne\n\
{def}\n\
{pop pop}\n\
ifelse\n\
} forall\n\
/Encoding ISOLatin1Encoding def\n\
currentdict\n\
end\n\
/Helvetica-Bold-ISOLatin1 exch definefont pop\n\
/Helvetica-Oblique findfont\n\
dup length dict begin\n\
{ 1 index /FID ne\n\
{def}\n\
{pop pop}\n\
ifelse\n\
} forall\n\
/Encoding ISOLatin1Encoding def\n\
currentdict\n\
end\n\
/Helvetica-Oblique-ISOLatin1 exch definefont pop\n\
/TimesNewRoman findfont\n\
dup length dict begin\n\
{ 1 index /FID ne\n\
{def}\n\
{pop pop}\n\
ifelse\n\
} forall\n\
/Encoding ISOLatin1Encoding def\n\
currentdict\n\
end\n\
/TimesNewRoman-ISOLatin1 exch definefont pop\n\
/TimesNewRoman-Bold findfont\n\
dup length dict begin\n\
{ 1 index /FID ne\n\
{def}\n\
{pop pop}\n\
ifelse\n\
} forall\n\
/Encoding ISOLatin1Encoding def\n\
currentdict\n\
end\n\
/TimesNewRoman-Bold-ISOLatin1 exch definefont pop\n\
/Courier findfont\n\
dup length dict begin\n\
{ 1 index /FID ne\n\
{def}\n\
{pop pop}\n\
ifelse\n\
} forall\n\
/Encoding ISOLatin1Encoding def\n\
currentdict\n\
end\n\
/Courier-ISOLatin1 exch definefont pop\n\
1.000000 1.000000 scale\n\
save\n"
/* Nice functions */
#define ODD(a) (((int)(a) & 1) != 0)
#define EVEN(a) (((int)(a) & 1) == 0)
#define max(Dragon,Eagle) ((Dragon) > (Eagle) ? (Dragon) : (Eagle))
#define min(Dragon,Eagle) ((Dragon) < (Eagle) ? (Dragon) : (Eagle))
#ifndef __ALPHA
#define abs(Dragon) ((Dragon) >= 0 ? (Dragon) : (-(Dragon)))
#endif
void CnvToPs::cnv_text( char *to, char *from)
{
if ( !from) {
strcpy( to, "");
return;
}
char *t = to;
char *s = from;
for ( ; *s; s++) {
switch ( *s) {
case '(':
*t++ = '\\';
*t++ = '(';
break;
case ')':
*t++ = '\\';
*t++ = ')';
break;
case '\\':
*t++ = '\\';
*t++ = '\\';
default:
*t++ = *s;
}
}
*t = 0;
}
void CnvToPs::print_text( char *text, CnvStyle& style, int mode)
{
char str[1000];
cnv_text( str, text);
if ( style.sidebreak && mode & ps_mPrintMode_Pos) {
if ( page_number[cf] == 0) {
// First header, no pagebreak
page_number[cf] = 1;
}
else {
print_pagebreak( 1);
if ( EVEN(page_number[cf]))
print_pagebreak( 1);
}
}
else if ( style.pagebreak && mode & ps_mPrintMode_Pos)
print_pagebreak( 1);
if ( mode & ps_mPrintMode_Pos || mode & ps_mPrintMode_Start) {
y -= style.top_offset;
if ( y - style.bottom_offset < ps_cBottomMargin) {
print_pagebreak( 1);
}
}
else
y += style.bottom_offset;
if ( !(mode & ps_mPrintMode_FixX)) {
if ( style.alignment == cnv_eAlignment_Center) {
x = ps_cLeftMargin/2 + (ps_cPageWidth - ps_cLeftMargin/2)/ 2 -
0.50 * strlen(text) * style.font_size / 2;
if ( x < ps_cLeftMargin/2)
x = ps_cLeftMargin/2;
}
else
x = ps_cLeftMargin + style.indentation;
}
int pmode = mode & 31;
if ( !conf_pass) {
if ( strcmp( text, "") != 0) {
switch ( pmode) {
case ps_mPrintMode_Pos:
case ps_mPrintMode_KeepY: {
// Full path with beginning and end
fp[cf] <<
"/" << style.font << " findfont" << endl <<
style.font_size << " scalefont" << endl <<
"setfont" << endl <<
"newpath" << endl <<
x << " " << y << " moveto" << endl <<
"("<< str << ") show" << endl <<
"closepath" << endl <<
"stroke" << endl;
break;
}
case ps_mPrintMode_Start: {
// Start new path
fp[cf] <<
"/" << style.font << " findfont" << endl <<
style.font_size << " scalefont" << endl <<
"setfont" << endl <<
"newpath" << endl <<
x << " " << y << " moveto" << endl <<
"("<< str << ") show" << endl;
break;
}
case ps_mPrintMode_Continue: {
// Continue current path
fp[cf] <<
"/" << style.font << " findfont" << endl <<
style.font_size << " scalefont" << endl <<
"setfont" << endl <<
"("<< str << ") show" << endl;
break;
}
case ps_mPrintMode_End: {
// Continue and close current path
fp[cf] <<
"/" << style.font << " findfont" << endl <<
style.font_size << " scalefont" << endl <<
"setfont" << endl <<
"("<< str << ") show" << endl <<
"closepath" << endl <<
"stroke" << endl;
break;
}
default: ;
}
}
else {
switch ( pmode) {
case ps_mPrintMode_Start: {
// Start new path
fp[cf] <<
"newpath" << endl <<
x << " " << y << " moveto" << endl;
break;
}
case ps_mPrintMode_End: {
// Continue and close current path
fp[cf] <<
"closepath" << endl <<
"stroke" << endl;
break;
}
default: ;
}
}
}
y -= style.bottom_offset;
}
void CnvToPs::print_pagebreak( int printnum)
{
if ( printnum && !conf_pass && cf != ps_eFile_Info) {
double page_x;
if ( page_number[cf] == 0) {
page_number[cf]++;
return;
}
if ( ODD(page_number[cf]))
page_x = ps_cPageNumX;
else
page_x = 40;
fp[cf] <<
"newpath" << endl <<
10 << " " <<ps_cPageHeight - 20 << " moveto" << endl <<
ps_cPageWidth + 90 << " " << ps_cPageHeight - 20 << " lineto" << endl <<
ps_cPageWidth + 90 << " " << ps_cPageHeight - 20 << " moveto" << endl <<
"closepath" << endl <<
"stroke" << endl <<
"/Helvetica-ISOLatin1 findfont" << endl <<
"10 scalefont" << endl <<
"setfont" << endl <<
"newpath" << endl <<
ps_cPageWidth / 2 - 10 * 0.5 * strlen(previous_chapter) << " " << ps_cPageNumY << " moveto" << endl <<
"(" << previous_chapter << ") show" << endl <<
"closepath" << endl <<
"stroke" << endl <<
"newpath" << endl <<
page_x << " " << ps_cPageNumY << " moveto" << endl <<
"(" << page_number[cf] << ") show" << endl <<
"closepath" << endl <<
"stroke" << endl;
}
page_number[cf]++;
if ( !conf_pass) {
fp[cf] <<
"save" << endl <<
"showpage" << endl <<
"restore" << endl;
}
y = ps_cPageHeight - ps_cTopMargin;
}
void CnvToPs::print_content()
{
cf = ps_eFile_Info;
ci = ps_eId_Content;
x = ps_cLeftMargin;
y = ps_cPageHeight - ps_cTopMargin;
print_pagebreak( 0);
print_text( Lng::translate("Contents"), style[ci].h1);
for ( int i = 0; i < (int)content.tab.size(); i++) {
char page_str[20];
CnvStyle *cstyle = &style[ci].boldtext;
fp[cf] <<
"gsave" << endl <<
"[1 3] 0 setdash" << endl;
sprintf( page_str, "%d", content.tab[i].page_number);
print_text( content.tab[i].header_number, *cstyle);
x = ps_cLeftMargin + 30 + content.tab[i].header_level * 5;
y += cstyle->top_offset + cstyle->bottom_offset;
print_text( content.tab[i].text, *cstyle, ps_mPrintMode_Start | ps_mPrintMode_FixX);
x = ps_cLeftMargin + 340;
fp[cf] <<
x << " " << y + cstyle->bottom_offset << " lineto" << endl <<
x << " " << y + cstyle->bottom_offset << " moveto" << endl <<
"closepath" << endl <<
"stroke" << endl <<
"grestore" << endl;
print_text( page_str, *cstyle, ps_mPrintMode_KeepY | ps_mPrintMode_FixX);
}
print_pagebreak(0);
if ( ODD(page_number[ps_eFile_Info]))
print_pagebreak(0);
}
CnvToPs::~CnvToPs()
{
}
void CnvToPs::close()
{
cf = ps_eFile_Body;
print_pagebreak( 1);
cf = ps_eFile_Info;
print_content();
if ( !conf_pass) {
fp[ps_eFile_Info].close();
fp[ps_eFile_Body].close();
}
char cmd[256];
// Concatenate files
sprintf( cmd, "cat %s >> %s", filename[ps_eFile_Body],
filename[ps_eFile_Info]);
system( cmd);
}
void CnvToPs::print_horizontal_line()
{
y -= 3;
if ( !conf_pass) {
fp[cf] <<
"newpath" << endl <<
ps_cLeftMargin - 50 << " " << y << " moveto" << endl <<
ps_cPageWidth << " " << y << " lineto" << endl <<
ps_cPageWidth << " " << y << " moveto" << endl <<
"closepath" << endl <<
"stroke" << endl;
}
y -= 3;
}
int CnvToPs::print_image( char *filename)
{
ImlibImage *image;
Pixmap pixmap;
pwr_tFileName fname;
int sts;
int width, height;
unsigned char *rgb;
unsigned char transp[3] = {255,0,255};
int i, j;
int grey;
double scalex = 0.71;
double scaley = 0.78;
x = ps_cLeftMargin;
strcpy( fname, "$pwr_doc/help/");
strcat( fname, filename);
dcli_translate_filename( fname, fname);
sts = cnv_get_image( fname, &image, &pixmap);
if ( EVEN(sts)) return 0;
width = image->rgb_width;
height = image->rgb_height;
if ( width * scalex > ps_cPageWidth - ps_cLeftMargin) {
x = ps_cPageWidth - width * scalex;
if ( x < 50) {
x = 50;
scalex = scalex * (ps_cPageWidth - 50) / (width * scalex);
scaley = scaley * (ps_cPageWidth - 50) / (width * scalex);
}
}
if ( y - height * scaley + 20 < ps_cBottomMargin)
print_pagebreak( 1);
if ( !conf_pass) {
fp[cf] <<
"save" << endl <<
scalex * width << " " << scaley * height << " scale" << endl <<
"/oneline " << width << " string def" << endl <<
"/drawimage {" << endl <<
" " << width << " " << height << " 8 [" << width << " 0 0 -" << height << " 0 " << height << "]" << endl <<
" { currentfile oneline readhexstring pop } image" << endl <<
"} def" << endl <<
x/scalex/width << " " << (y - height*scaley)/scaley/height << " translate" << endl <<
"drawimage" << endl;
fp[cf].flags( (fp[cf].flags() & ~ios_base::dec) | ios_base::hex | ios_base::uppercase);
fp[cf].fill('0');
rgb = image->rgb_data;
j = 0;
for ( i = 0; i < image->rgb_height * image->rgb_width * 3; i+=3) {
if ( *rgb == transp[0] && *(rgb+1) == transp[1] && *(rgb+2) == transp[2]) {
grey = 255;
}
else {
grey = (int) ((0.0 + *rgb + *(rgb+1) + *(rgb+2)) / 3 + 0.5);
}
rgb += 3;
fp[cf].width(2);
fp[cf] << grey;
if ( ++j >= 40) {
j = 0;
fp[cf] << endl;
}
}
fp[cf] << endl <<
"restore" << endl;
fp[cf].flags( ((fp[cf].flags() & ~ios_base::hex) & ~ios_base::uppercase) | ios_base::dec);
cnv_free_image( image, pixmap);
}
y -= height * scaley;
return 1;
}
void CnvToPs::set_pageheader( char *text)
{
strcpy( previous_chapter, current_chapter);
strcpy( current_chapter, text);
}
void CnvToPs::print_h1( char *text, int hlevel, char *subject)
{
char hnum[40];
if ( cf == ps_eFile_Info)
return;
if ( ci == ps_eId_Chapter) {
set_pageheader( text);
}
if ( style[ci].h1.display_number) {
if ( hlevel < 0)
hlevel = 0;
if ( hlevel > ps_cMaxLevel - 1)
hlevel = ps_cMaxLevel - 1;
header_number[hlevel]++;
switch ( hlevel) {
case 0:
sprintf( hnum, "%d", header_number[0]);
break;
case 1:
sprintf( hnum, "%d.%d", header_number[0], header_number[1]);
break;
case 2:
sprintf( hnum, "%d.%d.%d", header_number[0], header_number[1],
header_number[2]);
break;
case 3:
sprintf( hnum, "%d.%d.%d.%d", header_number[0], header_number[1],
header_number[2], header_number[3]);
break;
default: ;
}
x = ps_cLeftMargin - 50;
print_text( hnum, style[ci].h1, ps_mPrintMode_Pos | ps_mPrintMode_FixX);
x = ps_cLeftMargin;
print_text( text, style[ci].h1, ps_mPrintMode_KeepY | ps_mPrintMode_FixX);
}
else
print_text( text, style[ci].h1);
if ( conf_pass) {
CnvContentElem cnt;
cnt.page_number = page_number[cf];
cnt.header_level = hlevel;
strcpy( cnt.header_number, hnum);
strcpy( cnt.text, text);
strcpy( cnt.subject, subject);
content.add( cnt);
}
strcpy( previous_chapter, current_chapter);
}
void CnvToPs::print_h2( char *text)
{
print_text( text, style[ci].h2);
}
void CnvToPs::print_h3( char *text)
{
print_text( text, style[ci].h3);
}
void CnvToPs::open()
{
y = ps_cPageHeight - ps_cTopMargin;
if ( !conf_pass) {
fp[ps_eFile_Info].open( filename[ps_eFile_Info]);
fp[ps_eFile_Body].open( filename[ps_eFile_Body]);
}
if ( !conf_pass)
fp[cf] <<
ps_cHead << endl;
for ( int i = 1; i < ps_cMaxLevel; i++)
header_number[i] = 0;
}
void CnvToPs::incr_headerlevel()
{
ci++;
if ( ci > ps_eId_TopicL3)
ci = ps_eId_TopicL3;
if ( ci < ps_eId_TopicL1)
ci = ps_eId_TopicL1;
header_number[ci-(int)ps_eId_Chapter] = 0;
}
void CnvToPs::decr_headerlevel()
{
ci--;
if ( ci < ps_eId_TopicL1)
ci = ps_eId_TopicL1;
}
void CnvToPs::reset_headernumbers( int level)
{
for ( int i = level; i < ps_cMaxLevel; i++)
header_number[i] = 0;
}
#ifndef cnv_tops_h
#define cnv_tops_h
/* cnv_tops.h -- Postscript output
PROVIEW/R
Copyright (C) 1996 by Comator Process AB.
<Description>. */
using namespace std;
#include <iostream.h>
#include <vector.h>
#include <string>
#include "pwr.h"
#include "cnv_style.h"
#include "cnv_content.h"
#define ps_cMaxLevel 4
#define ps_cPageHeight 820
#define ps_cPageWidth 535
#define ps_cPageNumX (ps_cPageWidth - 10)
#define ps_cPageNumY (ps_cPageHeight - 13)
#define ps_cLeftMargin 100
#define ps_cTopMargin 100
#define ps_cBottomMargin 50
#define ps_cCellSize 110
#define ps_cTmpFile "/tmp/ptmp.ps"
typedef enum {
ps_mPrintMode_Pos = 1 << 0,
ps_mPrintMode_Start = 1 << 1,
ps_mPrintMode_Continue= 1 << 2,
ps_mPrintMode_End = 1 << 3,
ps_mPrintMode_KeepY = 1 << 4,
ps_mPrintMode_FixX = 1 << 5
} ps_mPrintMode;
typedef enum {
ps_eFile_Info,
ps_eFile_Body,
ps_eFile__
} ps_eFile;
typedef enum {
ps_eId_TitlePage,
ps_eId_InfoPage,
ps_eId_Content,
ps_eId_Chapter,
ps_eId_TopicL1,
ps_eId_TopicL2,
ps_eId_TopicL3,
ps_eId_Function,
ps_eId_Class,
ps_eId__
} ps_eId;
class CnvToPs {
public:
CnvToPs() :
cf(0), ci(0), conf_pass(false)
{
for ( int i = 0; i < ps_cMaxLevel; i++)
header_number[i] = 0;
for ( int i = 0; i < ps_eFile__; i++)
page_number[i] = 0;
style[ps_eId_TitlePage].h1 =
CnvStyle( "Helvetica-Bold-ISOLatin1", 35, 0, 100, 20, cnv_eAlignment_Center, 0, 0, 0);
style[ps_eId_TitlePage].h2 =
CnvStyle( "Helvetica-Bold-ISOLatin1", 25, 0, 50, 20, cnv_eAlignment_Center, 0, 0, 0);
style[ps_eId_TitlePage].h3 =
CnvStyle( "Helvetica-Bold-ISOLatin1", 15, 0, 25, 10, cnv_eAlignment_Center, 0, 0, 0);
style[ps_eId_TitlePage].text =
CnvStyle( "Helvetica-ISOLatin1", 8, 0, 9, 1, cnv_eAlignment_Center, 0, 0, 0);
style[ps_eId_TitlePage].boldtext =
CnvStyle( "Helvetica-Bold-ISOLatin1", 8, 0, 9, 1, cnv_eAlignment_Center, 0, 0, 0);
style[ps_eId_Chapter].h1 =
CnvStyle( "Helvetica-Bold-ISOLatin1", 24, 0, 24, 40, cnv_eAlignment_Left, 0, 1, 1);
style[ps_eId_TopicL2].h1 =
CnvStyle( "Helvetica-Bold-ISOLatin1", 12, 0, 20, 10, cnv_eAlignment_Left, 0, 0, 1);
style[ps_eId_TopicL2].h2 =
CnvStyle( "Helvetica-Bold-ISOLatin1", 10, 0, 16, 8, cnv_eAlignment_Left, 0, 0, 0);
style[ps_eId_TopicL3].h1 =
CnvStyle( "Helvetica-Bold-ISOLatin1", 10, 0, 16, 8, cnv_eAlignment_Left, 0, 0, 1);
style[ps_eId_TopicL3].h2 =
CnvStyle( "Helvetica-Bold-ISOLatin1", 8, 0, 16, 5, cnv_eAlignment_Left, 0, 0, 0);
style[ps_eId_Function].h1 =
CnvStyle( "Helvetica-Bold-ISOLatin1", 24, 0, 24, 20, cnv_eAlignment_Left, 1, 0, 1);
style[ps_eId_Class].h1 =
CnvStyle( "Helvetica-Bold-ISOLatin1", 24, 0, 24, 20, cnv_eAlignment_Left, 1, 0, 1);
style[ps_eId_Class].h2 =
CnvStyle( "Helvetica-Bold-ISOLatin1", 20, 0, 24, 8, cnv_eAlignment_Left, 0, 0, 0);
style[ps_eId_Class].h3 =
CnvStyle( "Helvetica-Bold-ISOLatin1", 16, -40, 24, 6, cnv_eAlignment_Left, 0, 0, 0);
style[ps_eId_Content].boldtext =
CnvStyle( "Helvetica-Bold-ISOLatin1", 10, 0, 11, 1, cnv_eAlignment_Left, 0, 0, 0);
style[ps_eId_Chapter].text =
CnvStyle( "TimesNewRoman-ISOLatin1", 10, 0, 11, 1, cnv_eAlignment_Left, 0, 0, 0);
style[ps_eId_TopicL1].text =
CnvStyle( "TimesNewRoman-ISOLatin1", 10, 0, 11, 1, cnv_eAlignment_Left, 0, 0, 0);
style[ps_eId_TopicL2].text =
CnvStyle( "TimesNewRoman-ISOLatin1", 10, 0, 11, 1, cnv_eAlignment_Left, 0, 0, 0);
style[ps_eId_TopicL3].text =
CnvStyle( "TimesNewRoman-ISOLatin1", 10, 0, 11, 1, cnv_eAlignment_Left, 0, 0, 0);
}
~CnvToPs();
void close();
void print_text( char *text, CnvStyle& style, int mode = ps_mPrintMode_Pos);
void print_pagebreak( int print_num);
void print_content();
void print_h1( char *text, int hlevel, char *subject);
void print_h2( char *text);
void print_h3( char *text);
void print_horizontal_line();
int print_image( char *filename);
void cnv_text( char *to, char *from);
void set_confpass( bool conf) {
conf_pass = conf;
if ( !conf) {
// Reset
for ( int i = 0; i < ps_cMaxLevel; i++)
header_number[i] = 0;
for ( int i = 0; i < ps_eFile__; i++)
page_number[i] = 0;
cf = 0;
ci = 0;
}
}
void set_ci( int val) { ci = val;}
void set_cf( int val) { cf = val;}
void set_filename( int idx, char *name) {
strcpy( filename[idx], name);
}
void open();
void incr_headerlevel();
void decr_headerlevel();
void reset_headernumbers( int level);
void set_pageheader( char *text);
CnvContent content;
CnvIdStyle style[ps_eId__];
ofstream fp[ps_eFile__];
pwr_tFileName filename[ps_eFile__];
int cf;
int ci;
double x;
double y;
int page_number[ps_eFile__];
int header_number[ps_cMaxLevel];
bool conf_pass;
char current_chapter[160];
char previous_chapter[160];
};
#endif
#include <iostream.h>
#include <fstream.h>
#include <float.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
extern "C" {
#include "pwr.h"
#include "co_dcli.h"
#include "co_cdh.h"
}
#include "cnv_wblto.h"
int CnvWblTo::init( char *)
{
return 1;
}
#ifndef cnv_wblto_h
#define cnv_wblto_h
/* cnv_wblto.h -- Documentation
PROVIEW/R
Copyright (C) 1996 by Comator Process AB.
<Description>. */
#if defined __cplusplus
extern "C" {
#endif
#include "pwr.h"
#include "cnv_readwbl.h"
using namespace std;
class CnvReadWbl;
typedef enum {
Cnv_eWblToType_Html,
Cnv_eWblToType_H,
Cnv_eWblToType_Xtthelp,
Cnv_eWblToType_Ps
} Cnv_eWblToType;
class CnvWblTo {
public:
// CnvWblTo() {}
virtual ~CnvWblTo() {}
virtual int init( char *);
virtual int close() { return 1;}
virtual int class_exec() { return 1;}
virtual int class_close() { return 1;}
virtual int body_exec() { return 1;}
virtual int body_close() { return 1;}
virtual int attribute_exec() { return 1;}
virtual int typedef_exec() { return 1;}
virtual int typedef_close() { return 1;}
virtual int bit_exec() { return 1;}
virtual int graphplcnode() { return 1;}
virtual int graphplccon() { return 1;}
virtual int template_exec() { return 1;}
virtual Cnv_eWblToType type() { return Cnv_eWblToType_H;}
virtual int class_open() { return 0;}
virtual int index_open() { return 0;}
virtual bool confpass() { return false;}
virtual void set_confpass( bool conf) {};
};
#if defined __cplusplus
}
#endif
#endif
......@@ -12,42 +12,43 @@ extern "C" {
#include "co_dcli.h"
#include "co_cdh.h"
}
#include "cnv_classread.h"
#include "cnv_ctx.h"
#include "cnv_wbltoh.h"
typedef struct {
char name[40];
unsigned int id;
} struct_tCixArray;
int ClassRead::struct_init()
int CnvWblToH::init( char *first)
{
pwr_tFileName struct_filename;
pwr_tFileName fname;
int sts;
struct_get_filename( struct_filename);
strcpy( fname, dir);
get_filename( ctx->rw, struct_filename, ctx->hpp);
strcpy( fname, ctx->dir);
strcat( fname, struct_filename);
fp_struct.open( fname);
if ( hpp) {
if ( strcmp( low(volume_name), "pwrb") == 0)
if ( ctx->hpp) {
if ( strcmp( CnvCtx::low(ctx->rw->volume_name), "pwrb") == 0)
sprintf( fname, "pwr_%sclasses_hpp", "base");
else if ( strcmp( low(volume_name), "pwrs") == 0)
else if ( strcmp( CnvCtx::low(ctx->rw->volume_name), "pwrs") == 0)
sprintf( fname, "pwr_%sclasses_hpp", "system");
else
sprintf( fname, "pwr_%sclasses_hpp", low(volume_name));
sprintf( fname, "pwr_%sclasses_hpp", CnvCtx::low(ctx->rw->volume_name));
}
else {
if ( strcmp( low(volume_name), "pwrb") == 0)
if ( strcmp( CnvCtx::low(ctx->rw->volume_name), "pwrb") == 0)
sprintf( fname, "pwr_%sclasses_h", "base");
else if ( strcmp( low(volume_name), "pwrs") == 0)
else if ( strcmp( CnvCtx::low(ctx->rw->volume_name), "pwrs") == 0)
sprintf( fname, "pwr_%sclasses_h", "system");
else
sprintf( fname, "pwr_%sclasses_h", low(volume_name));
sprintf( fname, "pwr_%sclasses_h", CnvCtx::low(ctx->rw->volume_name));
}
sts = struct_volname_to_id();
sts = volname_to_id();
if ( sts == 0)
{
// printf( "** Can't get volume id\n");
......@@ -68,7 +69,7 @@ endl;
return 1;
}
int ClassRead::struct_close()
int CnvWblToH::close()
{
fp_struct <<
......@@ -79,7 +80,7 @@ int ClassRead::struct_close()
return 1;
}
int ClassRead::struct_class()
int CnvWblToH::class_exec()
{
// Open class struct file
......@@ -87,21 +88,23 @@ int ClassRead::struct_class()
pwr_tFileName fname;
char volume_name_low[40];
strcpy( volume_name_low, low(volume_name));
strcpy( volume_name_low, CnvCtx::low(ctx->rw->volume_name));
struct_get_filename( struct_filename);
if ( hpp)
sprintf( fname, "%s%s_c_%s.hpp", dir, volume_name_low, low(class_name));
get_filename( ctx->rw, struct_filename, ctx->hpp);
if ( ctx->hpp)
sprintf( fname, "%s%s_c_%s.hpp", ctx->dir, volume_name_low,
CnvCtx::low(ctx->rw->class_name));
else
sprintf( fname, "%s%s_c_%s.h", dir, volume_name_low, low(class_name));
if ( !common_structfile_only) {
sprintf( fname, "%s%s_c_%s.h", ctx->dir, volume_name_low,
CnvCtx::low(ctx->rw->class_name));
if ( !ctx->common_structfile_only) {
cstruc = new CnvFile();
cstruc->f.open( fname);
}
struct_class_open = 1;
sprintf( fname, "%s_c_%s_h", volume_name_low, low(class_name));
sprintf( fname, "%s_c_%s_h", volume_name_low, CnvCtx::low(ctx->rw->class_name));
if ( !common_structfile_only)
if ( !ctx->common_structfile_only)
cstruc->f <<
"/* Generated by co_convert */" << endl << endl <<
"#ifndef " << fname << endl <<
......@@ -121,7 +124,7 @@ endl;
return 1;
}
int ClassRead::struct_body()
int CnvWblToH::body_exec()
{
int sts;
char cclass_name[80];
......@@ -131,48 +134,48 @@ int ClassRead::struct_body()
attr_count = 0;
if ( strcmp( low( body_name), "devbody") == 0) {
if ( hpp)
if ( strcmp( CnvCtx::low( ctx->rw->body_name), "devbody") == 0) {
if ( ctx->hpp)
strcpy( struct_name, "pwr_dClass_");
else
strcpy( struct_name, "pwr_sdClass_");
}
else {
if ( hpp)
if ( ctx->hpp)
strcpy( struct_name, "pwr_Class_");
else
strcpy( struct_name, "pwr_sClass_");
}
if ( strcmp( body_structname, "") == 0)
strcat( struct_name, class_name);
if ( strcmp( ctx->rw->body_structname, "") == 0)
strcat( struct_name, ctx->rw->class_name);
else
strcat( struct_name, body_structname);
strcat( struct_name, ctx->rw->body_structname);
// For systemclasses classindex is defined as a pwr_eCix...
if ( strncmp( class_id, "pwr_eCix_", strlen("pwr_eCix_")) == 0)
if ( strncmp( ctx->rw->class_id, "pwr_eCix_", strlen("pwr_eCix_")) == 0)
{
sts = struct_cixstr_to_classid( class_id, &cid);
sts = cixstr_to_classid( ctx->rw->class_id, &cid);
if ( EVEN(sts))
{
printf("Error, unknown classid %s", class_id);
printf("Error, unknown classid %s", ctx->rw->class_id);
return sts;
}
}
else
{
// Classindex is a number
sts = sscanf( class_id, "%d", &cix);
sts = sscanf( ctx->rw->class_id, "%d", &cix);
if ( sts != 1)
{
printf("Error, unknown classid %s", class_id);
printf("Error, unknown classid %s", ctx->rw->class_id);
return 0;
}
struct_cix_to_classid( cix, &cid);
cix_to_classid( cix, &cid);
}
if ( strcmp( body_structname, "") == 0)
strcpy( cclass_name, class_name);
if ( strcmp( ctx->rw->body_structname, "") == 0)
strcpy( cclass_name, ctx->rw->class_name);
else
strcpy( cclass_name, body_structname);
strcpy( cclass_name, ctx->rw->body_structname);
if ( !struct_cclass_written)
{
......@@ -181,7 +184,7 @@ endl <<
"#ifndef pwr_cClass_" << cclass_name << endl <<
"#define pwr_cClass_" << cclass_name << " " << cid << endl <<
endl;
if ( !common_structfile_only)
if ( !ctx->common_structfile_only)
cstruc->f <<
endl <<
"#ifndef pwr_cClass_" << cclass_name << endl <<
......@@ -190,34 +193,34 @@ endl;
struct_cclass_written = 1;
}
if ( strcmp( low( body_name), "rtbody") == 0 &&
class_devonly)
if ( strcmp( CnvCtx::low( ctx->rw->body_name), "rtbody") == 0 &&
ctx->rw->class_devonly)
{
fp_struct <<
"/* Class: " << class_name << endl <<
" Body: " << body_name << endl <<
"/* Class: " << ctx->rw->class_name << endl <<
" Body: " << ctx->rw->body_name << endl <<
" Body is virtual" << endl <<
"*/" << endl << endl;
return 1;
}
fp_struct <<
"/*_* Class: " << class_name << endl <<
" Body: " << body_name << endl <<
" @Aref " << class_name << " " << struct_name << endl <<
"/*_* Class: " << ctx->rw->class_name << endl <<
" Body: " << ctx->rw->body_name << endl <<
" @Aref " << ctx->rw->class_name << " " << struct_name << endl <<
"*/" << endl;
if ( !common_structfile_only)
if ( !ctx->common_structfile_only)
cstruc->f <<
"/* Body: " << body_name << " */" << endl;
"/* Body: " << ctx->rw->body_name << " */" << endl;
if ( hpp)
if ( ctx->hpp)
fp_struct << endl <<
"class " << struct_name << " ";
else
fp_struct << endl <<
"typedef struct {" << endl;
if ( !common_structfile_only) {
if ( hpp)
if ( !ctx->common_structfile_only) {
if ( ctx->hpp)
cstruc->f << endl <<
"class " << struct_name << " ";
else
......@@ -227,12 +230,12 @@ endl;
return 1;
}
int ClassRead::struct_body_close()
int CnvWblToH::body_close()
{
char struct_name[80];
if ( strcmp( low( body_name), "rtbody") == 0 &&
class_devonly)
if ( strcmp( CnvCtx::low( ctx->rw->body_name), "rtbody") == 0 &&
ctx->rw->class_devonly)
return 1;
if ( attr_count == 0)
......@@ -240,58 +243,58 @@ int ClassRead::struct_body_close()
// Write a dummy element...
fp_struct <<
" int dummy;" << endl;
if ( !common_structfile_only)
if ( !ctx->common_structfile_only)
cstruc->f <<
" int dummy;" << endl;
}
if ( strcmp( low( body_name), "devbody") == 0)
if ( strcmp( CnvCtx::low( ctx->rw->body_name), "devbody") == 0)
strcpy( struct_name, "pwr_sdClass_");
else
strcpy( struct_name, "pwr_sClass_");
if ( strcmp( body_structname, "") == 0)
strcat( struct_name, class_name);
if ( strcmp( ctx->rw->body_structname, "") == 0)
strcat( struct_name, ctx->rw->class_name);
else
strcat( struct_name, body_structname);
strcat( struct_name, ctx->rw->body_structname);
if ( hpp) {
if ( ctx->hpp) {
fp_struct <<
"};" << endl;
if ( !common_structfile_only)
if ( !ctx->common_structfile_only)
cstruc->f <<
"};" << endl;
}
else {
fp_struct <<
"} " << struct_name << ";" << endl;
if ( !common_structfile_only)
if ( !ctx->common_structfile_only)
cstruc->f <<
"} " << struct_name << ";" << endl;
}
fp_struct <<
endl;
if ( !common_structfile_only)
if ( !ctx->common_structfile_only)
cstruc->f <<
endl;
return 1;
}
int ClassRead::struct_class_close()
int CnvWblToH::class_close()
{
if ( !struct_cclass_written)
{
fp_struct <<
endl <<
"#ifndef pwr_cClass_" << class_name << endl <<
"#define pwr_cClass_" << class_name << " " << class_id << endl <<
"#ifndef pwr_cClass_" << ctx->rw->class_name << endl <<
"#define pwr_cClass_" << ctx->rw->class_name << " " << ctx->rw->class_id << endl <<
endl;
if ( !common_structfile_only && struct_class_open)
if ( !ctx->common_structfile_only && struct_class_open)
cstruc->f <<
endl <<
"#ifndef pwr_cClass_" << class_name << endl <<
"#define pwr_cClass_" << class_name << " " << class_id << endl <<
"#ifndef pwr_cClass_" << ctx->rw->class_name << endl <<
"#define pwr_cClass_" << ctx->rw->class_name << " " << ctx->rw->class_id << endl <<
endl;
struct_cclass_written = 1;
......@@ -303,7 +306,7 @@ endl;
"#endif" << endl <<
endl;
if ( !common_structfile_only && struct_class_open)
if ( !ctx->common_structfile_only && struct_class_open)
cstruc->f <<
"#endif" << endl <<
endl;
......@@ -311,11 +314,11 @@ endl;
}
// Close class structfile
if ( !common_structfile_only && struct_class_open)
if ( !ctx->common_structfile_only && struct_class_open)
cstruc->f <<
"#endif" << endl <<
endl;
if ( !common_structfile_only && struct_class_open) {
if ( !ctx->common_structfile_only && struct_class_open) {
cstruc->f.close();
delete cstruc;
struct_class_open = 0;
......@@ -324,7 +327,7 @@ endl;
return 1;
}
int ClassRead::struct_attribute()
int CnvWblToH::attribute_exec()
{
int i;
int fill;
......@@ -334,57 +337,60 @@ int ClassRead::struct_attribute()
char pgmname[80];
int sts;
if ( strcmp( low( body_name), "rtbody") == 0 &&
class_devonly)
if ( strcmp( CnvCtx::low( ctx->rw->body_name), "rtbody") == 0 &&
ctx->rw->class_devonly)
return 1;
// if ( attr_rtvirtual)
// return 1;
if ( strcmp( attr_pgmname, "") == 0)
strcpy( pgmname, attr_name);
if ( strcmp( ctx->rw->attr_pgmname, "") == 0)
strcpy( pgmname, ctx->rw->attr_name);
else
strcpy( pgmname, attr_pgmname);
strcpy( pgmname, ctx->rw->attr_pgmname);
if ( strncmp( low(attr_typeref), "pwr_etype_", strlen("pwr_etype_")) == 0)
strcpy( attr_typeref, &attr_typeref[strlen("pwr_etype_")]);
else if ( strncmp( low(attr_typeref), "pwr_etypedef_", strlen("pwr_etypedef_")) == 0)
strcpy( attr_typeref, &attr_typeref[strlen("pwr_etypedef_")]);
if ( strncmp( CnvCtx::low(ctx->rw->attr_typeref), "pwr_etype_", strlen("pwr_etype_")) == 0)
strcpy( ctx->rw->attr_typeref,
&ctx->rw->attr_typeref[strlen("pwr_etype_")]);
else if ( strncmp( CnvCtx::low(ctx->rw->attr_typeref),
"pwr_etypedef_", strlen("pwr_etypedef_")) == 0)
strcpy( ctx->rw->attr_typeref,
&ctx->rw->attr_typeref[strlen("pwr_etypedef_")]);
if ( strcmp( low(attr_type), "buffer") == 0)
if ( strcmp( CnvCtx::low(ctx->rw->attr_type), "buffer") == 0)
{
strcpy( type_name, "pwr_s");
if ( attr_typeref[11] == '$')
strcat( type_name, &attr_typeref[12]);
if ( ctx->rw->attr_typeref[11] == '$')
strcat( type_name, &ctx->rw->attr_typeref[12]);
else
strcat( type_name, &attr_typeref[11]);
strcat( type_name, &ctx->rw->attr_typeref[11]);
}
else if ( strcmp( low(attr_typeref), "attrref") == 0)
else if ( strcmp( CnvCtx::low(ctx->rw->attr_typeref), "attrref") == 0)
{
strcpy( type_name, "pwr_s");
strcat( type_name, attr_typeref);
strcat( type_name, ctx->rw->attr_typeref);
}
else if ( attr_isclass)
else if ( ctx->rw->attr_isclass)
{
if ( hpp)
if ( ctx->hpp)
strcpy( type_name, "pwr_Class_");
else
strcpy( type_name, "pwr_sClass_");
strcat( type_name, attr_typeref);
strcat( type_name, ctx->rw->attr_typeref);
}
else
{
strcpy( type_name, "pwr_t");
strcat( type_name, attr_typeref);
strcat( type_name, ctx->rw->attr_typeref);
}
// For backward compatibility...
if ( strcmp( type_name, "pwr_tObjId") == 0)
strcpy( type_name, "pwr_tObjid");
// Check type for baseclasses
if ( strcmp( low(volume_name), "pwrb") == 0)
if ( strcmp( CnvCtx::low(ctx->rw->volume_name), "pwrb") == 0)
{
sts = struct_check_typename( attr_typeref_volume, type_name);
sts = check_typename( ctx->rw->attr_typeref_volume, type_name);
if ( EVEN(sts))
{
printf("Error, unknown attribute type '%s'", type_name);
......@@ -392,12 +398,12 @@ int ClassRead::struct_attribute()
}
}
if ( hpp && attr_count == 0) {
if ( attr_isclass && strcmp( pgmname, "Super") == 0) {
if ( ctx->hpp && attr_count == 0) {
if ( ctx->rw->attr_isclass && strcmp( pgmname, "Super") == 0) {
fp_struct <<
": public " << type_name << " {" << endl <<
" public:" << endl;
if ( !common_structfile_only)
if ( !ctx->common_structfile_only)
cstruc->f <<
type_name << " {" << endl <<
" public:" << endl;
......@@ -408,170 +414,170 @@ int ClassRead::struct_attribute()
fp_struct <<
" {" << endl <<
" public:" << endl;
if ( !common_structfile_only)
if ( !ctx->common_structfile_only)
cstruc->f <<
" {" << endl <<
" public:" << endl;
}
}
if ( strcmp( low(attr_type), "input") == 0)
if ( strcmp( CnvCtx::low(ctx->rw->attr_type), "input") == 0)
{
if ( attr_array && attr_pointer)
if ( ctx->rw->attr_array && ctx->rw->attr_pointer)
{
fp_struct <<
" " << type_name;
if ( !common_structfile_only)
if ( !ctx->common_structfile_only)
cstruc->f <<
" " << type_name;
for ( i = 0; i < int(36 - strlen(type_name)); i++)
{
fp_struct << ' ';
if ( !common_structfile_only)
if ( !ctx->common_structfile_only)
cstruc->f << ' ';
}
fp_struct << "**" << pgmname << "P[" << attr_elements << "];" << endl;
if ( !common_structfile_only)
cstruc->f << "**" << pgmname << "P[" << attr_elements << "];" << endl;
fp_struct << "**" << pgmname << "P[" << ctx->rw->attr_elements << "];" << endl;
if ( !ctx->common_structfile_only)
cstruc->f << "**" << pgmname << "P[" << ctx->rw->attr_elements << "];" << endl;
}
else if ( attr_array)
else if ( ctx->rw->attr_array)
{
fp_struct <<
" " << type_name;
if ( !common_structfile_only)
if ( !ctx->common_structfile_only)
cstruc->f <<
" " << type_name;
for ( i = 0; i < int(36 - strlen(type_name)); i++)
{
fp_struct << ' ';
if ( !common_structfile_only)
if ( !ctx->common_structfile_only)
cstruc->f << ' ';
}
fp_struct << "*" << pgmname << "P[" << attr_elements << "];" << endl;
if ( !common_structfile_only)
cstruc->f << "*" << pgmname << "P[" << attr_elements << "];" << endl;
fp_struct << "*" << pgmname << "P[" << ctx->rw->attr_elements << "];" << endl;
if ( !ctx->common_structfile_only)
cstruc->f << "*" << pgmname << "P[" << ctx->rw->attr_elements << "];" << endl;
}
else if ( attr_pointer)
else if ( ctx->rw->attr_pointer)
{
fp_struct <<
" " << type_name;
if ( !common_structfile_only)
if ( !ctx->common_structfile_only)
cstruc->f <<
" " << type_name;
for ( i = 0; i < int(36 - strlen(type_name)); i++)
{
fp_struct << ' ';
if ( !common_structfile_only)
if ( !ctx->common_structfile_only)
cstruc->f << ' ';
}
fp_struct << "**" << pgmname << "P;" << endl;
if ( !common_structfile_only)
if ( !ctx->common_structfile_only)
cstruc->f << "**" << pgmname << "P;" << endl;
}
else
{
fp_struct <<
" " << type_name;
if ( !common_structfile_only)
if ( !ctx->common_structfile_only)
cstruc->f <<
" " << type_name;
for ( i = 0; i < int(36 - strlen(type_name)); i++)
{
fp_struct << ' ';
if ( !common_structfile_only)
if ( !ctx->common_structfile_only)
cstruc->f << ' ';
}
fp_struct << "*" << pgmname << "P;" << endl;
if ( !common_structfile_only)
if ( !ctx->common_structfile_only)
cstruc->f << "*" << pgmname << "P;" << endl;
}
}
if ( attr_array && attr_pointer)
if ( ctx->rw->attr_array && ctx->rw->attr_pointer)
{
fp_struct <<
" " << type_name;
if ( !common_structfile_only)
if ( !ctx->common_structfile_only)
cstruc->f <<
" " << type_name;
for ( i = 0; i < int(36 - strlen(type_name)); i++)
{
fp_struct << ' ';
if ( !common_structfile_only)
if ( !ctx->common_structfile_only)
cstruc->f << ' ';
}
fp_struct << "*" << pgmname << "[" << attr_elements << "];" << endl;
if ( !common_structfile_only)
cstruc->f << "*" << pgmname << "[" << attr_elements << "];" << endl;
fp_struct << "*" << pgmname << "[" << ctx->rw->attr_elements << "];" << endl;
if ( !ctx->common_structfile_only)
cstruc->f << "*" << pgmname << "[" << ctx->rw->attr_elements << "];" << endl;
}
else if ( attr_array)
else if ( ctx->rw->attr_array)
{
fp_struct <<
" " << type_name;
if ( !common_structfile_only)
if ( !ctx->common_structfile_only)
cstruc->f <<
" " << type_name;
for ( i = 0; i < int(36 - strlen(type_name)); i++)
{
fp_struct << ' ';
if ( !common_structfile_only)
if ( !ctx->common_structfile_only)
cstruc->f << ' ';
}
fp_struct << pgmname << "[" << attr_elements << "];" << endl;
if ( !common_structfile_only)
cstruc->f << pgmname << "[" << attr_elements << "];" << endl;
fp_struct << pgmname << "[" << ctx->rw->attr_elements << "];" << endl;
if ( !ctx->common_structfile_only)
cstruc->f << pgmname << "[" << ctx->rw->attr_elements << "];" << endl;
}
else if ( attr_pointer)
else if ( ctx->rw->attr_pointer)
{
fp_struct <<
" " << type_name;
if ( !common_structfile_only)
if ( !ctx->common_structfile_only)
cstruc->f <<
" " << type_name;
for ( i = 0; i < int(36 - strlen(type_name)); i++)
{
fp_struct << ' ';
if ( !common_structfile_only)
if ( !ctx->common_structfile_only)
cstruc->f << ' ';
}
fp_struct << "*" << pgmname << ";" << endl;
if ( !common_structfile_only)
if ( !ctx->common_structfile_only)
cstruc->f << "*" << pgmname << ";" << endl;
}
else
{
fp_struct <<
" " << type_name;
if ( !common_structfile_only)
if ( !ctx->common_structfile_only)
cstruc->f <<
" " << type_name;
for ( i = 0; i < int(36 - strlen(type_name)); i++)
{
fp_struct << ' ';
if ( !common_structfile_only)
if ( !ctx->common_structfile_only)
cstruc->f << ' ';
}
fp_struct << pgmname << ";" << endl;
if ( !common_structfile_only)
if ( !ctx->common_structfile_only)
cstruc->f << pgmname << ";" << endl;
}
if ( attr_pointer)
if ( ctx->rw->attr_pointer)
size = 4;
else if ( strcmp( low(attr_typeref), "uint8") == 0 ||
strcmp( low(attr_typeref), "int8") == 0 ||
strcmp( low(attr_typeref), "char") == 0)
else if ( strcmp( CnvCtx::low(ctx->rw->attr_typeref), "uint8") == 0 ||
strcmp( CnvCtx::low(ctx->rw->attr_typeref), "int8") == 0 ||
strcmp( CnvCtx::low(ctx->rw->attr_typeref), "char") == 0)
size = 1;
else if ( strcmp( low(attr_typeref), "uint16") == 0 ||
strcmp( low(attr_typeref), "int16") == 0)
else if ( strcmp( CnvCtx::low(ctx->rw->attr_typeref), "uint16") == 0 ||
strcmp( CnvCtx::low(ctx->rw->attr_typeref), "int16") == 0)
size = 2;
else
size = 4;
if ( attr_elem == 0)
if ( ctx->rw->attr_elem == 0)
elements = 1;
else
elements = attr_elem;
elements = ctx->rw->attr_elem;
if ( size < 4)
{
......@@ -586,25 +592,25 @@ int ClassRead::struct_attribute()
{
fp_struct <<
" " << "char";
if ( !common_structfile_only)
if ( !ctx->common_structfile_only)
cstruc->f <<
" " << "char";
for ( i = 0; i < int(36 - strlen("char")); i++)
{
fp_struct << ' ';
if ( !common_structfile_only)
if ( !ctx->common_structfile_only)
cstruc->f << ' ';
}
if ( fill == 1)
{
fp_struct << "filler_" << struct_filler_cnt << ";" << endl;
if ( !common_structfile_only)
if ( !ctx->common_structfile_only)
cstruc->f << "filler_" << struct_filler_cnt << ";" << endl;
}
else
{
fp_struct << "filler_" << struct_filler_cnt << "[" << fill << "];" << endl;
if ( !common_structfile_only)
if ( !ctx->common_structfile_only)
cstruc->f << "filler_" << struct_filler_cnt << "[" << fill << "];" << endl;
}
struct_filler_cnt++;
......@@ -613,88 +619,88 @@ int ClassRead::struct_attribute()
return 1;
}
int ClassRead::struct_typedef()
int CnvWblToH::typedef_exec()
{
if ( strcmp( typedef_typeref, "Mask") == 0 ||
strcmp( typedef_typeref, "Enum") == 0) {
if ( strcmp(typedef_pgmname, "") == 0)
strcpy( typedef_pgmname, typedef_name);
if ( strcmp( ctx->rw->typedef_typeref, "Mask") == 0 ||
strcmp( ctx->rw->typedef_typeref, "Enum") == 0) {
if ( strcmp(ctx->rw->typedef_pgmname, "") == 0)
strcpy( ctx->rw->typedef_pgmname, ctx->rw->typedef_name);
fp_struct <<
"/*_* " << typedef_typeref << ": " << typedef_name << endl <<
" @Aref " << typedef_name << " " << typedef_name << endl <<
"/*_* " << ctx->rw->typedef_typeref << ": " << ctx->rw->typedef_name << endl <<
" @Aref " << ctx->rw->typedef_name << " " << ctx->rw->typedef_name << endl <<
"*/" << endl << endl <<
"typedef pwr_t" << typedef_typeref << " pwr_t" << typedef_name << ";" << endl << endl <<
"typedef pwr_t" << ctx->rw->typedef_typeref << " pwr_t" << ctx->rw->typedef_name << ";" << endl << endl <<
"typedef enum {" << endl;
}
else if ( strcmp( typedef_typeref, "String") == 0) {
if ( typedef_elements > 1)
else if ( strcmp( ctx->rw->typedef_typeref, "String") == 0) {
if ( ctx->rw->typedef_elements > 1)
fp_struct <<
"typedef char pwr_t" << typedef_name << "[" << typedef_elements << "];" << endl << endl;
"typedef char pwr_t" << ctx->rw->typedef_name << "[" << ctx->rw->typedef_elements << "];" << endl << endl;
else
fp_struct <<
"typedef char pwr_t" << typedef_name << ";" << endl << endl;
"typedef char pwr_t" << ctx->rw->typedef_name << ";" << endl << endl;
}
else {
if ( typedef_elements > 1)
if ( ctx->rw->typedef_elements > 1)
fp_struct <<
"typedef pwr_t" << typedef_typeref << " pwr_t" << typedef_name << "[" << typedef_elements << "];" << endl << endl;
"typedef pwr_t" << ctx->rw->typedef_typeref << " pwr_t" << ctx->rw->typedef_name << "[" << ctx->rw->typedef_elements << "];" << endl << endl;
else
fp_struct <<
"typedef pwr_t" << typedef_typeref << " pwr_t" << typedef_name << ";" << endl << endl;
"typedef pwr_t" << ctx->rw->typedef_typeref << " pwr_t" << ctx->rw->typedef_name << ";" << endl << endl;
}
struct_class_open = 1;
return 1;
}
int ClassRead::struct_typedef_close()
int CnvWblToH::typedef_close()
{
if ( strcmp(typedef_pgmname, "") == 0)
strcpy( typedef_pgmname, typedef_name);
if ( strcmp(ctx->rw->typedef_pgmname, "") == 0)
strcpy( ctx->rw->typedef_pgmname, ctx->rw->typedef_name);
if ( strcmp( typedef_typeref, "Mask") == 0)
if ( strcmp( ctx->rw->typedef_typeref, "Mask") == 0)
fp_struct <<
"} pwr_m" << typedef_pgmname << ";" << endl << endl;
else if ( strcmp( typedef_typeref, "Enum") == 0)
"} pwr_m" << ctx->rw->typedef_pgmname << ";" << endl << endl;
else if ( strcmp( ctx->rw->typedef_typeref, "Enum") == 0)
fp_struct <<
"} pwr_e" << typedef_pgmname << ";" << endl << endl;
"} pwr_e" << ctx->rw->typedef_pgmname << ";" << endl << endl;
struct_class_open = 0;
return 1;
}
int ClassRead::struct_bit()
int CnvWblToH::bit_exec()
{
char pgmname[80];
int i;
if ( strcmp(typedef_pgmname, "") == 0)
strcpy( typedef_pgmname, typedef_name);
if ( strcmp(ctx->rw->typedef_pgmname, "") == 0)
strcpy( ctx->rw->typedef_pgmname, ctx->rw->typedef_name);
if ( strcmp( bit_pgmname, "") == 0)
strcpy( pgmname, bit_name);
if ( strcmp( ctx->rw->bit_pgmname, "") == 0)
strcpy( pgmname, ctx->rw->bit_name);
else
strcpy( pgmname, bit_pgmname);
strcpy( pgmname, ctx->rw->bit_pgmname);
if ( strcmp( bit_type, "Bit") == 0) {
if ( strcmp( ctx->rw->bit_type, "Bit") == 0) {
fp_struct <<
" pwr_m" << typedef_pgmname << "_" << pgmname;
for ( i = 0; i < int(30 - strlen(typedef_pgmname) - strlen(pgmname)); i++)
" pwr_m" << ctx->rw->typedef_pgmname << "_" << pgmname;
for ( i = 0; i < int(30 - strlen(ctx->rw->typedef_pgmname) - strlen(pgmname)); i++)
fp_struct << ' ';
fp_struct << " = " << bit_value << "," << endl;
fp_struct << " = " << ctx->rw->bit_value << "," << endl;
}
else if ( strcmp( bit_type, "Value") == 0) {
else if ( strcmp( ctx->rw->bit_type, "Value") == 0) {
fp_struct <<
" pwr_e" << typedef_pgmname << "_" << pgmname;
for ( i = 0; i < int(30 - strlen(typedef_pgmname) - strlen(pgmname)); i++)
" pwr_e" << ctx->rw->typedef_pgmname << "_" << pgmname;
for ( i = 0; i < int(30 - strlen(ctx->rw->typedef_pgmname) - strlen(pgmname)); i++)
fp_struct << ' ';
fp_struct << " = " << bit_value << "," << endl;
fp_struct << " = " << ctx->rw->bit_value << "," << endl;
}
return 1;
}
int ClassRead::struct_volname_to_id()
int CnvWblToH::volname_to_id()
{
FILE *fp;
pwr_tFileName fname;
......@@ -706,13 +712,13 @@ int ClassRead::struct_volname_to_id()
strcpy( struct_volid, "");
strcpy( fname, source_dir);
strcat( fname, low(volume_name));
strcpy( fname, ctx->rw->source_dir);
strcat( fname, CnvCtx::low(ctx->rw->volume_name));
strcat( fname, "_v.wb_load");
fp = fopen( fname, "r");
if ( !fp) {
strcpy( fname, current_file);
strcpy( fname, ctx->rw->current_file);
fp = fopen( fname, "r");
if ( !fp) {
printf( "** Unable to find Volume declaration\n");
......@@ -722,12 +728,12 @@ int ClassRead::struct_volname_to_id()
while( 1)
{
sts = read_line( line, sizeof(line), fp);
sts = CnvCtx::read_line( line, sizeof(line), fp);
if ( !sts)
break;
else
{
remove_spaces( line, line);
CnvCtx::remove_spaces( line, line);
if ( strcmp( line, "") == 0)
continue;
......@@ -737,7 +743,7 @@ int ClassRead::struct_volname_to_id()
nr = dcli_parse( line, " =", "", (char *)line_part,
sizeof( line_part) / sizeof( line_part[0]),
sizeof( line_part[0]), 0);
if ( strcmp( low( line_part[0]), "volume") == 0)
if ( strcmp( CnvCtx::low( line_part[0]), "volume") == 0)
{
if ( nr > 3)
{
......@@ -761,7 +767,7 @@ int ClassRead::struct_volname_to_id()
return 1;
}
void ClassRead::struct_cix_to_classid( unsigned int cix, pwr_tClassId *cid)
void CnvWblToH::cix_to_classid( unsigned int cix, pwr_tClassId *cid)
{
cdh_uTypeId lcid;
......@@ -773,7 +779,7 @@ void ClassRead::struct_cix_to_classid( unsigned int cix, pwr_tClassId *cid)
*cid = lcid.pwr;
}
int ClassRead::struct_cixstr_to_classid( char *cix_str, pwr_tClassId *cid)
int CnvWblToH::cixstr_to_classid( char *cix_str, pwr_tClassId *cid)
{
int found;
struct_tCixArray *cix_p;
......@@ -851,21 +857,21 @@ int ClassRead::struct_cixstr_to_classid( char *cix_str, pwr_tClassId *cid)
if ( !found)
return 0;
struct_cix_to_classid( cix_p->id, cid);
cix_to_classid( cix_p->id, cid);
return 1;
}
void ClassRead::struct_get_filename( char *struct_file)
void CnvWblToH::get_filename( CnvReadWbl *rw, char *struct_file, int hpp)
{
strcpy( struct_file, "pwr_");
if ( strcmp( low(volume_name), "pwrb") == 0)
if ( strcmp( CnvCtx::low(rw->volume_name), "pwrb") == 0)
strcat( struct_file, "base");
else if ( strcmp( low(volume_name), "pwrs") == 0)
else if ( strcmp( CnvCtx::low(rw->volume_name), "pwrs") == 0)
// To separate from pwr_systemclasses.h
strcat( struct_file, "system");
else
strcat( struct_file, low(volume_name));
strcat( struct_file, CnvCtx::low(rw->volume_name));
if ( hpp)
strcat( struct_file, "classes.hpp");
......@@ -873,7 +879,7 @@ void ClassRead::struct_get_filename( char *struct_file)
strcat( struct_file, "classes.h");
}
int ClassRead::struct_check_typename( char *type_volume, char *type_name)
int CnvWblToH::check_typename( char *type_volume, char *type_name)
{
// Only types in pwrs can be typechecked
if ( strcmp( type_volume, "pwrs") == 0 || strcmp( type_volume, "") == 0) {
......@@ -933,6 +939,7 @@ int ClassRead::struct_check_typename( char *type_volume, char *type_name)
"pwr_tString1",
"pwr_tText1024",
"pwr_tURL",
"pwr_tOpSysEnum",
""};
for ( name = valid_names[0]; strcmp(name,"") != 0;
......
#ifndef cnv_wbltoh_h
#define cnv_wbltoh_h
/* cnv_wbltoh.h -- Documentation
PROVIEW/R
Copyright (C) 1996 by Comator Process AB.
<Description>. */
#if defined __cplusplus
extern "C" {
#endif
#include "pwr.h"
#include "cnv_readwbl.h"
#include "cnv_wblto.h"
using namespace std;
class CnvReadWbl;
class CnvWblToH : public CnvWblTo {
public:
CnvWblToH( CnvCtx *cnv_ctx) : ctx(cnv_ctx), struct_class_open(0),
struct_filler_cnt(0), attr_count(0) {}
virtual ~CnvWblToH() {}
CnvCtx *ctx;
int struct_class_open;
ofstream fp_struct;
CnvFile *cstruc;
int struct_cclass_written;
int struct_cclass_endwritten;
int struct_filler_cnt;
char struct_volid[80];
unsigned int struct_vid_0;
unsigned int struct_vid_1;
int attr_count;
int init( char *first);
int close();
int class_exec();
int class_close();
int body_exec();
int body_close();
int attribute_exec();
int typedef_exec();
int typedef_close();
int bit_exec();
int graphplcnode() { return 1;}
int graphplccon() { return 1;}
int template_exec() { return 1;}
Cnv_eWblToType type() { return Cnv_eWblToType_H;}
int class_open() { return struct_class_open;}
int index_open() { return 0;}
int volname_to_id();
void cix_to_classid( unsigned int cix, pwr_tClassId *cid);
int cixstr_to_classid( char *cix_str, pwr_tClassId *cid);
static void get_filename( CnvReadWbl *rw, char *struct_file, int hpp);
int check_typename( char *type_volume, char *type_name);
};
#if defined __cplusplus
}
#endif
#endif
......@@ -6,7 +6,9 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "cnv_classread.h"
#include "cnv_wbltohtml.h"
#include "cnv_wbltoh.h"
#include "cnv_readsrc.h"
extern "C" {
#include "pwr.h"
#include "co_cdh.h"
......@@ -14,7 +16,7 @@ extern "C" {
}
int ClassRead::html_init( char *first)
int CnvWblToHtml::init( char *first)
{
pwr_tFileName fname;
pwr_tFileName gname;
......@@ -22,27 +24,27 @@ int ClassRead::html_init( char *first)
char timestr[80];
time_AtoAscii( 0, time_eFormat_DateAndTime, timestr, sizeof(timestr));
strcpy( html_first, volume_name);
strcpy( html_first, ctx->rw->volume_name);
strcat( html_first, "_");
strcat( html_first, first);
cdh_ToLower( html_first, html_first);
strcpy( allclasses_name, volume_name);
strcpy( allclasses_name, ctx->rw->volume_name);
strcat( allclasses_name, "_allclasses.html");
cdh_ToLower( allclasses_name, allclasses_name);
// Create index file
{
strcpy( fname, dir);
strcat( fname, volume_name);
strcpy( fname, ctx->dir);
strcat( fname, ctx->rw->volume_name);
strcat( fname, "_index.html");
cdh_ToLower( fname, fname);
ofstream fp( fname);
// Get group menu name
if ( setup_group_cnt) {
strcpy( gname, low(volume_name));
if ( ctx->setup->group_cnt) {
strcpy( gname, CnvCtx::low(ctx->rw->volume_name));
strcat( gname, "_menu_group.html");
cdh_ToLower( fname, fname);
}
......@@ -58,7 +60,7 @@ int ClassRead::html_init( char *first)
"<link rel=\"stylesheet\" type=\"text/css\" href=\"orm.css\">" << endl <<
"</HEAD>" << endl <<
"<FRAMESET cols=\"20%,80%\">" << endl;
if ( setup_group_cnt)
if ( ctx->setup->group_cnt)
fp <<
"<FRAMESET rows=\"20%,80%\">" << endl <<
"<FRAME src=\"" << gname << "\" name=\"groupFrame\">" << endl <<
......@@ -84,21 +86,21 @@ int ClassRead::html_init( char *first)
// Create js index file
strcpy( fname, dir);
strcat( fname, volume_name);
strcpy( fname, ctx->dir);
strcat( fname, ctx->rw->volume_name);
strcat( fname, "_allclasses.jsf");
cdh_ToLower( fname, fname);
fp_js_all.open( fname);
js_all_first = true;
fp_js_all <<
"function " << volume_name << "_AllClasses( parent)" << endl <<
"function " << ctx->rw->volume_name << "_AllClasses( parent)" << endl <<
"{" << endl <<
"parent.addChildren([" << endl;
// Create group menu file
if ( setup_group_cnt) {
strcpy( fname, dir);
if ( ctx->setup->group_cnt) {
strcpy( fname, ctx->dir);
strcat( fname, gname);
cdh_ToLower( fname, fname);
......@@ -125,7 +127,7 @@ int ClassRead::html_init( char *first)
"<TD NOWRAP><FONT CLASS=\"FrameItemFont\"> " << endl;
// Put index filename in fname
strcpy( fname, volume_name);
strcpy( fname, ctx->rw->volume_name);
strcat( fname, "_index.html");
cdh_ToLower( fname, fname);
......@@ -133,16 +135,16 @@ int ClassRead::html_init( char *first)
"<A HREF=\"" << fname << "\" TARGET=\"_parent\">AllClasses</A>" << endl <<
"<BR>" << endl;
for ( int i = 0; i < setup_group_cnt; i++) {
for ( int i = 0; i < ctx->setup->group_cnt; i++) {
// Put group index filename in fname
strcpy( fname, volume_name);
strcpy( fname, ctx->rw->volume_name);
strcat( fname, "_group_");
strcat( fname, setup_groups[i]);
strcat( fname, ctx->setup->groups[i]);
strcat( fname, "_index.html");
cdh_ToLower( fname, fname);
fp <<
"<A HREF=\"" << fname << "\" TARGET=\"_parent\">" << setup_groups[i] << "</A>" << endl <<
"<A HREF=\"" << fname << "\" TARGET=\"_parent\">" << ctx->setup->groups[i] << "</A>" << endl <<
"<BR>" << endl;
}
......@@ -157,7 +159,7 @@ int ClassRead::html_init( char *first)
}
// Open allclasses file
strcpy( fname, dir);
strcpy( fname, ctx->dir);
strcat( fname, allclasses_name);
cdh_ToLower( fname, fname);
fp_html_index.open( fname);
......@@ -185,22 +187,22 @@ int ClassRead::html_init( char *first)
"<TD NOWRAP><FONT CLASS=\"FrameItemFont\"> " << endl;
// Open one index file for each configured group
for ( int i = 0; i < setup_group_cnt; i++) {
for ( int i = 0; i < ctx->setup->group_cnt; i++) {
// Create index page for each group
strcpy( fname, dir);
strcat( fname, volume_name);
strcpy( fname, ctx->dir);
strcat( fname, ctx->rw->volume_name);
strcat( fname, "_group_");
strcat( fname, setup_groups[i]);
strcat( fname, ctx->setup->groups[i]);
strcat( fname, "_index.html");
cdh_ToLower( fname, fname);
{
ofstream fp( fname);
// Put menu filename in fname
strcpy( fname, volume_name);
strcpy( fname, ctx->rw->volume_name);
strcat( fname, "_group_");
strcat( fname, setup_groups[i]);
strcat( fname, ctx->setup->groups[i]);
strcat( fname, ".html");
cdh_ToLower( fname, fname);
......@@ -219,12 +221,12 @@ int ClassRead::html_init( char *first)
"<FRAME src=\"" << gname << "\" name=\"groupFrame\">" << endl <<
"<FRAME src=\"" << fname << "\" name=\"menuFrame\">" << endl <<
"</FRAMESET>" << endl;
if ( strcmp( setup_groups_startpage[i], "") == 0)
if ( strcmp( ctx->setup->groups_startpage[i], "") == 0)
fp <<
"<FRAME name=\"classFrame\">" << endl;
else
fp <<
"<FRAME src=\"" << setup_groups_startpage[i] << "\" name=\"classFrame\">" << endl;
"<FRAME src=\"" << ctx->setup->groups_startpage[i] << "\" name=\"classFrame\">" << endl;
fp <<
"</FRAMESET>" << endl <<
......@@ -241,18 +243,18 @@ int ClassRead::html_init( char *first)
}
// Create menu page
strcpy( fname, dir);
strcat( fname, volume_name);
strcpy( fname, ctx->dir);
strcat( fname, ctx->rw->volume_name);
strcat( fname, "_group_");
strcat( fname, setup_groups[i]);
strcat( fname, ctx->setup->groups[i]);
strcat( fname, ".html");
cdh_ToLower( fname, fname);
fp_html_group[i].open( fname);
strcpy( fname, dir);
strcat( fname, volume_name);
strcpy( fname, ctx->dir);
strcat( fname, ctx->rw->volume_name);
strcat( fname, "_group_");
strcat( fname, setup_groups[i]);
strcat( fname, ctx->setup->groups[i]);
strcat( fname, ".jsf");
cdh_ToLower( fname, fname);
fp_js_group[i].open( fname);
......@@ -263,13 +265,13 @@ int ClassRead::html_init( char *first)
"<HTML>" << endl <<
"<HEAD>" << endl <<
"<TITLE>" << endl <<
setup_groups[i] << endl <<
ctx->setup->groups[i] << endl <<
"</TITLE>" << endl <<
"<link rel=\"stylesheet\" type=\"text/css\" href=\"orm.css\">" << endl <<
"</HEAD>" << endl <<
"<BODY BGCOLOR=\"white\">" << endl <<
"<FONT size=\"+1\" CLASS=\"FrameHeadingFont\">" << endl <<
"<B>" << setup_groups[i] << "</B></FONT>" << endl <<
"<B>" << ctx->setup->groups[i] << "</B></FONT>" << endl <<
"<BR>" << endl <<
"" << endl <<
"<TABLE BORDER=\"0\" WIDTH=\"100%\">" << endl <<
......@@ -279,7 +281,7 @@ setup_groups[i] << endl <<
js_group_first[i] = true;
fp_js_group[i] <<
"function " << volume_name << "_" << setup_groups[i] << "(parent)" << endl <<
"function " << ctx->rw->volume_name << "_" << ctx->setup->groups[i] << "(parent)" << endl <<
"{" << endl <<
"parent.addChildren([" << endl;
......@@ -287,28 +289,28 @@ setup_groups[i] << endl <<
// Create js map for volume
{
strcpy( fname, dir);
strcat( fname, volume_name);
strcpy( fname, ctx->dir);
strcat( fname, ctx->rw->volume_name);
strcat( fname, "_groups.jsf");
cdh_ToLower( fname, fname);
ofstream fp( fname);
fp <<
"function " << volume_name << "(parent)" << endl <<
"function " << ctx->rw->volume_name << "(parent)" << endl <<
"{" << endl <<
" aux = insFld(parent, gFld(\"AllClasses\",\"" << volume_name << "_index.html\"))" << endl <<
" " << volume_name << "_AllClasses(aux)" << endl;
" aux = insFld(parent, gFld(\"AllClasses\",\"" << ctx->rw->volume_name << "_index.html\"))" << endl <<
" " << ctx->rw->volume_name << "_AllClasses(aux)" << endl;
for ( int i = 0; i < setup_group_cnt; i++) {
strcpy( fname, volume_name);
for ( int i = 0; i < ctx->setup->group_cnt; i++) {
strcpy( fname, ctx->rw->volume_name);
strcat( fname, "_group_");
strcat( fname, setup_groups[i]);
strcat( fname, ctx->setup->groups[i]);
strcat( fname, "_index.html");
cdh_ToLower( fname, fname);
fp <<
" aux = insFld(parent, gFld(\"" << setup_groups[i] << "\",\"" << fname << "\"))" << endl <<
" " << volume_name << "_" << setup_groups[i] << "(aux)" << endl;
" aux = insFld(parent, gFld(\"" << ctx->setup->groups[i] << "\",\"" << fname << "\"))" << endl <<
" " << ctx->rw->volume_name << "_" << ctx->setup->groups[i] << "(aux)" << endl;
}
fp <<
"}" << endl;
......@@ -317,7 +319,7 @@ setup_groups[i] << endl <<
return 1;
}
int ClassRead::html_close()
int CnvWblToHtml::close()
{
fp_html_index <<
......@@ -334,7 +336,7 @@ int ClassRead::html_close()
"}" << endl;
fp_js_all.close();
for ( int i = 0; i < setup_group_cnt; i++) {
for ( int i = 0; i < ctx->setup->group_cnt; i++) {
fp_html_group[i] <<
"</FONT></TD>" << endl <<
"</TR>" << endl <<
......@@ -354,7 +356,7 @@ int ClassRead::html_close()
{
char fname[200];
strcpy( fname, dir);
strcpy( fname, ctx->dir);
strcat( fname, "index.jsm");
cdh_ToLower( fname, fname);
ofstream fp( fname);
......@@ -376,13 +378,14 @@ int ClassRead::html_close()
#endif
char cmd[200];
sprintf( cmd, "cat %s/*.jsf %s/../orm_menu.js > %s/menu.js", dir, dir, dir);
sprintf( cmd, "cat %s/*.jsf %s/../orm_menu.js > %s/menu.js", ctx->dir,
ctx->dir, ctx->dir);
system( cmd);
return 1;
}
int ClassRead::html_class()
int CnvWblToHtml::class_exec()
{
pwr_tFileName fname;
int i;
......@@ -398,20 +401,20 @@ int ClassRead::html_class()
time_AtoAscii( 0, time_eFormat_DateAndTime, timestr, sizeof(timestr));
cdh_ToLower( low_volume_name, volume_name);
cdh_ToLower( low_class_name, class_name);
cdh_ToLower( low_volume_name, ctx->rw->volume_name);
cdh_ToLower( low_class_name, ctx->rw->class_name);
struct_get_filename( fname);
src_filename_to_html( struct_file, fname);
CnvWblToH::get_filename( ctx->rw, fname, 0);
CnvReadSrc::filename_to_html( struct_file, fname);
hpp = 1;
struct_get_filename( fname);
src_filename_to_html( hpp_file, fname);
hpp = 0;
ctx->hpp = 1;
CnvWblToH::get_filename( ctx->rw, fname, 0);
CnvReadSrc::filename_to_html( hpp_file, fname);
ctx->hpp = 0;
strcpy( full_class_name, volume_name);
strcpy( full_class_name, ctx->rw->volume_name);
strcat( full_class_name, ":");
strcat( full_class_name, class_name);
strcat( full_class_name, ctx->rw->class_name);
strcpy( html_file_name, low_volume_name);
strcat( html_file_name, "_");
......@@ -419,7 +422,7 @@ int ClassRead::html_class()
// Add into index file
fp_html_index <<
"<A HREF=\"" << html_file_name << ".html\" TARGET=\"classFrame\">" << class_name << "</A>" << endl <<
"<A HREF=\"" << html_file_name << ".html\" TARGET=\"classFrame\">" << ctx->rw->class_name << "</A>" << endl <<
"<BR>" << endl;
// Add into AllClasses js file
......@@ -429,14 +432,14 @@ int ClassRead::html_class()
js_all_first = false;
fp_js_all <<
"[\"" << class_name << "\",\"" << html_file_name << ".html\"]" << endl;
"[\"" << ctx->rw->class_name << "\",\"" << html_file_name << ".html\"]" << endl;
// Add into group file
for ( int i = 0; i < doc_group_cnt; i++) {
for ( int j = 0; j < setup_group_cnt; j++) {
if ( cdh_NoCaseStrcmp( doc_groups[i], setup_groups[j]) == 0) {
for ( int i = 0; i < ctx->rw->doc_group_cnt; i++) {
for ( int j = 0; j < ctx->setup->group_cnt; j++) {
if ( cdh_NoCaseStrcmp( ctx->rw->doc_groups[i], ctx->setup->groups[j]) == 0) {
fp_html_group[j] <<
"<A HREF=\"" << html_file_name << ".html\" TARGET=\"classFrame\">" << class_name << "</A>" << endl <<
"<A HREF=\"" << html_file_name << ".html\" TARGET=\"classFrame\">" << ctx->rw->class_name << "</A>" << endl <<
"<BR>" << endl;
if ( !js_group_first[j])
......@@ -444,14 +447,14 @@ int ClassRead::html_class()
else
js_group_first[j] = false;
fp_js_group[j] <<
"[\"" << class_name << "\",\"" << html_file_name << ".html\"]" << endl;
"[\"" << ctx->rw->class_name << "\",\"" << html_file_name << ".html\"]" << endl;
}
}
}
// Create class html file
strcpy( fname, dir);
strcpy( fname, ctx->dir);
strcat( fname, html_file_name);
strcat( fname, ".html");
cdh_ToLower( fname, fname);
......@@ -483,7 +486,7 @@ int ClassRead::html_class()
"<TABLE BORDER=\"0\" WIDTH=\"100%\" CELLPADDING=\"1\" CELLSPACING=\"0\">" << endl <<
"<TR>" << endl <<
"<TD COLSPAN=2 BGCOLOR=\"#EEEEFF\" CLASS=\"NavBarCell1\">" << endl <<
"<A NAME=\"navbar_top_firstrow\"><FONT CLASS=\"NavBarFont1Rev\"><B>Volume " << volume_name << "</B></FONT></A>" << endl <<
"<A NAME=\"navbar_top_firstrow\"><FONT CLASS=\"NavBarFont1Rev\"><B>Volume " << ctx->rw->volume_name << "</B></FONT></A>" << endl <<
"</TD>" << endl <<
"</TR>" << endl <<
endl <<
......@@ -495,11 +498,11 @@ endl <<
"&nbsp;|&nbsp;<A HREF=\"#template\">Template</A>" << endl <<
"&nbsp;|&nbsp;<A HREF=\"#detail\">Detail</A>" << endl <<
"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;C Binding: " << endl <<
"&nbsp;<A HREF=\"" << struct_file << "#" << class_name << "\">Struct</A>" << endl <<
"&nbsp;|&nbsp<A HREF=\"" << hpp_file << "#" << class_name << "\">Class</A>" << endl;
"&nbsp;<A HREF=\"" << struct_file << "#" << ctx->rw->class_name << "\">Struct</A>" << endl <<
"&nbsp;|&nbsp<A HREF=\"" << hpp_file << "#" << ctx->rw->class_name << "\">Class</A>" << endl;
if ( doc_fresh && strcmp( doc_code, "") != 0) {
src_filename_to_html( ref_name, doc_code);
if ( ctx->rw->doc_fresh && strcmp( ctx->rw->doc_code, "") != 0) {
CnvReadSrc::filename_to_html( ref_name, ctx->rw->doc_code);
html_clf->f <<
"&nbsp;|&nbsp;<A HREF=\"" << ref_name << "#" << low_class_name << "\">Code</A>" << endl;
}
......@@ -516,104 +519,104 @@ endl <<
"<HR>" << endl <<
"<!-- ======== START OF CLASS DATA ======== -->" << endl <<
"<H2>" << endl <<
"Class " << class_name << "</H2>" << endl <<
"Class " << ctx->rw->class_name << "</H2>" << endl <<
"<HR>" << endl <<
"<DL>" << endl;
if ( doc_fresh && strcmp( doc_author, "") != 0)
if ( ctx->rw->doc_fresh && strcmp( ctx->rw->doc_author, "") != 0)
{
html_clf->f <<
"<DT><B>Author</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" << doc_author << "<DT>" << endl;
"<DT><B>Author</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" << ctx->rw->doc_author << "<DT>" << endl;
}
if ( doc_fresh && strcmp( doc_version, "") != 0)
if ( ctx->rw->doc_fresh && strcmp( ctx->rw->doc_version, "") != 0)
{
html_clf->f <<
"<DT><B>Version</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" << doc_version << "<DT>" << endl;
"<DT><B>Version</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" << ctx->rw->doc_version << "<DT>" << endl;
}
if ( doc_fresh && strcmp( doc_code, "") != 0)
if ( ctx->rw->doc_fresh && strcmp( ctx->rw->doc_code, "") != 0)
{
html_clf->f <<
"<DT><B>Code</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A HREF=\"" << ref_name << "#" << low_class_name << "\"><FONT size=\"-1\">" << doc_code << "</FONT></A><DT>" << endl;
"<DT><B>Code</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A HREF=\"" << ref_name << "#" << low_class_name << "\"><FONT size=\"-1\">" << ctx->rw->doc_code << "</FONT></A><DT>" << endl;
}
html_clf->f <<
"<BR><DT><B>Description</B><DT><BR>" << endl <<
"</DL><DIV ID=\"description\"><XMP>" << endl;
if ( doc_fresh) {
for ( i = 0; i < doc_cnt; i++) {
remove_spaces( doc_text[i], txt);
if ( strncmp( low(txt), "@image", 6) == 0) {
if ( ctx->rw->doc_fresh) {
for ( i = 0; i < ctx->rw->doc_cnt; i++) {
ctx->remove_spaces( ctx->rw->doc_text[i], txt);
if ( strncmp( CnvCtx::low(txt), "@image", 6) == 0) {
char imagefile[80];
remove_spaces( txt + 6, imagefile);
ctx->remove_spaces( txt + 6, imagefile);
html_clf->f << "</XMP><IMG SRC=\"" << imagefile << "\"><XMP>" << endl;
}
else if ( strncmp( low(txt), "@b", 2) == 0) {
else if ( strncmp( CnvCtx::low(txt), "@b", 2) == 0) {
html_clf->f << "</XMP><B><FONT SIZE=\"3\">" << txt + 2 << "</FONT></B><XMP>" << endl;
}
else if ( strncmp( low(txt), "@h1", 3) == 0) {
else if ( strncmp( CnvCtx::low(txt), "@h1", 3) == 0) {
html_clf->f << "</XMP><H3>" << txt + 3 << "</H3><XMP>" << endl;
}
else if ( strncmp( low(txt), "@h2", 3) == 0) {
else if ( strncmp( CnvCtx::low(txt), "@h2", 3) == 0) {
html_clf->f << "</XMP><H4>" << txt + 3 << "</H4><XMP>" << endl;
}
else
html_clf->f << doc_text[i] << endl;
html_clf->f << ctx->rw->doc_text[i] << endl;
}
}
html_clf->f <<
"</XMP>" << endl;
for ( i = 0; i < doc_link_cnt; i++) {
for ( i = 0; i < ctx->rw->doc_link_cnt; i++) {
html_clf->f <<
" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A HREF=\"" << doc_link_ref[i] << "\" TARGET=\"_self\"><FONT size=\"-1\"> " << doc_link_text[i] <<"</FONT></A><BR>" << endl;
" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A HREF=\"" << ctx->rw->doc_link_ref[i] << "\" TARGET=\"_self\"><FONT size=\"-1\"> " << ctx->rw->doc_link_text[i] <<"</FONT></A><BR>" << endl;
}
for ( i = 0; i < doc_clink_cnt; i++) {
for ( i = 0; i < ctx->rw->doc_clink_cnt; i++) {
html_clf->f <<
" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A HREF=\"" << doc_clink_ref[i] << "\" TARGET=\"_self\"><FONT size=\"-1\"> " << doc_clink_text[i] <<"</FONT></A><BR>" << endl;
" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A HREF=\"" << ctx->rw->doc_clink_ref[i] << "\" TARGET=\"_self\"><FONT size=\"-1\"> " << ctx->rw->doc_clink_text[i] <<"</FONT></A><BR>" << endl;
}
html_clf->f <<
"</DIV>" << endl;
return 1;
}
int ClassRead::html_body()
int CnvWblToHtml::body_exec()
{
char struct_name[80];
pwr_tFileName fname;
pwr_tFileName struct_file;
struct_get_filename( fname);
src_filename_to_html( struct_file, fname);
CnvWblToH::get_filename( ctx->rw, fname, 0);
CnvReadSrc::filename_to_html( struct_file, fname);
if ( strcmp( low(body_name), "devbody") == 0)
if ( strcmp( CnvCtx::low(ctx->rw->body_name), "devbody") == 0)
strcpy( struct_name, "");
else
{
strcpy( struct_name, "pwr_sClass_");
if ( strcmp( body_structname, "") == 0)
strcat( struct_name, class_name);
if ( strcmp( ctx->rw->body_structname, "") == 0)
strcat( struct_name, ctx->rw->class_name);
else
strcat( struct_name, body_structname);
strcat( struct_name, ctx->rw->body_structname);
}
html_clf->f <<
"<!-- =========== BODY =========== -->" << endl <<
endl <<
"<HR><BR>" << endl <<
"<A NAME=\"" << body_name << "\"><!-- --></A>" << endl <<
"<A NAME=\"" << ctx->rw->body_name << "\"><!-- --></A>" << endl <<
"<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\" WIDTH=\"100%\">" << endl <<
"<TR BGCOLOR=\"#CCCCFF\" CLASS=\"TableHeadingColor\">" << endl <<
"<TD COLSPAN=3><FONT SIZE=\"+2\">" << endl <<
"<B>" << body_name << " attributes</B></FONT>" <<
"<FONT SIZE=\"+1\"<B>&nbsp;&nbsp;&nbsp;&nbsp; <A HREF=\"" << struct_file << "#" << class_name << "\">" << struct_name << "</A></B></FONT></TD>" << endl <<
"<B>" << ctx->rw->body_name << " attributes</B></FONT>" <<
"<FONT SIZE=\"+1\"<B>&nbsp;&nbsp;&nbsp;&nbsp; <A HREF=\"" << struct_file << "#" << ctx->rw->class_name << "\">" << struct_name << "</A></B></FONT></TD>" << endl <<
"</TR>" << endl;
return 1;
}
int ClassRead::html_body_close()
int CnvWblToHtml::body_close()
{
html_clf->f <<
"</TABLE>" << endl;
......@@ -621,7 +624,7 @@ int ClassRead::html_body_close()
return 1;
}
int ClassRead::html_graphplcnode()
int CnvWblToHtml::graphplcnode()
{
int i;
......@@ -633,22 +636,22 @@ endl <<
"<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\" WIDTH=\"100%\">" << endl <<
"<TR BGCOLOR=\"#CCCCFF\" CLASS=\"TableHeadingColor\">" << endl <<
"<TD COLSPAN=2><FONT SIZE=\"+2\">" << endl <<
"<B>" << graphplcnode_name << "</B></FONT></TD>" << endl <<
"<B>" << ctx->rw->graphplcnode_name << "</B></FONT></TD>" << endl <<
"</TR>" << endl;
for ( i = 0; i < doc_cnt; i += 2)
for ( i = 0; i < ctx->rw->doc_cnt; i += 2)
{
html_clf->f <<
"<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" << endl <<
"<TD><CODE><B>" << doc_text[i] << "</B></CODE></TD>" << endl <<
"<TD><CODE>" << doc_text[i+1] << "</CODE></TD>" << endl;
"<TD><CODE><B>" << ctx->rw->doc_text[i] << "</B></CODE></TD>" << endl <<
"<TD><CODE>" << ctx->rw->doc_text[i+1] << "</CODE></TD>" << endl;
}
html_clf->f << "</TABLE>" << endl;
return 1;
}
int ClassRead::html_graphplccon()
int CnvWblToHtml::graphplccon()
{
int i;
......@@ -659,22 +662,22 @@ endl <<
"<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\" WIDTH=\"100%\">" << endl <<
"<TR BGCOLOR=\"#CCCCFF\" CLASS=\"TableHeadingColor\">" << endl <<
"<TD COLSPAN=2><FONT SIZE=\"+2\">" << endl <<
"<B>" << graphplccon_name << "</B></FONT></TD>" << endl <<
"<B>" << ctx->rw->graphplccon_name << "</B></FONT></TD>" << endl <<
"</TR>" << endl;
for ( i = 0; i < doc_cnt; i += 2)
for ( i = 0; i < ctx->rw->doc_cnt; i += 2)
{
html_clf->f <<
"<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" << endl <<
"<TD><CODE><B>" << doc_text[i] << "</B></CODE></TD>" << endl <<
"<TD><CODE>" << doc_text[i+1] << "</CODE></TD>" << endl;
"<TD><CODE><B>" << ctx->rw->doc_text[i] << "</B></CODE></TD>" << endl <<
"<TD><CODE>" << ctx->rw->doc_text[i+1] << "</CODE></TD>" << endl;
}
html_clf->f << "</TABLE>" << endl;
return 1;
}
int ClassRead::html_template()
int CnvWblToHtml::template_exec()
{
int i;
......@@ -692,24 +695,24 @@ endl <<
"<B>Template Object</B></FONT></TD>" << endl <<
"</TR>" << endl;
for ( i = 0; i < doc_cnt; i += 2)
for ( i = 0; i < ctx->rw->doc_cnt; i += 2)
{
html_clf->f <<
"<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" << endl <<
"<TD><CODE><B>" << doc_text[i] << "</B></CODE></TD>" << endl <<
"<TD><CODE>" << doc_text[i+1] << "</CODE></TD>" << endl;
"<TD><CODE><B>" << ctx->rw->doc_text[i] << "</B></CODE></TD>" << endl <<
"<TD><CODE>" << ctx->rw->doc_text[i+1] << "</CODE></TD>" << endl;
}
html_clf->f << "</TABLE>" << endl;
return 1;
}
int ClassRead::html_class_close()
int CnvWblToHtml::class_close()
{
fp_tmp.close();
// Copy temporary file
copy_tmp_file( cread_cTmpFile1, html_clf->f);
ctx->rw->copy_tmp_file( cread_cTmpFile1, html_clf->f);
html_clf->f <<
"<!-- ========= END OF CLASS DATA ========= -->" << endl <<
......@@ -724,35 +727,35 @@ int ClassRead::html_class_close()
return 1;
}
int ClassRead::html_attribute()
int CnvWblToHtml::attribute_exec()
{
int i;
char txt[200];
char typeref_href[80];
char attrtype_href[80];
if ( strncmp( attr_typeref, "pwr_eClass_", 11) == 0) {
strcpy( typeref_href, &attr_typeref[11]);
strcpy( attr_typeref, typeref_href);
if ( strncmp( ctx->rw->attr_typeref, "pwr_eClass_", 11) == 0) {
strcpy( typeref_href, &ctx->rw->attr_typeref[11]);
strcpy( ctx->rw->attr_typeref, typeref_href);
}
else if ( strncmp( attr_typeref, "pwr_eType_", 10) == 0) {
strcpy( typeref_href, &attr_typeref[10]);
strcpy( attr_typeref, typeref_href);
else if ( strncmp( ctx->rw->attr_typeref, "pwr_eType_", 10) == 0) {
strcpy( typeref_href, &ctx->rw->attr_typeref[10]);
strcpy( ctx->rw->attr_typeref, typeref_href);
}
else if ( strncmp( attr_typeref, "pwr_eTypeDef_", 13) == 0) {
strcpy( typeref_href, &attr_typeref[13]);
strcpy( attr_typeref, typeref_href);
else if ( strncmp( ctx->rw->attr_typeref, "pwr_eTypeDef_", 13) == 0) {
strcpy( typeref_href, &ctx->rw->attr_typeref[13]);
strcpy( ctx->rw->attr_typeref, typeref_href);
}
if ( strcmp( attr_typeref_volume, "") != 0) {
if ( strcmp( ctx->rw->attr_typeref_volume, "") != 0) {
char low_volname[80];
strcpy( low_volname, low(attr_typeref_volume));
strcpy( low_volname, CnvCtx::low(ctx->rw->attr_typeref_volume));
sprintf( typeref_href, "%s_%s.html", low_volname,
low(attr_typeref));
CnvCtx::low(ctx->rw->attr_typeref));
}
else
sprintf( typeref_href, "pwrs_%s.html", low(attr_typeref));
sprintf( typeref_href, "pwrs_%s.html", CnvCtx::low(ctx->rw->attr_typeref));
sprintf( attrtype_href, "pwrs_%s.html", low(attr_type));
sprintf( attrtype_href, "pwrs_%s.html", CnvCtx::low(ctx->rw->attr_type));
// Summary
......@@ -761,49 +764,49 @@ int ClassRead::html_attribute()
"<TD ALIGN=\"right\" VALIGN=\"top\" WIDTH=\"1%\"><FONT SIZE=\"-1\">" << endl <<
"<A HREF=\"" << typeref_href << "\">";
if ( attr_array && attr_pointer)
if ( ctx->rw->attr_array && ctx->rw->attr_pointer)
html_clf->f <<
"<CODE>Array of pointers to "<< attr_typeref << "</CODE></FONT></A></TD>" << endl;
else if ( attr_array)
"<CODE>Array of pointers to "<< ctx->rw->attr_typeref << "</CODE></FONT></A></TD>" << endl;
else if ( ctx->rw->attr_array)
html_clf->f <<
"<CODE>Array of "<< attr_typeref << "</CODE></FONT></A></TD>" << endl;
else if ( attr_pointer)
"<CODE>Array of "<< ctx->rw->attr_typeref << "</CODE></FONT></A></TD>" << endl;
else if ( ctx->rw->attr_pointer)
html_clf->f <<
"<CODE>Pointer to " << attr_typeref << "</CODE></FONT></A></TD>" << endl;
"<CODE>Pointer to " << ctx->rw->attr_typeref << "</CODE></FONT></A></TD>" << endl;
else
html_clf->f <<
"<CODE>" << attr_typeref << "</CODE></FONT></A></TD>" << endl;
"<CODE>" << ctx->rw->attr_typeref << "</CODE></FONT></A></TD>" << endl;
html_clf->f <<
"</A><TD><A HREF=\"#" << attr_name << "\"><CODE><B>" << attr_name << "</B></CODE></A></TD>" << endl <<
"</A><TD><A HREF=\"#" << ctx->rw->attr_name << "\"><CODE><B>" << ctx->rw->attr_name << "</B></CODE></A></TD>" << endl <<
"<TD>";
if ( doc_fresh)
if ( ctx->rw->doc_fresh)
{
if ( strcmp( doc_summary, "") == 0)
if ( strcmp( ctx->rw->doc_summary, "") == 0)
{
for ( i = 0; i < doc_cnt; i++) {
remove_spaces( doc_text[i], txt);
if ( strncmp( low(txt), "@image", 6) == 0) {
for ( i = 0; i < ctx->rw->doc_cnt; i++) {
ctx->remove_spaces( ctx->rw->doc_text[i], txt);
if ( strncmp( CnvCtx::low(txt), "@image", 6) == 0) {
continue;
}
else if ( strncmp( low(txt), "@b", 2) == 0) {
else if ( strncmp( CnvCtx::low(txt), "@b", 2) == 0) {
html_clf->f << "</XMP><B><FONT SIZE=\"3\">" << txt + 2 << "</FONT></B><XMP>" << endl;
}
else if ( strncmp( low(txt), "@h1", 3) == 0) {
else if ( strncmp( CnvCtx::low(txt), "@h1", 3) == 0) {
html_clf->f << "<H3>" << txt + 3 << "</H3>" << endl;
}
else if ( strncmp( low(txt), "@h2", 3) == 0) {
else if ( strncmp( CnvCtx::low(txt), "@h2", 3) == 0) {
html_clf->f << "<H4>" << txt + 3 << "</H4>" << endl;
}
else {
html_clf->f << doc_text[i];
if ( i < doc_cnt - 1)
html_clf->f << ctx->rw->doc_text[i];
if ( i < ctx->rw->doc_cnt - 1)
html_clf->f << "<BR>" << endl;
}
}
}
else
html_clf->f << doc_summary << endl;
html_clf->f << ctx->rw->doc_summary << endl;
}
else
html_clf->f << "<BR>" << endl;
......@@ -816,59 +819,59 @@ int ClassRead::html_attribute()
fp_tmp <<
"<HR>" << endl <<
"<A NAME=\"" << attr_name << "\"> <H3>" <<
"<FONT SIZE=\"-1\">" << attr_type << "</FONT> " << attr_name << "</H3></A>" << endl <<
"<A NAME=\"" << ctx->rw->attr_name << "\"> <H3>" <<
"<FONT SIZE=\"-1\">" << ctx->rw->attr_type << "</FONT> " << ctx->rw->attr_name << "</H3></A>" << endl <<
"<DL><DT>" << endl;
if ( attr_array && attr_pointer)
if ( ctx->rw->attr_array && ctx->rw->attr_pointer)
fp_tmp <<
"<CODE><B>Type</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Array of pointers to <A HREF=\"" << typeref_href << "\">" << attr_typeref << "</A></CODE><DT>" << endl;
else if ( attr_array)
"<CODE><B>Type</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Array of pointers to <A HREF=\"" << typeref_href << "\">" << ctx->rw->attr_typeref << "</A></CODE><DT>" << endl;
else if ( ctx->rw->attr_array)
fp_tmp <<
"<CODE><B>Type</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Array of <A HREF=\"" << typeref_href << "\">" << attr_typeref << "</A></CODE><DT>" << endl;
else if ( attr_pointer)
"<CODE><B>Type</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Array of <A HREF=\"" << typeref_href << "\">" << ctx->rw->attr_typeref << "</A></CODE><DT>" << endl;
else if ( ctx->rw->attr_pointer)
fp_tmp <<
"<CODE><B>Type</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pointer to <A HREF=\"" << typeref_href << "\">" << attr_typeref << "</A></CODE><DT>" << endl;
"<CODE><B>Type</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pointer to <A HREF=\"" << typeref_href << "\">" << ctx->rw->attr_typeref << "</A></CODE><DT>" << endl;
else
fp_tmp <<
"<CODE><B>Type</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A HREF=\"" << typeref_href << "\">" << attr_typeref << "</A></CODE><DT>" << endl;
"<CODE><B>Type</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A HREF=\"" << typeref_href << "\">" << ctx->rw->attr_typeref << "</A></CODE><DT>" << endl;
fp_tmp <<
"<DT><CODE><B><A HREF=\"" << attrtype_href << "#Flags\">Flags</A></B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" << attr_flags << "</CODE><DT>" << endl;
"<DT><CODE><B><A HREF=\"" << attrtype_href << "#Flags\">Flags</A></B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" << ctx->rw->attr_flags << "</CODE><DT>" << endl;
if ( attr_array)
if ( ctx->rw->attr_array)
fp_tmp <<
"<DT><CODE><B>Elements</B>&nbsp;&nbsp;" << attr_elements << "</CODE><DT>" << endl;
"<DT><CODE><B>Elements</B>&nbsp;&nbsp;" << ctx->rw->attr_elements << "</CODE><DT>" << endl;
fp_tmp <<
"<DT><CODE><B>Body</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" << body_name << "</CODE><DT>" << endl <<
"<DT><CODE><B>Class</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A HREF=\"" << attrtype_href << "\">$" << attr_type << "</A></CODE><DT>" << endl;
"<DT><CODE><B>Body</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" << ctx->rw->body_name << "</CODE><DT>" << endl <<
"<DT><CODE><B>Class</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A HREF=\"" << attrtype_href << "\">$" << ctx->rw->attr_type << "</A></CODE><DT>" << endl;
fp_tmp <<
"<BR>" << endl <<
"<CODE><B>Description</B></CODE><DT></DL>" << endl <<
"<DIV ID=\"description\"><XMP>" << endl;
if ( doc_fresh) {
for ( i = 0; i < doc_cnt; i++) {
remove_spaces( doc_text[i], txt);
if ( strncmp( low(txt), "@image", 6) == 0) {
if ( ctx->rw->doc_fresh) {
for ( i = 0; i < ctx->rw->doc_cnt; i++) {
ctx->remove_spaces( ctx->rw->doc_text[i], txt);
if ( strncmp( CnvCtx::low(txt), "@image", 6) == 0) {
char imagefile[80];
remove_spaces( txt + 6, imagefile);
ctx->remove_spaces( txt + 6, imagefile);
fp_tmp << "</XMP><IMG SRC=\"" << imagefile << "\"><XMP>" << endl;
}
else if ( strncmp( low(txt), "@b", 2) == 0) {
else if ( strncmp( CnvCtx::low(txt), "@b", 2) == 0) {
fp_tmp << "</XMP><B><FONT SIZE=\"3\">" << txt + 2 << "</FONT></B><XMP>" << endl;
}
else if ( strncmp( low(txt), "@h1", 3) == 0) {
else if ( strncmp( CnvCtx::low(txt), "@h1", 3) == 0) {
fp_tmp << "</XMP><H3>" << txt + 3 << "</H3><XMP>" << endl;
}
else if ( strncmp( low(txt), "@h2", 3) == 0) {
else if ( strncmp( CnvCtx::low(txt), "@h2", 3) == 0) {
fp_tmp << "</XMP><H4>" << txt + 3 << "</H4><XMP>" << endl;
}
else
fp_tmp << doc_text[i] << endl;
fp_tmp << ctx->rw->doc_text[i] << endl;
}
}
fp_tmp <<
......@@ -878,47 +881,47 @@ int ClassRead::html_attribute()
}
int ClassRead::html_bit()
int CnvWblToHtml::bit_exec()
{
int i;
char txt[200];
// Summary
char bitchar = _tolower(typedef_typeref[0]);
char bitchar = _tolower(ctx->rw->typedef_typeref[0]);
html_clf->f <<
"<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" << endl <<
"<TD>" << endl <<
"<CODE><FONT SIZE=\"-1\">pwr_" << bitchar << typedef_name << "_" << bit_pgmname << "</FONT></CODE></TD>" << endl <<
"<TD ALIGN =\"right\" VALIGN=\"top\" WIDTH=\"1%\"><A HREF=\"#" << bit_name << "\"><CODE><B>" << bit_text << "</B></CODE></A></TD>" << endl <<
"<CODE><FONT SIZE=\"-1\">pwr_" << bitchar << ctx->rw->typedef_name << "_" << ctx->rw->bit_pgmname << "</FONT></CODE></TD>" << endl <<
"<TD ALIGN =\"right\" VALIGN=\"top\" WIDTH=\"1%\"><A HREF=\"#" << ctx->rw->bit_name << "\"><CODE><B>" << ctx->rw->bit_text << "</B></CODE></A></TD>" << endl <<
"<TD>";
if ( doc_fresh)
if ( ctx->rw->doc_fresh)
{
if ( strcmp( doc_summary, "") == 0)
if ( strcmp( ctx->rw->doc_summary, "") == 0)
{
for ( i = 0; i < doc_cnt; i++) {
remove_spaces( doc_text[i], txt);
if ( strncmp( low(txt), "@image", 6) == 0) {
for ( i = 0; i < ctx->rw->doc_cnt; i++) {
ctx->remove_spaces( ctx->rw->doc_text[i], txt);
if ( strncmp( CnvCtx::low(txt), "@image", 6) == 0) {
continue;
}
else if ( strncmp( low(txt), "@b", 2) == 0) {
else if ( strncmp( CnvCtx::low(txt), "@b", 2) == 0) {
html_clf->f << "</XMP><B><FONT SIZE=\"3\">" << txt + 2 << "</FONT></B><XMP>" << endl;
}
else if ( strncmp( low(txt), "@h1", 3) == 0) {
else if ( strncmp( CnvCtx::low(txt), "@h1", 3) == 0) {
html_clf->f << "<H3>" << txt + 3 << "</H3>" << endl;
}
else if ( strncmp( low(txt), "@h2", 3) == 0) {
else if ( strncmp( CnvCtx::low(txt), "@h2", 3) == 0) {
html_clf->f << "<H4>" << txt + 3 << "</H4>" << endl;
}
else {
html_clf->f << doc_text[i];
if ( i < doc_cnt - 1)
html_clf->f << ctx->rw->doc_text[i];
if ( i < ctx->rw->doc_cnt - 1)
html_clf->f << "<BR>" << endl;
}
}
}
else
html_clf->f << doc_summary << endl;
html_clf->f << ctx->rw->doc_summary << endl;
}
else
html_clf->f << "<BR>" << endl;
......@@ -931,36 +934,36 @@ int ClassRead::html_bit()
fp_tmp <<
"<HR>" << endl <<
"<A NAME=\"" << bit_name << "\"> <H3>" <<
"<FONT SIZE=\"-1\">pwr_" << bitchar << typedef_name << "_" << bit_pgmname << "</FONT>&nbsp;&nbsp" << bit_text << "</H3></A>" << endl <<
"<A NAME=\"" << ctx->rw->bit_name << "\"> <H3>" <<
"<FONT SIZE=\"-1\">pwr_" << bitchar << ctx->rw->typedef_name << "_" << ctx->rw->bit_pgmname << "</FONT>&nbsp;&nbsp" << ctx->rw->bit_text << "</H3></A>" << endl <<
"<DL><DT>" << endl <<
"<CODE><B>Value</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" << bit_value << "</CODE><DT>" << endl;
"<CODE><B>Value</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" << ctx->rw->bit_value << "</CODE><DT>" << endl;
fp_tmp <<
"<BR>" << endl <<
"<CODE><B>Description</B></CODE><DT></DL>" << endl <<
"<DIV ID=\"description\"><XMP>" << endl;
if ( doc_fresh) {
for ( i = 0; i < doc_cnt; i++) {
remove_spaces( doc_text[i], txt);
if ( strncmp( low(txt), "@image", 6) == 0) {
if ( ctx->rw->doc_fresh) {
for ( i = 0; i < ctx->rw->doc_cnt; i++) {
ctx->remove_spaces( ctx->rw->doc_text[i], txt);
if ( strncmp( CnvCtx::low(txt), "@image", 6) == 0) {
char imagefile[80];
remove_spaces( txt + 6, imagefile);
ctx->remove_spaces( txt + 6, imagefile);
fp_tmp << "</XMP><IMG SRC=\"" << imagefile << "\"><XMP>" << endl;
}
else if ( strncmp( low(txt), "@b", 2) == 0) {
else if ( strncmp( CnvCtx::low(txt), "@b", 2) == 0) {
fp_tmp << "</XMP><B><FONT SIZE=\"3\">" << txt + 2 << "</FONT></B><XMP>" << endl;
}
else if ( strncmp( low(txt), "@h1", 3) == 0) {
else if ( strncmp( CnvCtx::low(txt), "@h1", 3) == 0) {
fp_tmp << "</XMP><H3>" << txt + 3 << "</H3><XMP>" << endl;
}
else if ( strncmp( low(txt), "@h2", 3) == 0) {
else if ( strncmp( CnvCtx::low(txt), "@h2", 3) == 0) {
fp_tmp << "</XMP><H4>" << txt + 3 << "</H4><XMP>" << endl;
}
else
fp_tmp << doc_text[i] << endl;
fp_tmp << ctx->rw->doc_text[i] << endl;
}
}
fp_tmp <<
......@@ -970,7 +973,7 @@ int ClassRead::html_bit()
}
int ClassRead::html_typedef()
int CnvWblToHtml::typedef_exec()
{
pwr_tFileName fname;
int i;
......@@ -983,17 +986,17 @@ int ClassRead::html_typedef()
char txt[200];
char code_aref[200];
strcpy( class_name, typedef_name);
strcpy( ctx->rw->class_name, ctx->rw->typedef_name);
cdh_ToLower( low_volume_name, volume_name);
cdh_ToLower( low_class_name, class_name);
cdh_ToLower( low_volume_name, ctx->rw->volume_name);
cdh_ToLower( low_class_name, ctx->rw->class_name);
struct_get_filename( fname);
src_filename_to_html( struct_file, fname);
CnvWblToH::get_filename( ctx->rw, fname, 0);
CnvReadSrc::filename_to_html( struct_file, fname);
strcpy( full_class_name, volume_name);
strcpy( full_class_name, ctx->rw->volume_name);
strcat( full_class_name, ":");
strcat( full_class_name, class_name);
strcat( full_class_name, ctx->rw->class_name);
strcpy( html_file_name, low_volume_name);
strcat( html_file_name, "_");
......@@ -1001,7 +1004,7 @@ int ClassRead::html_typedef()
// Add into index file
fp_html_index <<
"<A HREF=\"" << html_file_name << ".html\" TARGET=\"classFrame\">" << class_name << "</A>" << endl <<
"<A HREF=\"" << html_file_name << ".html\" TARGET=\"classFrame\">" << ctx->rw->class_name << "</A>" << endl <<
"<BR>" << endl;
// Add into AllClasses js file
......@@ -1011,14 +1014,14 @@ int ClassRead::html_typedef()
js_all_first = false;
fp_js_all <<
"[\"" << class_name << "\",\"" << html_file_name << ".html\"]" << endl;
"[\"" << ctx->rw->class_name << "\",\"" << html_file_name << ".html\"]" << endl;
// Add into group file
for ( int i = 0; i < doc_group_cnt; i++) {
for ( int j = 0; j < setup_group_cnt; j++) {
if ( cdh_NoCaseStrcmp( doc_groups[i], setup_groups[j]) == 0) {
for ( int i = 0; i < ctx->rw->doc_group_cnt; i++) {
for ( int j = 0; j < ctx->setup->group_cnt; j++) {
if ( cdh_NoCaseStrcmp( ctx->rw->doc_groups[i], ctx->setup->groups[j]) == 0) {
fp_html_group[j] <<
"<A HREF=\"" << html_file_name << ".html\" TARGET=\"classFrame\">" << class_name << "</A>" << endl <<
"<A HREF=\"" << html_file_name << ".html\" TARGET=\"classFrame\">" << ctx->rw->class_name << "</A>" << endl <<
"<BR>" << endl;
if ( !js_group_first[j])
......@@ -1027,14 +1030,14 @@ int ClassRead::html_typedef()
js_group_first[j] = false;
fp_js_group[j] <<
"[\"" << class_name << "\",\"" << html_file_name << ".html\"]" << endl;
"[\"" << ctx->rw->class_name << "\",\"" << html_file_name << ".html\"]" << endl;
}
}
}
// Create class html file
strcpy( fname, dir);
strcpy( fname, ctx->dir);
strcat( fname, html_file_name);
strcat( fname, ".html");
cdh_ToLower( fname, fname);
......@@ -1063,23 +1066,23 @@ int ClassRead::html_typedef()
"<TABLE BORDER=\"0\" WIDTH=\"100%\" CELLPADDING=\"1\" CELLSPACING=\"0\">" << endl <<
"<TR>" << endl <<
"<TD COLSPAN=2 BGCOLOR=\"#EEEEFF\" CLASS=\"NavBarCell1\">" << endl <<
"<A NAME=\"navbar_top_firstrow\"><FONT CLASS=\"NavBarFont1Rev\"><B>Volume " << volume_name << "</B></FONT></A>" << endl <<
"<A NAME=\"navbar_top_firstrow\"><FONT CLASS=\"NavBarFont1Rev\"><B>Volume " << ctx->rw->volume_name << "</B></FONT></A>" << endl <<
"</TD>" << endl <<
"</TR>" << endl <<
endl <<
"<TR>" << endl <<
"<TD BGCOLOR=\"white\" CLASS=\"NavBarCell2\"><FONT SIZE=\"-2\">" << endl;
if ( (strcmp( typedef_typeref, "Mask") == 0 ||
strcmp( typedef_typeref, "Enum") == 0) &&
if ( (strcmp( ctx->rw->typedef_typeref, "Mask") == 0 ||
strcmp( ctx->rw->typedef_typeref, "Enum") == 0) &&
strcmp( low_volume_name, "pwrs") != 0) {
sprintf( code_aref, "%s#%s", struct_file, typedef_name);
sprintf( code_aref, "%s#%s", struct_file, ctx->rw->typedef_name);
html_clf->f <<
" C Binding: &nbsp;<A HREF=\"" << code_aref << "\">Typedef</A>" << endl;
}
else if ( doc_fresh && strcmp( doc_code, "") != 0)
else if ( ctx->rw->doc_fresh && strcmp( ctx->rw->doc_code, "") != 0)
{
src_filename_to_html( ref_name, doc_code);
CnvReadSrc::filename_to_html( ref_name, ctx->rw->doc_code);
sprintf( code_aref, "%s#%s", ref_name, low_class_name);
html_clf->f <<
" C Binding: &nbsp;<A HREF=\"" << code_aref << "\">Typedef</A>" << endl;
......@@ -1098,88 +1101,88 @@ endl <<
"<HR>" << endl <<
"<!-- ======== START OF CLASS DATA ======== -->" << endl <<
"<H2>" << endl <<
"Type " << class_name << "</H2>" << endl <<
"Type " << ctx->rw->class_name << "</H2>" << endl <<
"<HR>" << endl <<
"<DL>" << endl;
if ( doc_fresh && strcmp( doc_author, "") != 0)
if ( ctx->rw->doc_fresh && strcmp( ctx->rw->doc_author, "") != 0)
{
html_clf->f <<
"<DT><B>Author</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" << doc_author << "<DT>" << endl;
"<DT><B>Author</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" << ctx->rw->doc_author << "<DT>" << endl;
}
if ( doc_fresh && strcmp( doc_version, "") != 0)
if ( ctx->rw->doc_fresh && strcmp( ctx->rw->doc_version, "") != 0)
{
html_clf->f <<
"<DT><B>Version</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" << doc_version << "<DT>" << endl;
"<DT><B>Version</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" << ctx->rw->doc_version << "<DT>" << endl;
}
if ( doc_fresh && strcmp( doc_code, "") != 0)
if ( ctx->rw->doc_fresh && strcmp( ctx->rw->doc_code, "") != 0)
{
html_clf->f <<
"<DT><B>Code</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" << doc_code << "<DT>" << endl;
"<DT><B>Code</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" << ctx->rw->doc_code << "<DT>" << endl;
}
html_clf->f <<
"<BR><DT><B>Description</B><DT><BR>" << endl <<
"</DL><DIV ID=\"description\"><XMP>" << endl;
if ( doc_fresh) {
for ( i = 0; i < doc_cnt; i++) {
remove_spaces( doc_text[i], txt);
if ( strncmp( low(txt), "@image", 6) == 0) {
if ( ctx->rw->doc_fresh) {
for ( i = 0; i < ctx->rw->doc_cnt; i++) {
ctx->remove_spaces( ctx->rw->doc_text[i], txt);
if ( strncmp( CnvCtx::low(txt), "@image", 6) == 0) {
char imagefile[80];
remove_spaces( txt + 6, imagefile);
ctx->remove_spaces( txt + 6, imagefile);
html_clf->f << "</XMP><IMG SRC=\"" << imagefile << "\"><XMP>" << endl;
}
else if ( strncmp( low(txt), "@b", 2) == 0) {
else if ( strncmp( CnvCtx::low(txt), "@b", 2) == 0) {
html_clf->f << "</XMP><B><FONT SIZE=\"3\">" << txt + 2 << "</FONT></B><XMP>" << endl;
}
else if ( strncmp( low(txt), "@h1", 3) == 0) {
else if ( strncmp( CnvCtx::low(txt), "@h1", 3) == 0) {
html_clf->f << "</XMP><H3>" << txt + 3 << "</H3><XMP>" << endl;
}
else if ( strncmp( low(txt), "@h2", 3) == 0) {
else if ( strncmp( CnvCtx::low(txt), "@h2", 3) == 0) {
html_clf->f << "</XMP><H4>" << txt + 3 << "</H4><XMP>" << endl;
}
else
html_clf->f << doc_text[i] << endl;
html_clf->f << ctx->rw->doc_text[i] << endl;
}
}
html_clf->f <<
"</XMP></DIV>" << endl;
for ( i = 0; i < doc_link_cnt; i++) {
for ( i = 0; i < ctx->rw->doc_link_cnt; i++) {
html_clf->f <<
" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A HREF=\"" << doc_link_ref[i] << "\" TARGET=\"_self\"><FONT size=\"-1\"> " << doc_link_text[i] <<"</FONT></A><BR>" << endl;
" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A HREF=\"" << ctx->rw->doc_link_ref[i] << "\" TARGET=\"_self\"><FONT size=\"-1\"> " << ctx->rw->doc_link_text[i] <<"</FONT></A><BR>" << endl;
}
for ( i = 0; i < doc_clink_cnt; i++) {
for ( i = 0; i < ctx->rw->doc_clink_cnt; i++) {
html_clf->f <<
" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A HREF=\"" << doc_clink_ref[i] << "\" TARGET=\"_self\"><FONT size=\"-1\"> " << doc_clink_text[i] <<"</FONT></A><BR>" << endl;
" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A HREF=\"" << ctx->rw->doc_clink_ref[i] << "\" TARGET=\"_self\"><FONT size=\"-1\"> " << ctx->rw->doc_clink_text[i] <<"</FONT></A><BR>" << endl;
}
html_clf->f <<
"</FONT>" << endl;
if ( strcmp( typedef_typeref, "Mask") == 0 ||
strcmp( typedef_typeref, "Enum") == 0) {
char bitchar = _tolower(typedef_typeref[0]);
if ( strcmp( ctx->rw->typedef_typeref, "Mask") == 0 ||
strcmp( ctx->rw->typedef_typeref, "Enum") == 0) {
char bitchar = _tolower(ctx->rw->typedef_typeref[0]);
html_clf->f <<
"<HR><BR>" << endl <<
"<A NAME=\"" << typedef_name << "\"><!-- --></A>" << endl <<
"<A NAME=\"" << ctx->rw->typedef_name << "\"><!-- --></A>" << endl <<
"<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\" WIDTH=\"100%\">" << endl <<
"<TR BGCOLOR=\"#CCCCFF\" CLASS=\"TableHeadingColor\">" << endl <<
"<TD COLSPAN=3><FONT SIZE=\"+2\">" << endl <<
"<B>" << typedef_name << " elements</B></FONT>" <<
"<FONT SIZE=\"+1\"<B>&nbsp;&nbsp;&nbsp;&nbsp; <A HREF=\"" << code_aref << "\">pwr_" << bitchar << typedef_name << "</A></B></FONT></TD>" << endl <<
"<B>" << ctx->rw->typedef_name << " elements</B></FONT>" <<
"<FONT SIZE=\"+1\"<B>&nbsp;&nbsp;&nbsp;&nbsp; <A HREF=\"" << code_aref << "\">pwr_" << bitchar << ctx->rw->typedef_name << "</A></B></FONT></TD>" << endl <<
"</TR>" << endl;
}
return 1;
}
int ClassRead::html_typedef_close()
int CnvWblToHtml::typedef_close()
{
if ( strcmp( typedef_typeref, "Mask") == 0 ||
strcmp( typedef_typeref, "Enum") == 0) {
if ( strcmp( ctx->rw->typedef_typeref, "Mask") == 0 ||
strcmp( ctx->rw->typedef_typeref, "Enum") == 0) {
html_clf->f <<
"</TABLE>" << endl;
}
......@@ -1187,7 +1190,7 @@ int ClassRead::html_typedef_close()
fp_tmp.close();
// Copy temporary file
copy_tmp_file( cread_cTmpFile1, html_clf->f);
ctx->rw->copy_tmp_file( cread_cTmpFile1, html_clf->f);
html_clf->f <<
"<!-- ========= END OF CLASS DATA ========= -->" << endl <<
......
#ifndef cnv_wbltohtml_h
#define cnv_wbltohtml_h
/* cnv_wbltohtml.h -- Documentation
PROVIEW/R
Copyright (C) 1996 by Comator Process AB.
<Description>. */
#if defined __cplusplus
extern "C" {
#endif
#include "pwr.h"
#include "cnv_readwbl.h"
#include "cnv_wblto.h"
using namespace std;
class CnvReadWbl;
class CnvWblToHtml : public CnvWblTo {
public:
CnvWblToHtml( CnvCtx *cnv_ctx) : ctx(cnv_ctx),
html_class_open(0), html_index_open(0), js_all_first(0) {}
virtual ~CnvWblToHtml() {}
CnvCtx *ctx;
CnvFile *html_clf;
ofstream fp_html_index;
ofstream fp_js_all;
ofstream fp_tmp;
ofstream fp_html_group[MAX_GROUPS];
ofstream fp_js_group[MAX_GROUPS];
char html_first[80];
char html_tmp_name[80];
int html_class_open;
int html_index_open;
bool js_all_first;
bool js_group_first[80];
int init( char *first);
int close();
int class_exec();
int class_close();
int body_exec();
int body_close();
int attribute_exec();
int graphplcnode();
int graphplccon();
int template_exec();
int typedef_exec();
int typedef_close();
int bit_exec();
Cnv_eWblToType type() { return Cnv_eWblToType_Html;}
int class_open() { return html_class_open;}
};
#if defined __cplusplus
}
#endif
#endif
#include <iostream.h>
#include <fstream.h>
#include <float.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "cnv_wbltops.h"
#include "cnv_ctx.h"
extern "C" {
#include "pwr.h"
#include "co_cdh.h"
}
#include "co_lng.h"
CnvWblToPs::~CnvWblToPs()
{
tops.close();
}
int CnvWblToPs::init( char *first)
{
pwr_tFileName fname;
char text[200];
strcpy( fname, ctx->dir);
strcat( fname, ctx->rw->volume_name);
strcat( fname, ".ps");
cdh_ToLower( fname, fname);
tops.set_filename( ps_eFile_Info, fname);
tops.set_filename( ps_eFile_Body, ps_cTmpFile);
tops.open();
// Print first page
tops.set_cf( ps_eFile_Info);
tops.set_ci( ps_eId_TitlePage);
tops.y -= 100;
tops.print_image("pwr_logga.gif");
tops.y -= 100;
tops.print_h2( "Object Reference Manual");
tops.print_h3( "Volume");
tops.print_h2( ctx->rw->volume_name);
tops.y -= 150;
tops.print_horizontal_line();
tops.print_text("Version V4.1.0", tops.style[tops.ci].text);
tops.print_horizontal_line();
tops.print_pagebreak( 0);
tops.set_cf( ps_eFile_Info);
tops.set_ci( ps_eId_InfoPage);
tops.y = ps_cPageHeight - ps_cTopMargin - 600;
tops.print_text("Copyright 2004 SSAB Oxelsund AB", tops.style[tops.ci].text);
tops.print_text("All rights reserved.", tops.style[tops.ci].text);
tops.y = ps_cPageHeight - ps_cTopMargin;
tops.set_cf( ps_eFile_Body);
tops.set_ci( ps_eId_Class);
sprintf( text, "Volume %s", ctx->rw->volume_name);
tops.set_pageheader( text);
return 1;
}
int CnvWblToPs::close()
{
return 1;
}
int CnvWblToPs::class_exec()
{
int i;
char full_class_name[80];
char link_ref[80];
char *s;
char txt[256];
strcpy( full_class_name, ctx->rw->volume_name);
strcat( full_class_name, ":");
strcat( full_class_name, ctx->rw->class_name);
tops.set_pageheader( full_class_name);
sprintf( txt, "Class %s", ctx->rw->class_name);
tops.print_h1( txt, 0, CnvCtx::low( ctx->rw->class_name));
if ( ctx->rw->doc_fresh && strcmp( ctx->rw->doc_author, "") != 0) {
sprintf( txt, "Author %s", ctx->rw->doc_author);
tops.print_text( txt, tops.style[tops.ci].text);
}
if ( ctx->rw->doc_fresh && strcmp( ctx->rw->doc_version, "") != 0) {
sprintf( txt, "Version %s", ctx->rw->doc_version);
tops.print_text( txt, tops.style[tops.ci].text);
}
if ( ctx->rw->doc_fresh && strcmp( ctx->rw->doc_code, "") != 0) {
sprintf( txt, "Code %s", ctx->rw->doc_code);
tops.print_text( txt, tops.style[tops.ci].text);
}
tops.print_h2( "Description");
if ( ctx->rw->doc_fresh) {
for ( i = 0; i < ctx->rw->doc_cnt; i++) {
CnvCtx::remove_spaces( ctx->rw->doc_text[i], txt);
if ( strncmp( CnvCtx::low(txt), "@image", 6) == 0) {
char imagefile[80];
CnvCtx::remove_spaces( txt + 6, imagefile);
tops.print_image( imagefile);
}
else if ( strncmp( CnvCtx::low(txt), "@b", 2) == 0) {
tops.print_text( txt + 2, tops.style[tops.ci].boldtext);
}
else if ( strncmp( CnvCtx::low(txt), "@h1", 3) == 0) {
tops.print_h2( txt + 3);
}
else if ( strncmp( CnvCtx::low(txt), "@h2", 3) == 0) {
tops.print_h3( txt + 3);
}
else
tops.print_text( ctx->rw->doc_text[i], tops.style[tops.ci].text);
}
}
for ( i = 0; i < ctx->rw->doc_clink_cnt; i++) {
if ( !conf_pass) {
int page;
char str[200];
char text[200];
if ( strncmp( ctx->rw->doc_clink_ref[i], "pwrb_", 5) == 0)
strcpy( link_ref, &ctx->rw->doc_clink_ref[i][5]);
else if ( strncmp( ctx->rw->doc_clink_ref[i], "pwrs_", 5) == 0)
strcpy( link_ref, &ctx->rw->doc_clink_ref[i][5]);
else if ( strncmp( ctx->rw->doc_clink_ref[i], "nmps_", 5) == 0)
strcpy( link_ref, &ctx->rw->doc_clink_ref[i][5]);
else if ( strncmp( ctx->rw->doc_clink_ref[i], "ssab_", 5) == 0)
strcpy( link_ref, &ctx->rw->doc_clink_ref[i][5]);
else
strcpy( link_ref, ctx->rw->doc_clink_ref[i]);
if ( (s = strrchr( link_ref, '.')))
*s = 0;
int sts = tops.content.find_link( link_ref, text, &page);
if ( ODD(sts)) {
sprintf( str, " (%s %s ", Lng::translate("See"), text);
sprintf( &str[strlen(str)], "%s %d)", Lng::translate("page"), page);
tops.print_text( ctx->rw->doc_clink_text[i],
tops.style[tops.ci].text, ps_mPrintMode_Start);
tops.print_text( str, tops.style[tops.ci].link, ps_mPrintMode_End);
}
else {
tops.print_text( ctx->rw->doc_clink_text[i],
tops.style[tops.ci].text, ps_mPrintMode_Start);
sprintf( str, " (%s %s)", Lng::translate("See"), ctx->rw->doc_clink_ref[i]);
tops.print_text( str, tops.style[tops.ci].link, ps_mPrintMode_End);
}
}
else
tops.print_text( ctx->rw->doc_clink_text[i],
tops.style[tops.ci].text);
}
return 1;
}
int CnvWblToPs::body_exec()
{
char text[80];
tops.y -= 10;
tops.print_horizontal_line();
sprintf( text, "Body %s", ctx->rw->body_name);
tops.print_h2( text);
sprintf( text, "Struct %s", ctx->rw->body_structname);
tops.print_text( text, tops.style[tops.ci].boldtext);
if ( strcmp( ctx->rw->body_flags, "") != 0) {
sprintf( text, "Flags %s", ctx->rw->body_flags);
tops.print_text( text, tops.style[tops.ci].boldtext);
}
return 1;
}
int CnvWblToPs::class_close()
{
return 1;
}
int CnvWblToPs::attribute_exec()
{
int i;
char *s;
char txt[200];
char text[200];
int page;
tops.print_h3( ctx->rw->attr_name);
if ( ctx->rw->attr_array && ctx->rw->attr_pointer)
sprintf( txt, "Type Array[%s] of pointers to %s", ctx->rw->attr_elements,
ctx->rw->attr_typeref);
else if ( ctx->rw->attr_array)
sprintf( txt, "Type Array[%s] of %s", ctx->rw->attr_elements,
ctx->rw->attr_typeref);
else if ( ctx->rw->attr_pointer)
sprintf( txt, "Type Pointer to %s", ctx->rw->attr_typeref);
else
sprintf( txt, "Type %s", ctx->rw->attr_typeref);
int sts = tops.content.find_link( CnvCtx::low(ctx->rw->attr_typeref), text, &page);
if ( ODD(sts)) {
tops.print_text( txt, tops.style[tops.ci].boldtext, ps_mPrintMode_Start);
sprintf( txt, " (%s ", Lng::translate("See"));
sprintf( &txt[strlen(txt)], "%s %d)", Lng::translate("page"), page);
tops.print_text( txt, tops.style[tops.ci].link, ps_mPrintMode_End);
}
else
tops.print_text( txt, tops.style[tops.ci].boldtext);
sprintf( txt, "Class %s", ctx->rw->attr_type);
tops.print_text( txt, tops.style[tops.ci].boldtext);
if ( strcmp( ctx->rw->attr_flags, "") != 0) {
sprintf( txt, "Flags %s", ctx->rw->attr_flags);
tops.print_text( txt, tops.style[tops.ci].boldtext);
}
if ( strcmp( ctx->rw->attr_pgmname, "") != 0) {
sprintf( txt, "PmgName %s", ctx->rw->attr_pgmname);
tops.print_text( txt, tops.style[tops.ci].boldtext);
}
tops.print_text( "", tops.style[tops.ci].text);
if ( ctx->rw->doc_fresh) {
for ( i = 0; i < ctx->rw->doc_cnt; i++) {
if ( (s = strstr( CnvCtx::low(ctx->rw->doc_text[i]), "@image")) != 0) {
char imagefile[80];
CnvCtx::remove_spaces( s + 6, imagefile);
tops.print_image( imagefile);
}
else
tops.print_text( ctx->rw->doc_text[i], tops.style[tops.ci].text);
}
}
return 1;
}
int CnvWblToPs::typedef_exec()
{
int i;
char full_class_name[80];
char link_ref[80];
char *s;
char txt[256];
strcpy( full_class_name, ctx->rw->volume_name);
strcat( full_class_name, ":");
strcat( full_class_name, ctx->rw->typedef_name);
tops.set_pageheader( full_class_name);
sprintf( txt, "Type %s", ctx->rw->typedef_name);
tops.print_h1( txt, 0, CnvCtx::low( ctx->rw->typedef_name));
if ( ctx->rw->doc_fresh && strcmp( ctx->rw->typedef_typeref, "") != 0) {
sprintf( txt, "TypeRef %s", ctx->rw->typedef_typeref);
tops.print_text( txt, tops.style[tops.ci].boldtext);
}
if ( ctx->rw->typedef_elements > 1) {
sprintf( txt, "Elements %d", ctx->rw->typedef_elements);
tops.print_text( txt, tops.style[tops.ci].boldtext);
}
if ( strcmp( ctx->rw->typedef_pgmname, "") != 0) {
sprintf( txt, "Pgmname %s", ctx->rw->typedef_pgmname);
tops.print_text( txt, tops.style[tops.ci].boldtext);
}
tops.print_text( "", tops.style[tops.ci].text);
if ( ctx->rw->doc_fresh && strcmp( ctx->rw->doc_author, "") != 0) {
sprintf( txt, "Author %s", ctx->rw->doc_author);
tops.print_text( txt, tops.style[tops.ci].text);
}
if ( ctx->rw->doc_fresh && strcmp( ctx->rw->doc_version, "") != 0) {
sprintf( txt, "Version %s", ctx->rw->doc_version);
tops.print_text( txt, tops.style[tops.ci].text);
}
if ( ctx->rw->doc_fresh && strcmp( ctx->rw->doc_code, "") != 0) {
sprintf( txt, "Code %s", ctx->rw->doc_code);
tops.print_text( txt, tops.style[tops.ci].text);
}
tops.print_h2( "Description");
if ( ctx->rw->doc_fresh) {
for ( i = 0; i < ctx->rw->doc_cnt; i++) {
CnvCtx::remove_spaces( ctx->rw->doc_text[i], txt);
if ( strncmp( CnvCtx::low(txt), "@image", 6) == 0) {
char imagefile[80];
CnvCtx::remove_spaces( txt + 6, imagefile);
tops.print_image( imagefile);
}
else if ( strncmp( CnvCtx::low(txt), "@b", 2) == 0) {
tops.print_text( txt + 2, tops.style[tops.ci].boldtext);
}
else if ( strncmp( CnvCtx::low(txt), "@h1", 3) == 0) {
tops.print_h2( txt + 3);
}
else if ( strncmp( CnvCtx::low(txt), "@h2", 3) == 0) {
tops.print_h3( txt + 3);
}
else
tops.print_text( ctx->rw->doc_text[i], tops.style[tops.ci].text);
}
}
for ( i = 0; i < ctx->rw->doc_clink_cnt; i++) {
if ( !conf_pass) {
int page;
char str[200];
char text[200];
if ( strncmp( ctx->rw->doc_clink_ref[i], "pwrb_", 5) == 0)
strcpy( link_ref, &ctx->rw->doc_clink_ref[i][5]);
else if ( strncmp( ctx->rw->doc_clink_ref[i], "pwrs_", 5) == 0)
strcpy( link_ref, &ctx->rw->doc_clink_ref[i][5]);
else if ( strncmp( ctx->rw->doc_clink_ref[i], "nmps_", 5) == 0)
strcpy( link_ref, &ctx->rw->doc_clink_ref[i][5]);
else if ( strncmp( ctx->rw->doc_clink_ref[i], "ssab_", 5) == 0)
strcpy( link_ref, &ctx->rw->doc_clink_ref[i][5]);
else
strcpy( link_ref, ctx->rw->doc_clink_ref[i]);
if ( (s = strrchr( link_ref, '.')))
*s = 0;
int sts = tops.content.find_link( link_ref, text, &page);
if ( ODD(sts)) {
sprintf( str, " (%s %s ", Lng::translate("See"), text);
sprintf( &str[strlen(str)], "%s %d)", Lng::translate("page"), page);
tops.print_text( ctx->rw->doc_clink_text[i],
tops.style[tops.ci].text, ps_mPrintMode_Start);
tops.print_text( str, tops.style[tops.ci].link, ps_mPrintMode_End);
}
else {
tops.print_text( ctx->rw->doc_clink_text[i],
tops.style[tops.ci].text, ps_mPrintMode_Start);
sprintf( str, " (%s %s)", Lng::translate("See"), ctx->rw->doc_clink_ref[i]);
tops.print_text( str, tops.style[tops.ci].link, ps_mPrintMode_End);
}
}
else
tops.print_text( ctx->rw->doc_clink_text[i],
tops.style[tops.ci].text);
}
return 1;
}
int CnvWblToPs::bit_exec()
{
int i;
char *s;
char txt[200];
tops.print_h3( ctx->rw->bit_name);
sprintf( txt, "Type %s", ctx->rw->bit_type);
tops.print_text( txt, tops.style[tops.ci].boldtext);
sprintf( txt, "Value %d", ctx->rw->bit_value);
tops.print_text( txt, tops.style[tops.ci].boldtext);
sprintf( txt, "Text %s", ctx->rw->bit_text);
tops.print_text( txt, tops.style[tops.ci].boldtext);
if ( strcmp( ctx->rw->bit_pgmname, "") != 0) {
sprintf( txt, "PmgName %s", ctx->rw->bit_pgmname);
tops.print_text( txt, tops.style[tops.ci].boldtext);
}
tops.print_text( "", tops.style[tops.ci].text);
if ( ctx->rw->doc_fresh) {
for ( i = 0; i < ctx->rw->doc_cnt; i++) {
if ( (s = strstr( CnvCtx::low(ctx->rw->doc_text[i]), "@image")) != 0) {
char imagefile[80];
CnvCtx::remove_spaces( s + 6, imagefile);
tops.print_image( imagefile);
}
else
tops.print_text( ctx->rw->doc_text[i], tops.style[tops.ci].text);
}
}
return 1;
}
#ifndef cnv_wbltops_h
#define cnv_wbltops_h
/* cnv_wbltops.h -- Documentation
PROVIEW/R
Copyright (C) 1996 by Comator Process AB.
<Description>. */
#include "pwr.h"
#include "cnv_readwbl.h"
#include "cnv_wblto.h"
#include "cnv_tops.h"
using namespace std;
class CnvReadWbl;
class CnvWblToPs : public CnvWblTo {
public:
CnvWblToPs( CnvCtx *cnv_ctx) :
ctx(cnv_ctx), conf_pass(false) {}
virtual ~CnvWblToPs();
CnvCtx *ctx;
CnvToPs tops;
bool conf_pass;
int init( char *first);
int close();
int class_exec();
int class_close();
int body_exec();
int attribute_exec();
int typedef_exec();
int bit_exec();
Cnv_eWblToType type() { return Cnv_eWblToType_Ps;}
int index_open() { return 0;}
void set_confpass( bool conf) {
tops.set_confpass( conf);
conf_pass = conf;
}
bool confpass() { return true;}
};
#endif
......@@ -6,19 +6,20 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "cnv_classread.h"
#include "cnv_wbltoxtthelp.h"
#include "cnv_ctx.h"
extern "C" {
#include "pwr.h"
#include "co_cdh.h"
}
int ClassRead::xtthelp_init()
int CnvWblToXtthelp::init( char *first)
{
pwr_tFileName fname;
strcpy( fname, dir);
strcat( fname, volume_name);
strcpy( fname, ctx->dir);
strcat( fname, ctx->rw->volume_name);
strcat( fname, "_xtthelp.dat");
cdh_ToLower( fname, fname);
......@@ -30,13 +31,13 @@ int ClassRead::xtthelp_init()
xtthelp_in_topic= 1;
fp_xtthelp_index <<
"<TOPIC> " << volume_name << endl <<
"ClassVolume " << volume_name << endl << endl;
"<TOPIC> " << ctx->rw->volume_name << endl <<
"ClassVolume " << ctx->rw->volume_name << endl << endl;
return 1;
}
int ClassRead::xtthelp_close()
int CnvWblToXtthelp::close()
{
fp_xtthelp_index <<
......@@ -44,13 +45,13 @@ int ClassRead::xtthelp_close()
fp_tmp.close();
copy_tmp_file( cread_cTmpFile2, fp_xtthelp_index);
ctx->rw->copy_tmp_file( cread_cTmpFile2, fp_xtthelp_index);
fp_xtthelp_index.close();
return 1;
}
int ClassRead::xtthelp_class()
int CnvWblToXtthelp::class_exec()
{
int i;
char full_class_name[80];
......@@ -58,13 +59,13 @@ int ClassRead::xtthelp_class()
char *s;
char txt[256];
strcpy( full_class_name, volume_name);
strcpy( full_class_name, ctx->rw->volume_name);
strcat( full_class_name, ":");
strcat( full_class_name, class_name);
strcat( full_class_name, ctx->rw->class_name);
// Add into index file
fp_xtthelp_index <<
"<B>" << class_name << "<T><T> " << doc_summary << " <LINK> " << class_name << endl;
"<B>" << ctx->rw->class_name << "<T><T> " << ctx->rw->doc_summary << " <LINK> " << ctx->rw->class_name << endl;
// Add to class file
if ( xtthelp_in_topic)
......@@ -73,74 +74,74 @@ int ClassRead::xtthelp_class()
xtthelp_in_topic = 1;
fp_tmp <<
"<TOPIC> " << class_name << endl <<
"<TOPIC> " << ctx->rw->class_name << endl <<
"Class " << full_class_name << endl <<
"<H1>" << class_name << endl << endl;
"<H1>" << ctx->rw->class_name << endl << endl;
if ( doc_fresh && strcmp( doc_author, "") != 0)
if ( ctx->rw->doc_fresh && strcmp( ctx->rw->doc_author, "") != 0)
{
fp_tmp <<
"<B>Author<T>" << doc_author << endl;
"<B>Author<T>" << ctx->rw->doc_author << endl;
}
if ( doc_fresh && strcmp( doc_version, "") != 0)
if ( ctx->rw->doc_fresh && strcmp( ctx->rw->doc_version, "") != 0)
{
fp_tmp <<
"<B>Version<T>" << doc_version << endl;
"<B>Version<T>" << ctx->rw->doc_version << endl;
}
fp_tmp <<
"<H1>Description" << endl;
if ( doc_fresh) {
if ( ctx->rw->doc_fresh) {
for ( i = 0; i < doc_cnt; i++) {
remove_spaces( doc_text[i], txt);
if ( strncmp( low(txt), "@image", 6) == 0) {
for ( i = 0; i < ctx->rw->doc_cnt; i++) {
CnvCtx::remove_spaces( ctx->rw->doc_text[i], txt);
if ( strncmp( CnvCtx::low(txt), "@image", 6) == 0) {
char imagefile[80];
remove_spaces( txt + 6, imagefile);
CnvCtx::remove_spaces( txt + 6, imagefile);
fp_tmp << "<IMAGE> " << imagefile << endl;
}
else if ( strncmp( low(txt), "@b", 2) == 0) {
else if ( strncmp( CnvCtx::low(txt), "@b", 2) == 0) {
fp_tmp << "<B> " << txt + 2 << endl;
}
else if ( strncmp( low(txt), "@h1", 3) == 0) {
else if ( strncmp( CnvCtx::low(txt), "@h1", 3) == 0) {
fp_tmp << "<H1> " << txt + 3 << endl;
}
else if ( strncmp( low(txt), "@h2", 3) == 0) {
else if ( strncmp( CnvCtx::low(txt), "@h2", 3) == 0) {
fp_tmp << "<H2> " << txt + 3 << endl;
}
else
fp_tmp << doc_text[i] << endl;
fp_tmp << ctx->rw->doc_text[i] << endl;
}
}
for ( i = 0; i < doc_clink_cnt; i++) {
if ( strncmp( doc_clink_ref[i], "pwrb_", 5) == 0)
strcpy( link_ref, &doc_clink_ref[i][5]);
else if ( strncmp( doc_clink_ref[i], "pwrs_", 5) == 0)
strcpy( link_ref, &doc_clink_ref[i][5]);
else if ( strncmp( doc_clink_ref[i], "nmps_", 5) == 0)
strcpy( link_ref, &doc_clink_ref[i][5]);
else if ( strncmp( doc_clink_ref[i], "ssab_", 5) == 0)
strcpy( link_ref, &doc_clink_ref[i][5]);
for ( i = 0; i < ctx->rw->doc_clink_cnt; i++) {
if ( strncmp( ctx->rw->doc_clink_ref[i], "pwrb_", 5) == 0)
strcpy( link_ref, &ctx->rw->doc_clink_ref[i][5]);
else if ( strncmp( ctx->rw->doc_clink_ref[i], "pwrs_", 5) == 0)
strcpy( link_ref, &ctx->rw->doc_clink_ref[i][5]);
else if ( strncmp( ctx->rw->doc_clink_ref[i], "nmps_", 5) == 0)
strcpy( link_ref, &ctx->rw->doc_clink_ref[i][5]);
else if ( strncmp( ctx->rw->doc_clink_ref[i], "ssab_", 5) == 0)
strcpy( link_ref, &ctx->rw->doc_clink_ref[i][5]);
if ( (s = strrchr( link_ref, '.')))
*s = 0;
fp_tmp << " " << doc_clink_text[i] << " <LINK>" << link_ref << endl;
fp_tmp << " " << ctx->rw->doc_clink_text[i] << " <LINK>" << link_ref << endl;
}
return 1;
}
int ClassRead::xtthelp_body()
int CnvWblToXtthelp::body_exec()
{
fp_tmp <<
"<HR>" << endl <<
"<H1>" << body_name << endl;
"<H1>" << ctx->rw->body_name << endl;
return 1;
}
int ClassRead::xtthelp_class_close()
int CnvWblToXtthelp::class_close()
{
xtthelp_in_topic = 0;
......@@ -150,51 +151,51 @@ int ClassRead::xtthelp_class_close()
return 1;
}
int ClassRead::xtthelp_bit()
int CnvWblToXtthelp::bit_exec()
{
return 1;
}
int ClassRead::xtthelp_attribute()
int CnvWblToXtthelp::attribute_exec()
{
int i;
char *s;
fp_tmp <<
endl <<
"<H1>" << attr_name << endl;
if ( attr_array && attr_pointer)
"<H1>" << ctx->rw->attr_name << endl;
if ( ctx->rw->attr_array && ctx->rw->attr_pointer)
fp_tmp <<
"<B>Array[" << attr_elements << "] of pointers to " << attr_typeref << " ";
else if ( attr_array)
"<B>Array[" << ctx->rw->attr_elements << "] of pointers to " << ctx->rw->attr_typeref << " ";
else if ( ctx->rw->attr_array)
fp_tmp <<
"<B>Array[" << attr_elements << "] of "<< attr_typeref << " ";
else if ( attr_pointer)
"<B>Array[" << ctx->rw->attr_elements << "] of "<< ctx->rw->attr_typeref << " ";
else if ( ctx->rw->attr_pointer)
fp_tmp <<
"<B>Pointer to " << attr_typeref << " ";
"<B>Pointer to " << ctx->rw->attr_typeref << " ";
else
fp_tmp <<
"<B>" << attr_typeref << " ";
"<B>" << ctx->rw->attr_typeref << " ";
fp_tmp <<
"$" << attr_type << " ";
"$" << ctx->rw->attr_type << " ";
if ( strcmp( attr_flags, "") != 0)
if ( strcmp( ctx->rw->attr_flags, "") != 0)
fp_tmp <<
"Flags[" << attr_flags << "]";
"Flags[" << ctx->rw->attr_flags << "]";
fp_tmp << endl;
if ( doc_fresh) {
for ( i = 0; i < doc_cnt; i++) {
if ( (s = strstr( low(doc_text[i]), "@image")) != 0) {
if ( ctx->rw->doc_fresh) {
for ( i = 0; i < ctx->rw->doc_cnt; i++) {
if ( (s = strstr( CnvCtx::low(ctx->rw->doc_text[i]), "@image")) != 0) {
char imagefile[80];
remove_spaces( s + 6, imagefile);
CnvCtx::remove_spaces( s + 6, imagefile);
fp_tmp << "<IMAGE> " << imagefile << endl;
}
else
fp_tmp << doc_text[i] << endl;
fp_tmp << ctx->rw->doc_text[i] << endl;
}
}
return 1;
......
#ifndef cnv_wbltoxtthelp_h
#define cnv_wbltoxtthelp_h
/* cnv_wbltoxtthelp.h -- Documentation
PROVIEW/R
Copyright (C) 1996 by Comator Process AB.
<Description>. */
#if defined __cplusplus
extern "C" {
#endif
#include "pwr.h"
#include "cnv_readwbl.h"
#include "cnv_wblto.h"
using namespace std;
class CnvReadWbl;
class CnvWblToXtthelp : public CnvWblTo {
public:
CnvWblToXtthelp( CnvCtx *cnv_ctx) :
ctx(cnv_ctx), xtthelp_index_open(0), xtthelp_in_topic(0) {}
virtual ~CnvWblToXtthelp() {}
CnvCtx *ctx;
ofstream fp_xtthelp_index;
int xtthelp_index_open;
int xtthelp_in_topic;
ofstream fp_tmp;
int init( char *first);
int close();
int class_exec();
int class_close();
int body_exec();
int attribute_exec();
int bit_exec();
Cnv_eWblToType type() { return Cnv_eWblToType_Xtthelp;}
int index_open() { return xtthelp_index_open;}
};
#if defined __cplusplus
}
#endif
#endif
#ifndef cnv_xtthelpto_h
#define cnv_xtthelpto_h
/* cnv_xtthelpto.h -- Documentation
PROVIEW/R
Copyright (C) 1996 by Comator Process AB.
<Description>. */
#if defined __cplusplus
extern "C" {
#endif
#include "pwr.h"
#include "co_nav_help.h"
#include "cnv_readxtthelp.h"
using namespace std;
class CnvReadXtthelp;
typedef enum {
Cnv_eXtthelpToType_Html,
Cnv_eXtthelpToType_Xml,
Cnv_eXtthelpToType_Ps
} Cnv_eXtthelpToType;
class CnvXtthelpTo {
public:
// CnvXtthelpTo() {}
virtual Cnv_eXtthelpToType type() { return Cnv_eXtthelpToType_Html;}
virtual void *insert( navh_eItemType item_type, char *text1,
char *text2, char *text3, char *link,
char *link_bookmark, char *file_name,
navh_eHelpFile file_type, int help_index,
char *bookmark)
{ return 0;}
virtual bool confpass() { return false;}
virtual void set_confpass( bool conf) {};
};
#if defined __cplusplus
}
#endif
#endif
/* cnv_help.cpp --
/* cnv_xtthelptohtml.cpp --
PROVIEW/R
Copyright (C) 1996-98 by Mandator AB.
......@@ -20,7 +20,9 @@ extern "C" {
}
#include "co_nav_help.h"
#include "cnv_help.h"
#include "cnv_ctx.h"
#include "cnv_readxtthelp.h"
#include "cnv_xtthelptohtml.h"
#define CNV_TAB 18
......@@ -33,32 +35,16 @@ extern "C" {
#define abs(Dragon) ((Dragon) >= 0 ? (Dragon) : (-(Dragon)))
#endif
XhelpToHtml::XhelpToHtml( char *x_name, char *x_directory)
{
char *s;
strcpy( filename, x_name);
if ( (s = strrchr(x_name,'/')))
strcpy( name, s+1);
else
strcpy( name, x_name);
if ((s = strrchr( name, '.')))
*s = 0;
strcpy( directory, x_directory);
generate();
}
void XhelpToHtml::subject_to_fname( char *fname, char *subject, int path)
void CnvXtthelpToHtml::subject_to_fname( char *fname, char *subject, int path)
{
char *s, *t;
if ( path) {
strcpy( fname, directory);
strcat( fname, name);
strcpy( fname, ctx->dir);
strcat( fname, ctx->rx->name);
}
else
strcpy( fname, name);
strcpy( fname, ctx->rx->name);
strcat( fname, "_");
t = fname + strlen(fname);
for ( s = subject; *s; s++,t++) {
......@@ -72,20 +58,19 @@ void XhelpToHtml::subject_to_fname( char *fname, char *subject, int path)
cdh_ToLower( fname, fname);
}
void *wnav_help_insert_cb( void *ctx, navh_eItemType item_type, char *text1,
char *text2, char *text3, char *link,
char *link_bookmark, char *file_name,
navh_eHelpFile file_type, int help_index,
char *bookmark)
void *CnvXtthelpToHtml::insert( navh_eItemType item_type, char *text1,
char *text2, char *text3, char *link,
char *link_bookmark, char *file_name,
navh_eHelpFile file_type, int help_index,
char *bookmark)
{
XhelpToHtml *xh = (XhelpToHtml *)ctx;
int i;
static int in_table = 0;
if ( (text2 && strcmp(text2, "") != 0) ||
(text3 && strcmp(text3, "") != 0) ) {
if ( !in_table) {
xh->fp << "<TABLE>" << endl;
fp << "<TABLE>" << endl;
in_table = 1;
}
}
......@@ -94,8 +79,9 @@ void *wnav_help_insert_cb( void *ctx, navh_eItemType item_type, char *text1,
// Close table (keep if empty line)
if ( !( text1 && strcmp( text1, "") == 0 &&
(item_type == navh_eItemType_Help ||
item_type == navh_eItemType_HelpCode ||
item_type == navh_eItemType_HelpBold))) {
xh->fp << "</TABLE>" << endl;
fp << "</TABLE>" << endl;
in_table = 0;
}
}
......@@ -105,9 +91,9 @@ void *wnav_help_insert_cb( void *ctx, navh_eItemType item_type, char *text1,
{
pwr_tFileName fname;
xh->subject_to_fname( fname, text1, 1);
xh->fp.open( fname);
xh->fp <<
subject_to_fname( fname, text1, 1);
fp.open( fname);
fp <<
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"\"http://www.w3.org/TR/REC-html40/loose.dtd>" << endl <<
"<!--NewPage-->" << endl <<
"<HTML>" << endl <<
......@@ -124,10 +110,11 @@ void *wnav_help_insert_cb( void *ctx, navh_eItemType item_type, char *text1,
}
case navh_eItemType_EndTopic:
{
xh->fp.close();
fp.close();
return NULL;
}
case navh_eItemType_Help:
case navh_eItemType_HelpCode:
{
if ( strcmp( link, "") != 0) {
......@@ -144,43 +131,43 @@ void *wnav_help_insert_cb( void *ctx, navh_eItemType item_type, char *text1,
strcpy( fname, link);
}
else {
xh->subject_to_fname( fname, link, 0);
subject_to_fname( fname, link, 0);
if ( strcmp( link_bookmark, "") != 0) {
strcat( fname, "#");
strcat( fname, link_bookmark);
}
}
xh->fp << "<A HREF=\"" << fname << "\">";
fp << "<A HREF=\"" << fname << "\">";
}
else if ( bookmark) {
xh->fp << "<A NAME=\"" << bookmark << "\">";
fp << "<A NAME=\"" << bookmark << "\">";
}
if ( ! in_table) {
xh->fp << text1;
fp << text1;
if ( strcmp( link, "") != 0 || bookmark)
xh->fp << "<BR></A>" << endl;
fp << "<BR></A>" << endl;
else
xh->fp << "<BR>" << endl;
fp << "<BR>" << endl;
}
else {
xh->fp << "<TR><TD>" << text1;
fp << "<TR><TD>" << text1;
if ( strcmp( text2, "") != 0 || strcmp( text3, "") != 0) {
for ( i = 0; i < (int)(CNV_TAB - strlen(text1)); i++)
xh->fp << "&nbsp;";
xh->fp << "&nbsp;&nbsp;</TD><TD>" << text2;
fp << "&nbsp;";
fp << "&nbsp;&nbsp;</TD><TD>" << text2;
if ( strcmp( text3, "") != 0) {
for ( i = 0; i < (int)(CNV_TAB - strlen(text2)); i++)
xh->fp << "&nbsp;";
xh->fp << "&nbsp;&nbsp;</TD><TD>" << text3;
fp << "&nbsp;";
fp << "&nbsp;&nbsp;</TD><TD>" << text3;
}
}
xh->fp << "</TD></TR>";
fp << "</TD></TR>";
if ( strcmp( link, "") != 0 || bookmark)
xh->fp << "</A>" << endl;
fp << "</A>" << endl;
else
xh->fp << endl;
fp << endl;
}
return NULL;
}
......@@ -199,77 +186,77 @@ void *wnav_help_insert_cb( void *ctx, navh_eItemType item_type, char *text1,
strcpy( fname, link);
}
else {
xh->subject_to_fname( fname, link, 0);
subject_to_fname( fname, link, 0);
if ( strcmp( link_bookmark, "") != 0) {
strcat( fname, "#");
strcat( fname, link_bookmark);
}
}
if ( !in_table)
xh->fp << "<A HREF=\"" << fname << "\">";
fp << "<A HREF=\"" << fname << "\">";
}
else if ( bookmark) {
if ( !in_table)
xh->fp << "<A NAME=\"" << bookmark << "\">";
fp << "<A NAME=\"" << bookmark << "\">";
}
if ( ! in_table) {
xh->fp << "<B>" << text1 << "</B>";
fp << "<B>" << text1 << "</B>";
if ( strcmp( link, "") != 0 || bookmark)
xh->fp<< "<BR></A>" << endl;
fp<< "<BR></A>" << endl;
else
xh->fp<< "<BR>" << endl;
fp<< "<BR>" << endl;
}
else {
xh->fp << "<TR><TD><B>";
fp << "<TR><TD><B>";
if ( strcmp( link, "") != 0)
xh->fp << "<A HREF=\"" << fname << "\">";
fp << "<A HREF=\"" << fname << "\">";
else if ( bookmark != 0)
xh->fp << "<A NAME=\"" << bookmark << "\">";
xh->fp << text1;
fp << "<A NAME=\"" << bookmark << "\">";
fp << text1;
if ( strcmp( link, "") != 0 || bookmark)
xh->fp << "</A>";
fp << "</A>";
if ( strcmp( text2, "") != 0 || strcmp( text3, "") != 0) {
for ( i = 0; i < (int)(CNV_TAB - strlen(text1)); i++)
xh->fp << "&nbsp;";
xh->fp << "&nbsp;&nbsp;</B></TD><TD><B>" << text2;
fp << "&nbsp;";
fp << "&nbsp;&nbsp;</B></TD><TD><B>" << text2;
if ( strcmp( text3, "") != 0) {
for ( i = 0; i < (int)(CNV_TAB - strlen(text2)); i++)
xh->fp << "&nbsp;";
xh->fp << "&nbsp;&nbsp;</B></TD><TD><B>" << text3;
fp << "&nbsp;";
fp << "&nbsp;&nbsp;</B></TD><TD><B>" << text3;
}
}
xh->fp << "</B></TD></TR>";
fp << "</B></TD></TR>";
if ( strcmp( link, "") != 0 || bookmark)
xh->fp << "</A>" << endl;
fp << "</A>" << endl;
else
xh->fp << endl;
fp << endl;
}
return NULL;
}
case navh_eItemType_HelpHeader:
{
xh->fp << "<H1>" << text1 << "</H1><BR>" << endl;
fp << "<H1>" << text1 << "</H1><BR>" << endl;
return NULL;
}
case navh_eItemType_Header:
{
xh->fp << "<H3>" << text1 << "</H3><BR>" << endl;
fp << "<H3>" << text1 << "</H3><BR>" << endl;
return NULL;
}
case navh_eItemType_HeaderLarge:
{
xh->fp << "<H2>" << text1 << "</H2><BR>" << endl;
fp << "<H2>" << text1 << "</H2><BR>" << endl;
return NULL;
}
case navh_eItemType_HorizontalLine:
{
xh->fp << "<HR>" << endl;
fp << "<HR>" << endl;
return NULL;
}
case navh_eItemType_Image:
{
xh->fp << "<IMG SRC=\"" << text1 << "\"><BR>" << endl;
fp << "<IMG SRC=\"" << text1 << "\"><BR>" << endl;
return NULL;
}
default:
......@@ -277,21 +264,8 @@ void *wnav_help_insert_cb( void *ctx, navh_eItemType item_type, char *text1,
}
}
int XhelpToHtml::generate()
{
int sts;
void *bookmark_node;
NavHelp *navhelp = new NavHelp( (void *)this, "$pwr_exe/wtt_help.dat",
"$pwrp_exe/xtt_help.dat");
navhelp->insert_cb = wnav_help_insert_cb;
sts = navhelp->help( NULL, "", navh_eHelpFile_Other,
filename, &bookmark_node);
if ( EVEN(sts)) return sts;
delete navhelp;
return 1;
}
......
#ifndef cnv_xtthelptohtml_h
#define cnv_xtthelptohtml_h
/* cnv_xtthelptohtml.h -- Documentation
PROVIEW/R
Copyright (C) 1996 by Comator Process AB.
<Description>. */
#if defined __cplusplus
extern "C" {
#endif
#include "pwr.h"
#include "cnv_xtthelpto.h"
using namespace std;
class CnvCtx;
class CnvXtthelpToHtml : public CnvXtthelpTo {
public:
CnvXtthelpToHtml( CnvCtx *cnv_ctx) :
ctx(cnv_ctx) {}
virtual ~CnvXtthelpToHtml() {}
Cnv_eXtthelpToType type() { return Cnv_eXtthelpToType_Html;}
void *insert( navh_eItemType item_type, char *text1,
char *text2, char *text3, char *link,
char *link_bookmark, char *file_name,
navh_eHelpFile file_type, int help_index,
char *bookmark);
void subject_to_fname( char *fname, char *subject, int path);
CnvCtx *ctx;
ofstream fp;
};
#if defined __cplusplus
}
#endif
#endif
/* cnv_xtthelptops.cpp --
PROVIEW/R
Copyright (C) 1996-98 by Mandator AB.
Convert xtt help file to postscript. */
/*_Include files_________________________________________________________*/
#include <iostream.h>
#include <fstream.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
extern "C" {
#include "co_cdh.h"
#include "co_dcli.h"
}
#include "co_nav_help.h"
#include "co_lng.h"
#include "cnv_ctx.h"
#include "cnv_readxtthelp.h"
#include "cnv_xtthelptops.h"
#include "cnv_image.h"
#define ps_cCellSize 110
/* Nice functions */
#define ODD(a) (((int)(a) & 1) != 0)
#define EVEN(a) (((int)(a) & 1) == 0)
#define max(Dragon,Eagle) ((Dragon) > (Eagle) ? (Dragon) : (Eagle))
#define min(Dragon,Eagle) ((Dragon) < (Eagle) ? (Dragon) : (Eagle))
#ifndef __ALPHA
#define abs(Dragon) ((Dragon) >= 0 ? (Dragon) : (-(Dragon)))
#endif
void CnvXtthelpToPs::subject_to_fname( char *fname, char *subject, int path)
{
if ( path) {
strcpy( fname, ctx->dir);
strcat( fname, ctx->rx->name);
}
else
strcpy( fname, ctx->rx->name);
strcat( fname, ".ps");
cdh_ToLower( fname, fname);
}
CnvXtthelpToPs::~CnvXtthelpToPs()
{
if ( !first_topic) {
if ( status & ps_mStatus_xtthelp) {
status &= ~ps_mStatus_xtthelp;
}
}
tops.close();
}
void *CnvXtthelpToPs::insert( navh_eItemType item_type, char *text1,
char *text2, char *text3, char *link,
char *link_bookmark, char *file_name,
navh_eHelpFile file_type, int help_index,
char *bookmark)
{
if ( (text2 && strcmp(text2, "") != 0) ||
(text3 && strcmp(text3, "") != 0) ) {
if ( !(status & ps_mStatus_table))
status |= ps_mStatus_table;
}
else {
if ( status & ps_mStatus_table) {
// Close table (keep if empty line)
if ( !( text1 && strcmp( text1, "") == 0 &&
(item_type == navh_eItemType_Help ||
item_type == navh_eItemType_HelpCode ||
item_type == navh_eItemType_HelpBold)))
status &= ~ps_mStatus_table;
}
}
switch ( item_type) {
case navh_eItemType_DocTitlePage:
case navh_eItemType_DocInfoPage:
case navh_eItemType_Topic:
{
strcpy( current_subject, text1);
if ( item_type == navh_eItemType_DocTitlePage) {
tops.set_cf( ps_eFile_Info);
tops.set_ci( ps_eId_TitlePage);
}
else if ( item_type == navh_eItemType_DocInfoPage) {
tops.set_cf( ps_eFile_Info);
tops.set_ci( ps_eId_InfoPage);
tops.print_pagebreak( 0);
}
else {
if ( tops.ci == ps_eId_Chapter) {
if ( !first_chaptertopic)
tops.set_ci( ps_eId_TopicL1);
else
first_chaptertopic = 0;
}
if ( tops.cf == ps_eFile_Info)
tops.y = ps_cPageHeight - ps_cTopMargin;
tops.set_cf( ps_eFile_Body);
}
if ( first_topic) {
pwr_tFileName fname;
subject_to_fname( fname, text1, 1);
tops.set_filename( ps_eFile_Info, fname);
tops.set_filename( ps_eFile_Body, ps_cTmpFile);
tops.open();
status |= ps_mStatus_xtthelp;
first_topic = 0;
}
status |= ps_mStatus_topic;
return NULL;
}
case navh_eItemType_EndTopic: {
if ( status & ps_mStatus_table)
status &= ~ps_mStatus_table;
if ( status & ps_mStatus_paragraph)
status &= ~ps_mStatus_paragraph;
if ( status & ps_mStatus_topic)
status &= ~ps_mStatus_topic;
if ( user_style) {
user_style = 0;
tops.set_ci( base_ci);
}
return NULL;
}
case navh_eItemType_Style: {
if ( cdh_NoCaseStrcmp( text1, "function") == 0) {
base_ci = tops.ci;
tops.set_ci( ps_eId_Function);
user_style = 1;
}
return NULL;
}
case navh_eItemType_EndChapter: {
if ( status & ps_mStatus_table)
status &= ~ps_mStatus_table;
if ( status & ps_mStatus_paragraph)
status &= ~ps_mStatus_paragraph;
if ( status & ps_mStatus_topic)
status &= ~ps_mStatus_topic;
tops.set_ci( ps_eId_TopicL1);
user_style = 0;
return NULL;
}
case navh_eItemType_Chapter: {
if ( status & ps_mStatus_table)
status &= ~ps_mStatus_table;
if ( status & ps_mStatus_paragraph)
status &= ~ps_mStatus_paragraph;
if ( status & ps_mStatus_topic)
status &= ~ps_mStatus_topic;
tops.set_ci( ps_eId_Chapter);
first_chaptertopic = 1;
user_style = 0;
tops.reset_headernumbers( 1);
return NULL;
}
case navh_eItemType_HeaderLevel: {
if ( user_style) {
user_style = 0;
tops.set_ci( base_ci);
}
tops.incr_headerlevel();
return NULL;
}
case navh_eItemType_EndHeaderLevel: {
if ( user_style) {
user_style = 0;
tops.set_ci( base_ci);
}
tops.decr_headerlevel();
return NULL;
}
case navh_eItemType_PageBreak: {
tops.print_pagebreak(1);
return NULL;
}
case navh_eItemType_Help:
case navh_eItemType_HelpCode:
case navh_eItemType_HelpBold:
{
int printmode;
CnvStyle *hstyle;
if ( item_type == navh_eItemType_Help)
hstyle = &tops.style[tops.ci].text;
else if ( item_type == navh_eItemType_HelpBold)
hstyle = &tops.style[tops.ci].boldtext;
else if ( item_type == navh_eItemType_HelpCode)
hstyle = &tops.style[tops.ci].code;
if ( strcmp( link, "") != 0)
printmode = ps_mPrintMode_Start;
else
printmode = ps_mPrintMode_Pos;
if ( !(status & ps_mStatus_table)) {
tops.x = ps_cLeftMargin;
tops.print_text( text1, *hstyle, printmode);
}
else {
tops.x = ps_cLeftMargin;
tops.print_text( text1, *hstyle);
if ( text2 && strcmp( text2, "") != 0) {
tops.x = ps_cLeftMargin + ps_cCellSize;
tops.print_text( text2, *hstyle, ps_mPrintMode_KeepY | ps_mPrintMode_FixX);
}
if ( text3 && strcmp( text3, "") != 0) {
tops.x = ps_cLeftMargin + 2 * ps_cCellSize;
tops.print_text( text3, *hstyle, ps_mPrintMode_KeepY | ps_mPrintMode_FixX);
}
}
if ( strcmp( link, "") != 0 && !conf_pass) {
pwr_tFileName fname;
char str[200];
int page;
if ( strncmp( link, "$web:", 5) == 0) {
if ( strncmp( &link[5], "$pwrp_web/", 10) == 0)
strcpy( fname, &link[15]);
else
strcpy( fname, &link[5]);
sprintf( str, " (%s %s)", Lng::translate("See"), fname);
if ( !(status & ps_mStatus_table))
tops.print_text( str, tops.style[tops.ci].link,
ps_mPrintMode_End | ps_mPrintMode_FixX);
else {
tops.x = ps_cLeftMargin + 3 * ps_cCellSize;
if ( ps_cLeftMargin + 2 * ps_cCellSize + strlen(text3) * hstyle->font_size * 0.65 > tops.x)
tops.x = ps_cLeftMargin + 2 * ps_cCellSize + strlen(text3) * hstyle->font_size * 0.65;
tops.print_text( str, tops.style[tops.ci].link,
ps_mPrintMode_End | ps_mPrintMode_FixX);
}
}
else if ( (strstr( link, ".htm") != 0) ||
(strstr( link, ".pdf") != 0)) {
strcpy( fname, link);
sprintf( str, " (%s %s)", Lng::translate("See"), fname);
if ( !(status & ps_mStatus_table))
tops.print_text( str, tops.style[tops.ci].link,
ps_mPrintMode_End | ps_mPrintMode_FixX);
else {
tops.x = ps_cLeftMargin + 3 * ps_cCellSize;
if ( ps_cLeftMargin + 2 * ps_cCellSize + strlen(text3) * hstyle->font_size * 0.65 > tops.x)
tops.x = ps_cLeftMargin + 2 * ps_cCellSize + strlen(text3) * hstyle->font_size * 0.65;
tops.print_text( str, tops.style[tops.ci].link,
ps_mPrintMode_End | ps_mPrintMode_FixX);
}
}
else {
char text[80];
int sts = tops.content.find_link( link, text, &page);
if ( ODD(sts)) {
sprintf( str, " (%s %s ", Lng::translate("See"), text);
sprintf( &str[strlen(str)], "%s %d)", Lng::translate("page"), page);
if ( !(status & ps_mStatus_table))
tops.print_text( str, tops.style[tops.ci].link,
ps_mPrintMode_End | ps_mPrintMode_FixX);
else {
if ( !(text3 && strcmp(text3, "") != 0)) {
tops.x = ps_cLeftMargin + 2 * ps_cCellSize;
if ( ps_cLeftMargin + ps_cCellSize + strlen(text2) * hstyle->font_size * 0.5 > tops.x)
tops.x = ps_cLeftMargin + ps_cCellSize + strlen(text2) * hstyle->font_size * 0.5;
}
else {
tops.x = ps_cLeftMargin + 3 * ps_cCellSize;
if ( ps_cLeftMargin + ps_cCellSize + strlen(text3) * hstyle->font_size * 0.5 > tops.x)
tops.x = ps_cLeftMargin + 2 * ps_cCellSize + strlen(text3) * hstyle->font_size * 0.5;
}
tops.print_text( str, tops.style[tops.ci].link,
ps_mPrintMode_KeepY | ps_mPrintMode_FixX);
}
}
}
}
else if ( bookmark) {
// fp[cf] << tags[ps_eTag_link].start << " name=\"" << bookmark << "\">";
}
return NULL;
}
case navh_eItemType_HelpHeader:
{
int hlevel;
if ( !user_style)
hlevel = tops.ci - (int) ps_eId_Chapter;
else
hlevel = base_ci - (int) ps_eId_Chapter;
tops.print_h1( text1, hlevel, current_subject);
return NULL;
}
case navh_eItemType_Header:
{
tops.print_h3( text1);
return NULL;
}
case navh_eItemType_HeaderLarge:
{
tops.print_h2( text1);
return NULL;
}
case navh_eItemType_HorizontalLine:
{
tops.print_horizontal_line();
return NULL;
}
case navh_eItemType_Image:
{
int sts = tops.print_image( text1);
if ( EVEN(sts))
printf( "Image: %s not found\n", text1);
return NULL;
}
default:
return 0;
}
return 0;
}
#ifndef cnv_xtthelptops_h
#define cnv_xtthelptops_h
/* cnv_xtthelptops.h -- Documentation
PROVIEW/R
Copyright (C) 1996 by Comator Process AB.
<Description>. */
using namespace std;
#include <iostream.h>
#include <vector.h>
#include <string>
#include "pwr.h"
#include "cnv_xtthelpto.h"
#include "cnv_style.h"
#include "cnv_content.h"
#include "cnv_tops.h"
class CnvCtx;
typedef enum {
ps_mStatus_xtthelp = 1 << 0,
ps_mStatus_paragraph = 1 << 1,
ps_mStatus_table = 1 << 2,
ps_mStatus_topic = 1 << 3
} ps_mStatus;
class CnvXtthelpToPs : public CnvXtthelpTo {
public:
CnvXtthelpToPs( CnvCtx *cnv_ctx) :
ctx(cnv_ctx), base_ci(0), first_topic(1), user_style(0), status(0),
conf_pass(false)
{
strcpy( current_subject, "");
}
virtual ~CnvXtthelpToPs();
Cnv_eXtthelpToType type() { return Cnv_eXtthelpToType_Ps;}
void *insert( navh_eItemType item_type, char *text1,
char *text2, char *text3, char *link,
char *link_bookmark, char *file_name,
navh_eHelpFile file_type, int help_index,
char *bookmark);
void subject_to_fname( char *fname, char *subject, int path);
bool confpass() { return true;}
void set_confpass( bool conf) {
tops.set_confpass( conf);
conf_pass = conf;
if ( !conf) {
// Reset
base_ci = 0;
user_style = 0;
first_topic = 1;
status = 0;
}
}
CnvCtx *ctx;
CnvToPs tops;
int base_ci;
int first_topic;
int first_chaptertopic;
int user_style;
unsigned int status;
bool conf_pass;
char current_subject[80];
};
#endif
/* cnv_xtthelptoxml.cpp --
PROVIEW/R
Copyright (C) 1996-98 by Mandator AB.
Convert xtt help file to xml. */
/*_Include files_________________________________________________________*/
#include <iostream.h>
#include <fstream.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
extern "C" {
#include "co_cdh.h"
#include "co_dcli.h"
}
#include "co_nav_help.h"
#include "cnv_ctx.h"
#include "cnv_readxtthelp.h"
#include "cnv_xtthelptoxml.h"
#define CNV_TAB 18
#define xml_cHead "<?xml version=\"1.0\" ?>"
#define xml_cCss "<?xml-stylesheet type=\"text/css\" href=\"pxtthelp.css\" ?>"
typedef enum {
xml_eTag_paragraph = 0,
xml_eTag_bold = 1,
xml_eTag_link = 2,
xml_eTag_weblink = 3,
xml_eTag_h1 = 4,
xml_eTag_h2 = 5,
xml_eTag_h3 = 6,
xml_eTag_topic = 7,
xml_eTag_image = 8,
xml_eTag_table = 9,
xml_eTag_t1 = 10,
xml_eTag_t2 = 11,
xml_eTag_t3 = 12,
xml_eTag_xtthelp = 13,
xml_eTag_break = 14,
xml_eTag_hline = 15
} xml_eTag;
typedef struct {
char start[40];
char end[40];
} xml_sTag;
static xml_sTag tags[] = {
{"<p>" , "</p>"},
{"<b>" , "</b>"},
{"<a>" , "</a>"},
{"<a" , "</a>"},
{"<h1>" , "</h1>"},
{"<h2>" , "</h2>"},
{"<h3>" , "</h3>"},
{"<topic>" , "</topic>"},
{"<img " , " />"},
{"<table>" , "</table>"},
{"<t1>" , "</t1>"},
{"<t2>" , "</t2>"},
{"<t3>" , "</t3>"},
{"<xtthelp>" , "</xtthelp>"},
{"<br/>" , ""},
{"<hr/>" , ""}
};
/* Nice functions */
#define ODD(a) (((int)(a) & 1) != 0)
#define EVEN(a) (((int)(a) & 1) == 0)
#define max(Dragon,Eagle) ((Dragon) > (Eagle) ? (Dragon) : (Eagle))
#define min(Dragon,Eagle) ((Dragon) < (Eagle) ? (Dragon) : (Eagle))
#ifndef __ALPHA
#define abs(Dragon) ((Dragon) >= 0 ? (Dragon) : (-(Dragon)))
#endif
void CnvXtthelpToXml::cnv_text( char *to, char *from)
{
if ( !from) {
strcpy( to, "");
return;
}
char *t = to;
char *s = from;
for ( ; *s; s++) {
switch ( *s) {
case '<':
*t++ = 'l';
*t++ = 't';
*t++ = ';';
break;
case '>':
*t++ = 'g';
*t++ = 't';
*t++ = ';';
break;
case '&':
*t++ = 'a';
*t++ = 'm';
*t++ = 'p';
*t++ = ';';
break;
case '\'':
*t++ = 'a';
*t++ = 'p';
*t++ = 'o';
*t++ = 's';
*t++ = ';';
break;
case '\"':
*t++ = 'q';
*t++ = 'u';
*t++ = 'o';
*t++ = 't';
*t++ = ';';
break;
default:
*t++ = *s;
}
}
*t = 0;
}
void CnvXtthelpToXml::subject_to_fname( char *fname, char *subject, int path)
{
char *s, *t;
if ( path) {
strcpy( fname, ctx->dir);
strcat( fname, ctx->rx->name);
}
else
strcpy( fname, ctx->rx->name);
if ( !ctx->common_structfile_only) {
strcat( fname, "_");
t = fname + strlen(fname);
for ( s = subject; *s; s++,t++) {
if ( *s == ' ' || *s == '(' || *s == ')')
*t = '_';
else
*t = *s;
}
*t = 0;
}
strcat( fname, ".xml");
cdh_ToLower( fname, fname);
}
CnvXtthelpToXml::~CnvXtthelpToXml()
{
if ( ctx->common_structfile_only && !first_topic) {
if ( status & xml_mStatus_xtthelp) {
fp <<
tags[xml_eTag_xtthelp].end << endl;
status &= ~xml_mStatus_xtthelp;
}
fp.close();
}
}
void *CnvXtthelpToXml::insert( navh_eItemType item_type, char *t1,
char *t2, char *t3, char *link,
char *link_bookmark, char *file_name,
navh_eHelpFile file_type, int help_index,
char *bookmark)
{
int i;
static int in_table = 0;
char text1[1000];
char text2[1000];
char text3[1000];
cnv_text( text1, t1);
cnv_text( text2, t2);
cnv_text( text3, t3);
if ( (t2 && strcmp(text2, "") != 0) ||
(t3 && strcmp(text3, "") != 0) ) {
if ( !status & xml_mStatus_table) {
fp <<
tags[xml_eTag_table].start << endl;
status |= xml_mStatus_table;
}
}
else {
if ( status & xml_mStatus_table) {
// Close table (keep if empty line)
if ( !( t1 && strcmp( text1, "") == 0 &&
(item_type == navh_eItemType_Help ||
item_type == navh_eItemType_HelpCode ||
item_type == navh_eItemType_HelpBold))) {
fp <<
tags[xml_eTag_table].end << endl;
status &= ~xml_mStatus_table;
}
}
}
switch ( item_type) {
case navh_eItemType_Topic:
{
pwr_tFileName fname;
if ( first_topic || !ctx->common_structfile_only) {
subject_to_fname( fname, text1, 1);
fp.open( fname);
fp <<
xml_cHead << endl <<
xml_cCss << endl <<
tags[xml_eTag_xtthelp].start << endl;
status |= xml_mStatus_xtthelp;
first_topic = 0;
}
fp <<
tags[xml_eTag_topic].start << endl;
status |= xml_mStatus_topic;
return NULL;
}
case navh_eItemType_EndTopic:
{
if ( status & xml_mStatus_table) {
fp <<
tags[xml_eTag_table].end << endl;
status &= ~xml_mStatus_table;
}
if ( status & xml_mStatus_paragraph) {
fp <<
tags[xml_eTag_paragraph].end << endl;
status &= ~xml_mStatus_paragraph;
}
if ( status & xml_mStatus_topic) {
fp <<
tags[xml_eTag_topic].end << endl;
status &= ~xml_mStatus_topic;
}
if ( !ctx->common_structfile_only) {
if ( status & xml_mStatus_xtthelp) {
fp <<
tags[xml_eTag_xtthelp].end << endl;
status &= ~xml_mStatus_xtthelp;
}
fp.close();
}
return NULL;
}
case navh_eItemType_Help:
case navh_eItemType_HelpCode:
{
if ( strcmp( link, "") != 0) {
pwr_tFileName fname;
if ( strncmp( link, "$web:", 5) == 0) {
if ( strncmp( &link[5], "$pwrp_web/", 10) == 0)
strcpy( fname, &link[15]);
else
strcpy( fname, &link[5]);
}
else if ( (strstr( link, ".htm") != 0) ||
(strstr( link, ".pdf") != 0)) {
strcpy( fname, link);
}
else {
subject_to_fname( fname, link, 0);
if ( strcmp( link_bookmark, "") != 0) {
strcat( fname, "#");
strcat( fname, link_bookmark);
}
}
fp << tags[xml_eTag_link].start << " href=\"" << fname << "\">";
}
else if ( bookmark) {
fp << tags[xml_eTag_link].start << " name=\"" << bookmark << "\">";
}
if ( ! in_table) {
fp << text1;
if ( strcmp( link, "") != 0 || bookmark)
fp << tags[xml_eTag_break].start << tags[xml_eTag_link].end << endl;
else
fp << tags[xml_eTag_break].start << endl;
}
else {
fp << "<TR><TD>" << text1;
if ( strcmp( text2, "") != 0 || strcmp( text3, "") != 0) {
for ( i = 0; i < (int)(CNV_TAB - strlen(text1)); i++)
fp << "&nbsp;";
fp << "&nbsp;&nbsp;</TD><TD>" << text2;
if ( strcmp( text3, "") != 0) {
for ( i = 0; i < (int)(CNV_TAB - strlen(text2)); i++)
fp << "&nbsp;";
fp << "&nbsp;&nbsp;</TD><TD>" << text3;
}
}
fp << "</TD></TR>";
if ( strcmp( link, "") != 0 || bookmark)
fp << tags[xml_eTag_link].end << endl;
else
fp << endl;
}
return NULL;
}
case navh_eItemType_HelpBold:
{
pwr_tFileName fname;
if ( strcmp( link, "") != 0) {
if ( strncmp( link, "$web:", 5) == 0) {
if ( strncmp( &link[5], "$pwrp_web/", 10) == 0)
strcpy( fname, &link[15]);
else
strcpy( fname, &link[5]);
}
else if ( (strstr( link, ".htm") != 0) ||
(strstr( link, ".pdf") != 0)) {
strcpy( fname, link);
}
else {
subject_to_fname( fname, link, 0);
if ( strcmp( link_bookmark, "") != 0) {
strcat( fname, "#");
strcat( fname, link_bookmark);
}
}
if ( !in_table)
fp << tags[xml_eTag_link].start << " href=\"" << fname << "\">";
}
else if ( bookmark) {
if ( !in_table)
fp << tags[xml_eTag_link].start <<" name=\"" << bookmark << "\">";
}
if ( ! in_table) {
fp << tags[xml_eTag_bold].start << text1 << tags[xml_eTag_bold].end;
if ( strcmp( link, "") != 0 || bookmark)
fp<< tags[xml_eTag_break].start << tags[xml_eTag_link].end << endl;
else
fp<< tags[xml_eTag_break].start << endl;
}
else {
fp << "<TR><TD><B>";
if ( strcmp( link, "") != 0)
fp << "<A HREF=\"" << fname << "\">";
else if ( bookmark != 0)
fp << "<A NAME=\"" << bookmark << "\">";
fp << text1;
if ( strcmp( link, "") != 0 || bookmark)
fp << "</A>";
if ( strcmp( text2, "") != 0 || strcmp( text3, "") != 0) {
for ( i = 0; i < (int)(CNV_TAB - strlen(text1)); i++)
fp << "&nbsp;";
fp << "&nbsp;&nbsp;</B></TD><TD><B>" << text2;
if ( strcmp( text3, "") != 0) {
for ( i = 0; i < (int)(CNV_TAB - strlen(text2)); i++)
fp << "&nbsp;";
fp << "&nbsp;&nbsp;</B></TD><TD><B>" << text3;
}
}
fp << "</B></TD></TR>";
if ( strcmp( link, "") != 0 || bookmark)
fp << "</A>" << endl;
else
fp << endl;
}
return NULL;
}
case navh_eItemType_HelpHeader:
{
fp << tags[xml_eTag_h1].start << text1 << tags[xml_eTag_h1].end <<
tags[xml_eTag_break].start << endl;
return NULL;
}
case navh_eItemType_Header:
{
fp << tags[xml_eTag_h3].start << text1 << tags[xml_eTag_h3].end <<
tags[xml_eTag_break].start << endl;
return NULL;
}
case navh_eItemType_HeaderLarge:
{
fp << tags[xml_eTag_h2].start << text1 << tags[xml_eTag_h2].end <<
tags[xml_eTag_break].start << endl;
return NULL;
}
case navh_eItemType_HorizontalLine:
{
fp << tags[xml_eTag_hline].start << endl;
return NULL;
}
case navh_eItemType_Image:
{
fp << tags[xml_eTag_image].start <<
" src=\"" << text1 << "\"" << tags[xml_eTag_image].end << endl <<
tags[xml_eTag_break].start << endl;
return NULL;
}
default:
return 0;
}
}
#ifndef cnv_xtthelptoxml_h
#define cnv_xtthelptoxml_h
/* cnv_xtthelptoxml.h -- Documentation
PROVIEW/R
Copyright (C) 1996 by Comator Process AB.
<Description>. */
#if defined __cplusplus
extern "C" {
#endif
#include "pwr.h"
#include "cnv_xtthelpto.h"
using namespace std;
class CnvCtx;
typedef enum {
xml_mStatus_xtthelp = 1 << 0,
xml_mStatus_paragraph = 1 << 1,
xml_mStatus_table = 1 << 2,
xml_mStatus_topic = 1 << 3
} xml_mStatus;
class CnvXtthelpToXml : public CnvXtthelpTo {
public:
CnvXtthelpToXml( CnvCtx *cnv_ctx) :
ctx(cnv_ctx), first_topic(1), status(0) {}
virtual ~CnvXtthelpToXml();
Cnv_eXtthelpToType type() { return Cnv_eXtthelpToType_Xml;}
void *insert( navh_eItemType item_type, char *text1,
char *text2, char *text3, char *link,
char *link_bookmark, char *file_name,
navh_eHelpFile file_type, int help_index,
char *bookmark);
void subject_to_fname( char *fname, char *subject, int path);
void cnv_text( char *to, char *from);
CnvCtx *ctx;
ofstream fp;
int first_topic;
unsigned int status;
};
#if defined __cplusplus
}
#endif
#endif
......@@ -10,8 +10,18 @@ extern "C" {
#include "co_dcli.h"
#include "co_cdh.h"
}
#include "cnv_classread.h"
#include "cnv_help.h"
#include "co_lng.h"
#include "cnv_ctx.h"
#include "cnv_readwbl.h"
#include "cnv_readsrc.h"
#include "cnv_wbltohtml.h"
#include "cnv_wbltoh.h"
#include "cnv_wbltoxtthelp.h"
#include "cnv_wbltops.h"
#include "cnv_readxtthelp.h"
#include "cnv_xtthelptohtml.h"
#include "cnv_xtthelptoxml.h"
#include "cnv_xtthelptops.h"
typedef char cnv_tName[200];
......@@ -62,9 +72,11 @@ static void help()
static int convert_sort_files( const void *file1, const void *file2)
{
// Types before classes
if ( strstr( (char *)file1, "_td_") && !strstr( (char *)file2, "_td_"))
if ( (strstr( (char *)file1, "_td_") || strstr( (char *)file1, "_t_")) &&
!(strstr( (char *)file2, "_td_") || strstr( (char *)file2, "_t_")))
return -1;
else if (!strstr( (char *)file1, "_td_") && strstr( (char *)file2, "_td_"))
else if ( !(strstr( (char *)file1, "_td_") || strstr( (char *)file1, "_t_")) &&
(strstr( (char *)file2, "_td_") || strstr( (char *)file2, "_t_")))
return 1;
return ( strcmp( (char *)file1, (char *)file2));
}
......@@ -73,7 +85,7 @@ static int convert_sort_files( const void *file1, const void *file2)
int main( int argc, char *argv[])
{
int exit_sts = 1;
ClassRead *cr;
CnvCtx *ctx;
int sts;
char found_file[200];
char files[200];
......@@ -84,14 +96,15 @@ int main( int argc, char *argv[])
cnv_tName *file_p;
cnv_tName *old_file_p;
int xtthelp_to_html = 0;
int xtthelp_to_xml = 0;
int xtthelp_to_ps = 0;
if ( argc < 2 || argc > 8) {
usage();
exit(0);
}
cr = new ClassRead();
ctx = new CnvCtx();
for ( i = 1; i < argc; i++) {
if ( strcmp( argv[i], "-d") == 0) {
......@@ -99,16 +112,16 @@ int main( int argc, char *argv[])
usage();
exit(0);
}
strcpy( cr->dir, argv[i+1]);
strcpy( ctx->dir, argv[i+1]);
i++;
#if defined OS_VMS
if ( cr->dir[strlen(cr->dir)-1] != ':' &&
(cr->dir[strlen(cr->dir)-1] != '>' &&
cr->dir[strlen(cr->dir)-1] != ']' ))
strcat( cr->dir , ":");
if ( ctx->dir[strlen(ctx->dir)-1] != ':' &&
(ctx->dir[strlen(ctx->dir)-1] != '>' &&
ctx->dir[strlen(ctx->dir)-1] != ']' ))
strcat( ctx->dir , ":");
#else
if ( cr->dir[strlen(cr->dir)-1] != '/')
strcat( cr->dir , "/");
if ( ctx->dir[strlen(ctx->dir)-1] != '/')
strcat( ctx->dir , "/");
#endif
}
if ( strcmp( argv[i], "-g") == 0) {
......@@ -116,7 +129,15 @@ int main( int argc, char *argv[])
usage();
exit(0);
}
strcpy( cr->setup_filename, argv[i+1]);
strcpy( ctx->setup_filename, argv[i+1]);
i++;
}
if ( strcmp( argv[i], "-l") == 0) {
if ( i+1 >= argc) {
usage();
exit(0);
}
Lng::set( argv[i+1]);
i++;
}
else if ( argv[i][0] == '-') {
......@@ -127,30 +148,40 @@ int main( int argc, char *argv[])
help();
exit(0);
case 'w':
cr->generate_html = 1;
ctx->generate_html = 1;
break;
case 'x':
cr->generate_xtthelp = 1;
ctx->generate_xtthelp = 1;
break;
case 'c':
cr->generate_src = 1;
ctx->generate_src = 1;
break;
case 's':
cr->generate_struct = 1;
ctx->generate_struct = 1;
break;
case 'q':
ctx->generate_ps = 1;
ctx->common_structfile_only = 1;
break;
case 'p':
cr->generate_struct = 1;
cr->hpp = 1;
ctx->generate_struct = 1;
ctx->hpp = 1;
break;
case 'o':
cr->common_structfile_only = 1;
ctx->common_structfile_only = 1;
break;
case 'v':
cr->verbose = 1;
ctx->verbose = 1;
break;
case 't':
xtthelp_to_html = 1;
break;
case 'm':
xtthelp_to_xml = 1;
break;
case 'n':
xtthelp_to_ps = 1;
break;
default:
usage();
exit(0);
......@@ -162,12 +193,33 @@ int main( int argc, char *argv[])
strcpy( files, argv[i]);
}
if ( strcmp( cr->setup_filename, "") != 0)
cr->setup();
ctx->setup = new CnvSetup();
if ( strcmp( ctx->setup_filename, "") != 0) {
ctx->setup->setup( ctx->setup_filename);
}
if ( xtthelp_to_html) {
XhelpToHtml *xh = new XhelpToHtml( files, cr->dir);
delete xh;
CnvXtthelpToHtml *xtthelpto = new CnvXtthelpToHtml( ctx);
ctx->rx = new CnvReadXtthelp( files, ctx->dir, xtthelpto);
ctx->rx->read_xtthelp();
delete ctx->rx;
delete xtthelpto;
exit(0);
}
if ( xtthelp_to_xml) {
CnvXtthelpToXml *xtthelpto = new CnvXtthelpToXml( ctx);
ctx->rx = new CnvReadXtthelp( files, ctx->dir, xtthelpto);
ctx->rx->read_xtthelp();
delete ctx->rx;
delete xtthelpto;
exit(0);
}
if ( xtthelp_to_ps) {
CnvXtthelpToPs *xtthelpto = new CnvXtthelpToPs( ctx);
ctx->rx = new CnvReadXtthelp( files, ctx->dir, xtthelpto);
ctx->rx->read_xtthelp();
delete ctx->rx;
delete xtthelpto;
exit(0);
}
......@@ -195,16 +247,58 @@ int main( int argc, char *argv[])
sts = dcli_search_file( files, found_file, DCLI_DIR_SEARCH_NEXT);
}
dcli_search_file( files, found_file, DCLI_DIR_SEARCH_END);
if ( file_cnt == 0) {
printf( "No files found\n");
exit(0);
}
qsort( file_p, file_cnt, sizeof(*file_p), convert_sort_files);
CnvReadSrc *sr = 0;
if ( ctx->generate_src) {
sr = new CnvReadSrc( ctx);
}
else {
if ( ctx->generate_html)
ctx->wblto = new CnvWblToHtml( ctx);
else if ( ctx->generate_struct)
ctx->wblto = new CnvWblToH( ctx);
else if ( ctx->generate_xtthelp)
ctx->wblto = new CnvWblToXtthelp( ctx);
else if ( ctx->generate_ps)
ctx->wblto = new CnvWblToPs( ctx);
ctx->rw = new CnvReadWbl( ctx, ctx->wblto);
}
if ( ctx->wblto && ctx->wblto->confpass()) {
ctx->wblto->set_confpass( true);
for ( i = 0; i < file_cnt; i++) {
if ( ctx->verbose)
printf( "Configure file %s\n", file_p[i]);
if ( ctx->generate_src) {
sr->read_src( file_p[i]);
}
else {
sts = ctx->rw->read_wbl( file_p[i]);
if ( EVEN(sts)) {
exit_sts = sts;
break;
}
}
}
ctx->wblto->set_confpass( false);
ctx->first_class = 1;
}
for ( i = 0; i < file_cnt; i++) {
if ( cr->verbose)
if ( ctx->verbose)
printf( "Processing file %s\n", file_p[i]);
if ( cr->generate_src)
cr->src_read( file_p[i]);
if ( ctx->generate_src) {
sr->read_src( file_p[i]);
}
else {
sts = cr->read( file_p[i]);
sts = ctx->rw->read_wbl( file_p[i]);
if ( EVEN(sts)) {
exit_sts = sts;
break;
......@@ -212,15 +306,21 @@ int main( int argc, char *argv[])
}
}
if ( cr->generate_html && cr->html_index_open)
cr->html_close();
if ( cr->generate_xtthelp && cr->xtthelp_index_open)
cr->xtthelp_close();
if ( cr->generate_struct)
cr->struct_close();
if ( ctx->generate_html && ctx->wblto->index_open())
ctx->wblto->close();
if ( ctx->generate_xtthelp && ctx->wblto->index_open())
ctx->wblto->close();
if ( ctx->generate_struct)
ctx->wblto->close();
if ( allocated)
free( file_p);
if ( sr)
delete sr;
if ( ctx->rw)
delete ctx->rw;
if ( ctx->wblto)
delete ctx->wblto;
if ( EVEN(exit_sts))
#if defined OS_VMS
......
......@@ -2,6 +2,6 @@ ifndef link_rule_mk
link_rule_mk := 1
link = $(ldxx) $(linkflags) $(domap) -o $(export_exe) $(export_obj) \
$(objects) -lpwr_co -lrt -lm
$(objects) -L/usr/X11R6/lib -lpwr_co -lImlib -lX11 -lrt -lm
endif
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