LCOV - code coverage report
Current view: top level - basic - unit-name.h (source / functions) Hit Total Coverage
Test: systemd test coverage Lines: 2 2 100.0 %
Date: 2015-07-29 18:47:03 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
       2             : 
       3             : #pragma once
       4             : 
       5             : /***
       6             :   This file is part of systemd.
       7             : 
       8             :   Copyright 2010 Lennart Poettering
       9             : 
      10             :   systemd is free software; you can redistribute it and/or modify it
      11             :   under the terms of the GNU Lesser General Public License as published by
      12             :   the Free Software Foundation; either version 2.1 of the License, or
      13             :   (at your option) any later version.
      14             : 
      15             :   systemd is distributed in the hope that it will be useful, but
      16             :   WITHOUT ANY WARRANTY; without even the implied warranty of
      17             :   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
      18             :   Lesser General Public License for more details.
      19             : 
      20             :   You should have received a copy of the GNU Lesser General Public License
      21             :   along with systemd; If not, see <http://www.gnu.org/licenses/>.
      22             : ***/
      23             : 
      24             : #include <stdbool.h>
      25             : 
      26             : #include "macro.h"
      27             : 
      28             : #define UNIT_NAME_MAX 256
      29             : 
      30             : typedef enum UnitType UnitType;
      31             : typedef enum UnitLoadState UnitLoadState;
      32             : typedef enum UnitDependency UnitDependency;
      33             : 
      34             : enum UnitType {
      35             :         UNIT_SERVICE = 0,
      36             :         UNIT_SOCKET,
      37             :         UNIT_BUSNAME,
      38             :         UNIT_TARGET,
      39             :         UNIT_SNAPSHOT,
      40             :         UNIT_DEVICE,
      41             :         UNIT_MOUNT,
      42             :         UNIT_AUTOMOUNT,
      43             :         UNIT_SWAP,
      44             :         UNIT_TIMER,
      45             :         UNIT_PATH,
      46             :         UNIT_SLICE,
      47             :         UNIT_SCOPE,
      48             :         _UNIT_TYPE_MAX,
      49             :         _UNIT_TYPE_INVALID = -1
      50             : };
      51             : 
      52             : enum UnitLoadState {
      53             :         UNIT_STUB = 0,
      54             :         UNIT_LOADED,
      55             :         UNIT_NOT_FOUND,
      56             :         UNIT_ERROR,
      57             :         UNIT_MERGED,
      58             :         UNIT_MASKED,
      59             :         _UNIT_LOAD_STATE_MAX,
      60             :         _UNIT_LOAD_STATE_INVALID = -1
      61             : };
      62             : 
      63             : enum UnitDependency {
      64             :         /* Positive dependencies */
      65             :         UNIT_REQUIRES,
      66             :         UNIT_REQUIRES_OVERRIDABLE,
      67             :         UNIT_REQUISITE,
      68             :         UNIT_REQUISITE_OVERRIDABLE,
      69             :         UNIT_WANTS,
      70             :         UNIT_BINDS_TO,
      71             :         UNIT_PART_OF,
      72             : 
      73             :         /* Inverse of the above */
      74             :         UNIT_REQUIRED_BY,             /* inverse of 'requires' is 'required_by' */
      75             :         UNIT_REQUIRED_BY_OVERRIDABLE, /* inverse of 'requires_overridable' is 'required_by_overridable' */
      76             :         UNIT_REQUISITE_OF,            /* inverse of 'requisite' is 'requisite_of' */
      77             :         UNIT_REQUISITE_OF_OVERRIDABLE,/* inverse of 'requisite_overridable' is 'requisite_of_overridable' */
      78             :         UNIT_WANTED_BY,               /* inverse of 'wants' */
      79             :         UNIT_BOUND_BY,                /* inverse of 'binds_to' */
      80             :         UNIT_CONSISTS_OF,             /* inverse of 'part_of' */
      81             : 
      82             :         /* Negative dependencies */
      83             :         UNIT_CONFLICTS,               /* inverse of 'conflicts' is 'conflicted_by' */
      84             :         UNIT_CONFLICTED_BY,
      85             : 
      86             :         /* Order */
      87             :         UNIT_BEFORE,                  /* inverse of 'before' is 'after' and vice versa */
      88             :         UNIT_AFTER,
      89             : 
      90             :         /* On Failure */
      91             :         UNIT_ON_FAILURE,
      92             : 
      93             :         /* Triggers (i.e. a socket triggers a service) */
      94             :         UNIT_TRIGGERS,
      95             :         UNIT_TRIGGERED_BY,
      96             : 
      97             :         /* Propagate reloads */
      98             :         UNIT_PROPAGATES_RELOAD_TO,
      99             :         UNIT_RELOAD_PROPAGATED_FROM,
     100             : 
     101             :         /* Joins namespace of */
     102             :         UNIT_JOINS_NAMESPACE_OF,
     103             : 
     104             :         /* Reference information for GC logic */
     105             :         UNIT_REFERENCES,              /* Inverse of 'references' is 'referenced_by' */
     106             :         UNIT_REFERENCED_BY,
     107             : 
     108             :         _UNIT_DEPENDENCY_MAX,
     109             :         _UNIT_DEPENDENCY_INVALID = -1
     110             : };
     111             : 
     112             : typedef enum UnitNameFlags {
     113             :         UNIT_NAME_PLAIN = 1,      /* Allow foo.service */
     114             :         UNIT_NAME_INSTANCE = 2,   /* Allow foo@bar.service */
     115             :         UNIT_NAME_TEMPLATE = 4,   /* Allow foo@.service */
     116             :         UNIT_NAME_ANY = UNIT_NAME_PLAIN|UNIT_NAME_INSTANCE|UNIT_NAME_TEMPLATE,
     117             : } UnitNameFlags;
     118             : 
     119             : bool unit_name_is_valid(const char *n, UnitNameFlags flags) _pure_;
     120             : bool unit_prefix_is_valid(const char *p) _pure_;
     121             : bool unit_instance_is_valid(const char *i) _pure_;
     122             : bool unit_suffix_is_valid(const char *s) _pure_;
     123             : 
     124             : static inline int unit_prefix_and_instance_is_valid(const char *p) {
     125             :         /* For prefix+instance and instance the same rules apply */
     126             :         return unit_instance_is_valid(p);
     127             : }
     128             : 
     129             : int unit_name_to_prefix(const char *n, char **prefix);
     130             : int unit_name_to_instance(const char *n, char **instance);
     131             : int unit_name_to_prefix_and_instance(const char *n, char **ret);
     132             : 
     133             : UnitType unit_name_to_type(const char *n) _pure_;
     134             : 
     135             : int unit_name_change_suffix(const char *n, const char *suffix, char **ret);
     136             : 
     137             : int unit_name_build(const char *prefix, const char *instance, const char *suffix, char **ret);
     138             : 
     139             : char *unit_name_escape(const char *f);
     140             : int unit_name_unescape(const char *f, char **ret);
     141             : int unit_name_path_escape(const char *f, char **ret);
     142             : int unit_name_path_unescape(const char *f, char **ret);
     143             : 
     144             : int unit_name_replace_instance(const char *f, const char *i, char **ret);
     145             : 
     146             : int unit_name_template(const char *f, char **ret);
     147             : 
     148             : int unit_name_from_path(const char *path, const char *suffix, char **ret);
     149             : int unit_name_from_path_instance(const char *prefix, const char *path, const char *suffix, char **ret);
     150             : int unit_name_to_path(const char *name, char **ret);
     151             : 
     152             : char *unit_dbus_path_from_name(const char *name);
     153             : int unit_name_from_dbus_path(const char *path, char **name);
     154             : 
     155             : typedef enum UnitNameMangle {
     156             :         UNIT_NAME_NOGLOB,
     157             :         UNIT_NAME_GLOB,
     158             : } UnitNameMangle;
     159             : 
     160             : int unit_name_mangle_with_suffix(const char *name, UnitNameMangle allow_globs, const char *suffix, char **ret);
     161             : 
     162         154 : static inline int unit_name_mangle(const char *name, UnitNameMangle allow_globs, char **ret) {
     163         154 :         return unit_name_mangle_with_suffix(name, allow_globs, ".service", ret);
     164             : }
     165             : 
     166             : int slice_build_parent_slice(const char *slice, char **ret);
     167             : int slice_build_subslice(const char *slice, const char*name, char **subslice);
     168             : bool slice_name_is_valid(const char *name);
     169             : 
     170             : const char *unit_type_to_string(UnitType i) _const_;
     171             : UnitType unit_type_from_string(const char *s) _pure_;
     172             : 
     173             : const char *unit_load_state_to_string(UnitLoadState i) _const_;
     174             : UnitLoadState unit_load_state_from_string(const char *s) _pure_;
     175             : 
     176             : const char *unit_dependency_to_string(UnitDependency i) _const_;
     177             : UnitDependency unit_dependency_from_string(const char *s) _pure_;

Generated by: LCOV version 1.11