File: System.c

package info (click to toggle)
fvwm2 2.0.46-BETA-3
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 5,172 kB
  • ctags: 5,559
  • sloc: ansic: 52,902; cpp: 2,465; perl: 2,275; python: 779; sh: 604; makefile: 221
file content (81 lines) | stat: -rw-r--r-- 1,461 bytes parent folder | download | duplicates (2)
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
/*
** System.c: code for dealing with various OS system call variants
*/

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

#if defined ___AIX || defined _AIX || defined __QNX__ || defined ___AIXV3 || defined AIXV3 || defined _SEQUENT_
#include <sys/select.h>
#endif

#include "../configure.h"

#if HAVE_UNAME
#include <sys/utsname.h>
#endif

#ifndef min
#define min(a,b) ((a)<(b)?(a):(b))
#endif

/*
** just in case...
*/
#ifndef FD_SETSIZE
#define FD_SETSIZE 2048
#endif

int GetFdWidth(void)
{
#ifdef HAVE_SYSCONF
  return min(sysconf(_SC_OPEN_MAX),FD_SETSIZE);
#else
  return min(getdtablesize(),FD_SETSIZE);
#endif
}

#if HAVE_UNAME
/* define mygethostname() by using uname() */
int mygethostname(char *client, int length)
{
  struct utsname sysname;
  
  uname(&sysname);
  strncpy(client,sysname.nodename,length);
}
/* return a string indicating the OS type (i.e. "Linux", "SINIX-D", ... ) */
int mygetostype(char *buf, int max)
{
  struct utsname sysname;
  int ret;
  
  if ((ret = uname(&sysname)) == -1)
    strcpy (buf,"");
  else
    strncat (strcpy(buf,""), sysname.sysname, max);
  return ret;
}
#else 
#if HAVE_GETHOSTNAME
/* define mygethostname() by using gethostname() :-) */

int mygethostname(char *client, int length)
{
  gethostname(client, length);
}
#else
int mygethostname(char *client, int length)
{
  *client = 0;
}
#endif
int mygetostype(char *buf, int max)
{
  strcpy (buf,"");
  return -1;
}
#endif