Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!husc6!rutgers!ames!sdcsvax!ucbvax!dewey.soe.berkeley.edu!oster
From: oster@dewey.soe.berkeley.edu (David Phillip Oster)
Newsgroups: comp.windows.x
Subject: xpostit - strange file format, fixes:
Message-ID: <20075@ucbvax.BERKELEY.EDU>
Date: Tue, 11-Aug-87 21:06:36 EDT
Article-I.D.: ucbvax.20075
Posted: Tue Aug 11 21:06:36 1987
Date-Received: Thu, 13-Aug-87 06:48:28 EDT
Sender: usenet@ucbvax.BERKELEY.EDU
Reply-To: oster@dewey.soe.berkeley.edu.UUCP (David Phillip Oster)
Distribution: world
Organization: School of Education, UC-Berkeley
Lines: 93
I've been using xpostit, and I don't like the data file format.
The format is:
example:
=160x120+674+26
15
This is a Test.
It is obnoxious to have a character count, as this prevents me from editing
the file with a standard text editor.
What follows is a fix for this problem. It requires the "stat" system
call, and requires that the structure defined in stdio.h keep a count
of how many characters remain in the buffer. I use it on Suns.
After this fix is applied to the file "file.c" in xpostit, the file format
of xpostit becomes:
example:
=160x120+674+26
This is a Test.
You must remember to modify the Makefile, so that CFLAGS line becomes:
CFLAGS= -O -I../include -DUNIX
Here are the diffs to file.c:
-------------------------------------------
9a10,11
> * changes: David Oster July, '87 - removed explicit char count from files
> * since change uses Unix system calls, make them #ifdef UNIX
12a15,16
> #include
> #include
90,91c94
< * Print the geometry and the number of characters in the
< * note to the file.
---
> * Print the geometry to the file.
94d96
< fprintf(fp, "%d\n", n->nchars);
95a98
> #ifndef UNIX
96a100,105
> * Print the size to the file
> */
> fprintf(fp, "%s\n", n->notetext);
> #endif
>
> /*
191c200
< * Read in the number of characters in the note.
---
> * Get the number of characters in the note.
193,194d201
< fgets(buf, sizeof(buf), fp);
< sscanf(buf, "%d", &size);
195a203,204
> size = GetRemainingSize(fp);
>
244a254,278
>
>
> /* GetRemainingSize - given a FILE, return the number of chars remaining
> * in the file.
> */
> int GetRemainingSize(fp)FILE *fp;{
> #ifdef UNIX
> struct stat buf;
>
> fstat(fileno(fp), &buf);
> return fp->_cnt + buf.st_size - lseek(fileno(fp), 0L, L_INCR);
>
> #else
>
> char buf[512];
> int size;
>
> fgets(buf, sizeof(buf), fp);
> sscanf(buf, "%d", &size);
> return size;
> #endif
>
> }
>
>
--- David Phillip Oster --My Good News: "I'm a perfectionist."
Arpa: oster@dewey.soe.berkeley.edu --My Bad News: "I don't charge by the hour."
Uucp: {seismo,decvax,...}!ucbvax!oster%dewey.s i i ir oir oi
y