GRASS 8 Programmer's Manual 8.6.0dev(2026)-1d1e47ad9d
Loading...
Searching...
No Matches
pager.c
Go to the documentation of this file.
1#include <stdio.h>
2#include <stdlib.h>
3#include <signal.h>
4
5#include <unistd.h>
6
7#include <grass/gis.h>
8
9#ifdef SIGPIPE
10static void (*sigpipe)(int);
11#endif
12
14{
15 const char *program = getenv("GRASS_PAGER");
16 FILE *fp;
17
19
20 if (!program)
21 return stdout;
22
24 return stdout;
25
26#ifdef SIGPIPE
27 sigpipe = signal(SIGPIPE, SIG_IGN);
28#endif
29
31
32 return fp ? fp : stdout;
33}
34
36{
38
39#ifdef SIGPIPE
40 if (sigpipe)
41 signal(SIGPIPE, sigpipe);
42#endif
43}
44
46{
47 const char *user = G_whoami();
48 const char *argv[3];
49 FILE *fp;
50
52
53 if (!user || !*user)
54 return NULL;
55
56 argv[0] = "mail";
57 argv[1] = user;
58 argv[2] = NULL;
59
60 fp = G_popen_write(mail, "mail", argv);
61
62 return fp;
63}
64
65void G_close_mail(struct Popen *mail)
66{
68}
#define NULL
Definition ccmath.h:32
void G_popen_clear(struct Popen *)
Definition popen.c:56
void G_popen_close(struct Popen *)
Definition popen.c:72
const char * G_whoami(void)
Gets user's name.
Definition gis/whoami.c:34
FILE * G_popen_write(struct Popen *, const char *, const char **)
Definition popen.c:62
void G_close_mail(struct Popen *mail)
Definition pager.c:65
FILE * G_open_pager(struct Popen *pager)
Definition pager.c:13
FILE * G_open_mail(struct Popen *mail)
Definition pager.c:45
void G_close_pager(struct Popen *pager)
Definition pager.c:35
Definition gis.h:629
#define STDOUT_FILENO
Definition unistd.h:28
#define isatty
Definition unistd.h:12