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