1: #include "parms.h"
2: #include "structs.h"
3:
4: #ifdef RCSIDENT
5: static char rcsid[] = "$Header: gtext.c,v 1.7 85/01/18 15:12:11 notes Rel $";
6: #endif RCSIDENT
7:
8: /*
9: * get the text for a note/response
10: *
11: * Calls unix editor with a unique file name
12: * Also makes sure the returned text is of
13: * appropriate size
14: *
15: * Ray Essick 10/23/80
16: * Modified : rbk 10/26/80
17: * modified again: rbe 12 nov 81 fix to version 7 and general shtuff
18: * modified a third time to add insert-text for user
19: * Ray Essick December 1981
20: */
21:
22: long gettext (io, where, preface, editflag)
23: struct io_f *io;
24: struct daddr_f *where; /* where we left it */
25: FILE * preface; /* text included in buffer */
26: int editflag; /* EDIT if want editor, else NOEDIT */
27: {
28: FILE * scr, *fopen ();
29: register int c;
30: long count;
31: char fn[20]; /* scratch file name */
32:
33: sprintf (fn, "/tmp/nf%d", getpid ());
34: x ((scr = fopen (fn, "w")) == NULL, "gettext: create scratch");
35: x (chmod (fn, 0666) < 0, "gettext: chmod tmp");
36: if (preface != NULL)
37: {
38: while ((c = getc (preface)) != EOF)
39: putc (c, scr); /* move included text */
40: }
41: fclose (scr);
42: fflush (stdout); /* clean it out */
43:
44: if (editflag == EDIT)
45: {
46: #ifndef FASTFORK
47: {
48: char cmd[CMDLEN]; /* build editor call */
49: sprintf (cmd, "%s %s", hised, fn);
50: dounix (cmd, 1, 1); /* get the text */
51: }
52: #else
53: dounix (1, 1, hised, fn, 0, 0, 0); /* call his editor */
54: #endif
55: } /* end of editflag test */
56:
57: if ((scr = fopen (fn, "r")) == NULL) /* no text to read */
58: {
59: unlink (fn); /* might just be protections */
60: return ((long) 0);
61: }
62:
63: count = pagein (io, scr, where); /* move text in */
64: fclose (scr); /* close the scratch file and */
65: x (unlink (fn) < 0, "gettext: unlink"); /* unlink it */
66: return ((long) count); /* chars moved */
67: }
Defined functions
Defined variables
rcsid
defined in line
5;
never used