import-util.c revision 74eff91e5f118224c1e556d2716d5360dd97a87d
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2015 Lennart Poettering
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 "util.h"
#include "import-util.h"
const char *e, *p;
char *s;
e--;
p = e;
p--;
if (e <= p)
return -EINVAL;
s = strndup(p, e - p);
if (!s)
return -ENOMEM;
*ret = s;
return 0;
}
const char *e;
char *s;
e--;
e--;
if (e <= url)
return -EINVAL;
if (!s)
return -ENOMEM;
*ret = s;
return 0;
}
static const char* const import_verify_table[_IMPORT_VERIFY_MAX] = {
[IMPORT_VERIFY_NO] = "no",
[IMPORT_VERIFY_CHECKSUM] = "checksum",
[IMPORT_VERIFY_SIGNATURE] = "signature",
};
const char *e;
char *s;
if (!e)
if (!e)
if (!e)
if (!e)
if (!e)
if (e <= name)
return -EINVAL;
if (!s)
return -ENOMEM;
*ret = s;
return 0;
}
int raw_strip_suffixes(const char *p, char **ret) {
static const char suffixes[] =
".xz\0"
".gz\0"
".bz2\0"
".raw\0"
".qcow2\0"
".img\0"
".bin\0";
_cleanup_free_ char *q = NULL;
q = strdup(p);
if (!q)
return -ENOMEM;
for (;;) {
const char *sfx;
bool changed = false;
char *e;
if (e) {
*e = 0;
changed = true;
}
}
if (!changed)
break;
}
*ret = q;
q = NULL;
return 0;
}
bool dkr_digest_is_valid(const char *digest) {
/* 7 chars for prefix, 64 chars for the digest itself */
return false;
}
bool dkr_ref_is_valid(const char *ref) {
const char *colon;
return false;
if (!colon)
return filename_is_valid(ref);
return dkr_digest_is_valid(ref);
}
bool dkr_name_is_valid(const char *name) {
const char *slash, *p;
return false;
if (!slash)
return false;
return false;
if (!filename_is_valid(p))
return false;
return true;
}
bool dkr_id_is_valid(const char *id) {
if (!filename_is_valid(id))
return false;
return false;
return true;
}