Re: PL/I and C (was Re: Simple (?) C question)

2017-06-21 Thread Bernd Oppolzer
__ From: IBM Mainframe Discussion List on behalf of Bernd Oppolzer Sent: Wednesday, June 21, 2017 2:04 PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: PL/I and C (was Re: Simple (?) C question) Hi Frank, 1.) yes, the C area acquired by malloc must be freed by someone 2.) unfortunately,

Re: PL/I and C (was Re: Simple (?) C question)

2017-06-21 Thread Frank Swarbrick
regard. Frank From: IBM Mainframe Discussion List on behalf of Bernd Oppolzer Sent: Wednesday, June 21, 2017 2:04 PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: PL/I and C (was Re: Simple (?) C question) Hi Frank, 1.) yes, the C area acquired by malloc must be freed by someone 2.) unfortunately

Re: PL/I and C (was Re: Simple (?) C question)

2017-06-21 Thread Bernd Oppolzer
viously NOT do this for str1ptr.) Side request... Could someone post the PL/I "JNI" copybook? Thanks, Frank From: Frank Swarbrick Sent: Tuesday, June 20, 2017 9:47 AM To: IBM Mainframe Discussion List Subject: Re: Simple (?) C question Thanks John. I

PL/I and C (was Re: Simple (?) C question)

2017-06-21 Thread Frank Swarbrick
anks, Frank From: Frank Swarbrick Sent: Tuesday, June 20, 2017 9:47 AM To: IBM Mainframe Discussion List Subject: Re: Simple (?) C question Thanks John. I know of no code that does this, nor do I intend to implement any. What I was really trying to determine i

Re: Simple (?) C question

2017-06-20 Thread Paul Gilmartin
On Tue, 20 Jun 2017 16:37:56 -0700, retired mainframer wrote: >Does MacOS run on any IBM mainframe? >> No, but I've used setvbuf() that I mentioned later in this thread to accomplish this purpose on z/OS xlc. If xlc doesn't conform to POSIX it ought to be APARable: On Tue, 20 Jun 2017 09:44:02

Re: Simple (?) C question

2017-06-20 Thread retired mainframer
Does MacOS run on any IBM mainframe? > -Original Message- > From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On > Behalf Of Paul Gilmartin > Sent: Tuesday, June 20, 2017 7:44 AM > To: IBM-MAIN@LISTSERV.UA.EDU > Subject: Re: Simple (?) C question &

Re: Simple (?) C question

2017-06-20 Thread Bernd Oppolzer
Some additional remarks below ... Am 20.06.2017 um 22:56 schrieb Bernd Oppolzer: I tried the program, too, using my local Watcom C compiler. No problems, but I had to add some global definitions to make it run. Looks like this: #include #include #include char *get_static_string(void) {

Re: Simple (?) C question

2017-06-20 Thread Bernd Oppolzer
regard. Thanks to everyone who answered. Frank From: IBM Mainframe Discussion List on behalf of John McKown Sent: Monday, June 19, 2017 7:59 PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: Simple (?) C question On Mon, Jun 19, 2017 at 4:25 PM, Frank Swarbrick < frank.swarbr...@o

Re: Simple (?) C question

2017-06-20 Thread Bernd Oppolzer
It's thread safe in that sense that several processes (LE enclaves) running in parallel each get their own instance of the WSA, so there is no mixing of static variables in this case. Of course, if you use other variants of multi-threading which don't involve separate (that is, parallel) LE encla

Re: Simple (?) C question

