]> git.proxmox.com Git - mirror_lxc.git/blobdiff - src/lxc/confile_utils.c
spelling: device
[mirror_lxc.git] / src / lxc / confile_utils.c
index 9b133147ada251d64bcc20efc290811ac057f80c..04926854d1134c11168e8dab2a2f694e030c17fb 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include "config.h"
-
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE 1
+#endif
+#include <arpa/inet.h>
 #include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <arpa/inet.h>
 
 #include "conf.h"
+#include "config.h"
 #include "confile.h"
 #include "confile_utils.h"
 #include "error.h"
@@ -540,7 +542,7 @@ int network_ifname(char *valuep, const char *value, size_t size)
 
        retlen = strlcpy(valuep, value, size);
        if (retlen >= size)
-               ERROR("Network devie name \"%s\" is too long (>= %zu)", value,
+               ERROR("Network device name \"%s\" is too long (>= %zu)", value,
                      size);
 
        return 0;
@@ -672,6 +674,21 @@ int lxc_get_conf_str(char *retv, int inlen, const char *value)
        return value_len;
 }
 
+int lxc_get_conf_bool(struct lxc_conf *c, char *retv, int inlen, bool v)
+{
+       int len;
+       int fulllen = 0;
+
+       if (!retv)
+               inlen = 0;
+       else
+               memset(retv, 0, inlen);
+
+       strprint(retv, inlen, "%d", v);
+
+       return fulllen;
+}
+
 int lxc_get_conf_int(struct lxc_conf *c, char *retv, int inlen, int v)
 {
        int len;
@@ -721,9 +738,9 @@ bool parse_limit_value(const char **value, rlim_t *res)
 {
        char *endptr = NULL;
 
-       if (strncmp(*value, "unlimited", sizeof("unlimited") - 1) == 0) {
+       if (strncmp(*value, "unlimited", STRLITERALLEN("unlimited")) == 0) {
                *res = RLIM_INFINITY;
-               *value += sizeof("unlimited") - 1;
+               *value += STRLITERALLEN("unlimited");
                return true;
        }