Extended the lentgh of user and host name. macro

This commit is contained in:
Sagi Dayan 2014-04-03 23:46:22 +03:00
parent c3286b0698
commit 16de16f34d

5
main.c
View file

@ -8,6 +8,7 @@
#define true 1 #define true 1
#define false 0 #define false 0
#define LEN 512 #define LEN 512
#define HOST_USER_LEN 20
#define PATH "/bin/" #define PATH "/bin/"
#define ERROR -1 #define ERROR -1
#define EXIT_1 256 #define EXIT_1 256
@ -68,7 +69,7 @@ int main()
*/ */
int getHostName(char* host) int getHostName(char* host)
{ {
if(gethostname(host, 10) != 0) if(gethostname(host, HOST_USER_LEN) != 0)
{ {
fprintf(stderr, "%s\n", "Error: while getting host name"); fprintf(stderr, "%s\n", "Error: while getting host name");
return ERROR; return ERROR;
@ -83,7 +84,7 @@ int main()
*/ */
int getUserName(char* name) int getUserName(char* name)
{ {
if(getlogin_r(name, 10) != 0) if(getlogin_r(name, HOST_USER_LEN) != 0)
{ {
fprintf(stderr, "%s\n", "Error: while getting User name"); fprintf(stderr, "%s\n", "Error: while getting User name");
return ERROR; return ERROR;