home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2002 April / pcpro0402.iso / essentials / graphics / Gimp / gimp-src-20001226.exe / src / gimp / unofficial-plug-ins / mathmap / internals.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-21  |  1.8 KB  |  70 lines

  1. /*
  2.  * internals.c
  3.  *
  4.  * MathMap
  5.  *
  6.  * Copyright (C) 1997-2000 Mark Probst
  7.  *
  8.  * This program is free software; you can redistribute it and/or
  9.  * modify it under the terms of the GNU General Public License
  10.  * as published by the Free Software Foundation; either version 2
  11.  * of the License, or (at your option) any later version.
  12.  *
  13.  * This program is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  * GNU General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU General Public License
  19.  * along with this program; if not, write to the Free Software
  20.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  */
  22.  
  23. #include <stdlib.h>
  24. #include <string.h>
  25.  
  26. #include "tags.h"
  27. #include "internals.h"
  28.  
  29. static internal_t *first = 0;
  30.  
  31. internal_t*
  32. register_internal (const char *name, int number, int length)
  33. {
  34.     internal_t *internal = (internal_t*)malloc(sizeof(internal_t));
  35.  
  36.     strncpy(internal->name, name, MAX_INTERNAL_LENGTH);
  37.     internal->name[MAX_INTERNAL_LENGTH] = '\0';
  38.     internal->value.number = number;
  39.     internal->value.length = length;
  40.     internal->next = first;
  41.     first = internal;
  42.  
  43.     return internal;
  44. }
  45.  
  46. internal_t*
  47. lookup_internal (const char *name, tuple_info_t *type)
  48. {
  49.     internal_t *internal;
  50.  
  51.     for (internal = first; internal != 0; internal = internal->next)
  52.     if (strcmp(internal->name, name) == 0)
  53.     {
  54.         *type = make_tuple_info(internal->value.number, internal->value.length);
  55.         internal->is_used = 1;
  56.         return internal;
  57.     }
  58.  
  59.     return 0;
  60. }
  61.  
  62. void
  63. internals_clear_used (void)
  64. {
  65.     internal_t *internal;
  66.  
  67.     for (internal = first; internal != 0; internal = internal->next)
  68.     internal->is_used = 0;
  69. }
  70.