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
10
static
void
(*
sigpipe
)(
int
);
11
#endif
12
13
FILE
*
G_open_pager
(
struct
Popen
*
pager
)
14
{
15
const
char
*
program
=
getenv
(
"GRASS_PAGER"
);
16
FILE
*fp;
17
18
G_popen_clear
(
pager
);
19
20
if
(!
program
)
21
return
stdout
;
22
23
if
(!
isatty
(
STDOUT_FILENO
))
24
return
stdout
;
25
26
#ifdef SIGPIPE
27
sigpipe
= signal(
SIGPIPE
,
SIG_IGN
);
28
#endif
29
30
fp =
G_popen_write
(
pager
,
program
,
NULL
);
31
32
return
fp ? fp :
stdout
;
33
}
34
35
void
G_close_pager
(
struct
Popen
*
pager
)
36
{
37
G_popen_close
(
pager
);
38
39
#ifdef SIGPIPE
40
if
(
sigpipe
)
41
signal(
SIGPIPE
,
sigpipe
);
42
#endif
43
}
44
45
FILE
*
G_open_mail
(
struct
Popen
*
mail
)
46
{
47
const
char
*user =
G_whoami
();
48
const
char
*
argv
[3];
49
FILE
*fp;
50
51
G_popen_clear
(
mail
);
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
65
void
G_close_mail
(
struct
Popen
*
mail
)
66
{
67
G_popen_close
(
mail
);
68
}
NULL
#define NULL
Definition
ccmath.h:32
AMI_STREAM
Definition
ami_stream.h:153
G_popen_clear
void G_popen_clear(struct Popen *)
Definition
popen.c:56
G_popen_close
void G_popen_close(struct Popen *)
Definition
popen.c:72
G_whoami
const char * G_whoami(void)
Gets user's name.
Definition
gis/whoami.c:34
G_popen_write
FILE * G_popen_write(struct Popen *, const char *, const char **)
Definition
popen.c:62
gis.h
G_close_mail
void G_close_mail(struct Popen *mail)
Definition
pager.c:65
G_open_pager
FILE * G_open_pager(struct Popen *pager)
Definition
pager.c:13
G_open_mail
FILE * G_open_mail(struct Popen *mail)
Definition
pager.c:45
G_close_pager
void G_close_pager(struct Popen *pager)
Definition
pager.c:35
stdio.h
stdlib.h
Popen
Definition
gis.h:629
unistd.h
STDOUT_FILENO
#define STDOUT_FILENO
Definition
unistd.h:28
isatty
#define isatty
Definition
unistd.h:12
lib
gis
pager.c
Generated on Fri Apr 3 2026 06:59:53 for GRASS 8 Programmer's Manual by
1.9.8