-static void
-print_folders (void)
-{
- int i, len, hasempty = 0, curprinted;
- int maxlen = 0, maxnummsg = 0, maxlowmsg = 0;
- int maxhghmsg = 0, maxcurmsg = 0, total_msgs = 0;
- int nummsgdigits, lowmsgdigits;
- int hghmsgdigits, curmsgdigits;
- char tmpname[BUFSIZ];
-
- /*
- * 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);
- if (len > maxlen)
- maxlen = len;
-
- /* If folder has error, skip the rest */
- if (fi[i].error)
- continue;
-
- /* calculate total number of messages */
- total_msgs += fi[i].nummsg;
-
- /* maximum number of messages */
- if (fi[i].nummsg > maxnummsg)
- maxnummsg = fi[i].nummsg;
-
- /* maximum low message */
- if (fi[i].lowmsg > maxlowmsg)
- maxlowmsg = fi[i].lowmsg;
-
- /* maximum high message */
- if (fi[i].hghmsg > maxhghmsg)
- maxhghmsg = fi[i].hghmsg;
-
- /* maximum current message */
- if (fi[i].curmsg >= fi[i].lowmsg &&
- fi[i].curmsg <= fi[i].hghmsg &&
- fi[i].curmsg > maxcurmsg)
- maxcurmsg = fi[i].curmsg;
-
- /* check for empty folders */
- if (fi[i].nummsg == 0)
- hasempty = 1;
- }
- nummsgdigits = num_digits (maxnummsg);
- lowmsgdigits = num_digits (maxlowmsg);
- hghmsgdigits = num_digits (maxhghmsg);
- curmsgdigits = num_digits (maxcurmsg);
-
- if (hasempty && nummsgdigits < 2)
- nummsgdigits = 2;
-
- /*
- * Print the header
- */
- if (fheader > 0 || (all && !fshort && fheader >= 0))
- printf ("%-*s %*s %-*s; %-*s %*s\n",
- maxlen+1, "FOLDER",
- nummsgdigits + 13, "# MESSAGES",
- lowmsgdigits + hghmsgdigits + 4, " RANGE",
- curmsgdigits + 4, "CUR",
- 9, "(OTHERS)");
-
- /*
- * Print folder information
- */
- if (all || fshort || ftotal < 1) {
- for (i = 0; i < total_folders; i++) {
- if (fshort) {
- printf ("%s\n", fi[i].name);
- continue;
- }
-
- /* Add `+' to end of name, if folder is current */
- if (strcmp (folder, fi[i].name))
- snprintf (tmpname, sizeof(tmpname), "%s", fi[i].name);
- else
- snprintf (tmpname, sizeof(tmpname), "%s+", fi[i].name);
-
- if (fi[i].error) {
- printf ("%-*s is unreadable\n", maxlen+1, tmpname);
- continue;
- }
-
- printf ("%-*s ", maxlen+1, tmpname);
-
- curprinted = 0; /* remember if we print cur */
- if (fi[i].nummsg == 0) {
- printf ("has %*s messages%*s",
- nummsgdigits, "no",
- fi[i].others ? lowmsgdigits + hghmsgdigits + 5 : 0, "");
- } else {
- printf ("has %*d message%s (%*d-%*d)",
- nummsgdigits, fi[i].nummsg,
- (fi[i].nummsg == 1) ? " " : "s",
- lowmsgdigits, fi[i].lowmsg,
- hghmsgdigits, fi[i].hghmsg);
- if (fi[i].curmsg >= fi[i].lowmsg && fi[i].curmsg <= fi[i].hghmsg) {
- curprinted = 1;
- printf ("; cur=%*d", curmsgdigits, fi[i].curmsg);