File: util.c

package info (click to toggle)
mrtgutils 0.8.3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 124 kB
  • ctags: 42
  • sloc: ansic: 497; makefile: 32
file content (30 lines) | stat: -rw-r--r-- 552 bytes parent folder | download
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
#include "util.h"
#include <stdio.h>
#include <unistd.h>
#include <netdb.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>

void print_hostname(void)
{
  char hostname[255];
  struct hostent *h;

  gethostname(hostname, sizeof(hostname));
  h = gethostbyname(hostname);
  printf("%s\n", (h ? h->h_name : "(none)"));
}

void setD(int* c,const char* name, double* ar, double i)
{
  (*c)++;
  if ((*c) > 2) {
    fprintf(stderr, "%s:error: only two parameters at a time\n", name);
    exit(2);
  }

   ar[1] = i;
   if (*c == 1) ar[0] = i;
}