Re: Using printf() in a 4gl program w/C
Posted in 1992
Path: emory!wupost!uunet!halexii!halexv!greg From: greg@halexv.uucp (Gregory F. Hogg) Newsgroups: comp.databases.informix Message-ID: <1992Jan30.111017.541@halexv.uucp> Date: 30 Jan 92 11:10:17 GMT References: <1992Jan28.215456.3789@kodak.kodak.com> <1992Jan30.000533.25067@cbnewsm.att.com> Reply-To: greg@halexv.UUCP (Gregory F. Hogg) Organization: HOGG'S SOFTWARE; Abingdon, MD In article <1992Jan30.000533.25067@cbnewsm.att.com> jonesie@cbnewsm.att.com (The Bohemian Welshman) writes: >In article <1992Jan28.215456.3789@kodak.kodak.com> (Mitch Amiano) writes: > >>This may be a simple question, but are there any known problems >>calling a C function which uses printf() from a 4gl program ? > >>My program is a 4gl executable with ESQL/C functions linked in. The >>ESQL/C functions use stdio routines for i/o. Is this ok/not-ok ? > > [...] > >> The output looks like this: >> >> First status message. >> Next status message. >> Next message... > > > Yep, I had the identical problem when using stdio. The I/O control >is just not set up by the 4gl executables in the fashion you would expect. > > Try calling the following routine, or something like it, before >using the stdio calls. (It sets the "on a NL do a CR" bit for standard >out. So far no evil has befallen me, but as always, test your hacks >well. You may also want to improve there error handling.) > >#include <termio.h> >void fix_io() >{ > struct termio arg_struct; > > if ( ioctl(1,TCGETA,&arg_struct) < 0) > fprintf(stderr,"TCGETA error\\n"); > arg_struct.c_oflag = arg_struct.c_oflag | ONLCR; > if ( ioctl(1,TCSETA,&arg_struct) < 0) > fprintf(stderr,"TCSETA error\\n"); >} > >-- > Chuck Jones > cej@ccsitn.att.com > Speaking just for me, not AT&T Chuck, Might be a good idea to save the tty state before you do the ioctl and restore it after you finish printing before returning to the 4GL program. That way all tty modes will be as they where before you changed them. +++++++++++++++++ +++++++++++++++++++ Greg Hogg +++ +++ ++ ++ HOGG'S SOFTWARE +++ +++ +++++++++++++++++++ +++++++++++++++++ voice : 410-538-7241 ++++ ++++ ++++ ++++ fax : 410-538-6130 ++++ +++++ +++++ ++++ uucp : uunet!halexii!greg ++++ ++++++ ++++++ ++++ cis : 74176,1320 -- +++++++++++++++++ +++++++++++++++++++ Greg Hogg +++ +++