1: #ifndef lint
   2: static char *sccsid = "@(#)scandir.c	1.2	(Berkeley) 3/5/86";
   3: #endif
   4: 
   5: #include "common.h"
   6: 
   7: /*
   8:  * scan_dir -- scan the current directory for news articles,
   9:  *	loading the article numbers into art_array.  Return
  10:  *	number of articles loaded.
  11:  *
  12:  *	Paramaters:	"low_msg", "high_msg" are the low
  13:  *			and high messages numbers in this
  14:  *			group; we ignore numbers outside this
  15:  *			range.
  16:  *
  17:  *	Returns:	Number of articles loaded into
  18:  *			array.
  19:  *
  20:  *	Side effects:	Changes "art_array".
  21:  */
  22: 
  23: extern  int intcmp();
  24: 
  25: scan_dir(low_msg, high_msg)
  26: int low_msg, high_msg;
  27: {
  28:     register struct direct  *dirent;
  29:     register DIR        *dirp;
  30:     int         artnum;
  31: 
  32:     num_arts = 0;
  33: 
  34:     dirp = opendir(".");
  35: 
  36:     if (dirp == NULL) {
  37:         return(0);
  38:     }
  39: 
  40:     while ((dirent = readdir(dirp)) != NULL) {
  41:         artnum = atoi(dirent->d_name);
  42:         if (artnum != 0 && artnum >= low_msg && artnum <= high_msg)
  43:             art_array[num_arts++] = artnum;
  44:     }
  45: 
  46:     closedir(dirp);
  47: 
  48:     qsort((char *) art_array, num_arts, sizeof(int), intcmp);
  49: 
  50:     return(num_arts);
  51: }
  52: 
  53: /*
  54:  * intcmp -- compare to integers.
  55:  *
  56:  *	Parameters:	"x", "y" point to the integers to be compared.
  57:  *
  58:  *	Returns:	-1 if "x" is less than "y",
  59:  *			0 if "x" equals "y", and
  60:  *			1 if "x" is greater than "y".
  61:  *
  62:  *	Side effects:	None.
  63:  */
  64: 
  65: intcmp(x, y)
  66: register int    *x, *y;
  67: {
  68:     if (*x < *y)
  69:         return (-1);
  70:     else if (*x > *y)
  71:         return (1);
  72:     return (0);
  73: }

Defined functions

intcmp defined in line 65; used 2 times
scan_dir defined in line 25; used 1 times

Defined variables

sccsid defined in line 2; never used
Last modified: 1986-03-21
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 935
Valid CSS Valid XHTML 1.0 Strict