91.592 Directed Study (Software Engineering)
Spring 2002
BDE Replay Project Report
Zhongmin Cao
May 2002
Table of Contents
1 Introduction
1.1 Purpose
1.2 Background and Objectives
1.3 Overview of project work
2 Design and approach
2.1 The replay function implementation
2.2 Test program for the replay function
2.3 Preparation work for future BDE porting
3 Testing, evaluation and results
4 References
Appendices A, B, C, D
1. Introduction
1.1 Purpose
This report is intended to summarize the work and results of the BDE project undertaken during the spring semester in 2002. It is to document the enhancement and changes made to the project, and for future reference.
1.2 Background and Objectives
BDE(Block Diagram Editor) is an existing graphic editor running in the X environment on Digital Alpha systems. This project is to add the replay function in addition to the current functionalities.
1.3 Overview of project work
The project work consists of the following several components:
1) Implement the replay functionality
2) Test the replay implementation.
3) Preparation work for the BDE application's porting to the FOX platform independent graphic user toolkits.
2 Design and Approach
2.1 The replay function implementation
The existing BDE contains two functions related to the replay process, they are pr_replay() and replay_log() in the file pr_log.c under the directory pr_util. This project revises the replay_log() to be part of the callback/event handler function of an X event, such as key press. It is extracted from pr_log.c to be separate file under bde/src directory with file name called bdeReplay.cc pr_replay() still remains in pr_log.c.
So, with the current implementation, BDE calls pr_load, to load the contents of the database from the database file using the specified view: pr_load() in pr_load.c calls load_data (), load_data() reads the initial database file, such as *DB1.dat, row by row and calls pr_add to add it to the database. But if load_data() finds line "SR" in the file, which means the file is a log file, not a database file. load_data() will return true to pr_load() right after. In any cases, pr_load() then closes the file opened. If load_data() returns 1, pr_replay() will be called by pr_load().
pr_replay() checks the hcg_log value, if it is 1, means logging is in process, reports error and exits. Otherwise set the hcg_log to 2 to allow the start of the replay process. pr_replay() sets hcg_log back to 0 at the end of it.
After the initial database is loaded and displayed, the X events will trigger the real replay process. One X event triggers the call to the replay_log() for only one time. Each time the replay_log() is called, one line of the log file is read in, parsed and necessary actions are executed accordingly. Besides, the replay process is revised to be a three-state process.
2.1.1 BDE replay state diagram
During the replay process, at any given time, it must be in one of the three replay states. The three states for the BDE replay process are: STATE0, STATE1 and STATE2.
STATE0 is the initial state, every replay starts with this state. STATE1 opens the log file, gets the first line of the log file and parse the line to get the command token, verifies that the command token is "SR", and then sets the replay state to STATE1.
In STATE1, the process first reads in one more line and parses it and gets the command token, Depends on the type of command, executes different actions. If the token is one of the SetFltCmd, SetInitCmd, SetKeyCmd, SetStrCmd, AddRowCmd and DeleteCmd, it will call clearObjects() to clear the object hierarchy by deleting the topobject, and creates a new one. , then set the HG_pkey value, call updatedisplaylist() to update the graphic object list and finally call ReDraw() to redraw the graph according to the current graph object list.If the token is StopCmd, it sets the replayState to STATE2 for final stage cleanup work. If the command is something other than these, nothing will be done within this state.
In STATE2, depending on the contents of the log file, sets the replayStatus value and then close the log file. Another task need to be performed in this state is to check weather the final database is necessary to be saved. The parameter control this action is take_endsnapshot. If it is set to be 1, save the database after the replay in a file called *DB3.dat, otherwise, nothing need to be done.
In any of the state, once it finishes the action sequence required, the replayState value is returned to the calling function, which is the callback/event handler function of an X event.
The state diagram is shown in the file zcao_BDE_Replay_STD.ppt
2.1.2 Initial database file
The initial database with name *DB1.dat contains the snapshot of the database just before the replay logging is started.
Please refer to the Appendix D for a sample initial database file mylogDB1.dat.
2.1.3 Replay log file
The replay log file *.txt starts with line "SR", which means the start of the logging, and normally ends with "SP", which means the stop of logging.
Please refer to the Appendix E for a sample replay log file mylog.txt.
2.2 Test program for the replay function
The purpose of the test program bdr.cc (block diagram replay) is for testing the correctness of the replay_log() function in the bdeReplay.cc file under bde/src directory.
In order to isolate other factors that may prevent the function from running properly, bdr.cc keeps only the minimum components required for a replay, thus the test program creates a window with a drawing area (canvas) only. There is no menu bar and left navigation bar present in the display window.
To start the program, enter
# bdr logDB1.txt log.dat
The first command line argument logDB1.txt is the initial database file, which represents the initial state before the replay. The second argument log.dat is the log file containing "SR" line in it. So supply the proper DB file and the log file accordingly to the command line.
After the program is started, the initial database file is loaded and displayed in the canvas. To start the replay, select the window created by bdr.cc and press the key "s" on the keyboard, each key press triggers one step of replay, press "s" continuously to step through the replay process until it reach the end of the log file log.dat.
To support the build of the bdr executable without interfering the normal bde build process, BDR is defined in the configure.h file under bde directory. Besides, Imakefile in bde/src directory is modified to allow the build of bdr other than bde. The partial modified bde/src/Imakefile is attached below:
#ifdef BDR
OBJS = bendpt.o bendptops.o bdr.o bdeReplay.o buttonevent.o \
captionops.o cursor.o dialog.o display.o draw.o edit.o fileio.o \
font.o fprint.o graphobject.o graphops.o handler.o help.o hlink.o \
infodialog.o infomessage.o init.o initClasses.o leftmenu.o leftmenu_cb.o \
linkops.o menubar.o menubar_cb.o msgBox.o nodeops.o select.o \
smselect.o strdup.o text.o textops.o
SRCS = bdr.cc bdeReplay.cc bendpt.cc bendptops.cc buttonevent.cc \
captionops.cc cursor.cc dialog.cc display.cc draw.cc edit.cc fileio.cc \
font.cc fprint.cc graphobject.cc graphops.cc handler.cc help.cc hlink.cc \
infodialog.cc infomessage.cc init.cc initClasses.cc leftmenu.cc leftmenu_cb.cc \
linkops.cc menubar.cc menubar_cb.cc msgBox.cc nodeops.cc select.cc \
smselect.cc strdup.cc text.cc textops.cc
ComplexCplusplusProgramTarget(bdr)
#else
OBJS = bendpt.o bendptops.o bde.o bdeReplay.o buttonevent.o \
captionops.o cursor.o dialog.o display.o draw.o edit.o fileio.o \
font.o fprint.o graphobject.o graphops.o handler.o help.o hlink.o \
infodialog.o infomessage.o init.o initClasses.o leftmenu.o leftmenu_cb.o \
linkops.o menubar.o menubar_cb.o msgBox.o nodeops.o select.o \
smselect.o strdup.o text.o textops.o
SRCS = bde.cc bdeReplay.cc bendpt.cc bendptops.cc buttonevent.cc \
captionops.cc cursor.cc dialog.cc display.cc draw.cc edit.cc fileio.cc \
font.cc fprint.cc graphobject.cc graphops.cc handler.cc help.cc hlink.cc \
infodialog.cc infomessage.cc init.cc initClasses.cc leftmenu.cc leftmenu_cb.cc \
linkops.cc menubar.cc menubar_cb.cc msgBox.cc nodeops.cc select.cc \
smselect.cc strdup.cc text.cc textops.cc
ComplexCplusplusProgramTarget(bde)
#endif
So there is one switch to control the build target. To build regular bde, nothing extra is necessary to be done. If choose to build bdr, add a line #define BDR to the file configure.h and then do a make. The executable for the bdr test program is bdr in the bde/src directory.
The source code for bdr.cc is shown on the next page.
/*********************************************************/
/* File : bdr.cc */
/* Description : Test program for BDE replay function */
/* Created by : 02s592 */
/* Routines : keypressHandler() */
/* Usage: %bdr filename1 filename2 */
/* filename1: the *DB1.dat database file */
/* filename2: the log file */
/*********************************************************/
#include "prototype.h"
#include "94sbde_schema.h"
#include "bde.h"
#include "graph.h"
#include "defs.h"
#include "loaddefaults.h"
#define WIDGET
#include "widget.h"
extern char *GetBDEViewDefsFile( void );
extern char *GetBDEDatFileList(char * );
extern void initClasses();
extern "C" int replay_log(void);
extern void updatedisplaylist(struct HG *cHG);
extern Widget canvas;
extern Screen *rootscreen;
extern Display *display;
extern struct HG *HGcurr;
extern int endOfReplay;
void keypressHandler(Widget w, XtPointer input,
XEvent *event, Boolean *continue_dispatch);
void canvascallback(Widget w, caddr_t *client_data,
XmDrawingAreaCallbackStruct *cb);
Widget toplevel;
Select selected;
XtAppContext app_context;
int stepCount = 0, replayState = 0, dcount =0;
char *infile;
int main(int argc, char **argv)
{
unsigned long color;
infile = argv[1];
extern char* logfile;
logfile=argv[2];
endOfReplay=0;
toplevel = XtAppInitialize(&app_context, "ReplayTest",
NULL, 0, &argc, argv,NULL,NULL,0);
Arg args[4];
int n=0;
XtSetArg(args[n], XmNwidth, 830); n++;
XtSetArg(args[n], XmNheight, 430); n++;
color = WhitePixel(XtDisplay(toplevel),DefaultScreen( XtDisplay(toplevel)));
XtSetArg(args[n], XmNbackground,color ); n++;
color = BlackPixel(XtDisplay(toplevel),DefaultScreen(
XtDisplay(toplevel)));XtSetArg(args[n], XmNforeground,color ); n++;
canvas = XtCreateManagedWidget( "canvas",
xmDrawingAreaWidgetClass, toplevel, args, n);
XtAddCallback(canvas, XmNexposeCallback,canvascallback, NULL);
XtAddEventHandler(canvas, KeyPressMask, FALSE, keypressHandler, NULL);
initClasses();
XtRealizeWidget(toplevel);
XtAppMainLoop(app_context);
}
void canvascallback(Widget w, caddr_t *client_data,
XmDrawingAreaCallbackStruct *cb)
{
if (dcount ==0) {
hcg_initialized = 0;
pr_init( GetBDEViewDefsFile(), GetBDEDatFileList(infile) );
pr_load("94sbdeview",infile);
if (HGcurr == NULL) {
printf("HGcurr is NULL \n");
}
else {
updatedisplaylist(HGcurr);
ReDraw();
}
dcount =1;
}
}
void keypressHandler(Widget w, XtPointer input,
XEvent *event, Boolean *continue_dispatch)
{
KeySym keysym_return;
Modifiers mod;
if(event->type == KeyPress)
{
XtTranslateKeycode(display, event->xkey.keycode,
event-> xkey.state, &mod, &keysym_return);
if ((strcmp(XKeysymToString(keysym_return),"s")==0) & (endOfReplay==0))
{
printf("\n====== replay step %d, replayState %d\n",
++stepCount, replayState);
replayState = replay_log();
}
}
}
A sample output from a run of bdr can be found in the section 3.
2.3 Preparation work for future BDE porting.
Because the current BDE's graphic user interface is implemented by calling X/Motif routines, this makes the application heavily rely on the X/Motif environment to run, with the increasing amount of the Microsoft Windows user base, no support for Microsoft Windows environment becomes an issue. Other than providing an Windows version as a solution to address this problem, porting the BDE application to be on top of an independent graphic user interface platform allowing both the X/Motif and Microsoft Windows users access the BDE application is also a good option.
The benefit of the second solution brings us is that only a single version of the software is necessary to be maintained, so lets future application enhancement work easier. The disadvantage of this is we will need to rely on the 3rd party's support on the future new platforms or releases.
The independent graphic user interface that has been chosen for BDE porting work is the FOX Toolkit. FOX Toolkit offers a collection of Controls and capabilities such as drag and drop, selection, as well as OpenGL widgets for 3D graphical manipulation. The most attractive feature to the BDE project is its wide range of platform support, which is claimed as platform independent. FOX Toolkit now runs on operating systems ranging from Linux, FreeBSD, SGI IRIX, HP-UX, IBM AIX, SUN Solaris, DEC/Compaq Tru64 UNIX, to MS-Window operating systems like Windows 9x, Windows NT, Windows ME and Windows 2000.
The porting preparation work has been started as part of the project. As an assistant for decision making on how to do the porting, a better overall knowledge on the Xlib and Motif routines called by BDE is necessary. The program a.cc and b.cc are for this purpose.
a.cc and b.cc extract the Xlib and Motif calls from the all BDE source code together with the calling parameters, and then sorted them for better analysis. a.cc's output lists the calls in the filename order, while b.cc's lists the results in routine name order. Both results give out the number of occurrence and the line numbers.
The output for the two programs is listed below. The source code can be found in Appendix D and E.
Partial results of sorted by File: for text.cc
The first column shows the line number of the occurrence in the file, the second column shows the routine called, the third column is the complete call presented in the file.
text.cc:
---------------------
184 XmSelectionBoxGetChild: str = XmTextGetString(XmSelectionBoxGetChild( graphCaptionDialog,
XmDIALOG_TEXT ));
186 XtUnmanageChild: XtUnmanageChild(graphCaptionDialog);
203 XmSelectionBoxGetChild: str = XmTextGetString(XmSelectionBoxGetChild( textDialog,
XmDIALOG_TEXT ));
206 XtUnmanageChild: XtUnmanageChild(textDialog);
211 XDrawString: XDrawString(XtDisplay(canvas),XtWindow(canvas),xorGC,
data->cur_x,data->cur_y,
data->cur_val,strlen(data->cur_val));
216 XDrawString: XDrawString(XtDisplay(canvas),XtWindow(canvas),copyGC,
data->x,data->y,data->str,strlen(data->str));
233 XmSelectionBoxGetChild: str = XmTextGetString(XmSelectionBoxGetChild( textDialog,
XmDIALOG_TEXT ));
237 XtUnmanageChild: XtUnmanageChild(textDialog);
265 XtUnmanageChild: XtUnmanageChild(textDialog);
310 XLoadQueryFont: font = XLoadQueryFont(XtDisplay(canvas), fontname);
312 XLoadQueryFont: font = XLoadQueryFont(XtDisplay(canvas),"Fixed") ;
313 XSetFont: XSetFont(XtDisplay(canvas), gc, font->fid);
324 XLoadQueryFont: font = XLoadQueryFont(XtDisplay(canvas), fontname);
Partial results of sorted by routines: for routine XCreateGC
The first column shows the file name, the numbers in the parenthesis show the line number in the file, and the third column is the complete call presented in the file.
XCreateGC:
---------------------
initClasses.cpp(154): copyGC = XCreateGC(display, rootscreen->root,
(GCForeground | GCBackground | GCLineWidth | GCFont),
&values);
initClasses.cpp(158): segmentGC = XCreateGC(display, rootscreen->root,
(GCForeground | GCBackground | GCLineWidth | GCFont),
&values); // 96subde: fjara, ianandak
initClasses.cpp(172): xorGC = XCreateGC(display, rootscreen->root,
(GCFunction | GCForeground | GCBackground |
GCPlaneMask),
&values);
initClasses.cpp(185): highlightGC = XCreateGC(display, rootscreen -> root,
(GCFunction | GCForeground | GCLineWidth |
GCBackground | GCLineStyle | GCPlaneMask),
&values);
3 Testing, evaluation and results
The following tests were performed in order to check to what extent the replay function works.
3.1 BDE
The executable bde.exe in /usr/proj3/case/gen/ver_12/sjaganat/Test/bde/executables/alpha was run with key press events to start the replay. The result was the same as what was expected. The output from the replay is shown below:
% /nfs/saturn/proj3/case/gen/ver_12/sjaganat/Test/bde/executables/alpha/bde.exe mylog.txt
Using GENV12
Replay file : mylog.txt | Click Options -> Start Replay to start replay
GD defaults file not specified. Using BDE defaults
SCnode 0x11 17
dostate: selected.getstate = 0x11 = 17
Using default viewdefs: ../lib/bdetest.viewdefs
Warning: unknown table /* found in scanned datafile ../lib/fonts.dat, ignored.
Warning: unknown table /* found in scanned datafile ../lib/fonts.dat, ignored.
Warning: unknown table found in scanned datafile ../lib/fonts.dat, ignored.
Warning: unknown table found in scanned datafile ../lib/fonts.dat, ignored.
Warning: unknown table () found in datafile, ignored.
Replay Ready : 1Token=SR, Command = 6
Found SR
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=VN, Command = 11
Found VN with viewname 94sbdeview.
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=/*, Command = -1
Logfile: unknown command '/*' - ignored
Unknown pkey /*: skipping
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=HA000002, Command = 12
Found Add with pkey HA000002, rest HN000011 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* E .
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=DL, Command = 5
Found DL with pkey HA000001.
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=HA000003, Command = 12
Found Add with pkey HA000003, rest HN000012 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* E .
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=DL, Command = 5
Found DL with pkey HA000002.
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=HA000004, Command = 12
Found Add with pkey HA000004, rest HN000012 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* N .
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=DL, Command = 5
Found DL with pkey HA000003.
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=HA000005, Command = 12
Found Add with pkey HA000005, rest HN000013 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* N .
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=DL, Command = 5
Found DL with pkey HA000004.
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=HA000006, Command = 12
Found Add with pkey HA000006, rest HN000014 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* N .
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=DL, Command = 5
Found DL with pkey HA000005.
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=HA000007, Command = 12
Found Add with pkey HA000007, rest HN000015 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* N .
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=DL, Command = 5
Found DL with pkey HA000006.
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=HA000008, Command = 12
Found Add with pkey HA000008, rest HN000016 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* N .
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=DL, Command = 5
Found DL with pkey HA000007.
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=HA000009, Command = 12
Found Add with pkey HA000009, rest HN000016 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* W .
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=DL, Command = 5
Found DL with pkey HA000008.
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=HA000010, Command = 12
Found Add with pkey HA000010, rest HN000017 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* W .
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=DL, Command = 5
Found DL with pkey HA000009.
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=HA000011, Command = 12
Found Add with pkey HA000011, rest HN000018 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* W .
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=DL, Command = 5
Found DL with pkey HA000010.
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=HA000012, Command = 12
Found Add with pkey HA000012, rest HN000019 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* W .
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=DL, Command = 5
Found DL with pkey HA000011.
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=HA000013, Command = 12
Found Add with pkey HA000013, rest HN000004 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* W .
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=DL, Command = 5
Found DL with pkey HA000012.
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=HA000014, Command = 12
Found Add with pkey HA000014, rest HN000004 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* S .
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=DL, Command = 5
Found DL with pkey HA000013.
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=HA000015, Command = 12
Found Add with pkey HA000015, rest HN000005 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* S .
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=DL, Command = 5
Found DL with pkey HA000014.
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=HA000016, Command = 12
Found Add with pkey HA000016, rest HN000006 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* S .
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=DL, Command = 5
Found DL with pkey HA000015.
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=HA000017, Command = 12
Found Add with pkey HA000017, rest HN000007 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* S .
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=DL, Command = 5
Found DL with pkey HA000016.
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=HA000018, Command = 12
Found Add with pkey HA000018, rest HN000008 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* S .
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=DL, Command = 5
Found DL with pkey HA000017.
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=HA000019, Command = 12
Found Add with pkey HA000019, rest HN000008 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* E .
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=DL, Command = 5
Found DL with pkey HA000018.
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=HA000020, Command = 12
Found Add with pkey HA000020, rest HN000009 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* E .
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=DL, Command = 5
Found DL with pkey HA000019.
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=HA000021, Command = 12
Found Add with pkey HA000021, rest HN000010 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* E .
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=DL, Command = 5
Found DL with pkey HA000020.
Fileio.cc:replay_Log returns: replayStatus = 1
Replay Ready : 1Token=SP, Command = 10
Found SP
Fileio.cc:replay_Log returns: replayStatus = 2
signal_handler: signal 2
signal_handler: saving diagram to bdeabort.dat
3.2 BDR
The executable bdr in the directory /usr/proj3/case/02s592/zcao/bde/src was run with key press event to start the replay. The results was the same as what was expected.
The output from the replay is shown below:
% bdr mylogDB1.dat mylog.txt
Using default viewdefs: ../lib/bdetest.viewdefs
Warning: unknown table /* found in scanned datafile ../lib/fonts.dat, ignored.
Warning: unknown table /* found in scanned datafile ../lib/fonts.dat, ignored.
Warning: unknown table found in scanned datafile ../lib/fonts.dat, ignored.
Warning: unknown table found in scanned datafile ../lib/fonts.dat, ignored.
Warning: unknown table () found in datafile, ignored.
====== replay step 1, replayState 0
Token=SR, Command = 6
Found SR
====== replay step 2, replayState 1
Token=VN, Command = 11
Found VN with viewname 94sbdeview.
====== replay step 3, replayState 1
Token=/*, Command = -1
Logfile: unknown command '/*' - ignored
Unknown pkey /*: skipping
====== replay step 4, replayState 1
Token=HA000002, Command = 12
Found Add with pkey HA000002, rest HN000011 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* E .
====== replay step 5, replayState 1
Token=DL, Command = 5
Found DL with pkey HA000001.
====== replay step 6, replayState 1
Token=HA000003, Command = 12
Found Add with pkey HA000003, rest HN000012 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* E .
====== replay step 7, replayState 1
Token=DL, Command = 5
Found DL with pkey HA000002.
====== replay step 8, replayState 1
Token=HA000004, Command = 12
Found Add with pkey HA000004, rest HN000012 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* N .
====== replay step 9, replayState 1
Token=DL, Command = 5
Found DL with pkey HA000003.
====== replay step 10, replayState 1
Token=HA000005, Command = 12
Found Add with pkey HA000005, rest HN000013 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* N .
====== replay step 11, replayState 1
Token=DL, Command = 5
Found DL with pkey HA000004.
====== replay step 12, replayState 1
Token=HA000006, Command = 12
Found Add with pkey HA000006, rest HN000014 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* N .
====== replay step 13, replayState 1
Token=DL, Command = 5
Found DL with pkey HA000005.
====== replay step 14, replayState 1
Token=HA000007, Command = 12
Found Add with pkey HA000007, rest HN000015 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* N .
====== replay step 15, replayState 1
Token=DL, Command = 5
Found DL with pkey HA000006.
====== replay step 16, replayState 1
Token=HA000008, Command = 12
Found Add with pkey HA000008, rest HN000016 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* N .
====== replay step 17, replayState 1
Token=DL, Command = 5
Found DL with pkey HA000007.
====== replay step 18, replayState 1
Token=HA000009, Command = 12
Found Add with pkey HA000009, rest HN000016 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* W .
====== replay step 19, replayState 1
Token=DL, Command = 5
Found DL with pkey HA000008.
====== replay step 20, replayState 1
Token=HA000010, Command = 12
Found Add with pkey HA000010, rest HN000017 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* W .
====== replay step 21, replayState 1
Token=DL, Command = 5
Found DL with pkey HA000009.
====== replay step 22, replayState 1
Token=HA000011, Command = 12
Found Add with pkey HA000011, rest HN000018 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* W .
====== replay step 23, replayState 1
Token=DL, Command = 5
Found DL with pkey HA000010.
====== replay step 24, replayState 1
Token=HA000012, Command = 12
Found Add with pkey HA000012, rest HN000019 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* W .
====== replay step 25, replayState 1
Token=DL, Command = 5
Found DL with pkey HA000011.
====== replay step 26, replayState 1
Token=HA000013, Command = 12
Found Add with pkey HA000013, rest HN000004 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* W .
====== replay step 27, replayState 1
Token=DL, Command = 5
Found DL with pkey HA000012.
====== replay step 28, replayState 1
Token=HA000014, Command = 12
Found Add with pkey HA000014, rest HN000004 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* S .
====== replay step 29, replayState 1
Token=DL, Command = 5
Found DL with pkey HA000013.
====== replay step 30, replayState 1
Token=HA000015, Command = 12
Found Add with pkey HA000015, rest HN000005 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* S .
====== replay step 31, replayState 1
Token=DL, Command = 5
Found DL with pkey HA000014.
====== replay step 32, replayState 1
Token=HA000016, Command = 12
Found Add with pkey HA000016, rest HN000006 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* S .
====== replay step 33, replayState 1
Token=DL, Command = 5
Found DL with pkey HA000015.
====== replay step 34, replayState 1
Token=HA000017, Command = 12
Found Add with pkey HA000017, rest HN000007 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* S .
====== replay step 35, replayState 1
Token=DL, Command = 5
Found DL with pkey HA000016.
====== replay step 36, replayState 1
Token=HA000018, Command = 12
Found Add with pkey HA000018, rest HN000008 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* S .
====== replay step 37, replayState 1
Token=DL, Command = 5
Found DL with pkey HA000017.
====== replay step 38, replayState 1
Token=HA000019, Command = 12
Found Add with pkey HA000019, rest HN000008 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* E .
====== replay step 39, replayState 1
Token=DL, Command = 5
Found DL with pkey HA000018.
====== replay step 40, replayState 1
Token=HA000020, Command = 12
Found Add with pkey HA000020, rest HN000009 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* E .
====== replay step 41, replayState 1
Token=DL, Command = 5
Found DL with pkey HA000019.
====== replay step 42, replayState 1
Token=HA000021, Command = 12
Found Add with pkey HA000021, rest HN000010 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* E .
====== replay step 43, replayState 1
Token=DL, Command = 5
Found DL with pkey HA000020.
====== replay step 44, replayState 1
Token=SP, Command = 10
Found SP
====== replay step 45, replayState 2
Replay is done.
4 References
- Final report, Software Engineer 94F523, BDEGC Team
- Final report, BDE2PC
- Final report, BDE as a test case for chgen versio 8, 93su523, Gen Team
- Genlog Project, Final Project Outline V2.3
Appendix A: bdeReplay.cc source code
/***********************************************************/
/* File : bdeReplay.cc */
/* Description : */
/* Created by : 02s592 */
/* Routines : replay_log */
/* updatedisplaylist */
/* Uses: encode_token and do_command in pr_log.c */
/***********************************************************/
/* TBD: CHeck if ReDraw is a callback wrapper or the real stuff -RJL */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include "94sbde_schema.h"
#include "bde.h"
#include "prototype.h" // no longer declares replay_log-RJL 020501
#include "graph.h" //class i'faces; #includes state.h
///////////// X/Xt/Motif include files ////////////////////
// RJL: Why do we need <X11*.h>in bdeReplay.cc?
// replay_log is called FROM the Xt callback routine in fileio.cc
//#include <X11/StringDefs.h>
//#include <X11/Xlib.h>
//#include <X11/Intrinsic.h>
//#include <Xm/Xm.h>
extern "C" {
/* in pr_load.c: */
void hcg_parse(char*, char*, int*);
extern char* viewname; /* view --> viewname - RJL 020501 */
/* in pr_log.c: */
void hcg_read_next(void);
extern hcg_key HG_pkey;
extern char *logfile;
extern FILE* logfile_fp;
extern char token[BUFSIZE];
extern int near_realtime;
extern int take_endsnapshot;
extern int replayState;
extern int replayStatus;
extern int idx;
} /* extern "C" */
// replayState values: (should be enum'd)
#define STATE0 0
#define STATE1 1
#define STATE2 2
// enumeration of command names as integers:
typedef
enum {SetIntCmd,SetFltCmd,SetKeyCmd,SetStrCmd,WaitCmd,DeleteCmd,
StartCmd,FreeCmd,InitCmd,LoadCmd,StopCmd,ViewNameCmd,AddRowCmd}
replayCode;
replayCode command; // for switch(command)
extern "C" {
replayCode do_command(char*, char*, int*);
}
// macros to avoid scattered #ifdefs below
// depend on argcount after format string
//ERROR: `#' operator should be followed by a macro argument name
// when tried to #define dprintf wraped in #ifdef DEBUG - RJL 020430
#define dprintf(string)\
printf(string);
#define dprintf1arg(string,arg1)\
printf(string, arg1);
#define dprintf2args(string,arg1,arg2)\
printf(string, arg1, arg2);
void updatedisplaylist(struct HG *cHG) /* updates HGcurr - RJL*/
/* updatedisplaylist regenerates the graph object list of HN/CG/HL ptrs
* after a database update or HG-row selection;
* it supplies input data for ReDraw.
* The caller is responsible for updating cHG - RJL 020427
*/
{
node *lastnode;
hlink *lastlink;
caption *lastcaption; // last caption Added by 94FBDE
HGcurr = cHG; // added 020427 - RJL (else why pass this argument?)
(void) new graph(HGcurr);
child_loop(HG,HN,HNid,HGid) // depends on HGcurr!
{
lastnode = new node(HNcurr);
child_loop(HN,HL,HLid1,HNid1)
{
lastlink = new hlink(HLcurr);
}
}
child_loop(HG,CG,CGid,HGid) // Added by 94FBDE
{
lastcaption = new caption(CGcurr);
}
} // end updatedisplaylist
void encode_token(char *token, int *command)
/* encode_token converts first token on a logfile line to an int arg
* for use as a switch(command) argument.
* Move this to pr_log.c where chgen can produce it - RJL 020427
*/
{
int tokenlength = strlen(token);
if (tokenlength==10) {
if (strcmp(token,"PR_SET_INT") == 0) *command = SetIntCmd;
else if (strcmp(token,"PR_SET_FLT") == 0) *command = SetFltCmd;
else if (strcmp(token,"PR_SET_KEY") == 0) *command = SetKeyCmd;
else if (strcmp(token,"PR_SET_STR") == 0) *command = SetStrCmd;
}
else if (tokenlength==2) { //ordered by decreasing frrequency
if (strcmp(token,"WA") == 0) *command = WaitCmd;
else if (strcmp(token,"DL") == 0) *command = DeleteCmd;
else if (strcmp(token,"FR") == 0) *command = FreeCmd;
else if (strcmp(token,"IN") == 0) *command = InitCmd;
else if (strcmp(token,"LD") == 0) *command = LoadCmd;
else if (strcmp(token,"SP") == 0) *command = StopCmd;
else if (strcmp(token,"SR") == 0) *command = StartCmd;
else if (strcmp(token,"VN") == 0) *command = ViewNameCmd;
}
else if (tokenlength != HCG_KEY_SIZE) // pkey, 8 or 12 bytes
{
printf("Logfile: unknown command '%s' - ignored\n", token);
}
else //expect table row to be pr_added */
{
*command = AddRowCmd; // default
};
dprintf2args("Token=%s, Command = %d\n", token, *command);
}
// end encode_token
/************************************************************/
/* Function:replay_log */
/* */
/* This is the callback function to parse one logfile line */
/* and execute the action of the log entry. */
/* The arguments are saved by pr_replay for reference here */
/* Arguments: logfile - logfile to replay */
/* near_realtime - flag indicates to */
/* replay in near realtime */
/* 0 = not real time */
/* 1 = real time */
/* replayStatus values: */
/* 0 - success parsing and replay */
/* -3 - cannot open file */
/* -5 - logfile doesn't start with line "SR" */
/* -7 - logfile doesn't end with line "SP" */
/* -9 - log file has stuff after the SP entry */
/* Return value: */
/* replayState: */
/* 0: STATE0 */
/* 1: STATE1 */
/* 2: STATE2 */
/* "SR" is a precondition if pr_load delegates to pr_replay.*/
/* "SP" is a post-condition that is not fatal */
/* fopen success is a pre-condition - pr_load already tried.*/
/* Effects: */
/* hcg_buffer - altered */
/* hcg_ascii_fp - altered */
/* hcg_t - altered */
/* value of database may be altered based on commamnds in */
/* the format of the data file. If no SP was found, */
/* replay_log will exit [with no change? - RJL] */
/************************************************************/
/******************************************************************
* Design Notes from RJL - 020429: a problem here is that most of the code
* below can be auto-generated by genv12; only the state machine and
* updatedisplaylist and ReDraw calls are bde-specific.
* The rest depends only on schema.h. and chgen can handle it.
*
* Therefore I refactored out some code and moved it to pr_util.
* THis includes the Level 2 command interpreter.
* Level 1: switch(state) as below;
* Level 2: encode(token, &command) and switch(command);
* encode_token() enumerates the commands for inner switch cases.
*
* The last 5 lines of each command case block
* were common to most but not all commands; I factored them out
* under one of two switch(command) blocks for selective action.
* SOme lines below call other pr_util library functions
* generated in pr_log.c by chgen.
*************************************************************
*/
extern "C" int replay_log(void);
int replay_log(void) // RJL: void
{
//This belongs in pr_replay - RJL 020427
assert((near_realtime == 1) || (near_realtime ==0));
// Valid command values depend on replayState:
switch(replayState) {
case STATE0:
/* re-open the log file and go to STATE1 or STATE2 */
if ((logfile_fp = fopen(logfile, "r")) ==NULL) {
hcg_log = 0;
return(-3);
}
hcg_ascii_fp = logfile_fp;
hcg_read_next(); /* read first line of log file */
assert(!feof(hcg_ascii_fp)); // pre-condition
idx = 0;
hcg_parse(hcg_buffer,token,&idx);
encode_token(token, (int*)&command);
assert(command == StartCmd);
//command "SR" is a pre-condition (verified by pr_load)
//so no need for switch(command)
dprintf("Found SR\n");
// Move read_next and feof test to start of State1:
replayState = STATE1; // GO TO STATE 1
break; // STATE0
case STATE1:
hcg_read_next(); // get first command
if (feof(hcg_ascii_fp)) {
replayState = STATE2; // empty logfile
break;
}
command = do_command(hcg_buffer, token, &idx);
/* TBD: produce by genv12 in pr_load.c - RJL 0204229 */
/* returns int command for switch(command) below */
/* lines 250-427 moved to pr_log.c includes encode_token
* and do_command functions that chgen can provide.-RJL 020429
*/
/* rest of replay_log belongs to bde/src/replay_log - RJL 020429 */
// second switch(command): redraws the display after DB update
switch(command) {
case SetFltCmd:
case SetIntCmd:
case SetKeyCmd:
case SetStrCmd:
case AddRowCmd:
case DeleteCmd:
clearObjects();
HG_pkey = HGcurr->HGid;
updatedisplaylist(HGcurr);
ReDraw();
break;
case WaitCmd: case StartCmd: case FreeCmd: case InitCmd:
case LoadCmd: case ViewNameCmd:
break;
case StopCmd:
replayState = STATE2; // let STATE2 do SP processing.
break;
default: break;
} // end 2nd switch(command)
break; // end STATE1
case STATE2:
if (feof(hcg_ascii_fp)) {
replayStatus = -7; /* file ends without SP line. */
} else if (command == StopCmd) {
hcg_read_next();
if (feof(hcg_ascii_fp))
replayStatus = 0; /* successful completion of log parsing. */
else
replayStatus = -9; /*log file has stuff after the SP entry */
}
fclose(logfile_fp);
if (take_endsnapshot==1) { /* take final snapshot */
char* tempvar;
sprintf(tempvar,"%sDB3.dat",logfile);
pr_dump(viewname, tempvar,0,"w"); //view->viewname RJL 020501
}
break; // end of STATE2
default:
printf("Illegal value %d for replayState\n", replayState);
break;
} // end switch(replayState)
return replayState; /* returns to X11 not pr_replay - RJL */
} // end replay_log
Appendix B: mylogDB1.dat
HG000001 FS010000 HN010000 LECHNER 19FEB02/2224 19FEB02/2224 ringPath.dat
HN000004 HG000001 FS010000 R 60.0000 60.0000 49.0000 49.0000 Fixed
0.0000 0.0000 0 0
HN000005 HG000001 FS010000 R 60.0000 110.0000 49.0000 49.0000 Fixed
0.0000 0.0000 0 0
HN000006 HG000001 FS010000 R 60.0000 160.0000 49.0000 49.0000 Fixed
0.0000 0.0000 0 0
HN000007 HG000001 FS010000 R 60.0000 210.0000 49.0000 49.0000 Fixed
0.0000 0.0000 0 0
HN000008 HG000001 FS010000 R 60.0000 260.0000 49.0000 49.0000 Fixed
0.0000 0.0000 0 0
HN000009 HG000001 FS010000 R 110.0000 260.0000 49.0000 49.0000 Fixed
0.0000 0.0000 0 0
HN000010 HG000001 FS010000 R 160.0000 260.0000 49.0000 49.0000 Fixed
0.0000 0.0000 0 0
HN000011 HG000001 FS010000 R 210.0000 260.0000 49.0000 49.0000 Fixed
0.0000 0.0000 0 0
HN000012 HG000001 FS010000 R 260.0000 260.0000 49.0000 49.0000 Fixed
0.0000 0.0000 0 0
HN000013 HG000001 FS010000 R 260.0000 210.0000 49.0000 49.0000 Fixed
0.0000 0.0000 0 0
HN000014 HG000001 FS010000 R 260.0000 160.0000 49.0000 49.0000 Fixed
0.0000 0.0000 0 0
HN000015 HG000001 FS010000 R 260.0000 110.0000 49.0000 49.0000 Fixed
0.0000 0.0000 0 0
HN000016 HG000001 FS010000 R 260.0000 60.0000 49.0000 49.0000 Fixed
0.0000 0.0000 0 0
HN000017 HG000001 FS010000 R 210.0000 60.0000 49.0000 49.0000 Fixed
0.0000 0.0000 0 0
HN000018 HG000001 FS010000 R 160.0000 60.0000 48.0000 48.0000 Fixed
11.0000 11.0000 30 13
HN000019 HG000001 FS010000 R 110.0000 60.0000 49.0000 49.0000 Fixed
0.0000 0.0000 0 0
HN000020 HG000001 FS010000 R 59.0000 59.0000 49.0000 49.0000 Fixed
0.0000 0.0000 0 0
HA000001 HN000010 DA010009 8.0000 -4.0000 0.0000 37 16 *helvet
ica-bold-r*140* E
CG000001 HG000001 370.0000 25.0000 50.0000 0.0000
CG000002 HG000001 509.0000 80.0000 416.0000 56.0000
CG000003 HG000001 515.0000 243.0000 422.0000 66.0000
GX000001 CG000001 DA010009 0.0000 *helvetica-bold-r*140* 36.0000 -6.0000
72 13 ringPath.dat
GX000002 CG000002 DA010009 0.0000 *helvetica-bold-r*140* 181.0000 10.0000
331 21 ringPath.dat: Closed Path for Hominid Navigation Test
GX000003 CG000002 DA010009 0.0000 *helvetica-bold-r*140* 181.0000 -12.0000
304 21 Created 020219; last changed 020522 as mylogDB1.dat
GX000004 CG000003 DA010009 0.0000 *helvetica-bold-r*140* 203.0000 16.0000
246 16 Nodes HN000000 thru HN000003 were removed.
GX000005 CG000003 DA010009 0.0000 *helvetica-bold-r*140* 202.2534 -1.0000
218 16 Nodes 4 to 20 proceed clockwise from upper left corner.
GX000006 CG000003 DA010009 0.0000 *helvetica-bold-r*140* 202.2534 -17.0000
218 16 Manual edits were made to this file - RJL 020522
Appendix C: mylog.txt
SR
VN 94sbdeview
/* DL HA000001 */
HA000002 HN000011 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* E
DL HA000001
HA000003 HN000012 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* E
DL HA000002
HA000004 HN000012 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* N
DL HA000003
HA000005 HN000013 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* N
DL HA000004
HA000006 HN000014 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* N
DL HA000005
HA000007 HN000015 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* N
DL HA000006
HA000008 HN000016 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* N
DL HA000007
HA000009 HN000016 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* W
DL HA000008
HA000010 HN000017 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* W
DL HA000009
HA000011 HN000018 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* W
DL HA000010
HA000012 HN000019 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* W
DL HA000011
HA000013 HN000004 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* W
DL HA000012
HA000014 HN000004 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* S
DL HA000013
HA000015 HN000005 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* S
DL HA000014
HA000016 HN000006 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* S
DL HA000015
HA000017 HN000007 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* S
DL HA000016
HA000018 HN000008 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* S
DL HA000017
HA000019 HN000008 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* E
DL HA000018
HA000020 HN000009 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* E
DL HA000019
HA000021 HN000010 DA010009 0.0000 0.0000 0.0000 0 0 *helvetica-bold-r*140* E
DL HA000020
SP
Appendix D:
/******************************************************************/
/* XRoutineSortByFile.cc */
/*********************************************************************************/
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
string xFunctionName;
string inFileName;
int lineWidth = 200;
char lineBuf[200];
string allBDECxxFiles[] = {
"bde.cpp", "bendpt.cpp", "bendptops.cpp", "buttonevent.cpp","buttons.cpp","captionops.cpp",
"cursor.cpp","db_playback.cpp","dialog.cpp","display.cpp","draw.cpp","edit.cpp",
"fileio.cpp","font.cpp","fprint.cpp","graphobject.cpp","graphops.cpp","handler.cpp",
"help.cpp","hlink.cpp","infodialog.cpp","infomessage.cpp","init.cpp","initClasses.cpp",
"initRXtScript.cpp","leftmenu.cpp","leftmenu_cb.cpp","linkops.cpp","log_menu.cpp",
"menubar.cpp","menubar_cb.cpp","msgBox.cpp","nodeops.cpp","s_reader.cpp","select.cpp",
"smselect.cpp","strdup.cpp","text.cpp","textops.cpp"
};
string allXFunctions[] = {
"XAllocNamedColor", "XChangeProperty","XChangeWindowAttributes", "XCheckMaskEvent", "XClearWindow", "XClientMessageEvent", "XCopyArea", "XCopyPlane", "XCreateFontCursor", "XCreateGC", "XCreateIC", "XCreatePixmapFromBitmapData", "XCreateSimpleWindow", "XDrawLine", "XDrawString", "XFillRectangle", "XFlush", "XFreeColors", "XFreePixmap", "XGetGeometry", "XGetImage", "XGetSelectionOwner", "XGetWindowProperty", "XInternAtom", "XLoadQueryFont", "XmActivateWMProtocol", "XmAddProtocolCallback", "XmAddProtocols", "XmAddTabGroup", "XmAddWMProtocolCallback", "XmAddWMProtocols", "XMapRaised",
"XmbLookupString", "XmChangeColor", "XmClipboardBeginCopy", "XmClipboardCancelCopy", "XmClipboardCopy", "XmClipboardCopyByName", "XmClipboardEndCopy", "XmClipboardEndRetrieve", "XmClipboardInquireCount", "XmClipboardInquireFormat", "XmClipboardInquireLength", "XmClipboardLock", "XmClipboardRegisterFormat",
"XmClipboardRetrieve", "XmClipboardStartCopy", "XmClipboardStartRetrieve", "XmClipboardUndoCopy", "XmClipboardUnlock", "XmClipboardWithdrawFormat", "XmCommandAppendValue", "XmCommandError","XmCommandGetChild", "XmCommandSetValue", "XmCreateCommand","XmCreateDialogShell", "XmCreateDragIcon", "XmCreateErrorDialog",
"XmCreateFileSelectionBox", "XmCreateFileSelectionDialog","XmCreateInformationDialog", "XmCreateLabel", "XmCreateMenuBar","XmCreateMessageBox", "XmCreateMessageDialog","XmCreateOptionMenu", "XmCreatePopupMenu",
"XmCreatePromptDialog", "XmCreatePulldownMenu", "XmCreatePushButton", "XmCreatePushButtonGadget", "XmCreateQuestionDialog", "XmCreateRadioBox", "XmCreateScrolledList", "XmCreateScrolledText", "XmCreateSelectionBox", "XmCreateSelectionDialog", "XmCreateSimpleCheckBox", "XmCreateSimplePulldownMenu",
"XmCreateTemplateDialog", "XmCreateWarningDialog", "XmCreateWorkingDialog", "XmDeactivateWMProtocol", "XmDestroyPixmap", "XmDragCancel", "XmDragStart", "XmDropSiteConfigureStackingOrder","XmDropSiteEndUpdate",
"XmDropSiteQueryStackingOrder", "XmDropSiteRegister", "XmDropSiteRetrieve", "XmDropSiteStartUpdate", "XmDropSiteUnregister", "XmDropSiteUpdate", "XmDropTransferAdd", "XmDropTransferStart", "XmFileSelectionBoxGetChild", "XmFileSelectionDoSearch", "XmFontListAdd", "XmFontListAppendEntry", "XmFontListCopy", "XmFontListCreate",
"XmFontListEntryCreate", "XmFontListEntryFree", "XmFontListEntryGetFont", "XmFontListEntryGetTag", "XmFontListEntryLoad", "XmFontListFree", "XmFontListFreeFontContext", "XmFontListGetNextFont", "XmFontListInitFontContext", "XmFontListNextEntry", "XmGetColors", "XmGetDragContext", "XmGetFocusWidget", "XmGetMenuCursor", "XmGetPixmap",
"XmGetPixmapByDepth", "XmGetTabGroup", "XmGetTearOffControl", "XmGetVisibility", "XmGetXmDisplay", "XmGetXmScreen", "XmInstallImage", "XmInternAtom", "XmIsTraversable", "XmListAddItem","XmListAddItems","XmListAddItemsUnselected","XmListAddItemUnselected", "XmListDeleteAllItems","XmListDeleteItem","XmListDeleteItems","XmListDeleteItemsPos",
"XmListDeletePos","XmListDeletePositions","XmListDeselectAllItems","XmListDeselectItem","XmListDeselectPos","XmListGetKbdItemPos", "XmListGetMatchPos","XmListGetSelectedPos", "XmListItemExists", "XmListItemPos", "XmListPosSelected", "XmListPosToBounds", "XmListReplaceItems", "XmListReplaceItemsPos", "XmListReplaceItemsPosUnselected", "XmListReplaceItemsUnselected", "XmListReplacePositions", "XmListSelectPos", "XmListSetBottomItem", "XmListSetBottomPos",
"XmListSetItem", "XmListSetKbdItemPos", "XmListSetPos", "XmListUpdateSelectedList", "XmListYToPos", "XmMainWindowSetAreas", "XmMenuPosition", "XmMessageBoxGetChild", "XmProcessTraversal", "XmRegisterSegmentEncoding", "XmRepTypeAddReverse",
"XmRepTypeGetId", "XmRepTypeGetNameList", "XmRepTypeGetRecord", "XmRepTypeGetRegistered", "XmRepTypeInstallTearOffModelConverter", "XmRepTypeRegister", "XmRepTypeValidValue", "XmScaleGetValue", "XmScaleSetValue", "XmScrollBarGetValues", "XmScrollBarSetValues",
"XmScrolledWindowSetAreas", "XmScrollVisible", "XmSelectionBoxGetChild", "XmSelectItem", "XmSelectPos", "XmSetFontUnit", "XmSetFontUnits", "XmSetMenuCursor", "XmStringBaseline", "XmStringByteCompare", "XmStringCompare", "XmStringConcat", "XmStringCopy", "XmStringCreate", "XmStringCreateLocalized", "XmStringCreateLtoR", "XmStringCreateSimple",
"XmStringDirectionCreate", "XmStringDraw", "XmStringDrawImage", "XmStringDrawUnderline", "XmStringEmpty", "XmStringExtent", "XmStringFree", "XmStringFreeContext", "XmStringGetLtoR", "XmStringGetNextSegment", "XmStringHasSubstring", "XmStringHeight", "XmStringInitContext", "XmStringLength", "XmStringLineCount", "XmStringLtoRCreate", "XmStringNConcat",
"XmStringNCopy", "XmStringSegmentCreate", "XmStringWidth", "XmTextClearSelection", "XmTextCopy", "XmTextCut", "XmTextDisableRedisplay", "XmTextEnableRedisplay", "XmTextFieldGetString", "XmTextFieldGetSubstring", "XmTextFieldSetCursorPosition", "XmTextFieldSetString","XmTextFindString","XmTextFindStringWcs",
"XmTextGetCursorPosition", "XmTextGetInsertionPosition", "XmTextGetLastPosition", "XmTextGetSelection", "XmTextGetSelectionPosition", "XmTextGetSelectionWcs", "XmTextGetString", "XmTextGetStringWcs", "XmTextGetSubstring", "XmTextGetSubstringWcs", "XmTextHighlight", "XmTextInsert", "XmTextInsertWcs", "XmTextPaste", "XmTextReplace", "XmTextReplaceWcs", "XmTextScroll", "XmTextSetCursorPosition", "XmTextSetHighlight", "XmTextSetInsertionPosition",
"XmTextSetSelection", "XmTextSetString", "XmTextSetStringWcs", "XmTextShowPosition", "XmToggleButtonGadgetGetState", "XmToggleButtonGadgetSetState", "XmToggleButtonGetState", "XmToggleButtonSetState", "XmTrackingEvent", "XmTrackingLocate", "XmTranslateKey", "XmUninstallImage", "XmUpdateDisplay", "XmVaCreateSimpleCheckBox", "XmVaCreateSimpleMenuBar", "XmVaCreateSimpleOptionMenu", "XmVaCreateSimplePopupMenu", "XmVaCreateSimplePulldownMenu", "XmVaCreateSimpleRadioBox", "XmWidgetGetBaselines", "XmWidgetGetDisplayRect", "XNextEvent", "XOpenIM", "XQueryBestCursor", "XQueryTree", "XrmCombineDatabases", "XSendEvent", "XSetErrorHandler", "XSetFont", "XSetForeground",
"XSetWindowBackgroundPixmap", "XtAddActions", "XtAddCallback", "XtAddCallbacks", "XtAddEventHandler", "XtAppAddActions", "XtAppAddInput", "XtAppAddTimeOut", "XtAppAddWorkProc", "XtAppMainLoop", "XtAppSetErrorHandler", "XtAppSetWarningHandler",
"XtAppWarning", "XtCallCallbacks", "XtCreateApplicationShell", "XtCreatePopupShell", "XtDestroyWidget", "XtDisplayOfObject", "XtGetMultiClickTime", "XtGetValues", "XtInitialize", "XtIsVendorShell", "XtMalloc", "XtManageChild", "XtNameToWidget", "XtNew", "XtOverrideTranslations", "XtParent", "XtParseTranslationTable", "XtPopdown", "XtPopup", "XtQueryGeometry", "XtRemoveEventHandler", "XtRemoveWorkProc", "XtResolvePathname",
"XtSetArg", "XtSetLanguageProc", "XtSetMultiClickTime", "XtSetSensitive", "XtSetValues", "XtUnmanageChild", "XtVaAppCreateShell", "XtVaAppInitialize", "XtVaCreateApplicationShell", "XtVaCreateArgsList", "XtVaCreateManagedWidget", "XtVaCreatePopupShell", "XtVaCreateWidget", "XtVaGetValues", "XtVaSetValues", "XtWindowOfObject","XwcLookupString"
};
int lineNumber;
int pos, poscomment;
int i,j;
int pcounter,posleft,posright;
string lineString;
ofstream outFile( "XRoutineSortByFileOutput.txt", ios_base::out);
if (! outFile) {
cerr << "error: unable to open output file: " << "XRoutineSortByFileOutput.txt" << endl;
}
for (i=0; i<39; i++) {
lineNumber = 0;
inFileName =allBDECxxFiles[i] ;
ifstream inFile(inFileName.c_str(), ios_base::in);
if (! inFile) {
cerr << "error: unable to open input file: " << inFileName << endl;
}
outFile << "\n" << inFileName << ": \n";
outFile << "---------------------\n";
while (inFile.getline(lineBuf, lineWidth)) {
lineNumber++;
lineString = lineBuf;
lineString=lineString+"\n";
for (j=0; j<327; j++) {
pos = lineString.find(allXFunctions[j]);
poscomment = lineString.find("//");
if (lineString.find("/*") != string::npos) {
if (lineString.find("*/") != string::npos)
poscomment = lineString.find("*/");
else
while (true) {
inFile.getline(lineBuf, lineWidth);
lineNumber++;
lineString = lineBuf;
lineString=lineString+"\n";
if (lineString.find("*/") != string::npos) break;
}
}
if ((pos != string::npos) && (poscomment == string::npos))
{
pcounter = 1;
outFile << lineNumber << " " << allXFunctions[j]<< ": " << lineString;
pos = lineString.find_first_of("(", pos)+1;
posleft = pos; posright = pos;
posleft = lineString.find_first_of("(", pos);
posright = lineString.find_first_of(")", pos);
while (true) {
if (posleft == string::npos) posleft = lineWidth;
if (posright == string::npos) posright = lineWidth;
if ((posleft == lineWidth) && (posright == lineWidth))
pos = lineWidth;
if (posleft < posright) {
pcounter++;
pos = posleft + 1;
posleft = lineString.find_first_of("(", pos);
} else {
if (pos != lineWidth) {
pcounter--;
pos = posright+1;
posright = lineString.find_first_of(")", pos);
}
}
if (pcounter == 0) break;
if (( pos == lineWidth)) {
inFile.getline(lineBuf, lineWidth);
lineNumber++;
lineString = lineBuf;
lineString = lineString + "\n";
outFile << " " << lineString;
pos = 0;
posleft = lineString.find_first_of("(", pos);
posright = lineString.find_first_of(")", pos);
}
}
}
}
}
}
return 0;
}
Appendix E:
/******************************************************************/
/* XRoutineSortByRoutine.cc */
/******************************************************************/
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
string xFunctionName;
string inFileName;
int lineWidth = 200;
char lineBuf[200];
string allBDECxxFiles[] = {
"bde.cpp", "bendpt.cpp", "bendptops.cpp", "buttonevent.cpp","buttons.cpp","captionops.cpp",
"cursor.cpp","db_playback.cpp", "dialog.cpp", "display.cpp","draw.cpp","edit.cpp",
"fileio.cpp","font.cpp","fprint.cpp","graphobject.cpp","graphops.cpp","handler.cpp",
"help.cpp","hlink.cpp","infodialog.cpp","infomessage.cpp","init.cpp","initClasses.cpp",
"initRXtScript.cpp","leftmenu.cpp","leftmenu_cb.cpp","linkops.cpp","log_menu.cpp",
"menubar.cpp","menubar_cb.cpp","msgBox.cpp","nodeops.cpp","s_reader.cpp","select.cpp",
"smselect.cpp","strdup.cpp","text.cpp","textops.cpp"
};
string allXFunctions[] = {
"XAllocNamedColor", "XChangeProperty","XChangeWindowAttributes", "XCheckMaskEvent", "XClearWindow", "XClientMessageEvent", "XCopyArea", "XCopyPlane", "XCreateFontCursor", "XCreateGC", "XCreateIC", "XCreatePixmapFromBitmapData", "XCreateSimpleWindow", "XDrawLine", "XDrawString", "XFillRectangle", "XFlush", "XFreeColors", "XFreePixmap", "XGetGeometry", "XGetImage", "XGetSelectionOwner", "XGetWindowProperty", "XInternAtom", "XLoadQueryFont", "XmActivateWMProtocol", "XmAddProtocolCallback", "XmAddProtocols", "XmAddTabGroup", "XmAddWMProtocolCallback", "XmAddWMProtocols", "XMapRaised",
"XmbLookupString", "XmChangeColor", "XmClipboardBeginCopy", "XmClipboardCancelCopy", "XmClipboardCopy", "XmClipboardCopyByName", "XmClipboardEndCopy", "XmClipboardEndRetrieve", "XmClipboardInquireCount", "XmClipboardInquireFormat", "XmClipboardInquireLength", "XmClipboardLock", "XmClipboardRegisterFormat",
"XmClipboardRetrieve", "XmClipboardStartCopy", "XmClipboardStartRetrieve", "XmClipboardUndoCopy", "XmClipboardUnlock", "XmClipboardWithdrawFormat", "XmCommandAppendValue", "XmCommandError","XmCommandGetChild", "XmCommandSetValue", "XmCreateCommand","XmCreateDialogShell", "XmCreateDragIcon", "XmCreateErrorDialog",
"XmCreateFileSelectionBox", "XmCreateFileSelectionDialog","XmCreateInformationDialog", "XmCreateLabel", "XmCreateMenuBar","XmCreateMessageBox", "XmCreateMessageDialog","XmCreateOptionMenu", "XmCreatePopupMenu",
"XmCreatePromptDialog", "XmCreatePulldownMenu", "XmCreatePushButton", "XmCreatePushButtonGadget", "XmCreateQuestionDialog", "XmCreateRadioBox", "XmCreateScrolledList", "XmCreateScrolledText", "XmCreateSelectionBox", "XmCreateSelectionDialog", "XmCreateSimpleCheckBox", "XmCreateSimplePulldownMenu",
"XmCreateTemplateDialog", "XmCreateWarningDialog", "XmCreateWorkingDialog", "XmDeactivateWMProtocol", "XmDestroyPixmap", "XmDragCancel", "XmDragStart", "XmDropSiteConfigureStackingOrder","XmDropSiteEndUpdate",
"XmDropSiteQueryStackingOrder", "XmDropSiteRegister", "XmDropSiteRetrieve", "XmDropSiteStartUpdate", "XmDropSiteUnregister", "XmDropSiteUpdate", "XmDropTransferAdd", "XmDropTransferStart", "XmFileSelectionBoxGetChild", "XmFileSelectionDoSearch", "XmFontListAdd", "XmFontListAppendEntry", "XmFontListCopy", "XmFontListCreate",
"XmFontListEntryCreate", "XmFontListEntryFree", "XmFontListEntryGetFont", "XmFontListEntryGetTag", "XmFontListEntryLoad", "XmFontListFree", "XmFontListFreeFontContext", "XmFontListGetNextFont", "XmFontListInitFontContext", "XmFontListNextEntry", "XmGetColors", "XmGetDragContext", "XmGetFocusWidget", "XmGetMenuCursor", "XmGetPixmap",
"XmGetPixmapByDepth", "XmGetTabGroup", "XmGetTearOffControl", "XmGetVisibility", "XmGetXmDisplay", "XmGetXmScreen", "XmInstallImage", "XmInternAtom", "XmIsTraversable", "XmListAddItem","XmListAddItems","XmListAddItemsUnselected","XmListAddItemUnselected", "XmListDeleteAllItems","XmListDeleteItem","XmListDeleteItems","XmListDeleteItemsPos",
"XmListDeletePos","XmListDeletePositions","XmListDeselectAllItems","XmListDeselectItem","XmListDeselectPos","XmListGetKbdItemPos", "XmListGetMatchPos","XmListGetSelectedPos", "XmListItemExists", "XmListItemPos", "XmListPosSelected", "XmListPosToBounds", "XmListReplaceItems", "XmListReplaceItemsPos", "XmListReplaceItemsPosUnselected", "XmListReplaceItemsUnselected", "XmListReplacePositions", "XmListSelectPos", "XmListSetBottomItem", "XmListSetBottomPos",
"XmListSetItem", "XmListSetKbdItemPos", "XmListSetPos", "XmListUpdateSelectedList", "XmListYToPos", "XmMainWindowSetAreas", "XmMenuPosition", "XmMessageBoxGetChild", "XmProcessTraversal", "XmRegisterSegmentEncoding", "XmRepTypeAddReverse",
"XmRepTypeGetId", "XmRepTypeGetNameList", "XmRepTypeGetRecord", "XmRepTypeGetRegistered", "XmRepTypeInstallTearOffModelConverter", "XmRepTypeRegister", "XmRepTypeValidValue", "XmScaleGetValue", "XmScaleSetValue", "XmScrollBarGetValues", "XmScrollBarSetValues",
"XmScrolledWindowSetAreas", "XmScrollVisible", "XmSelectionBoxGetChild", "XmSelectItem", "XmSelectPos", "XmSetFontUnit", "XmSetFontUnits", "XmSetMenuCursor", "XmStringBaseline", "XmStringByteCompare", "XmStringCompare", "XmStringConcat", "XmStringCopy", "XmStringCreate", "XmStringCreateLocalized", "XmStringCreateLtoR", "XmStringCreateSimple",
"XmStringDirectionCreate", "XmStringDraw", "XmStringDrawImage", "XmStringDrawUnderline", "XmStringEmpty", "XmStringExtent", "XmStringFree", "XmStringFreeContext", "XmStringGetLtoR", "XmStringGetNextSegment", "XmStringHasSubstring", "XmStringHeight", "XmStringInitContext", "XmStringLength", "XmStringLineCount", "XmStringLtoRCreate", "XmStringNConcat",
"XmStringNCopy", "XmStringSegmentCreate", "XmStringWidth", "XmTextClearSelection", "XmTextCopy", "XmTextCut", "XmTextDisableRedisplay", "XmTextEnableRedisplay", "XmTextFieldGetString", "XmTextFieldGetSubstring", "XmTextFieldSetCursorPosition", "XmTextFieldSetString","XmTextFindString","XmTextFindStringWcs",
"XmTextGetCursorPosition", "XmTextGetInsertionPosition", "XmTextGetLastPosition", "XmTextGetSelection", "XmTextGetSelectionPosition", "XmTextGetSelectionWcs", "XmTextGetString", "XmTextGetStringWcs", "XmTextGetSubstring", "XmTextGetSubstringWcs", "XmTextHighlight", "XmTextInsert", "XmTextInsertWcs", "XmTextPaste", "XmTextReplace", "XmTextReplaceWcs", "XmTextScroll", "XmTextSetCursorPosition", "XmTextSetHighlight", "XmTextSetInsertionPosition",
"XmTextSetSelection", "XmTextSetString", "XmTextSetStringWcs", "XmTextShowPosition", "XmToggleButtonGadgetGetState", "XmToggleButtonGadgetSetState", "XmToggleButtonGetState", "XmToggleButtonSetState", "XmTrackingEvent", "XmTrackingLocate", "XmTranslateKey", "XmUninstallImage", "XmUpdateDisplay", "XmVaCreateSimpleCheckBox",
"XmVaCreateSimpleMenuBar", "XmVaCreateSimpleOptionMenu", "XmVaCreateSimplePopupMenu", "XmVaCreateSimplePulldownMenu", "XmVaCreateSimpleRadioBox", "XmWidgetGetBaselines", "XmWidgetGetDisplayRect", "XNextEvent", "XOpenIM", "XQueryBestCursor", "XQueryTree", "XrmCombineDatabases", "XSendEvent", "XSetErrorHandler", "XSetFont", "XSetForeground",
"XSetWindowBackgroundPixmap", "XtAddActions", "XtAddCallback", "XtAddCallbacks", "XtAddEventHandler", "XtAppAddActions", "XtAppAddInput", "XtAppAddTimeOut", "XtAppAddWorkProc", "XtAppMainLoop", "XtAppSetErrorHandler", "XtAppSetWarningHandler",
"XtAppWarning", "XtCallCallbacks", "XtCreateApplicationShell", "XtCreatePopupShell", "XtDestroyWidget", "XtDisplayOfObject", "XtGetMultiClickTime", "XtGetValues", "XtInitialize", "XtIsVendorShell", "XtMalloc", "XtManageChild", "XtNameToWidget", "XtNew", "XtOverrideTranslations", "XtParent", "XtParseTranslationTable", "XtPopdown", "XtPopup", "XtQueryGeometry", "XtRemoveEventHandler", "XtRemoveWorkProc", "XtResolvePathname",
"XtSetArg", "XtSetLanguageProc", "XtSetMultiClickTime", "XtSetSensitive", "XtSetValues", "XtUnmanageChild", "XtVaAppCreateShell", "XtVaAppInitialize", "XtVaCreateApplicationShell", "XtVaCreateArgsList", "XtVaCreateManagedWidget", "XtVaCreatePopupShell", "XtVaCreateWidget", "XtVaGetValues", "XtVaSetValues", "XtWindowOfObject","XwcLookupString"
};
int readin;
int lineNumber;
int pos, poscomment;
int i,j;
string lineString;
int pcounter,posleft,posright;
ofstream outFile( "XRoutineSortByRoutineOutput.txt", ios_base::out);
if (! outFile) {
cerr << "error: unable to open output file: " << "XRoutineSortByRoutineOutput.txt" << endl;
}
for (j=0; j<327; j++) {
cout << allXFunctions[j] << "\n";
outFile << "\n" << allXFunctions[j] << ": \n";
outFile << "---------------------\n";
for (i=0; i<39; i++) {
lineNumber = 0;
inFileName =allBDECxxFiles[i] ;
ifstream inFile(inFileName.c_str(), ios_base::in);
if (! inFile) {
cerr << "error: unable to open input file: " << inFileName << endl;
}
while (inFile.getline(lineBuf, lineWidth)) {
lineNumber++;
readin = inFile.gcount();
lineString = lineBuf;
lineString=lineString+"\n";
pos = lineString.find(allXFunctions[j]);
poscomment = lineString.find("//");
if (lineString.find("/*") != string::npos) {
if (lineString.find("*/") != string::npos)
poscomment = lineString.find("*/");
else
while (true) {
inFile.getline(lineBuf, lineWidth);
lineNumber++;
lineString = lineBuf;
lineString=lineString+"\n";
if (lineString.find("*/") != string::npos) break;
}
}
if ((pos != string::npos) && (poscomment == string::npos))
{
pcounter = 1;
outFile << inFileName << "(" << lineNumber<< "): " << lineString;
pos = lineString.find_first_of("(", pos)+1;
posleft = pos; posright = pos;
posleft = lineString.find_first_of("(", pos);
posright = lineString.find_first_of(")", pos);
while (true) {
if (posleft == string::npos) posleft = lineWidth;
if (posright == string::npos) posright = lineWidth;
if ((posleft == lineWidth) && (posright == lineWidth))
pos = lineWidth;
if (posleft < posright) {
pcounter++;
pos = posleft + 1;
posleft = lineString.find_first_of("(", pos);
} else {
if (pos != lineWidth) {
pcounter--;
pos = posright+1;
posright = lineString.find_first_of(")", pos);
}
}
if (pcounter == 0) break;
if (( pos == lineWidth)) {
inFile.getline(lineBuf, lineWidth);
lineNumber++;
lineString = lineBuf;
lineString = lineString + "\n";
outFile << " " << lineString;
pos = 0;
posleft = lineString.find_first_of("(", pos);
posright = lineString.find_first_of(")", pos);
}
}
}
}
}
}
return 0;
}