HP3000-L Archives

March 1998, Week 2

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Mark Bixby <[log in to unmask]>
Reply To:
Date:
Thu, 12 Mar 1998 11:03:54 -0800
Content-Type:
text/plain
Parts/Attachments:
text/plain (51 lines)
John J Archer writes:
>
> I am new at coding in C and I'm working on a program that needs to
> write to a MSG file. Our procedures dictate that the EOF must be posted
> so no data is lost if something happens. I have been working w/ fflush
> but the EOF does not get updated. I have done some reading that seems to
> indicate that the interface to the system intrinsics like FCONTROL is
> not straight forward.
>
> My question is whether there is a C function or macro that I should use
> or is FCONTROL correct and via the mpe.h file which variables I should
> use. I'm using fopen (C function) to open the file.

It's easy with an HP C macro called _MPE_FILENO().  Here is an example from my
MPE/iX Porting Guide (due to be released tomorrow) which shows how:

int ftruncate(int fd, size_t wantsize) {
                extern FCONTROL(short, short, void *);

                long cursize;

                /* determine current file size */
                if ((cursize = lseek(fd, 0L, 2)) == -1)
                        return (-1);

                /* maybe lengthen... */
                if (cursize < wantsize) {
                        if (lseek(fd, wantsize - 1, 0) == -1 ||
                            write(fd, "", 1) == -1) {
                                return (-1);
                        }
                        return (0);
                }

                /* maybe shorten... */
                if (wantsize < cursize) {
                        if (lseek(fd, wantsize - 1, 0) == -1) {
                                return (-1);
                        }
                        FCONTROL(_MPE_FILENO(fd),6,0); /* Write smaller EOF */
                        return (0);
                }
                return (0);
        }
--
Mark Bixby                      E-mail: [log in to unmask]
Coast Community College Dist.   Web: http://www.cccd.edu/~markb/
District Information Services   1370 Adams Ave, Costa Mesa, CA, USA 92626-5429
Technical Support               Voice: +1 714 438-4647
"You can tune a file system, but you can't tune a fish." - tunefs(1M)

ATOM RSS1 RSS2