2017-06-20 Thread Bernd Oppolzer
Am 20.06.2017 um 13:12 schrieb Don Poitras: Not if you compile RENT. In that case the static is allocated in a separate area rather than being inside the load module. and: every invocation of the module from potentially parallel LE enclaves (for example, when used inside a DB2 stored proc envir

Re: Simple (?) C question

2017-06-20 Thread Anthony Giorgio
PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: Simple (?) C question On Mon, Jun 19, 2017 at 4:25 PM, Frank Swarbrick < frank.swarbr...@outlook.com> wrote: I know there are at least a few C developers here, so I was wondering if you could answer a question. Is the following valid C? (I

Re: Simple (?) C question

2017-06-20 Thread Frank Swarbrick
cKown Sent: Monday, June 19, 2017 7:59 PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: Simple (?) C question On Mon, Jun 19, 2017 at 4:25 PM, Frank Swarbrick < frank.swarbr...@outlook.com> wrote: > I know there are at least a few C developers here, so I was wondering if > you could answe

Re: Simple (?) C question

2017-06-20 Thread Paul Gilmartin
On Mon, 19 Jun 2017 17:13:00 -0700, retired mainframer wrote: > >Probably unrelated to your real question but the format string passed to >printf should also have a \n after the %s to insure the output is visible. > On MacOS, at least, buffers are flushed when the program exits, so the output wil

Re: Simple (?) C question

2017-06-20 Thread David Crayford
That's not what I meant. It's not thread safe without locking. And even if you're not multi-threaded it may be better practice to copy the static C string into a buffer. Take strerror() for example. Once you've got the error you either print it immediately or copy the message into a buffer. str

Re: Simple (?) C question

2017-06-20 Thread Don Poitras
Not if you compile RENT. In that case the static is allocated in a separate area rather than being inside the load module. In article <32db4b0b-1271-18b1-574c-9cb6a37a2...@gmail.com> you wrote: > If the string can be mutated either by the client or the runtime > returning by reference is not re-e

Re: Simple (?) C question

2017-06-19 Thread David Crayford
If the string can be mutated either by the client or the runtime returning by reference is not re-entrant. I would always prefer to use strings buffers: int get_string(char * buf, size_t buflen); Strings are s much easier in C++. On 20/06/2017 9:59 AM, John McKown wrote: On Mon, Jun 19,

Re: Simple (?) C question

2017-06-19 Thread John McKown
On Mon, Jun 19, 2017 at 4:25 PM, Frank Swarbrick < frank.swarbr...@outlook.com> wrote: > I know there are at least a few C developers here, so I was wondering if > you could answer a question. Is the following valid C? (I'm not asking if > one should actually do it; only if its valid at all.) >

Re: Simple (?) C question

2017-06-19 Thread retired mainframer
t; Subject: Simple (?) C question > > I know there are at least a few C developers here, so I was wondering if you could answer a > question. Is the following valid C? (I'm not asking if one should actually do it; only if its > valid at all.) > char *get_static_string(void) {

Re: Simple (?) C question

2017-06-19 Thread Paul Gilmartin
On Mon, 19 Jun 2017 21:25:50 +, Frank Swarbrick wrote: >I know there are at least a few C developers here, so I was wondering if you >could answer a question. Is the following valid C? (I'm not asking if one >should actually do it; only if its valid at all.) >char *get_static_string(void)

Re: Simple (?) C question

2017-06-19 Thread Tom Brennan
Looks good to me. Like Peter says, the function returns the pointer correctly, and the compiler should put that string in a static memory location instead of on the stack. Now if you were to do something like this: char * x; printf("%s\n", get_static_string()); x = get_static_string();

Re: Simple (?) C question

2017-06-19 Thread Farley, Peter x23353
first array member. Peter -Original Message- From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf Of Frank Swarbrick Sent: Monday, June 19, 2017 5:26 PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: Simple (?) C question I know there are at least a few C developers here,

Simple (?) C question

2017-06-19 Thread Frank Swarbrick
I know there are at least a few C developers here, so I was wondering if you could answer a question. Is the following valid C? (I'm not asking if one should actually do it; only if its valid at all.) char *get_static_string(void) { static char str[81] = "This is a statically allocated C st

Re: C question (IBM specific)

2013-08-30 Thread Bill Godfrey
On Fri, 30 Aug 2013 09:15:28 -0500, Mark Hammack wrote: >I would like to be able to pass a string to the IBM C/C++ compiler to include >in a program. I have tried every way I can think of to use the DEFINE() >compiler option but can't make it work. This is what I would like to do: > >... >//

Re: C question (IBM specific)

2013-08-30 Thread Michael Klaeschen
also failed with messages you described. Cheers Michael Von:Mark Hammack An: IBM-MAIN@LISTSERV.UA.EDU Datum: 2013-08-30 16:15 Betreff:C question (IBM specific) Gesendet von: IBM Mainframe Discussion List I would like to be able to pass a string to the IBM C/C++ compiler

Re: C question (IBM specific)

2013-08-30 Thread Miklos Szigetvari
Hi In batch I'm using like this: //COMPILE EXEC PGM=CCNDRVR,REGION=&CREGSIZ, //PARM=('&CRUN/&CPARM OPTFILE(DD:OPTFILE)') //STEPLIB DD DSN=&LIBPRFX..SCEERUN,DISP=SHR // DD DSN=CBC.SCCNCMP,DISP=SHR //USERLIB DD DISP=SHR,DSN=ESA.PRJ.CBTEXP.HPP //SYSMSGS DD DUMMY,DSN=&LNGPRFX..S

C question (IBM specific)

2013-08-30 Thread Mark Hammack
I would like to be able to pass a string to the IBM C/C++ compiler to include in a program. I have tried every way I can think of to use the DEFINE() compiler option but can't make it work. This is what I would like to do: ... // EXEC PGM=CCNDRVR,PARM=('...DEFINE(MYSTRING=TEST)') ... In the

Re: C question -- not sure where to ask it

2013-05-12 Thread Scott Ford
http://www.identityforge.com/   From: retired mainframer To: IBM-MAIN@LISTSERV.UA.EDU Sent: Saturday, May 11, 2013 3:25 PM Subject: Re: C question -- not sure where to ask it What is the character between the two single quote marks in the first call to

Re: C question -- not sure where to ask it

2013-05-11 Thread Bill Godfrey
On Sat, 11 May 2013 12:25:13 -0700, retired mainframer wrote: >What is the character between the two single quote marks in the first call >to memset? My email shows no character (the quotes are adjacent) and C does >not support an empty character constant. Perchance did you have a hex 00 >there?

Re: C question -- not sure where to ask it

2013-05-11 Thread retired mainframer
ays return 0 whenever it executes and is therefore useless. :>: -Original Message- :>: From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On :>: Behalf Of Scott Ford :>: Sent: Friday, May 10, 2013 1:04 PM :>: To: IBM-MAIN@LISTSERV.UA.EDU :>: Subject: C qu

Re: C question -- not sure where to ask it

2013-05-10 Thread Scott Ford
Bill, Your right ...a big Ty Scott ford www.identityforge.com from my IPAD 'Infinite wisdom through infinite means' On May 10, 2013, at 10:38 PM, Bill Godfrey wrote: > On Fri, 10 May 2013 13:04:12 -0700, Scott Ford wrote: > >> All: >> >> I am writing a routing and want to use type=memory f

Re: C question -- not sure where to ask it

2013-05-10 Thread Bill Godfrey
On Fri, 10 May 2013 13:04:12 -0700, Scott Ford wrote: >All: > >I am writing a routing and want to use type=memory files in C and this is what >i tried... These 3 lines: memset(buffout,'',sizeof(buffout)); strcpy(buffout,"\n"); fwrite(buffout,1,80,fobj); will write "\n" followed by

C question -- not sure where to ask it

2013-05-10 Thread Scott Ford
All:   I am writing a routing and want to use type=memory files in C and this is what i tried...       char buffer[80];   char buffout[80];   char lineout[121];   int rctr;   int wctr;   fobj = fopen("file.data","w,type=memory");   if(fobj != NULL)   printf("FOBJ  File Open at: %s\n",time_of_d

Re: C question

2013-04-25 Thread Mike Schwab
On Thu, Apr 25, 2013 at 2:26 AM, Bernd Oppolzer wrote: > It's easy, because you're always sure that the line will be terminated by a > hex zero which will throw you out of the loops. And that is how the buffer overflow bugs are created. Need to check for end of buffer. -- Mike A Schwab, Spring

Re: C question

2013-04-25 Thread Bernd Oppolzer
When dealing with such problems, I always ended up coding very simple loops looking for the start and end of the keywords etc. using char pointers, then moving the data out of the line buffer and doing the compare, like the following char *cp1; char *cp2; int l; char bufx [MAXL_KEYWORD]; cp1 = l

Re: C question

2013-04-24 Thread Scott Ford
gt; http://www.boost.org/doc/libs/1_53_0/libs/tokenizer/ > >> Charles >> >> -Original Message- >> From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On >> Behalf Of Scott Ford >> Sent: Monday, April 22, 2013 3:21 PM >> To: IBM-MA

Re: C question

2013-04-23 Thread David Crayford
/tokenizer/ Charles -Original Message- From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf Of Scott Ford Sent: Monday, April 22, 2013 3:21 PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: C question All: I need some C help .. I am reading a file and need to

Re: C question

2013-04-23 Thread Charles Mills
PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: C question All:   I need some C help ..   I am reading a file and need to Tokenize the file so i can examine the :   Parm = Value ..   I have tried strtok and works to a certain degree my problem comes when I tried to strcmp the value to chaeck validity

Re: C question

2013-04-22 Thread David Crayford
I'm not quite sure what you're requirement is but if all you want is a ini file parser (something that parses key=value pairs) there are plenty of good ones around http://code.google.com/p/inih/. On 23/04/2013 6:21 AM, Scott Ford wrote: All: I need some C help .. I am reading a file and

Re: C question

2013-04-22 Thread EXT-Schwarz, Barry
Show some code. Describe the problems in reasonable detail. > -Original Message- > From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] > On Behalf Of Scott Ford > Sent: Monday, April 22, 2013 3:21 PM > To: IBM-MAIN@LISTSERV.UA.EDU > Subject: C quest

Re: C question

2013-04-22 Thread Sam Siegel
Be sure to set the input string name in the parmlist to NULL on the second through last invocation of strtok; be sure your delimiters make sense for the invocation. You can change delimiters, if needed, on each invocation. On Mon, Apr 22, 2013 at 3:21 PM, Scott Ford wrote: > All: > > I need s

C question

2013-04-22 Thread Scott Ford
All:   I need some C help ..   I am reading a file and need to Tokenize the file so i can examine the :   Parm = Value ..   I have tried strtok and works to a certain degree my problem comes when I tried to strcmp the value to chaeck validity ...   Can some give this old man some pointers   Regard