Re: Assigns in Initializer



Some code excerpts that might help you:

STRING c_assign_table = 'P' :=
[
c_assign_collector_fname,13,"EMS-COLLECTOR",
c_assign_ecp_fname ,11,"ECP-PROCESS",
c_null,c_null
];

status := INITIALIZER( !rucb!
, !passthru!
, Catch_startup_message
, Catch_startup_param
, Catch_startup_assign
, flags
, timelimit
);

PROC Catch_startup_assign( rucb, passthru, message, msglen, match )
VARIABLE;
INT .rucb;
INT .passthru;
INT .message;
INT msglen;
INT match;
BEGIN
INT .assign_msg( assign_msg_def ) := @message;


!-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=!
!-=-=-=-=-=-=-=-=-=-= ** Procedure starts here **
=-=-=-=-=-=-=-=-=-=-=-=-=!

!-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=!


!--------------------------------------------------------------------------!
! Loop thru the 'c_assign_table'.
!

!--------------------------------------------------------------------------!
USE i;
i := 0;

WHILE c_assign_table[i] DO
BEGIN


!-----------------------------------------------------------------------!
! The layout of the c_assign_table is as follows:
!
!
!
!
----------------------------------------------------------------- !
! | ID | LENGTH | VALUE
| !
!
----------------------------------------------------------------- !
!
!
! We're simply matching the length+value part of the table with
the !
! length+value of the passed assign
('assign_msg.logicalunit.filename' !
! consist of 1 byte for the length and up to 30 bytes for the
name). !

!-----------------------------------------------------------------------!
IF ( assign_msg.logicalunit.filename = c_assign_table[i+1] FOR
assign_msg.logicalunit.filename + 1 BYTES ) THEN
BEGIN

!--------------------------------------------------------------------!
! We found a match. Get the value and return.
!

!--------------------------------------------------------------------!
CALL Catch_assign_values( c_assign_table[i], assign_msg.values
);
RETURN;
END; ! of IF ( assign_msg.logicalunit ....


!-----------------------------------------------------------------------!
! Calculate a new value for 'i' using the length data found in
the !
! 'c_assign_table'. Remember to add a value of 2 to allow for the
ID !
! and LENGTH part of the table.
!

!-----------------------------------------------------------------------!
i := i + ( c_assign_table[i+1] + 2 );

END; ! of WHILE c_assign_table[i] DO

DROP i;

END; ! of PROC Catch_startup_assign

PROC Catch_assign_values( assign_id, assign_values );
INT assign_id;
INT .assign_values;
BEGIN
INT .assigned( assign_values_def ) := @assign_values;
STRUCT .fcbarea ( fcb_def );
INT .fcb( fcb_def ) := @fcbarea;
INT error := c_ok;


!-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=!
!-=-=-=-=-=-=-=-=-=-= ** Procedure starts here **
=-=-=-=-=-=-=-=-=-=-=-=-=!

!-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=!


!--------------------------------------------------------------------------!
! Initialize FCB.
!

!--------------------------------------------------------------------------!
fcb ':=' c_null & fcb FOR ( ( __Sizeof( fcb ) - 2 ) / 2 );


!--------------------------------------------------------------------------!
! Load assign filename.
!

!--------------------------------------------------------------------------!
IF ( assigned.fieldmask.<0> ) THEN
BEGIN
error := OLDFILENAME_TO_FILENAME_(assigned.physicalfilename,
fcb.fname:__Sizeof( fcb.fname
),
fcb.flen
);
IF ( error ) THEN
BEGIN
END; ! of IF ( error )

END; ! IF ( assigned.fieldmask.<0> )


!--------------------------------------------------------------------------!
! Load correct FCB and validate input.
!

!--------------------------------------------------------------------------!
CASE ( assign_id ) OF
BEGIN
c_assign_collector_fname ->

!--------------------------------------------------------------------!
! Check whether we have the define for the collector already.
If so, !
! the below processing is not necessary.
!

!--------------------------------------------------------------------!
IF ( g_have_collector_define = c_true ) THEN
RETURN;


!--------------------------------------------------------------------!
! Move the filename from the temporary FCB into the
'g_collector' !
! structure. Change the address of the temporary data
structure to !
! point to the 'g_collector' data structure. This makes it
easier !
! for us to write generic code AFTER the CASE statement.
!

!--------------------------------------------------------------------!
g_collector.fname ':=' fcb.fname FOR fcb.flen BYTES;
g_collector.flen := fcb.flen;
@fcb := @g_collector;


!--------------------------------------------------------------------!
! Check whether the name of the collector is a valid EMS
collector. !

!--------------------------------------------------------------------!
error := Invalid_EMS_collector(
g_collector.fname:g_collector.flen );
IF ( error ) THEN
BEGIN

!-----------------------------------------------------------------!
! We'll defer the logging until we're done with startup
!
! processing. We must do the check to see if we have a
previous !
! error to ensure that we didn't encounter an error before
this !
! error. This is done so we log the first error.
!

!-----------------------------------------------------------------!
IF ( g_error = c_ok ) THEN
BEGIN
END; ! of IF ( g_error = c_ok )

END; ! of IF ( error )

c_assign_ecp_fname ->

!--------------------------------------------------------------------!
! Move the filename from the temporary FCB into the 'g_ecp'
!
! structure. Change the address of the temporary data
structure to !
! point to the 'g_collector' data structure. This makes it
easier !
! for us to write generic code AFTER the CASE statement.
!

!--------------------------------------------------------------------!
g_ecp.fname ':=' fcb.fname FOR fcb.flen BYTES;
g_ecp.flen := fcb.flen;
@fcb := @g_ecp;

OTHERWISE ->

!--------------------------------------------------------------------!
! Unknown assign.
!

!--------------------------------------------------------------------!
RETURN;

END; ! of CASE ( assign_id ) OF

END; ! of PROC Catch_assign_values


TandemQuest wrote:
Hello all

I am using the INITIALIZER guardian call with assignproc, is it
possible to have more than one assign? if so, how to get each assigns?
Is it delimited by a delimiter? If any of you throw more light on this
it would be great. Thanks.

.



Relevant Pages

  • Re: How to check for errors when inputting a number
    ... int read_num ... As a result, 'line' is initialized at the start of the program to the specified value of 0 (which is redundant, because objects with static storage duration are always initialized with 0 unless a different initializer is explicitly specified). ... Don't use such abbreviations, they're too obscure, and people might not be able to figure out what it is your abbreviating. ... I no longer remember what options you have with operating systems that aren't similar to Unix; its been a dozen years since I programmed for a DOS machine, and longer than that for VMS; I remember only that VMS had a VERY different idea about command line interfaces than Unix does. ...
    (comp.lang.c)
  • Re: Initializing compound type containing opaque type
    ... A workaround would be to rearrange the members of `struct foo' as ... which again provokes a missing initializer warning but is accepted. ...
    (comp.lang.c)
  • Re: Initializing compound type containing opaque type
    ... A workaround would be to rearrange the members of `struct foo' as ... which again provokes a missing initializer warning but is accepted. ... Though that'd initialize all members to 0, ...
    (comp.lang.c)
  • Re: Initializing static structs
    ... I have problems to initialize a static struct. ... int main ... The non-constant initializer element is &pA. ...
    (comp.lang.c)
  • Re: New list commands ... What do you think ? (LONG)
    ... static int ... int itemc, i, cmdLen, newObjc; ... proc prod2 list { ... proc map-helper {proc accum item} { ...
    (comp.lang.tcl)