summaryrefslogtreecommitdiff
path: root/doc/internals.texi
blob: 4cb9c2d689f8ce766a9bd5e8f0d58937d31321cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
@node LibGTop Internals, , Reference Manual, Top
@chapter LibGTop Internals

@menu
* General Internals::           General Internals
* Sysdeps Internals::           Sysdeps Internals
@end menu

@node General Internals, Sysdeps Internals, LibGTop Internals, LibGTop Internals
@section General Internals

@menu
* glibtop::                     The server structure
@end menu

@node glibtop,  , General Internals, General Internals
@subsection The server structure - @code{glibtop}

@example
@cartouche
typedef struct _glibtop         glibtop;

struct _glibtop
@{
        unsigned flags;
        unsigned method;
        unsigned error_method;
#ifdef HAVE_GLIBTOP_MACHINE_H
        glibtop_machine machine;
#endif
        int input [2];
        int output [2];
        int socket;
        int ncpu;
        unsigned long os_version_code;
        const char *name;
        const char *server_command;
        const char *server_host;
        const char *server_user;
        const char *server_rsh;
        unsigned long features;
        unsigned long server_port;
        glibtop_sysdeps sysdeps;
        glibtop_sysdeps required;
        glibtop_sysdeps wanted;
        pid_t pid;
@};
@end cartouche
@end example

@node Sysdeps Internals,  , General Internals, LibGTop Internals
@section Sysdeps Internals

@menu
* glibtop_open_s::              Non-privileged initializations
* glibtop_close_s::             Non-privileged cleanups
@end menu

@node glibtop_open_s, glibtop_close_s, Sysdeps Internals, Sysdeps Internals
@subsection glibtop_open_s

This function is used in the non-suid sysdeps library @samp{-lgtop_sysdeps} to
initialize a server. It should do all initializations that do not need any
privileges.

@example
@cartouche
void
glibtop_open_s (glibtop *server, const char *program_name,
		const unsigned long features,
		const unsigned flags);
@end cartouche
@end example

@table @code
@item server
Pointer to the @code{glibtop} server structure.
@item program_name
Name of the calling program; the implementation will usually
set @samp{server->name} to this so it'll be used as the program
name in error messages.
@end table

Typically, this function will set @code{server->name}, @code{server->ncpu} and
@code{server->os_version_code} and initialize any of the @code{server->machine}
fields which do not need any privileges.

It is normally implemented in @file{open.c} in the sysdeps directory.

@node glibtop_close_s,  , glibtop_open_s, Sysdeps Internals
@subsection glibtop_close_s

This function is used in the non-suid sysdeps library @samp{-lgtop_sysdeps} to
clean-up a server when it's no longer used.

It must free all resources that were allocated in @code{glibtop_open_s}.

@example
@cartouche
void
glibtop_close_s (glibtop *server);
@end cartouche
@end example

It is normally implemented in @file{close.c} in the sysdeps directory, but may
be empty.