$!/* comp.os.vms / gavron@sunquest.UUCP (Ehud Gavron) / 12:59 pm Jul 23, 1990 */ $! $! A little while back Jerry Leichter posted a small DCL routine $! which would generate C module definition include files from $! LIB.MLB. At the time it seemed to me to be of value in other $! languages, and hence, here is my version. $! $! Usage: @gen_module_defs [module [language ]] $! $! Example:@gen_module_defs irpdef dcl $! $! The output files can be generated for c, fortran, macro, and $! dcl, although modifying the program to generate other formats $! is quite simple. $! $! DCL usage example: $! $ some code $! $ @ssdef $! $ if (.not. all_privs_gotten) then exit ss$_nocmkrnl $! $! ************* $! $! $! Ehud $! $! $! ------------------ CUT HERE ----------------------- $ v='f$verify(f$trnlnm("SHARE_VERIFY"))' $! $! This archive created by VMS_SHARE Version 7.2-007 22-FEB-1990 $! On 23-JUL-1990 08:23:29.94 By user GAVRON $! $! This VMS_SHARE Written by: $! Andy Harper, Kings College London UK $! $! Acknowledgements to: $! James Gray - Original VMS_SHARE $! Michael Bednarek - Original Concept and implementation $! $! TO UNPACK THIS SHARE FILE, CONCATENATE ALL PARTS IN ORDER $! AND EXECUTE AS A COMMAND PROCEDURE ( @name ) $! $! THE FOLLOWING FILE(S) WILL BE CREATED AFTER UNPACKING: $! 1. [.COM]GEN_MODULE_DEFS.COM;5 $! $set="set" $set symbol/scope=(nolocal,noglobal) $f=f$parse("SHARE_TEMP","SYS$SCRATCH:.TMP_"+f$getjpi("","PID")) $e="write sys$error ""%UNPACK"", " $w="write sys$output ""%UNPACK"", " $ if f$trnlnm("SHARE_LOG") then $ w = "!" $ ve=f$getsyi("version") $ if ve-f$extract(0,1,ve) .ges. "4.4" then $ goto START $ e "-E-OLDVER, Must run at least VMS 4.4" $ v=f$verify(v) $ exit 44 $UNPACK: SUBROUTINE ! P1=filename, P2=checksum $ if f$search(P1) .eqs. "" then $ goto file_absent $ e "-W-EXISTS, File ''P1' exists. Skipped." $ delete 'f'* $ exit $file_absent: $ if f$parse(P1) .nes. "" then $ goto dirok $ dn=f$parse(P1,,,"DIRECTORY") $ w "-I-CREDIR, Creating directory ''dn'." $ create/dir 'dn' $ if $status then $ goto dirok $ e "-E-CREDIRFAIL, Unable to create ''dn'. File skipped." $ delete 'f'* $ exit $dirok: $ w "-I-PROCESS, Processing file ''P1'." $ if .not. f$verify() then $ define/user sys$output nl: $ EDIT/TPU/NOSEC/NODIS/COM=SYS$INPUT 'f'/OUT='P1' PROCEDURE Unpacker ON_ERROR ENDON_ERROR;SET(FACILITY_NAME,"UNPACK");SET( SUCCESS,OFF);SET(INFORMATIONAL,OFF);f:=GET_INFO(COMMAND_LINE,"file_name");b:= CREATE_BUFFER(f,f);p:=SPAN(" ")@r&LINE_END;POSITION(BEGINNING_OF(b)); LOOP EXITIF SEARCH(p,FORWARD)=0;POSITION(r);ERASE(r);ENDLOOP;POSITION( BEGINNING_OF(b));g:=0;LOOP EXITIF MARK(NONE)=END_OF(b);x:=ERASE_CHARACTER(1); IF g=0 THEN IF x="X" THEN MOVE_VERTICAL(1);ENDIF;IF x="V" THEN APPEND_LINE; MOVE_HORIZONTAL(-CURRENT_OFFSET);MOVE_VERTICAL(1);ENDIF;IF x="+" THEN g:=1; ERASE_LINE;ENDIF;ELSE IF x="-" THEN IF INDEX(CURRENT_LINE,"+-+-+-+-+-+-+-+")= 1 THEN g:=0;ENDIF;ENDIF;ERASE_LINE;ENDIF;ENDLOOP;t:="0123456789ABCDEF"; POSITION(BEGINNING_OF(b));LOOP r:=SEARCH("`",FORWARD);EXITIF r=0;POSITION(r); ERASE(r);x1:=INDEX(t,ERASE_CHARACTER(1))-1;x2:=INDEX(t,ERASE_CHARACTER(1))-1; COPY_TEXT(ASCII(16*x1+x2));ENDLOOP;WRITE_FILE(b,GET_INFO(COMMAND_LINE, "output_file"));ENDPROCEDURE;Unpacker;QUIT; $ delete/nolog 'f'* $ CHECKSUM 'P1' $ IF CHECKSUM$CHECKSUM .eqs. P2 THEN $ EXIT $ e "-E-CHKSMFAIL, Checksum of ''P1' failed." $ ENDSUBROUTINE $START: $ create 'f' X$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! X$! X$! Gen_Module_Defs.Com`09`09Version 2.0.0`09`0912-July-1990 X$! X$! Generate definition include files from MACRO definitions into X$! other language formats. X$! X$! Usage: @gen_module_defs name language X$! X$! where NAME is a definitional macro in either STARLET.MLB or LIB.MLB. X$! Output: `5B`5D'p1'.H X$! X$! where LANGUAGE is the name of a language, significant to three places X$! of the set `7BVAXC,MACRO,FORTRAN,DCL`7D X$! X$! X$! Originally written and posted to INFOVAX by: X$! X$! W.J.Moeller, GWDG, D-3400 Goettingen, F.R.Germany X$! Phone +49 551 201516 X$! X$! Later revised by Jerry Leichter (LEICHTER@YALE) X$! Later revised by Ehud Gavron (GAVRON@SUNQUEST.COM) X$! X$! Revision History X$! 0.0`09??-???-?? WJM`09Creation X$! 1.0`09 6-Apr-87 JSL`09Centralize actual creation of output lines in the E VMIT X$!`09`09`09macro; this makes changes a lot easier. Similarly, X$!`09`09`09define the output file type ("type") and the language X$!`09`09`09("lang") in symbols to simplify changes. Allow for X$!`09`09`09special handling of negative values in EMIT - for C, X$!`09`09`09wrap them in parentheses. Try to warn the user if X$!`09`09`09it looks like there was an error. X$! X$! 2.0 12-Jul-90 EG Modify to work with several languages. X$! X$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! V!! X$! X$ languages = "VAXC/H/*,MACRO/MAR/;,FORTRAN/INC/C,DCL/COM/$!" X$ set noon X$ on control_y then goto fin X$get_p1: X$ if "''p1'" .nes. "" then goto got_p1 X$ inquire/nopunct p1 "Module Name: " X$ goto get_p1 X$got_p1: X$get_p2: X$ if "''p2'" .nes. "" then goto got_p2 X$ inquire/nopunct p2 "Language Name: " X$ goto get_p2 X$got_p2: X$ lang = f$edit(f$extract(0,3,p2),"UPCASE") X$ sear = f$locate(lang,languages) X$ if sear .eq. f$length(languages) then goto unsupported_language X$ lang = f$extract(sear,f$length(languages)-sear,languages) X$ lang = f$element(0,",",lang) X$ type = f$element(1,"/",lang) X$ com = f$element(2,"/",lang) X$ lang = f$element(0,"/",lang) X$ open/write DEFS_MAR `5B`5Ddefs.tmp X$ write DEFS_MAR " .print;''com'" X$ write DEFS_MAR " .print;''com'`09`09`09`09''p1'.''type'" X$ write DEFS_MAR " .print;''com'" X$ write DEFS_MAR " .print;''com' Definitions created by ''lang'_DEFS",`09 V- X`09`09`09`09`09" at ''f$time()'" X$ write DEFS_MAR " .print;''com'" X$ write DEFS_MAR " $''p1'" X$ write DEFS_MAR " .print;''com'" X$ write DEFS_MAR " .print;''com' End of ''lang'_DEFS definitions" X$ write DEFS_MAR " .print;''com'" X$ write DEFS_MAR " .end" X$ close DEFS_MAR X$ open/write temp temp1.mar X$ write temp "`09.MACRO`09$GBLINI`09GBL" X$ WRITE TEMP " `09.MACRO`09EMIT`09SYM,VALUE" X$ goto 'lang' X$ goto unsupported_language X$vaxc: X$ write temp ".print;#define sym value" X$ goto more X$macro: X$ write temp ".print;$EQU sym value" X$ goto more X$fortran: X$ write temp ".print;`09parameter ( sym = value )" X$ goto more X$dcl: X$ write temp ".print;$ sym == value " X$ goto more X$! X$! Add more language definitions here... X$! X$more: X$ write temp ".ENDM" X$ close temp X$ append sys$input temp1.mar X .MACRO $DEF SYM,ALLOC,SIZ X .if NB,SYM XSYM: X`09EMIT`09SYM,\SYM X .endc X .IIF NB,ALLOC, ALLOC SIZ X .ENDM $DEF X .MACRO $EQU SYM,VAL X SYM=VAL X`09EMIT`09SYM,\SYM X .ENDM $EQU X .MACRO $VIELD1 MOD,SEP,SYM,SIZ,MSK X SIZ...=1 X .IIF NB,SIZ, SIZ...=SIZ X .IF NB,SYM X MOD'SEP'V_'SYM=BIT... X`09EMIT`09MOD'SEP'V_'SYM,\MOD'SEP'V_'SYM X .if nb,siz XMOD'SEP'S_'SYM=SIZ X`09EMIT`09MOD'SEP'S_'SYM,\MOD'SEP'S_'SYM X .endc X .if nb,msk XMOD'SEP'M_'SYM=<<<1@SIZ...>-1>@BIT...> X`09EMIT`09MOD'SEP'M_'SYM,\MOD'SEP'M_'SYM X .endc X .ENDC X BIT...=BIT...+SIZ... X .ENDM $VIELD1 X .ENDM $GBLINI X$ X$! X$ define/user SYS$ERROR 'p1'.'type`09! MACRO puts .PRINT output here X$ macro/nolist/noobject temp1.mar+SYS$LIBRARY:LIB/LIB+SYS$DISK:`5B`5Ddefs.tm Vp X$ delete temp1.mar;* X$! X$ assign/user _NL: SYS$ERROR`09`09`09!Avoid "No strings matched" X$ assign/user _NL: SYS$OUTPUT X$ search/nooutput 'p1'.'type' "%MACRO-" X$ if $severity .ne. 1 then goto fin X$ write SYS$ERROR "Error in producing ''p1'.''type' - file not usable." X$ write SYS$ERROR "(This probably means that there is no $",p1," macro.)" X$fin: X$ close/err=noerrdefs DEFS_MAR X$noerrdefs: X$ delete/nolog `5B`5Ddefs.tmp; $ CALL UNPACK [.COM]GEN_MODULE_DEFS.COM;5 544889551 $ v=f$verify(v) $ EXIT