]>
diplodocus.org Git - nmh/blob - docs/historical/mh-nov-1983/subs/m_gmsg.c
9 struct msgs
*m_gmsg(name
)
14 register struct msgs
*msgp
;
15 register struct direct
*dir
;
33 if ((dirp
= opendir(".")) == 0)
35 for(j
= 0; j
< 1000; j
++)
41 msgbuf
.xlowmsg
= 5000;
43 msgbuf
.xflags
= (access(".",2) == -1)? READONLY
:0;
46 * The following hack is that if the directory is writable
47 * and the cur file is not, we consider it to be read only
51 if (stat("cur", &statb
) >= 0 && access("cur", 2) < 0)
52 msgbuf
.xflags
|= READONLY
;
54 while (dir
= readdir(dirp
)) {
56 if (j
= mu_atoi(cp
)) {
57 if (j
> msgbuf
.xhghmsg
)
60 if (j
< msgbuf
.xlowmsg
)
62 msgbuf
.xmsgs
[j
] = EXISTS
;
63 } else if (*cp
!= ',' && *cp
!= '.' && *cp
!= '#')
64 if (strcmp(cp
, current
) == 0)
66 else if (strcmp(cp
, listname
) == 0)
74 if(msgbuf
.xflags
&READONLY
) {
75 sprintf(buf
, "cur-%s", name
);
76 /*** copy(name, copy("cur-", buf)); ***/
77 if((cp
= m_find(buf
)) != NULL
)
80 } else if(curfil
&& (i
= open(current
, 0)) >= 0) {
81 if((j
= read(i
, buf
, sizeof (buf
))) >= 2) {
82 buf
[j
-1] = '\0'; /* Zap <lf> */
88 if( (int) (msgp
= (struct msgs
*) malloc(sizeof *mp
+ msgbuf
.xhghmsg
+ 2)) == -1)
90 msgp
->hghmsg
= msgbuf
.xhghmsg
;
91 msgp
->nummsg
= msgbuf
.xnummsg
;
92 msgp
->lowmsg
= msgbuf
.xlowmsg
;
93 msgp
->curmsg
= msgbuf
.xcurmsg
;
94 msgp
->selist
= msgbuf
.xselist
;
95 msgp
->msgflags
= msgbuf
.xflags
;
96 msgp
->others
= msgbuf
.xothers
;
97 msgp
->foldpath
= name
;
101 for(j
= 0; j
<= msgbuf
.xhghmsg
; j
++)
102 msgp
->msgstats
[j
] = msgbuf
.xmsgs
[j
];
116 if(*cp
< '0' || *cp
> '9' || i
> 99)