annotate 3rdparty/packages/uemacs/uefile2.c @ 3027:32a23a8c3332

Fix for all ide rbsuper descripters being set for drive 0
author chawks4
date Fri, 12 Dec 2014 20:48:42 -0600
parents 48c646212b1c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
995
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
1 /*
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
2 * The routines in this file
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
3 * handle the reading and writing of
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
4 * disk files. All of details about the
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
5 * reading and writing of the disk are
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
6 * in "fileio.c".
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
7 */
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
8 #include <stdio.h>
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
9 #include "ueed.h"
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
10
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
11 /*
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
12 * Save the contents of the current
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
13 * buffer in its associatd file. No nothing
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
14 * if nothing has changed (this may be a bug, not a
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
15 * feature). Error if there is no remembered file
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
16 * name for the buffer. Bound to "C-X C-S". May
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
17 * get called by "C-Z".
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
18 */
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
19 filesave(f, n)
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
20 {
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
21 register WINDOW *wp;
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
22 register int s;
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
23
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
24 if ((curbp->b_flag&BFCHG) == 0) /* Return, no changes. */
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
25 return (TRUE);
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
26 if (curbp->b_fname[0] == 0) { /* Must have a name. */
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
27 mlwrite("No file name");
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
28 return (FALSE);
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
29 }
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
30 if ((s=writeout(curbp->b_fname)) == TRUE) {
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
31 curbp->b_flag &= ~BFCHG;
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
32 wp = wheadp; /* Update mode lines. */
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
33 while (wp != NULL) {
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
34 if (wp->w_bufp == curbp)
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
35 wp->w_flag |= WFMODE;
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
36 wp = wp->w_wndp;
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
37 }
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
38 }
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
39 return (s);
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
40 }
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
41
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
42 /*
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
43 * This function performs the details of file
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
44 * writing. Uses the file management routines in the
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
45 * "fileio.c" package. The number of lines written is
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
46 * displayed. Sadly, it looks inside a LINE; provide
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
47 * a macro for this. Most of the grief is error
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
48 * checking of some sort.
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
49 */
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
50 writeout(fn)
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
51 char *fn;
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
52 {
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
53 register int s;
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
54 register LINE *lp;
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
55 register int nline;
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
56
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
57 if ((s=ffwopen(fn)) != FIOSUC) /* Open writes message. */
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
58 return (FALSE);
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
59 lp = lforw(curbp->b_linep); /* First line. */
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
60 nline = 0; /* Number of lines. */
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
61 while (lp != curbp->b_linep) {
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
62 if ((s=ffputline(&lp->l_text[0], llength(lp))) != FIOSUC)
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
63 break;
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
64 ++nline;
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
65 lp = lforw(lp);
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
66 }
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
67 if (s == FIOSUC) { /* No write error. */
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
68 s = ffclose();
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
69 if (s == FIOSUC) { /* No close error. */
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
70 if (nline == 1)
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
71 mlwrite("[Wrote 1 line]");
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
72 else
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
73 mlwrite("[Wrote %d lines]", nline);
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
74 }
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
75 } else /* Ignore close error */
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
76 ffclose(); /* if a write error. */
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
77 if (s != FIOSUC) /* Some sort of error. */
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
78 return (FALSE);
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
79 return (TRUE);
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
80 }
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
81
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
82 /*
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
83 * The command allows the user
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
84 * to modify the file name associated with
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
85 * the current buffer. It is like the "f" command
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
86 * in UNIX "ed". The operation is simple; just zap
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
87 * the name in the BUFFER structure, and mark the windows
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
88 * as needing an update. You can type a blank line at the
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
89 * prompt if you wish.
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
90 */
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
91 filename(f, n)
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
92 {
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
93 register WINDOW *wp;
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
94 register int s;
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
95 char fname[NFILEN];
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
96
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
97 if ((s=mlreply("Name: ", fname, NFILEN)) == ABORT)
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
98 return (s);
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
99 if (s == FALSE)
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
100 strcpy(curbp->b_fname, "");
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
101 else
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
102 strcpy(curbp->b_fname, fname);
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
103 wp = wheadp; /* Update mode lines. */
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
104 while (wp != NULL) {
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
105 if (wp->w_bufp == curbp)
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
106 wp->w_flag |= WFMODE;
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
107 wp = wp->w_wndp;
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
108 }
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
109 return (TRUE);
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
110 }
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
111
48c646212b1c 'microEMACS' for OS-9.
roug
parents:
diff changeset
112