source: trunk/third/libgtop/lib/lib.c @ 20897

Revision 20897, 21.6 KB checked in by ghudson, 20 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r20896, which included commits to RCS files with non-trunk default branches.
Line 
1/* lib.c */
2/* This is a generated file.  Please modify `lib.pl' */
3
4#include <config.h>
5
6#include <glibtop.h>
7#include <glibtop/open.h>
8
9#include <glibtop/sysdeps.h>
10#include <glibtop/union.h>
11#include "libgtop-i18n.h"
12
13#include <glibtop/command.h>
14
15/* Some required fields are missing. */
16
17static void
18_glibtop_missing_feature (glibtop *server, const char *feature,
19                          const guint64 present, guint64 *required)
20{
21        guint64 old_required = *required;
22
23        /* Return if we have all required fields. */
24        if ((~present & old_required) == 0)
25                return;
26
27        switch (server->error_method) {
28        case GLIBTOP_ERROR_METHOD_WARN_ONCE:
29                *required &= present;
30        case GLIBTOP_ERROR_METHOD_WARN:
31                glibtop_warn_r (server,
32                                _("glibtop_get_%s (): Client requested "
33                                  "field mask %05lx, but only have %05lx."),
34                                 feature, (unsigned long) old_required,
35                                 (unsigned long) present);
36                break;
37        case GLIBTOP_ERROR_METHOD_ABORT:
38                glibtop_error_r (server,
39                                 _("glibtop_get_%s (): Client requested "
40                                  "field mask %05lx, but only have %05lx."),
41                                 feature, (unsigned long) old_required,
42                                 (unsigned long) present);
43                break;
44        }
45}
46
47/* Library functions. */
48
49void
50glibtop_get_cpu_l (glibtop *server, glibtop_cpu *buf)
51{
52        const void *send_ptr = NULL;
53        const size_t send_size = 0;
54
55        glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_CPU), 0);
56
57        /* If neccessary, we ask the server for the requested
58         * feature. If not, we call the sysdeps function. */
59
60        if ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&
61            (server->features & (1 << GLIBTOP_SYSDEPS_CPU)))
62        {
63                glibtop_call_l (server, GLIBTOP_CMND_CPU,
64                                send_size, send_ptr,
65                                sizeof (glibtop_cpu), buf);
66        } else {
67#if (!GLIBTOP_SUID_CPU)
68                glibtop_get_cpu_s (server, buf);
69#else
70                errno = ENOSYS;
71                glibtop_error_io_r (server, "glibtop_get_cpu");
72#endif
73        }
74
75        /* Make sure that all required fields are present. */
76
77        if (buf->flags & server->required.cpu)
78                _glibtop_missing_feature (server, "cpu", buf->flags,
79                                          &server->required.cpu);
80}
81
82void
83glibtop_get_mem_l (glibtop *server, glibtop_mem *buf)
84{
85        const void *send_ptr = NULL;
86        const size_t send_size = 0;
87
88        glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_MEM), 0);
89
90        /* If neccessary, we ask the server for the requested
91         * feature. If not, we call the sysdeps function. */
92
93        if ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&
94            (server->features & (1 << GLIBTOP_SYSDEPS_MEM)))
95        {
96                glibtop_call_l (server, GLIBTOP_CMND_MEM,
97                                send_size, send_ptr,
98                                sizeof (glibtop_mem), buf);
99        } else {
100#if (!GLIBTOP_SUID_MEM)
101                glibtop_get_mem_s (server, buf);
102#else
103                errno = ENOSYS;
104                glibtop_error_io_r (server, "glibtop_get_mem");
105#endif
106        }
107
108        /* Make sure that all required fields are present. */
109
110        if (buf->flags & server->required.mem)
111                _glibtop_missing_feature (server, "mem", buf->flags,
112                                          &server->required.mem);
113}
114
115void
116glibtop_get_swap_l (glibtop *server, glibtop_swap *buf)
117{
118        const void *send_ptr = NULL;
119        const size_t send_size = 0;
120
121        glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_SWAP), 0);
122
123        /* If neccessary, we ask the server for the requested
124         * feature. If not, we call the sysdeps function. */
125
126        if ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&
127            (server->features & (1 << GLIBTOP_SYSDEPS_SWAP)))
128        {
129                glibtop_call_l (server, GLIBTOP_CMND_SWAP,
130                                send_size, send_ptr,
131                                sizeof (glibtop_swap), buf);
132        } else {
133#if (!GLIBTOP_SUID_SWAP)
134                glibtop_get_swap_s (server, buf);
135#else
136                errno = ENOSYS;
137                glibtop_error_io_r (server, "glibtop_get_swap");
138#endif
139        }
140
141        /* Make sure that all required fields are present. */
142
143        if (buf->flags & server->required.swap)
144                _glibtop_missing_feature (server, "swap", buf->flags,
145                                          &server->required.swap);
146}
147
148void
149glibtop_get_uptime_l (glibtop *server, glibtop_uptime *buf)
150{
151        const void *send_ptr = NULL;
152        const size_t send_size = 0;
153
154        glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_UPTIME), 0);
155
156        /* If neccessary, we ask the server for the requested
157         * feature. If not, we call the sysdeps function. */
158
159        if ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&
160            (server->features & (1 << GLIBTOP_SYSDEPS_UPTIME)))
161        {
162                glibtop_call_l (server, GLIBTOP_CMND_UPTIME,
163                                send_size, send_ptr,
164                                sizeof (glibtop_uptime), buf);
165        } else {
166#if (!GLIBTOP_SUID_UPTIME)
167                glibtop_get_uptime_s (server, buf);
168#else
169                errno = ENOSYS;
170                glibtop_error_io_r (server, "glibtop_get_uptime");
171#endif
172        }
173
174        /* Make sure that all required fields are present. */
175
176        if (buf->flags & server->required.uptime)
177                _glibtop_missing_feature (server, "uptime", buf->flags,
178                                          &server->required.uptime);
179}
180
181void
182glibtop_get_loadavg_l (glibtop *server, glibtop_loadavg *buf)
183{
184        const void *send_ptr = NULL;
185        const size_t send_size = 0;
186
187        glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_LOADAVG), 0);
188
189        /* If neccessary, we ask the server for the requested
190         * feature. If not, we call the sysdeps function. */
191
192        if ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&
193            (server->features & (1 << GLIBTOP_SYSDEPS_LOADAVG)))
194        {
195                glibtop_call_l (server, GLIBTOP_CMND_LOADAVG,
196                                send_size, send_ptr,
197                                sizeof (glibtop_loadavg), buf);
198        } else {
199#if (!GLIBTOP_SUID_LOADAVG)
200                glibtop_get_loadavg_s (server, buf);
201#else
202                errno = ENOSYS;
203                glibtop_error_io_r (server, "glibtop_get_loadavg");
204#endif
205        }
206
207        /* Make sure that all required fields are present. */
208
209        if (buf->flags & server->required.loadavg)
210                _glibtop_missing_feature (server, "loadavg", buf->flags,
211                                          &server->required.loadavg);
212}
213
214void
215glibtop_get_shm_limits_l (glibtop *server, glibtop_shm_limits *buf)
216{
217        const void *send_ptr = NULL;
218        const size_t send_size = 0;
219
220        glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_SHM_LIMITS), 0);
221
222        /* If neccessary, we ask the server for the requested
223         * feature. If not, we call the sysdeps function. */
224
225        if ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&
226            (server->features & (1 << GLIBTOP_SYSDEPS_SHM_LIMITS)))
227        {
228                glibtop_call_l (server, GLIBTOP_CMND_SHM_LIMITS,
229                                send_size, send_ptr,
230                                sizeof (glibtop_shm_limits), buf);
231        } else {
232#if (!GLIBTOP_SUID_SHM_LIMITS)
233                glibtop_get_shm_limits_s (server, buf);
234#else
235                errno = ENOSYS;
236                glibtop_error_io_r (server, "glibtop_get_shm_limits");
237#endif
238        }
239
240        /* Make sure that all required fields are present. */
241
242        if (buf->flags & server->required.shm_limits)
243                _glibtop_missing_feature (server, "shm_limits", buf->flags,
244                                          &server->required.shm_limits);
245}
246
247void
248glibtop_get_msg_limits_l (glibtop *server, glibtop_msg_limits *buf)
249{
250        const void *send_ptr = NULL;
251        const size_t send_size = 0;
252
253        glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_MSG_LIMITS), 0);
254
255        /* If neccessary, we ask the server for the requested
256         * feature. If not, we call the sysdeps function. */
257
258        if ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&
259            (server->features & (1 << GLIBTOP_SYSDEPS_MSG_LIMITS)))
260        {
261                glibtop_call_l (server, GLIBTOP_CMND_MSG_LIMITS,
262                                send_size, send_ptr,
263                                sizeof (glibtop_msg_limits), buf);
264        } else {
265#if (!GLIBTOP_SUID_MSG_LIMITS)
266                glibtop_get_msg_limits_s (server, buf);
267#else
268                errno = ENOSYS;
269                glibtop_error_io_r (server, "glibtop_get_msg_limits");
270#endif
271        }
272
273        /* Make sure that all required fields are present. */
274
275        if (buf->flags & server->required.msg_limits)
276                _glibtop_missing_feature (server, "msg_limits", buf->flags,
277                                          &server->required.msg_limits);
278}
279
280void
281glibtop_get_sem_limits_l (glibtop *server, glibtop_sem_limits *buf)
282{
283        const void *send_ptr = NULL;
284        const size_t send_size = 0;
285
286        glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_SEM_LIMITS), 0);
287
288        /* If neccessary, we ask the server for the requested
289         * feature. If not, we call the sysdeps function. */
290
291        if ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&
292            (server->features & (1 << GLIBTOP_SYSDEPS_SEM_LIMITS)))
293        {
294                glibtop_call_l (server, GLIBTOP_CMND_SEM_LIMITS,
295                                send_size, send_ptr,
296                                sizeof (glibtop_sem_limits), buf);
297        } else {
298#if (!GLIBTOP_SUID_SEM_LIMITS)
299                glibtop_get_sem_limits_s (server, buf);
300#else
301                errno = ENOSYS;
302                glibtop_error_io_r (server, "glibtop_get_sem_limits");
303#endif
304        }
305
306        /* Make sure that all required fields are present. */
307
308        if (buf->flags & server->required.sem_limits)
309                _glibtop_missing_feature (server, "sem_limits", buf->flags,
310                                          &server->required.sem_limits);
311}
312
313unsigned *
314glibtop_get_proclist_l (glibtop *server, glibtop_proclist *buf,
315                        gint64 which, gint64 arg)
316{
317        const void *send_ptr = &which;
318        const size_t send_size =
319                sizeof (which) + sizeof (arg);
320        unsigned * retval = (unsigned *) 0;
321
322        glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_PROCLIST), 0);
323
324        /* If neccessary, we ask the server for the requested
325         * feature. If not, we call the sysdeps function. */
326
327        if ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&
328            (server->features & (1 << GLIBTOP_SYSDEPS_PROCLIST)))
329        {
330                retval = glibtop_call_l (server, GLIBTOP_CMND_PROCLIST,
331                                         send_size, send_ptr,
332                                         sizeof (glibtop_proclist), buf);
333        } else {
334#if (!GLIBTOP_SUID_PROCLIST)
335                retval = glibtop_get_proclist_s (server, buf, which, arg);
336#else
337                errno = ENOSYS;
338                glibtop_error_io_r (server, "glibtop_get_proclist");
339#endif
340        }
341
342        /* Make sure that all required fields are present. */
343
344        if (buf->flags & server->required.proclist)
345                _glibtop_missing_feature (server, "proclist", buf->flags,
346                                          &server->required.proclist);
347
348        /* Now we can return. */
349
350        return retval;
351}
352
353void
354glibtop_get_proc_state_l (glibtop *server, glibtop_proc_state *buf,
355                          pid_t pid)
356{
357        const void *send_ptr = &pid;
358        const size_t send_size =
359                sizeof (pid);
360
361        glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_PROC_STATE), 0);
362
363        /* If neccessary, we ask the server for the requested
364         * feature. If not, we call the sysdeps function. */
365
366        if ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&
367            (server->features & (1 << GLIBTOP_SYSDEPS_PROC_STATE)))
368        {
369                glibtop_call_l (server, GLIBTOP_CMND_PROC_STATE,
370                                send_size, send_ptr,
371                                sizeof (glibtop_proc_state), buf);
372        } else {
373#if (!GLIBTOP_SUID_PROC_STATE)
374                glibtop_get_proc_state_s (server, buf, pid);
375#else
376                errno = ENOSYS;
377                glibtop_error_io_r (server, "glibtop_get_proc_state");
378#endif
379        }
380
381        /* Make sure that all required fields are present. */
382
383        if (buf->flags & server->required.proc_state)
384                _glibtop_missing_feature (server, "proc_state", buf->flags,
385                                          &server->required.proc_state);
386}
387
388void
389glibtop_get_proc_uid_l (glibtop *server, glibtop_proc_uid *buf,
390                        pid_t pid)
391{
392        const void *send_ptr = &pid;
393        const size_t send_size =
394                sizeof (pid);
395
396        glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_PROC_UID), 0);
397
398        /* If neccessary, we ask the server for the requested
399         * feature. If not, we call the sysdeps function. */
400
401        if ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&
402            (server->features & (1 << GLIBTOP_SYSDEPS_PROC_UID)))
403        {
404                glibtop_call_l (server, GLIBTOP_CMND_PROC_UID,
405                                send_size, send_ptr,
406                                sizeof (glibtop_proc_uid), buf);
407        } else {
408#if (!GLIBTOP_SUID_PROC_UID)
409                glibtop_get_proc_uid_s (server, buf, pid);
410#else
411                errno = ENOSYS;
412                glibtop_error_io_r (server, "glibtop_get_proc_uid");
413#endif
414        }
415
416        /* Make sure that all required fields are present. */
417
418        if (buf->flags & server->required.proc_uid)
419                _glibtop_missing_feature (server, "proc_uid", buf->flags,
420                                          &server->required.proc_uid);
421}
422
423void
424glibtop_get_proc_mem_l (glibtop *server, glibtop_proc_mem *buf,
425                        pid_t pid)
426{
427        const void *send_ptr = &pid;
428        const size_t send_size =
429                sizeof (pid);
430
431        glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_PROC_MEM), 0);
432
433        /* If neccessary, we ask the server for the requested
434         * feature. If not, we call the sysdeps function. */
435
436        if ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&
437            (server->features & (1 << GLIBTOP_SYSDEPS_PROC_MEM)))
438        {
439                glibtop_call_l (server, GLIBTOP_CMND_PROC_MEM,
440                                send_size, send_ptr,
441                                sizeof (glibtop_proc_mem), buf);
442        } else {
443#if (!GLIBTOP_SUID_PROC_MEM)
444                glibtop_get_proc_mem_s (server, buf, pid);
445#else
446                errno = ENOSYS;
447                glibtop_error_io_r (server, "glibtop_get_proc_mem");
448#endif
449        }
450
451        /* Make sure that all required fields are present. */
452
453        if (buf->flags & server->required.proc_mem)
454                _glibtop_missing_feature (server, "proc_mem", buf->flags,
455                                          &server->required.proc_mem);
456}
457
458void
459glibtop_get_proc_time_l (glibtop *server, glibtop_proc_time *buf,
460                         pid_t pid)
461{
462        const void *send_ptr = &pid;
463        const size_t send_size =
464                sizeof (pid);
465
466        glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_PROC_TIME), 0);
467
468        /* If neccessary, we ask the server for the requested
469         * feature. If not, we call the sysdeps function. */
470
471        if ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&
472            (server->features & (1 << GLIBTOP_SYSDEPS_PROC_TIME)))
473        {
474                glibtop_call_l (server, GLIBTOP_CMND_PROC_TIME,
475                                send_size, send_ptr,
476                                sizeof (glibtop_proc_time), buf);
477        } else {
478#if (!GLIBTOP_SUID_PROC_TIME)
479                glibtop_get_proc_time_s (server, buf, pid);
480#else
481                errno = ENOSYS;
482                glibtop_error_io_r (server, "glibtop_get_proc_time");
483#endif
484        }
485
486        /* Make sure that all required fields are present. */
487
488        if (buf->flags & server->required.proc_time)
489                _glibtop_missing_feature (server, "proc_time", buf->flags,
490                                          &server->required.proc_time);
491}
492
493void
494glibtop_get_proc_signal_l (glibtop *server, glibtop_proc_signal *buf,
495                           pid_t pid)
496{
497        const void *send_ptr = &pid;
498        const size_t send_size =
499                sizeof (pid);
500
501        glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_PROC_SIGNAL), 0);
502
503        /* If neccessary, we ask the server for the requested
504         * feature. If not, we call the sysdeps function. */
505
506        if ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&
507            (server->features & (1 << GLIBTOP_SYSDEPS_PROC_SIGNAL)))
508        {
509                glibtop_call_l (server, GLIBTOP_CMND_PROC_SIGNAL,
510                                send_size, send_ptr,
511                                sizeof (glibtop_proc_signal), buf);
512        } else {
513#if (!GLIBTOP_SUID_PROC_SIGNAL)
514                glibtop_get_proc_signal_s (server, buf, pid);
515#else
516                errno = ENOSYS;
517                glibtop_error_io_r (server, "glibtop_get_proc_signal");
518#endif
519        }
520
521        /* Make sure that all required fields are present. */
522
523        if (buf->flags & server->required.proc_signal)
524                _glibtop_missing_feature (server, "proc_signal", buf->flags,
525                                          &server->required.proc_signal);
526}
527
528void
529glibtop_get_proc_kernel_l (glibtop *server, glibtop_proc_kernel *buf,
530                           pid_t pid)
531{
532        const void *send_ptr = &pid;
533        const size_t send_size =
534                sizeof (pid);
535
536        glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_PROC_KERNEL), 0);
537
538        /* If neccessary, we ask the server for the requested
539         * feature. If not, we call the sysdeps function. */
540
541        if ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&
542            (server->features & (1 << GLIBTOP_SYSDEPS_PROC_KERNEL)))
543        {
544                glibtop_call_l (server, GLIBTOP_CMND_PROC_KERNEL,
545                                send_size, send_ptr,
546                                sizeof (glibtop_proc_kernel), buf);
547        } else {
548#if (!GLIBTOP_SUID_PROC_KERNEL)
549                glibtop_get_proc_kernel_s (server, buf, pid);
550#else
551                errno = ENOSYS;
552                glibtop_error_io_r (server, "glibtop_get_proc_kernel");
553#endif
554        }
555
556        /* Make sure that all required fields are present. */
557
558        if (buf->flags & server->required.proc_kernel)
559                _glibtop_missing_feature (server, "proc_kernel", buf->flags,
560                                          &server->required.proc_kernel);
561}
562
563void
564glibtop_get_proc_segment_l (glibtop *server, glibtop_proc_segment *buf,
565                            pid_t pid)
566{
567        const void *send_ptr = &pid;
568        const size_t send_size =
569                sizeof (pid);
570
571        glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_PROC_SEGMENT), 0);
572
573        /* If neccessary, we ask the server for the requested
574         * feature. If not, we call the sysdeps function. */
575
576        if ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&
577            (server->features & (1 << GLIBTOP_SYSDEPS_PROC_SEGMENT)))
578        {
579                glibtop_call_l (server, GLIBTOP_CMND_PROC_SEGMENT,
580                                send_size, send_ptr,
581                                sizeof (glibtop_proc_segment), buf);
582        } else {
583#if (!GLIBTOP_SUID_PROC_SEGMENT)
584                glibtop_get_proc_segment_s (server, buf, pid);
585#else
586                errno = ENOSYS;
587                glibtop_error_io_r (server, "glibtop_get_proc_segment");
588#endif
589        }
590
591        /* Make sure that all required fields are present. */
592
593        if (buf->flags & server->required.proc_segment)
594                _glibtop_missing_feature (server, "proc_segment", buf->flags,
595                                          &server->required.proc_segment);
596}
597
598char *
599glibtop_get_proc_args_l (glibtop *server, glibtop_proc_args *buf,
600                         pid_t pid, unsigned max_len)
601{
602        const void *send_ptr = &pid;
603        const size_t send_size =
604                sizeof (pid) + sizeof (max_len);
605        char * retval = (char *) 0;
606
607        glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_PROC_ARGS), 0);
608
609        /* If neccessary, we ask the server for the requested
610         * feature. If not, we call the sysdeps function. */
611
612        if ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&
613            (server->features & (1 << GLIBTOP_SYSDEPS_PROC_ARGS)))
614        {
615                retval = glibtop_call_l (server, GLIBTOP_CMND_PROC_ARGS,
616                                         send_size, send_ptr,
617                                         sizeof (glibtop_proc_args), buf);
618        } else {
619#if (!GLIBTOP_SUID_PROC_ARGS)
620                retval = glibtop_get_proc_args_s (server, buf, pid, max_len);
621#else
622                errno = ENOSYS;
623                glibtop_error_io_r (server, "glibtop_get_proc_args");
624#endif
625        }
626
627        /* Make sure that all required fields are present. */
628
629        if (buf->flags & server->required.proc_args)
630                _glibtop_missing_feature (server, "proc_args", buf->flags,
631                                          &server->required.proc_args);
632
633        /* Now we can return. */
634
635        return retval;
636}
637
638glibtop_map_entry *
639glibtop_get_proc_map_l (glibtop *server, glibtop_proc_map *buf,
640                        pid_t pid)
641{
642        const void *send_ptr = &pid;
643        const size_t send_size =
644                sizeof (pid);
645        glibtop_map_entry * retval = (glibtop_map_entry *) 0;
646
647        glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_PROC_MAP), 0);
648
649        /* If neccessary, we ask the server for the requested
650         * feature. If not, we call the sysdeps function. */
651
652        if ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&
653            (server->features & (1 << GLIBTOP_SYSDEPS_PROC_MAP)))
654        {
655                retval = glibtop_call_l (server, GLIBTOP_CMND_PROC_MAP,
656                                         send_size, send_ptr,
657                                         sizeof (glibtop_proc_map), buf);
658        } else {
659#if (!GLIBTOP_SUID_PROC_MAP)
660                retval = glibtop_get_proc_map_s (server, buf, pid);
661#else
662                errno = ENOSYS;
663                glibtop_error_io_r (server, "glibtop_get_proc_map");
664#endif
665        }
666
667        /* Make sure that all required fields are present. */
668
669        if (buf->flags & server->required.proc_map)
670                _glibtop_missing_feature (server, "proc_map", buf->flags,
671                                          &server->required.proc_map);
672
673        /* Now we can return. */
674
675        return retval;
676}
677
678glibtop_mountentry *
679glibtop_get_mountlist_l (glibtop *server, glibtop_mountlist *buf,
680                         int all_fs)
681{
682        const void *send_ptr = &all_fs;
683        const size_t send_size =
684                sizeof (all_fs);
685        glibtop_mountentry * retval = (glibtop_mountentry *) 0;
686
687        glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_MOUNTLIST), 0);
688
689        /* If neccessary, we ask the server for the requested
690         * feature. If not, we call the sysdeps function. */
691
692        if ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&
693            (server->features & (1 << GLIBTOP_SYSDEPS_MOUNTLIST)))
694        {
695                retval = glibtop_call_l (server, GLIBTOP_CMND_MOUNTLIST,
696                                         send_size, send_ptr,
697                                         sizeof (glibtop_mountlist), buf);
698        } else {
699                retval = glibtop_get_mountlist_s (server, buf, all_fs);
700        }
701
702        /* Make sure that all required fields are present. */
703
704        if (buf->flags & server->required.mountlist)
705                _glibtop_missing_feature (server, "mountlist", buf->flags,
706                                          &server->required.mountlist);
707
708        /* Now we can return. */
709
710        return retval;
711}
712
713void
714glibtop_get_fsusage_l (glibtop *server, glibtop_fsusage *buf,
715                       const char *mount_dir)
716{
717        const void *send_ptr = mount_dir;
718        const size_t send_size =
719                strlen (mount_dir) + 1;
720
721        glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_FSUSAGE), 0);
722
723        /* If neccessary, we ask the server for the requested
724         * feature. If not, we call the sysdeps function. */
725
726        if ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&
727            (server->features & (1 << GLIBTOP_SYSDEPS_FSUSAGE)))
728        {
729                glibtop_call_l (server, GLIBTOP_CMND_FSUSAGE,
730                                send_size, send_ptr,
731                                sizeof (glibtop_fsusage), buf);
732        } else {
733                glibtop_get_fsusage_s (server, buf, mount_dir);
734        }
735
736        /* Make sure that all required fields are present. */
737
738        if (buf->flags & server->required.fsusage)
739                _glibtop_missing_feature (server, "fsusage", buf->flags,
740                                          &server->required.fsusage);
741}
742
743void
744glibtop_get_netload_l (glibtop *server, glibtop_netload *buf,
745                       const char *interface)
746{
747        const void *send_ptr = interface;
748        const size_t send_size =
749                strlen (interface) + 1;
750
751        glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_NETLOAD), 0);
752
753        /* If neccessary, we ask the server for the requested
754         * feature. If not, we call the sysdeps function. */
755
756        if ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&
757            (server->features & (1 << GLIBTOP_SYSDEPS_NETLOAD)))
758        {
759                glibtop_call_l (server, GLIBTOP_CMND_NETLOAD,
760                                send_size, send_ptr,
761                                sizeof (glibtop_netload), buf);
762        } else {
763#if (!GLIBTOP_SUID_NETLOAD)
764                glibtop_get_netload_s (server, buf, interface);
765#else
766                errno = ENOSYS;
767                glibtop_error_io_r (server, "glibtop_get_netload");
768#endif
769        }
770
771        /* Make sure that all required fields are present. */
772
773        if (buf->flags & server->required.netload)
774                _glibtop_missing_feature (server, "netload", buf->flags,
775                                          &server->required.netload);
776}
777
778void
779glibtop_get_ppp_l (glibtop *server, glibtop_ppp *buf,
780                   unsigned short device)
781{
782        const void *send_ptr = &device;
783        const size_t send_size =
784                sizeof (device);
785
786        glibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_PPP), 0);
787
788        /* If neccessary, we ask the server for the requested
789         * feature. If not, we call the sysdeps function. */
790
791        if ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&
792            (server->features & (1 << GLIBTOP_SYSDEPS_PPP)))
793        {
794                glibtop_call_l (server, GLIBTOP_CMND_PPP,
795                                send_size, send_ptr,
796                                sizeof (glibtop_ppp), buf);
797        } else {
798#if (!GLIBTOP_SUID_PPP)
799                glibtop_get_ppp_s (server, buf, device);
800#else
801                errno = ENOSYS;
802                glibtop_error_io_r (server, "glibtop_get_ppp");
803#endif
804        }
805
806        /* Make sure that all required fields are present. */
807
808        if (buf->flags & server->required.ppp)
809                _glibtop_missing_feature (server, "ppp", buf->flags,
810                                          &server->required.ppp);
811}
812
Note: See TracBrowser for help on using the repository browser.