1: #ifndef lint
   2: static char *sccsid = "@(#)scandir.c	1.3	(Berkeley) 6/26/87";
   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:     while ((dirent = readdir(dirp)) != NULL) {
  40:         artnum = atoi(dirent->d_name);
  41:         if (artnum != 0 && artnum >= low_msg && artnum <= high_msg)
  42:             art_array[num_arts++] = artnum;
  43:     }
  44: 
  45:     closedir(dirp);
  46: 
  47:     qsort((char *) art_array, num_arts, sizeof(int), intcmp);
  48: 
  49:     return (num_arts);
  50: }
  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:     return (*x - *y);
  69: }

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: 1987-06-26
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3017
Valid CSS Valid XHTML 1.0 Strict