home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume10 / lemming / part01 / lemgroup.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-08-05  |  553 b   |  39 lines

  1. /*
  2.  * lemgroup.c - object group maintenance
  3.  *
  4.  * copyright (c) by Alan W. Paeth, 1987. All rights reserved.
  5.  */
  6.  
  7. #include "lem.h"
  8.  
  9. addgroup()
  10.     {
  11.     int i, g;
  12.     g = uniquegroup();
  13.     forobjects
  14.     {
  15.     if (Osel) Ogroup = g;
  16.     }
  17.     }
  18.  
  19. removegroup()
  20.     {
  21.     int i;
  22.     forobjects
  23.     {
  24.     if (Ogroup) Ogroup = 0;
  25.     }
  26.     }
  27.  
  28. uniquegroup()
  29.     {
  30.     int i, groups[256];
  31.     for(i=0; i<256; i++) groups[i] = 0;
  32.     for(i=1; i<lastobj; i++) groups[Ogroup]++;
  33.     for(i=1; i<256; i++)
  34.     {
  35.     if (groups[i] == 0) break;
  36.     }
  37.     return(groups[i] == 0 ? i : 0);
  38.     }
  39.