Mercurial > retraceit
view src/util_linux.c @ 44:73e6b6b12412
(issue 1,2) Make the column used for the Timestamp value configurable
If the column contains a number it is interpreted as seconds since
epoch. Otherwise its a verbatim copy of the column string.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Wed, 06 May 2015 19:45:26 +0200 |
parents | 147b08bc7d64 |
children | 9daf778feaf1 |
line wrap: on
line source
#ifndef WIN32 /* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik * Software engineering by Intevation GmbH * * This file is Free Software under the GNU GPL (v>=2) * and comes with ABSOLUTELY NO WARRANTY! * See LICENSE.txt for details. */ /**@file Linux implementation of functions declared in util.h */ #include "util.h" #include "string.h" #include "strhelp.h" #include "unistd.h" #include <sys/types.h> #include <pwd.h> char * get_proc_install_dir(const char *proc) { char *retval = NULL, *procpath = NULL, *p = NULL, buf[MAX_PATH_LINUX]; ssize_t ret; size_t path_len = 0; if (!proc) { return NULL; } xasprintf(&procpath, "/proc/%s/exe", proc); ret = readlink (procpath, buf, MAX_PATH_LINUX); xfree(procpath); procpath = NULL; if (ret <= 0) { return NULL; } buf[ret] = '\0'; /* cut off the filename */ p = strrchr (buf, '/'); if (p == NULL) { return NULL; } *(p + 1) = '\0'; path_len = strlen (buf); retval = xmalloc (path_len + 1); strncpy (retval, buf, path_len); retval[path_len] = '\0'; return retval; } char * get_install_dir() { return get_proc_install_dir("self"); } #endif