Back to index

plt-scheme  4.2.1
Defines | Functions
Net.c File Reference
#include "gc.h"
#include "Net.h"
#include <pwd.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <netdb.h>

Go to the source code of this file.

Defines

#define WX_USE_GETHOSTBYNAME

Functions

int wxGetHostName (char *buf, int sz)
int wxGetEmailAddress (char *address, int maxSize)
int wxGetUserId (char *buf, int sz)
int wxGetUserName (char *buf, int sz)

Define Documentation

Definition at line 36 of file Net.c.


Function Documentation

int wxGetEmailAddress ( char *  address,
int  maxSize 
)

Definition at line 55 of file Net.c.

{
  char host[65];
  char user[65];
  char tmp[130];

  if (wxGetHostName(host, 64) == 0)
    return 0;
  if (wxGetUserId(user, 64) == 0)
    return 0;

  strcpy(tmp, user);
  strcat(tmp, "@");
  strcat(tmp, host);
  strncpy(address, tmp, maxSize - 1);
  address[maxSize-1] = '\0';
  return 1;
}

Here is the call graph for this function:

int wxGetHostName ( char *  buf,
int  sz 
)

Definition at line 40 of file Net.c.

{
#ifndef WX_USE_GETHOSTBYNAME
  return (sysinfo(SI_HOSTNAME, buf, sz - 1) != -1);
#else /* BSD Sockets */
  char name[255];
  /* Get hostname */
  if ((gethostname(name, sizeof(name)/sizeof(char)-1)) == -1)
    return 0;
  strncpy(buf, name, sz-1);
  buf[sz-1] = 0;
  return 1;
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

int wxGetUserId ( char *  buf,
int  sz 
)

Definition at line 74 of file Net.c.

{
  struct passwd *who;
  
  if ((who = getpwuid(getuid ())) != NULL) {
    strncpy (buf, who->pw_name, sz-1);
    buf[sz - 1]= 0;
    return 1;
  }
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int wxGetUserName ( char *  buf,
int  sz 
)

Definition at line 86 of file Net.c.

{
  struct passwd *who;
  
  if ((who = getpwuid (getuid ())) != NULL) {
    strncpy (buf, who->pw_gecos, sz - 1);
    buf[sz - 1]= 0;
    return 1;
  }
  return 0;
}

Here is the call graph for this function: