summaryrefslogtreecommitdiff
path: root/app/fvwm/libs/System.c
blob: ca76560f6d385705428834c66d397c01edc181ea (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
/*
** System.c: code for dealing with various OS system call variants
*/

#include "config.h"

#include <unistd.h>

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


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


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

/* return a string indicating the OS type (i.e. "Linux", "SINIX-D", ... ) */
int getostype(char *buf, int max)
{
#if HAVE_UNAME
    struct utsname sysname;

    if ( uname( &sysname ) >= 0 ) {
	strlcpy( buf, sysname.sysname, max);
	return 0;
    }
#endif
    strlcpy (buf,"",max);
    return -1;
}