GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-d6dec75dd4
htmldriver/text.c
Go to the documentation of this file.
1 /* Text.c - save text string into last_text buffer */
2 
3 #include <stdlib.h>
4 #include <string.h>
5 #include <grass/gis.h>
6 #include "driverlib.h"
7 #include "htmlmap.h"
8 
9 void HTML_Text(const char *text)
10 {
11  int len = strlen(text);
12  const char *s;
13  char *d;
14 
15  if (len > html.last_text_len) {
17  html.last_text = (char *)G_malloc(len + 1);
18  html.last_text_len = len;
19  }
20 
21  /* copy string to last_text area, make sure we don't copy \n */
22  for (d = html.last_text, s = text; *s != '\0'; s++) {
23  if (*s != '\n') {
24  *d = *s;
25  d++;
26  }
27  }
28  *d = '\0';
29 }
void G_free(void *)
Free allocated memory.
Definition: gis/alloc.c:150
#define G_malloc(n)
Definition: defs/gis.h:94
struct html_state html
void HTML_Text(const char *text)
char * last_text
Definition: htmlmap.h:26
int last_text_len
Definition: htmlmap.h:27