Changeset 12:675b8418ed59 in xplcommon


Ignore:
Timestamp:
12/29/12 09:21:06 (11 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
hg-Phase:
(<MercurialRepository 2 'hg:/home/ivaradi/xplane/hg/xplcommon' '/'>, 'public')
Message:

Implemented the missing function

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TODO

    r11 r12  
    11- POSIX: make the Waitable Failable
     2- POSIX: the buffered waitable should be renamed BufferedStream (or something like that), and made public
  • 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.