]> diplodocus.org Git - nmh/blob - docs/historical/mh-jun-1982/subs/m_setcur.c
Create new mh-format function %(ordinal)
[nmh] / docs / historical / mh-jun-1982 / subs / m_setcur.c
1 #ifdef COMMENT
2 Proprietary Rand Corporation, 1981.
3 Further distribution of this software
4 subject to the terms of the Rand
5 license agreement.
6 #endif
7
8 #include "../mh.h"
9 #include <stdio.h>
10
11 extern char *strcpy();
12
13 struct msgs *mp;
14
15 m_setcur(num)
16 {
17 char buf[6];
18 register int i;
19 register char *cp1;
20
21 if(mp->msgflags&READONLY) {
22 m_replace(cp1 = concat("cur-",mp->foldpath,0), m_name(num));
23 free(cp1);
24 } else {
25 strcpy(buf, m_name(num));
26 cp1 = buf + strlen(buf);
27 *cp1++ = '\n';
28 if(strcmp(current, "cur"))
29 error("\"current\" got Clobbered!! Bug!");
30 if((i = creat(current, 0660)) >= 0) {
31 if(write(i, buf, cp1-buf) != cp1-buf) {
32 fprintf(stderr, "m_setcur: write error on ");
33 perror(current);
34 done(1);
35 }
36 VOID close(i);
37 }
38 }
39 }