home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / fontutil.6 / fontutil / fontutils-0.6 / include / varstring.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-05-17  |  1.9 KB  |  64 lines

  1. /* varstring.h: variable-length strings.
  2.  
  3. Copyright (C) 1992 Free Software Foundation, Inc.
  4.  
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2, or (at your option)
  8. any later version.
  9.  
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  18.  
  19. #ifndef VARSTRING_H
  20. #define VARSTRING_H
  21.  
  22. #include "types.h"
  23.  
  24.  
  25. /* Initialize a variable-length string.  */
  26. typedef struct
  27. {
  28.   unsigned allocated;
  29.   unsigned used;
  30.   string data;
  31. } variable_string;
  32.  
  33. /* The data characters.  */
  34. #define VS_CHARS(vs) ((vs).data)
  35.  
  36. /* This is the number of bytes allocated for the string.  */
  37. #define VS_ALLOCATED(vs) ((vs).allocated)
  38.  
  39. /* This is the number of bytes used.  */
  40. #define VS_USED(vs) ((vs).used)
  41.  
  42.  
  43. /* Create a new structure, initializing the data to a null byte.  */
  44. extern variable_string vs_init (void);
  45.  
  46. /* Free the string.  */
  47. extern void vs_free (variable_string *);
  48.  
  49.  
  50. /* Put NEW_CHAR at position POS in S.  POS may be beyond the current
  51.    length of S.  You are responsible for putting a null at the end of
  52.    the string when you are done constructing it, if you want one.  */
  53. extern void vs_set_char (variable_string *s, unsigned pos, char new_char);
  54.  
  55. /* Put NEW_CHAR at the end of V.  As with `vs_set_char', no null is
  56.    appended.  */
  57. extern void vs_append_char (variable_string *v, char new_char);
  58.  
  59. /* Return concatenation of VS1 and VS2 in a new variable string.  */
  60. extern variable_string vs_concat (variable_string vs1, variable_string vs2);
  61.  
  62. #endif /* not VARSTRING_H */
  63.  
  64.