* and a pointer to the filehandle will be stored in
* folder structure, where it will later be used by
* seq_save().
+ *
+ * Return values:
+ * OK - successfully read the sequence files, or they don't exist
+ * NOTOK - failed to lock sequence file
*/
-void seq_read (struct msgs * mp, int lockflag);
+int seq_read (struct msgs * mp, int lockflag);
void seq_save (struct msgs *);
void seq_setcur (struct msgs *, int);
void seq_setprev (struct msgs *);
/*
* Read and initialize the sequence information.
*/
- seq_read (mp, lockflag);
+ if (seq_read (mp, lockflag) == NOTOK) {
+ char seqfile[PATH_MAX];
+
+ /* Failed to lock sequence file. */
+ snprintf (seqfile, sizeof(seqfile), "%s/%s", mp->foldpath, mh_seq);
+ advise (seqfile, "failed to lock");
+
+ return NULL;
+ }
return mp;
}
* static prototypes
*/
static int seq_init (struct msgs *, char *, char *);
-static void seq_public (struct msgs *, int);
+static int seq_public (struct msgs *, int);
static void seq_private (struct msgs *);
* or context file (for private sequences).
*/
-void
+int
seq_read (struct msgs *mp, int lockflag)
{
/*
/* If folder is empty, don't scan for sequence information */
if (mp->nummsg == 0)
- return;
+ return OK;
/* Initialize the public sequences */
- seq_public (mp, lockflag);
+ if (seq_public (mp, lockflag) == NOTOK) {
+ if (errno == EACCES || errno == EAGAIN || errno == EWOULDBLOCK) {
+ /* Failed to lock sequence file. */
+ return NOTOK;
+ }
+ }
/* Initialize the private sequences */
seq_private (mp);
+
+ return OK;
}
* read folder's sequences file for public sequences
*/
-static void
+static int
seq_public (struct msgs *mp, int lockflag)
{
int state;
* then just return, and do not initialize any public sequences.
*/
if (mh_seq == NULL || *mh_seq == '\0')
- return;
+ return OK;
/* get filename of sequence file */
snprintf (seqfile, sizeof(seqfile), "%s/%s", mp->foldpath, mh_seq);
if ((fp = lkfopendata (seqfile, lockflag ? "r+" : "r")) == NULL)
- return;
+ return NOTOK;
/* Use m_getfld to scan sequence file */
for (;;) {
} else {
lkfclosedata (fp, seqfile);
}
+
+ return OK;
}
if ((fp = lkfopendata (seqfile, "r")) == NULL) {
free(seqfile);
- return NULL;
+
+ if (errno == EACCES || errno == EAGAIN || errno == EWOULDBLOCK) {
+ /* Failed to lock sequence file. */
+ adios (seqfile, "failed to lock");
+ } else {
+ return NULL;
+ }
}
/* Use m_getfld to scan sequence file */