2 * Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
7 * Jérôme Duval, korli@users.berlios.de
8 * Axel Dörfler, axeld@pinc-software.de
12 #include <SupportDefs.h>
24 int _netstat(int fd
, char **output
, int verbose
);
25 int _socket_interrupt(void);
26 int closesocket(int socket
);
27 char *find_net_setting(net_settings
* settings
, const char* heading
,
28 const char* name
, char* value
, unsigned numBytes
);
29 status_t
set_net_setting(net_settings
* settings
, const char* heading
,
30 const char* name
, const char* value
);
31 int getusername(char *user
, size_t bufferLength
);
32 int getpassword(char *password
, size_t bufferLength
);
33 char *_netconfig_find(const char *heaading
, const char *name
, char *value
, int nbytes
);
37 int32 __gHErrnoTLS
= tls_allocate();
43 return (int *)tls_address(__gHErrnoTLS
);
48 _netstat(int fd
, char **output
, int verbose
)
55 _socket_interrupt(void)
62 closesocket(int socket
)
68 /* TODO: This is a terrible hack :(
69 * TODO: We should really get these settings values by parsing the real settings
73 find_net_setting(net_settings
* settings
, const char* heading
,
74 const char* name
, char* value
, unsigned numBytes
)
76 if (strcmp(heading
, "GLOBAL") != 0)
79 if (!strcmp(name
, "HOSTNAME"))
80 strlcpy(value
, "hostname", numBytes
);
81 else if (!strcmp(name
, "USERNAME"))
82 strlcpy(value
, "baron", numBytes
);
83 else if (!strcmp(name
, "PASSWORD"))
84 strlcpy(value
, "password", numBytes
);
85 else if (!strcmp(name
, "FTP_ENABLED"))
86 strlcpy(value
, "1", numBytes
);
87 else if (!strcmp(name
, "TELNETD_ENABLED"))
88 strlcpy(value
, "1", numBytes
);
97 set_net_setting(net_settings
* settings
, const char* heading
,
98 const char* name
, const char* value
)
100 return B_UNSUPPORTED
;
105 getusername(char *user
, size_t length
)
107 if (find_net_setting(NULL
, "GLOBAL", "USERNAME", user
, length
) == NULL
)
115 getpassword(char *password
, size_t length
)
117 if (find_net_setting(NULL
, "GLOBAL", "PASSWORD", password
, length
) == NULL
)
120 return strlen(password
);
124 _netconfig_find(const char *heading
, const char *name
, char *value
, int nbytes
)
126 return find_net_setting(NULL
, heading
, name
, value
, nbytes
);