home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dream 52
/
Amiga_Dream_52.iso
/
Linux
/
Divers
/
yagirc-0.51.tar.gz
/
yagirc-0.51.tar
/
yagirc-0.51
/
os.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-04-23
|
819b
|
44 lines
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <glib.h>
#include <sys/types.h>
#include <unistd.h>
#include <pwd.h>
#ifndef HAS_STRUPR
char *strupr(char *str)
{
char *tmp;
for (tmp = str; *tmp != '\0'; tmp++) *tmp = toupper(*tmp);
return str;
}
#endif
char *convhome(char *fname)
{
struct passwd *pwd;
char *tmp, *home;
if (*fname != '~') return g_strdup(fname);
home = getenv("HOME");
if (home == NULL)
{
if ((pwd = getpwuid(getuid())) == NULL)
home = NULL;
else
home = pwd->pw_dir;
}
if (home == NULL || *home == '\0')
return g_strdup(fname); /* couldn't find home directory.. */
tmp = (char *) g_malloc(strlen(fname)+strlen(home));
sprintf(tmp, "%s%s", home, fname+1);
return tmp;
}