[an error occurred while processing this directive]

Start end processing API

Here, being in common in command everything of MUSASHI, you explain it utilizes concerning the functional group which it utilizes "the start of the program and end" time.

The function regarding start end is, "mssInit, mssShowEndMsg and mssEnd" 3.


1. MssInit

Prescribed form: Void mssInit (int argc, char **argv and struct mssComHelp *comHelp);

First argument: The number of arguments which are given with command line
Second argument: The character string pointer to the argument which is given with command line
Third argument: Command name and the pointer to the structure which includes the Help document

1) initialization of global variable, 2) initialization of signal processing, it is two for mssInit function to do.

1.1. Initialization of global variable

With MUSASHI, from the program which the user draws up, "extern struct mssGlobalVariables mssGV; "At declaration the global variable group which becomes accessible is prepared. Principal variable is introduced at below.

MssGV->comHelp

The command name which is given with the third argument of mssInit and the structure which includes the Help document (the mssComHelp structure) to it is initialized with the pointer. At the source of the user you must define the mssComHelp structure.

The function which refers to this variable
When "-h" is given from command line, simple help is indicated. This is done at the mssHelpDoc function which is explained next. Referring to comHelp, it indicates this function in the picture the contents as a help document.

Utilization example with C source
Example 1) Printf ("%s¢@n" and mssGV->comHelp->name); Command name is indicated.
Example 2) Printf ("%s¢@n" and mssGV->comHelp->version); Version of command is indicated.

MssGV->argc and mssGV->argv

The first argument of mssInit and it is initialized with argument of the command line which is given with second argument.

The function which refers to this variable
Especially it is not

Utilization example with C source
Example 1) Printf ("%s¢@n", * (mssGV->comHelp->argv+0)); 0th argument (command name) it indicates.
Example 2) Printf ("%s¢@n" and mssGV->comHelp->argc); The number of arguments which are given with command line is indicated.

MssGV->inCnt and mssGV->outCnt

It is initialized with 0.
In each command input/output variable in order to count the number of lines of the data which is done. The developer in the program, should count raise these variables according to input/output number of cases.

The function which refers to this variable
Contents of these two variables like below it indicates mssEndMsg function, as portion of end message.
"#END# 20176 2003/08/01 10:06:25" xtcut -f * -i xxcc.xt "in=25 out=25"

MssGV->txtFlg

It is initialized with 0.
All being command common, when "-t" option is appointed to command line, this txtFlg variable is set to 1. When this flag is set, MUSASHI processes as ÇÂÆãÇÓÇç of plain text concerning the input/output data, not to be XMLtable.

The function which refers to this variable
If at the mssSetOption function which appraises command line option, -t is appointed, 1 is set.
In addition, the header functional group and the input/output functional group change processing contents with this variable.

MssGV->usedTempFileFlg

It is initialized with 0.
With the input API of MUSASHI, there are times when the processing which such as sorting the work file utilizes is done with the reverse side. That time, the work file is drawn up to the /tmp directory. When the processing which utilizes the work file (function) is called, 1 is set to this usedTempFileFlg.


The function which refers to this variable
If with mssEnd function, this flag is set, the work file is deleted. As for the work file "xt##xxxx-" (process number enters into xxxx as a pre- fix) has been attached, the file where this pre- fix is attached everything is deleted.

1.2. Initialization of signal processing

At present with MUSASHI have tried to cope with the processing for four signals below.

Signal name Meaning Coping method
SIGSEGV Segmentation violation Indicating error message, it ends
SIGPIPE Entry to the pipe which is not the process which it reads Usual end
SIGKILL Forced termination Indicating error message, it ends
SIGINT Interruption Indicating error message, it ends

When we would like to reset signal processing to default, like below if SIG_DFL should have been appointed with signal function.

Signal (SIGINT and SIG_DFL);

2. MssEndMsg

Prescribed form: Void mssShowEndMsg (void)

MssEndMsg, like below outputs message of usual end to stderr.

#END# 24851 2003/08/01 11:18:33 ". /init a b c" in=0 out=0

Meaning of each item is which is indicated as follows.

  1. #END#
  2. Process number
  3. End date
  4. Finish time
  5. The character string which is given with command line
  6. Input number of cases (mssGV.inCnt)
  7. Output number of cases (mssGV.outCnt)

3. MssEnd

Prescribed form: Void mssEnd (int status)

First argument: End status (exit (status) it executes)

If with mssEND, looking at mssGV.usedTempFileFlg, it is necessary, deletion of the work file, it does. And exit (status) being similar, it ends the program.

4. Sample program

Below, C source of the sample which makes the contents reflect which are explained here (init.c) it publishes.
Please refer tothe utilization method of the sample program and compile and verify operation.

#include <stdio.h> #include <signal.h> #include 
<musashi.h> struct mssComHelp comHelp= {"init" and /* command name * 
"1.0", /* version * "the start end processing sample of MUSASHI", /* 
command title * "this is the sample program,", /* summary * "init a b 
c", /* utilization example * "optstr" and /* reference command * 
"hambear" and /* writer information * the information "of 
musashi-users@lists.sourceforge.jp" and the /* bug report * "the 
musashi.sourceforge.jp" /* home page *}; Extern struct 
mssGlobalVariables mssGV; Int main (int argc and char *argv [ ])
{int i; MssInit (argc, argv and &comHelp); Initialization 
& printf such as /* signal processing ("name =%s¢@n", 
mssGV.comHelp->name); Printf ("version =%s¢@n", 
mssGV.comHelp->version); Printf ("title =%s¢@n", 
mssGV.comHelp->title); Printf ("summary =%s¢@n", 
mssGV.comHelp->summary); Printf ("example =%s¢@n", 
mssGV.comHelp->example); Printf ("reference=%s¢@n" and 
mssGV.comHelp->reference); Printf ("author =%s¢@n", 
mssGV.comHelp->author); Printf ("bugReport=%s¢@n" and 
mssGV.comHelp->bugReport); Printf ("homepage =%s¢@n", 
mssGV.comHelp->homepage); Printf ("arguments: ¢@n"); 
For (i=0; I<mssGV.argc; I++) {Printf ("arg [ 
%i ] =%s¢@n" and i, * (mssGV.argv+i)); } When resetting the end 
with /* ctr+c to the operation of default, comment is removed, * 
/*signal (SIGINT and SIG_DFL); * When the /* infinite loop 
(liking to verify the supplementation of the signal with ctr+c, 
comment is removed, * /*while (1); * MssShowEndMsg (); /* 
completion message * mssEnd (mssExitSuccess); /* end & return 
(0); /* to avoid warning message *}

The result of executing is "init a b c" as follows.

The $ . /init a b c
name =init version =1.0 title =MUSASHI as for start end 
processing sample summary = this example which is the sample program 
=init a b c reference=optstr author =hambear 
bugReport=musashi-users@lists.sourceforge.jp homepage 
=musashi.sourceforge.jp arguments: Arg [ 0 ] =. /init arg [ 1 ] 
=a arg [ 2 ] =b arg [ 3 ] =c #END# 24858 2003/08/01 11:47:18 ". /init 
a b c" in=0 out=0
[an error occurred while processing this directive]