• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List

opensync/opensync_user.c

00001 /*
00002  * libopensync - A synchronization framework
00003  * Copyright (C) 2004-2005  Armin Bauer <armin.bauer@opensync.org>
00004  * 
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Lesser General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2.1 of the License, or (at your option) any later version.
00009  * 
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Lesser General Public License for more details.
00014  * 
00015  * You should have received a copy of the GNU Lesser General Public
00016  * License along with this library; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00018  * 
00019  */
00020  
00021 #include "opensync.h"
00022 #include "opensync_internals.h"
00023 
00031 
00032 
00040 OSyncUserInfo *osync_user_new(OSyncError **error)
00041 {
00042         OSyncUserInfo *user = osync_try_malloc0(sizeof(OSyncUserInfo), error);
00043         if (!user)
00044                 return NULL;
00045         
00046         user->uid = getuid();
00047         user->gid = getgid();
00048         
00049         user->homedir = g_get_home_dir();
00050         user->username = g_get_user_name();
00051         
00052         user->confdir = g_strdup_printf("%s/.opensync", user->homedir);
00053         
00054         osync_trace(TRACE_INTERNAL, "Detected User:\nUID: %i\nGID: %i\nHome: %s\nOSyncDir: %s", user->uid, user->gid, user->homedir, user->confdir);
00055         
00056         return user;
00057 }
00058 
00059 
00060 void osync_user_free(OSyncUserInfo *info)
00061 {
00062         g_free(info->confdir);
00063         
00064         g_free(info);
00065 }
00066 
00075 void osync_user_set_confdir(OSyncUserInfo *user, const char *path)
00076 {
00077         g_assert(user);
00078         
00079         if (user->confdir)
00080                 g_free(user->confdir);
00081         
00082         user->confdir = g_strdup(path);
00083 }
00084 
00093 const char *osync_user_get_confdir(OSyncUserInfo *user)
00094 {
00095         g_assert(user);
00096         return user->confdir;
00097 }
00098 

Generated on Sat Aug 13 2011 for OpenSync by  doxygen 1.7.1