install-printf.c revision 19f6d710772305610b928bc2678b9d77fe11e770
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2013 Zbigniew Jędrzejewski-Szmek
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <assert.h>
#include <stdlib.h>
#include "specifier.h"
#include "unit-name.h"
#include "util.h"
#include "install-printf.h"
InstallInfo *i = userdata;
char *n;
assert(i);
n = unit_name_to_prefix_and_instance(i->name);
if (!n)
return -ENOMEM;
*ret = n;
return 0;
}
InstallInfo *i = userdata;
char *n;
assert(i);
n = unit_name_to_prefix(i->name);
if (!n)
return -ENOMEM;
*ret = n;
return 0;
}
InstallInfo *i = userdata;
char *instance;
int r;
assert(i);
if (r < 0)
return r;
if (!instance) {
if (!instance)
return -ENOMEM;
}
return 0;
}
InstallInfo *i = userdata;
const char *username;
assert(i);
if (i->user)
else
/* get USER env from env or our own uid */
switch (specifier) {
case 'u':
break;
case 'U': {
/* fish username from passwd */
int r;
if (r < 0)
return r;
return -ENOMEM;
break;
}}
return 0;
}
/* This is similar to unit_full_printf() but does not support
* anything path-related.
*
* %n: the full id of the unit (foo@bar.waldo)
* %N: the id of the unit without the suffix (foo@bar)
* %p: the prefix (foo)
* %i: the instance (bar)
* %U the UID of the configured user or running user
* %u the username of the configured user or running user
* %m the machine ID of the running system
* %H the host name of the running system
* %b the boot ID of the running system
* %v `uname -r` of the running system
*/
{}
};
assert(i);
}