/*
- * folder(s).c -- set/list the current message and/or folder
- * -- push/pop a folder onto/from the folder stack
- * -- list the folder stack
- *
- * This code is Copyright (c) 2002, 2008, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** folder(s).c -- set/list the current message and/or folder
+** -- push/pop a folder onto/from the folder stack
+** -- list the folder stack
+**
+** This code is Copyright (c) 2002, 2008, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <h/crawl_folders.h>
static char folder[BUFSIZ];
/*
- * Structure to hold information about
- * folders as we scan them.
- */
+** Structure to hold information about
+** folders as we scan them.
+*/
struct FolderInfo {
char *name;
int nummsg;
};
/*
- * Dynamically allocated space to hold
- * all the folder information.
- */
+** Dynamically allocated space to hold
+** all the folder information.
+*/
static struct FolderInfo *fi;
static int maxFolderInfo;
/*
- * static prototypes
- */
+** static prototypes
+*/
static int get_folder_info (char *, char *);
static crawl_callback_t get_folder_info_callback;
static void print_folders (void);
context_read();
/*
- * If program was invoked with name ending
- * in `s', then add switch `-all'.
- */
+ ** If program was invoked with name ending
+ ** in `s', then add switch `-all'.
+ */
if (argv[0][strlen (argv[0]) - 1] == 's')
all = 1;
nmhdir = concat (m_maildir (""), "/", NULL);
/*
- * If we aren't working with the folder stack
- * (-push, -pop, -list) then the default is to print.
- */
+ ** If we aren't working with the folder stack
+ ** (-push, -pop, -list) then the default is to print.
+ */
if (pushsw == 0 && popsw == 0 && listsw == 0)
printsw++;
cp = add (*ap, add (" ", cp));
context_replace (stack, cp); /* update folder stack */
} else {
- context_del (stack); /* delete folder stack entry from context */
+ /* delete folder stack entry from context */
+ context_del (stack);
}
free (dp);
}
cp = m_maildir(argfolder);
if (access (cp, F_OK) == NOTOK)
adios (cp, "unable to find folder");
- context_replace (pfolder, argfolder); /* update current folder */
+ /* update current folder */
+ context_replace (pfolder, argfolder);
context_save (); /* save the context file */
argfolder = NULL;
}
fi = mh_xmalloc (maxFolderInfo * sizeof(*fi));
/*
- * Scan the folders
- */
+ ** Scan the folders
+ */
if (all || ftotal > 0) {
/*
- * If no folder is given, do them all
- */
- /* change directory to base of nmh directory for crawl_folders */
+ ** If no folder is given, do them all
+ */
+ /*
+ ** change directory to base of nmh directory for
+ ** crawl_folders
+ */
if (chdir (nmhdir) == NOTOK)
adios (nmhdir, "unable to change directory to");
if (!argfolder) {
} else {
strncpy (folder, argfolder, sizeof(folder));
if (get_folder_info (argfolder, msg)) {
- context_replace (pfolder, argfolder);/* update current folder */
- context_save (); /* save the context file */
+ /* update current folder */
+ context_replace (pfolder, argfolder);
+ context_save ();
}
/*
- * Since recurse wasn't done in get_folder_info(),
- * we still need to list all level-1 sub-folders.
- */
+ ** Since recurse wasn't done in get_folder_info(),
+ ** we still need to list all level-1 sub-folders.
+ */
if (!frecurse)
crawl_folders (folder, get_folder_info_callback, NULL);
}
strncpy (folder, argfolder ? argfolder : getfolder (1), sizeof(folder));
/*
- * Check if folder exists. If not, then see if
- * we should create it, or just exit.
- */
+ ** Check if folder exists. If not, then see if
+ ** we should create it, or just exit.
+ */
create_folder (m_maildir (folder), fcreat, done);
if (get_folder_info (folder, msg) && argfolder) {
}
/*
- * Print out folder information
- */
+ ** Print out folder information
+ */
print_folders();
- context_save (); /* save the context file */
+ context_save ();
done (0);
return 1;
}
i = total_folders++;
/*
- * if necessary, reallocate the space
- * for folder information
- */
+ ** if necessary, reallocate the space
+ ** for folder information
+ */
if (total_folders >= maxFolderInfo) {
maxFolderInfo += CRAWL_NUMFOLDERS;
fi = mh_xrealloc (fi, maxFolderInfo * sizeof(*fi));
if ((ftotal > 0) || !fshort || msg || fpack) {
/*
- * create message structure and get folder info
- */
+ ** create message structure and get folder info
+ */
if (!(mp = folder_read (fold))) {
admonish (NULL, "unable to read folder %s", fold);
return 0;
if (crawl_children) {
crawl_folders (fold, get_folder_info_callback, NULL);
}
-
- return retval;
+return retval;
}
/*
- * Print folder information
- */
+** Print folder information
+*/
static void
print_folders (void)
char tmpname[BUFSIZ];
/*
- * compute a few values needed to for
- * printing various fields
- */
+ ** compute a few values needed to for
+ ** printing various fields
+ */
for (i = 0; i < total_folders; i++) {
/* length of folder name */
len = strlen (fi[i].name);
nummsgdigits = 2;
/*
- * Print the header
- */
+ ** Print the header
+ */
if (fheader > 0 || (all && !fshort && fheader >= 0))
printf ("%-*s %*s %-*s; %-*s %*s\n",
maxlen+1, "FOLDER",
9, "(OTHERS)");
/*
- * Print folder information
- */
+ ** Print folder information
+ */
if (all || fshort || ftotal < 1) {
for (i = 0; i < total_folders; i++) {
if (fshort) {
}
/*
- * Print folder/message totals
- */
+ ** Print folder/message totals
+ */
if (ftotal > 0 || (all && !fshort && ftotal >= 0)) {
if (all)
printf ("\n");
}
/*
- * Set the current message and sychronize sequences
- */
+** Set the current message and sychronize sequences
+*/
static int
sfold (struct msgs *mp, char *msg)
/*
- * Do the read only folders
- */
+** Do the read only folders
+*/
static void
readonly_folders (void)