home *** CD-ROM | disk | FTP | other *** search
/ vsiftp.vmssoftware.com / VSIPUBLIC@vsiftp.vmssoftware.com.tar / FREEWARE / FREEWARE40.ZIP / flistfrontend / src / dclarea.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-04  |  1.1 KB  |  49 lines

  1. #ifndef NO_IDENT
  2. static char *Id = "$Id: dclarea.c,v 1.4 1995/06/04 01:47:57 tom Exp $";
  3. #endif
  4.  
  5. /*
  6.  * Title:    dclarea.c
  7.  * Author:    Thomas E. Dickey
  8.  * Created:    13 Apr 1985
  9.  * Last update:
  10.  *        19 Feb 1995, prototyped
  11.  *        15 Jun 1985, typed 'calloc'
  12.  *        13 Apr 1985
  13.  *
  14.  * Function:    Allocate a string-area for a DCLOPT-table entry so we needn't
  15.  *        have a lot of large static buffers lying around.
  16.  *
  17.  * Arguments:    name    - name of entry to find in table 'opt[]'.
  18.  *        size    - number of bytes to allocate
  19.  *        opt[]    - DCLOPT array of permissible options
  20.  *        size_opt - sizeof(opt[]).
  21.  *
  22.  * Returns:    Pointer to the allocated area.  The DCLOPT entry also points
  23.  *        to this area.
  24.  */
  25.  
  26. #include    <stdlib.h>
  27. #include    <string.h>
  28.  
  29. #include    "dclopt.h"
  30.  
  31. char    *dclarea (char *name, int size, DCLOPT *opt, int size_opt)
  32. {
  33.     register int    j;
  34.     register int    maxopt    = size_opt / sizeof(DCLOPT);
  35.     register char    *area;
  36.  
  37.     area = calloc(1,size);
  38.     for (j = 0; j < maxopt; j++)
  39.     {
  40.         if (strcmp (opt[j].opt_name, name) == 0)
  41.         {
  42.             opt[j].opt_area = area;
  43.             opt[j].opt_size = size;
  44.             break;
  45.         }
  46.     }
  47.     return (area);
  48. }
  49.