Changeset 12:675b8418ed59 in xplcommon for src


Ignore:
Timestamp:
12/29/12 09:21:06 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Implemented the missing function

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/xplcommon/posix/LocalServerSocket.cc

    r11 r12  
    3232#include "LocalServerSocket.h"
    3333
     34#include <cstdio>
    3435#include <cerrno>
    3536
     37#include <pwd.h>
    3638#include <unistd.h>
    3739
     
    4244
    4345using xplcommon::posix::LocalServerSocket;
     46
     47//------------------------------------------------------------------------------
     48
     49void LocalServerSocket::setupPath(struct sockaddr_un& addr, const char* name)
     50{
     51#ifndef P_tmpdir
     52#define P_tmpdir "/tmp"
     53#endif
     54    struct passwd* passwd = getpwuid(geteuid());
     55    const char* userName = (passwd==0) ? "unknown" : passwd->pw_name;
     56    snprintf(addr.sun_path, sizeof(addr.sun_path), "%s/%s-%s",
     57             P_tmpdir, name, userName);
     58}
    4459
    4560//------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.