]> diplodocus.org Git - nmh/blob - docs/historical/mh-jun-1982/subs/m_getcur.c
Create new mh-format function %(ordinal)
[nmh] / docs / historical / mh-jun-1982 / subs / m_getcur.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 <stdio.h>
9 #include "../mh.h"
10
11 extern char *sprintf();
12
13 m_getcur(name)
14 char *name;
15 {
16 register char *cp;
17 register int i, j;
18 short readonly, curfil = 0;
19 char buf[132];
20
21 readonly = (access(".",2) == -1);
22 if(readonly) {
23 VOID sprintf(buf, "cur-%s", name);
24 if(cp = m_find(buf))
25 curfil = mu_atoi(cp);
26 } else if(i = open(current, 0)) {
27 if((j = read(i, buf, sizeof buf)) >= 2){
28 buf[j-1] = 0; /* Zap <lf> */
29 curfil = mu_atoi(buf);
30 }
31 VOID close(i);
32 }
33 return curfil;
34 }