Skip to content

Commit

Permalink
More g_* functions usage
Browse files Browse the repository at this point in the history
Follow coding standard
  • Loading branch information
moobyfr authored and metalefty committed Mar 26, 2018
1 parent 0dcae63 commit 8dbda1a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
16 changes: 9 additions & 7 deletions sesman/sessionrecord.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,27 +60,29 @@ add_xtmp_entry(int pid, const char *line, const char *user, const char *rhostnam
*
* So the IP is the string up the two last colons
*/
int i = strlen(rhostname) - 1;
while ((i>0) && (rhostname[i] != ':')) {
int i = g_strlen(rhostname) - 1;
while ((i>0) && (rhostname[i] != ':'))
{
i--;
}
i--;
while ((i>0) && (rhostname[i] != ':')) {
while ((i>0) && (rhostname[i] != ':'))
{
i--;
}

hostname = g_strndup(rhostname, i);

memset(&ut, 0, sizeof(ut));
g_memset(&ut, 0, sizeof(ut));

ut.ut_type=state;
ut.ut_pid = pid;
gettimeofday(&tv, NULL);
ut.ut_tv.tv_sec = tv.tv_sec;
ut.ut_tv.tv_usec = tv.tv_usec;
strncpy(ut.ut_line, line , sizeof(ut.ut_line));
strncpy(ut.ut_user, user , sizeof(ut.ut_user));
strncpy(ut.ut_host, hostname, sizeof(ut.ut_host));
g_strncpy(ut.ut_line, line , sizeof(ut.ut_line));
g_strncpy(ut.ut_user, user , sizeof(ut.ut_user));
g_strncpy(ut.ut_host, hostname, sizeof(ut.ut_host));

/* utmp */
setutxent();
Expand Down
10 changes: 4 additions & 6 deletions sesman/sessionrecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,14 @@ typedef struct utmp _utmp;

#define XRDP_LINE_FORMAT "xrdp:%d"

int add_xtmp_entry(int pid, const char *line, const char *user, const char *rhostname, short state);

/**
* @brief functions for adding utmp entries. one at login, one for logout
*
* @brief
*
* @param pid
* @param pid of the session, display, login, and hostname
* @return 0
*/

int add_xtmp_entry(int pid, const char *line, const char *user, const char *rhostname, short state);

int utmp_login(int pid, int display, const char *user, const char *rhostname);

int utmp_logout(int pid, int display, const char *user, const char *rhostname);
Expand Down

0 comments on commit 8dbda1a

Please sign in to comment.