How do you run this script? I tried it under UNIX and MVS as a rexx clist and get all kinds of errors.
$ ccsect psa.h:: ccsect 1: FSUM7351 not found edcdsect.rexx: ccsect 4: FSUM7351 not found $ -----Original Message----- From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf Of Kirk Wolf Sent: Friday, February 09, 2018 7:58 AM To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: Silly C problem adding hex 6C It is better IMO to use EDCDSECT and create C header files for the system DSECTS (PSA, ASCB, ASXB, etc), then you don't have to hard code offsets into your code. We have a little rexx shell script that we have been using for a dozen years that invokes the assembler + EDCDSECT. It is simple to add recipes to your Makefile for whatever system headers you want. For example: psa.h: echo " IHAPSA " > asm_temp.s echo " END" >> asm_temp.s edcdsect.rexx asm_temp.s > psa.h Then you can do: #include "psa.h" struct psa* pPSA = (struct psa*)0; struct ascb* pASCB = (struct ascb*)pPSA->psaaold; ... EDCDSECT is not perfect, but it generally works pretty well. Kirk Wolf Dovetailed Technologies http://dovetail.com On Fri, Feb 9, 2018 at 6:02 AM, Bernd Oppolzer <bernd.oppol...@t-online.de> wrote: > More simple ... the pointers don't need to be int pointers; > char pointers are just as good: > > > #include <stdlib.h> > #include <stdio.h> > #include <string.h> > #include <errno.h> > > int main (int argc, char **argv) > > { > char *PSA; > char *ASCB; > char *ASXB; > char *ASXBP; > char *JNPI; > char jobname[9]; > > PSA = (char *) 0x224; /* address of PSAAOLD */ > ASCB = (char *) (*PSA); > printf ("ASCB = %p\n", ASCB); > ASXB = ASCB + 0x6c; > printf ("ASXB = %p\n", ASXB); > ASXBP = (char *) (*ASXB); > printf ("ASXBP = %p\n", ASXBP); > JNPI = ASXBP + 0xC0; > printf ("JNPI = %p\n", JNPI); > memcpy (jobname, JNPI, 8); > jobname [8] = 0x00; > printf ("jobname = %s\n", jobname); > } > > > > Am 09.02.2018 um 12:57 schrieb Bernd Oppolzer: > >> This is a slightly modified version of jn2.c: >> >> #include <stdlib.h> >> #include <stdio.h> >> #include <string.h> >> #include <errno.h> >> >> int main (int argc, char **argv) >> >> { >> int *PSA; >> int *ASCB; >> int *ASXB; >> int *ASXBP; >> int *JNPI; >> char jobname[9]; >> >> PSA = (int *) 0x224; /* address of PSAAOLD */ >> ASCB = (int *) *PSA; >> printf ("ASCB = %p\n", ASCB); >> ASXB = (int *) ((char *) ASCB + 0x6c); >> printf ("ASXB = %p\n", ASXB); >> ASXBP = (int *) *ASXB; >> printf ("ASXBP = %p\n", ASXBP); >> JNPI = (int *) ((char *) ASXBP + 0xC0); >> printf ("JNPI = %p\n", JNPI); >> memcpy (jobname, JNPI, 8); >> jobname [8] = 0x00; >> printf ("jobname = %s\n", jobname); >> } >> >> a) pure ANSI C >> >> b) some intermediate steps and variables removed >> >> c) there is a subtle error in the original version: >> the terminating hex zero in jobname is missing. I added it. >> >> Caution: untested ... >> >> Kind regards >> >> Bernd >> >> >> >> Am 09.02.2018 um 12:41 schrieb Bernd Oppolzer: >> >>> .. in fact, the original source contains some parts, >>> which are not ANSI C, for example cout (which is C++) >>> and iostream.h (which is also part of the C++ library). >>> >>> Because I don't like C++ ... and the program claims to be >>> a C program, I would (as a QA person) force the coder to >>> eliminate these parts of the code. >>> >>> Kind regards >>> >>> Bernd >>> >>> >>> Am 09.02.2018 um 12:32 schrieb Bernd Oppolzer: >>> >>>> Am 09.02.2018 um 07:45 schrieb Elardus Engelbrecht: >>>> >>>>> Bernd Oppolzer wrote: >>>>> >>>>> To be more pedantic, use additional parantheses: >>>>>> ASXB = (int *) (((char *) ASCB) + 0x6c); >>>>>> >>>>> I C ( "I see" ;-D ) >>>>> >>>>> Seriously, I find this whole thread very interesting. >>>>> >>>>> Just a question please and please excuse my ignorance. >>>>> >>>>> Are these discussions about C or C++? >>>>> >>>>> Because: >>>>> >>>>> OP said 'crawl my way around C/C++' >>>>> Shmuel and Paul are talking about C and Charles talked about C++ (for >>>>> his 2 templates) >>>>> >>>>> Feel free to teach me so I can C... >>>>> >>>>> TIA! >>>>> >>>>> Groete / Greetings >>>>> Elardus Engelbrecht >>>>> >>>>> >>>>> >>>> I went back to the original post which started the thread; >>>> the OP said "C / C++", but posted a C program (called jn2.c), >>>> so I guess, the discussion should in fact be about C. >>>> >>>> a) It's all pure C syntax >>>> b) with C++, the filetype would have been "cpp" >>>> >>>> HTH, kind regards >>>> >>>> Bernd >>>> >>>> ---------------------------------------------------------------------- >>>> For IBM-MAIN subscribe / signoff / archive access instructions, >>>> send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN >>>> >>>> >>> >> ---------------------------------------------------------------------- >> For IBM-MAIN subscribe / signoff / archive access instructions, >> send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN >> >> > ---------------------------------------------------------------------- > For IBM-MAIN subscribe / signoff / archive access instructions, > send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN > ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN ________________________________ This e-mail, including any attachments, may be confidential, privileged or otherwise legally protected. It is intended only for the addressee. If you received this e-mail in error or from someone who was not authorized to send it to you, do not disseminate, copy or otherwise use this e-mail or its attachments. Please notify the sender immediately by reply e-mail and delete the e-mail from your system. ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN