Verified Commit 84ac7ebd authored by Max Rees's avatar Max Rees

src: update for blob.h & version.h

parent aff33e80
......@@ -9,28 +9,17 @@
* by the Free Software Foundation. See http://www.gnu.org/ for details.
*/
#ifndef APK_BLOB_H
#define APK_BLOB_H
#ifndef APK_BLOB_HI
#define APK_BLOB_HI
#include <ctype.h>
#include <string.h>
#include <apk/blob.h>
#include "apk_defines.h"
#include "apk_openssl.h"
typedef const unsigned char *apk_spn_match;
typedef unsigned char apk_spn_match_def[256 / 8];
struct apk_blob {
long len;
char *ptr;
};
typedef struct apk_blob apk_blob_t;
typedef int (*apk_blob_cb)(void *ctx, apk_blob_t blob);
extern apk_blob_t apk_null_blob;
#define BLOB_FMT "%.*s"
#define BLOB_PRINTF(b) (int)(b).len, (b).ptr
#define APK_CHECKSUM_NONE 0
#define APK_CHECKSUM_MD5 16
......@@ -61,31 +50,6 @@ static inline const EVP_MD *apk_checksum_default(void)
return apk_checksum_evp(APK_CHECKSUM_DEFAULT);
}
#define APK_BLOB_IS_NULL(blob) ((blob).ptr == NULL)
#define APK_BLOB_NULL ((apk_blob_t){0, NULL})
#define APK_BLOB_ERROR(err) ((apk_blob_t){err, NULL})
#define APK_BLOB_BUF(buf) ((apk_blob_t){sizeof(buf), (char *)(buf)})
#define APK_BLOB_CSUM(csum) ((apk_blob_t){(csum).type, (char *)(csum).data})
#define APK_BLOB_STRUCT(s) ((apk_blob_t){sizeof(s), (char*)&(s)})
#define APK_BLOB_PTR_LEN(beg,len) ((apk_blob_t){(len), (beg)})
#define APK_BLOB_PTR_PTR(beg,end) APK_BLOB_PTR_LEN((beg),(end)-(beg)+1)
static inline apk_blob_t APK_BLOB_STR(const char *str)
{
if (str == NULL)
return APK_BLOB_NULL;
return ((apk_blob_t){strlen(str), (void *)(str)});
}
static inline apk_blob_t apk_blob_trim(apk_blob_t blob)
{
apk_blob_t b = blob;
while (b.len > 0 && isspace(b.ptr[b.len-1]))
b.len--;
return b;
}
char *apk_blob_cstr(apk_blob_t str);
int apk_blob_spn(apk_blob_t blob, const apk_spn_match accept, apk_blob_t *l, apk_blob_t *r);
int apk_blob_cspn(apk_blob_t blob, const apk_spn_match reject, apk_blob_t *l, apk_blob_t *r);
......
......@@ -12,7 +12,7 @@
#ifndef APK_PKGDB_H
#define APK_PKGDB_H
#include "apk_version.h"
#include <apk/version.h>
#include "apk_hash.h"
#include "apk_archive.h"
#include "apk_package.h"
......
......@@ -12,7 +12,7 @@
#ifndef APK_PKG_H
#define APK_PKG_H
#include "apk_version.h"
#include <apk/version.h>
#include "apk_hash.h"
#include "apk_io.h"
#include "apk_solver_data.h"
......
......@@ -3,10 +3,10 @@
#include <lualib.h>
#include <lauxlib.h>
#include <apk/version.h>
#include "apk_blob.h"
#include "apk_database.h"
#include "apk_defines.h"
#include "apk_version.h"
#define LIBNAME "apk"
#define APK_DB_META "apk_database"
......
......@@ -5,7 +5,7 @@
* Copyright (C) 2017 William Pitcock <nenolod@dereferenced.org>
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation. See http://www.gnu.org/ for details.
*/
......@@ -13,10 +13,10 @@
#include <stdio.h>
#include <sys/stat.h>
#include <apk/version.h>
#include "apk_defines.h"
#include "apk_applet.h"
#include "apk_database.h"
#include "apk_version.h"
#include "apk_print.h"
/* TODO: support package files as well as generating manifest from the installed DB. */
......
......@@ -9,10 +9,11 @@
*/
#include <stdio.h>
#include <apk/version.h>
#include "apk_defines.h"
#include "apk_applet.h"
#include "apk_database.h"
#include "apk_version.h"
#include "apk_print.h"
extern const char * const apk_installed_file;
......
......@@ -10,10 +10,11 @@
*/
#include <stdio.h>
#include <apk/version.h>
#include "apk_defines.h"
#include "apk_applet.h"
#include "apk_database.h"
#include "apk_version.h"
#include "apk_print.h"
static int update_main(void *ctx, struct apk_database *db, struct apk_string_array *args)
......
......@@ -10,10 +10,11 @@
*/
#include <stdio.h>
#include <apk/version.h>
#include "apk_defines.h"
#include "apk_applet.h"
#include "apk_database.h"
#include "apk_version.h"
#include "apk_print.h"
struct ver_ctx {
......
......@@ -9,10 +9,10 @@
* by the Free Software Foundation. See http://www.gnu.org/ for details.
*/
#include <stdio.h>
#include <ctype.h>
#include <apk/version.h>
#include "apk_defines.h"
#include "apk_version.h"
/* Gentoo version: {digit}{.digit}...{letter}{_suf{#}}...{-r#} */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment