Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
30fdb54e94 | ||
|
|
4f552be5a9 | ||
|
|
1439df9f9a | ||
|
|
e676a0e258 |
@@ -20,7 +20,9 @@
|
||||
#define _MPW_MARSHALL_UTIL_H
|
||||
|
||||
#include <time.h>
|
||||
#if MPW_JSON
|
||||
#include "json-c/json.h"
|
||||
#endif
|
||||
|
||||
#include "mpw-algorithm.h"
|
||||
|
||||
@@ -37,6 +39,7 @@ time_t mpw_mktime(
|
||||
|
||||
/// JSON parsing.
|
||||
|
||||
#if MPW_JSON
|
||||
/** Search for a JSON child object in a JSON object tree.
|
||||
* @param section A dot-delimited list of JSON object keys to walk toward the child object.
|
||||
* @return A new JSON object or NULL if one of the section's object keys was not found in the source object's tree. */
|
||||
@@ -57,6 +60,7 @@ int64_t mpw_get_json_int(
|
||||
* @return The boolean value or defaultValue if one of the section's object keys was not found in the source object's tree. */
|
||||
bool mpw_get_json_boolean(
|
||||
json_object *obj, const char *section, bool defaultValue);
|
||||
#endif
|
||||
|
||||
/// mpw.
|
||||
|
||||
|
||||
@@ -33,7 +33,11 @@ typedef mpw_enum( unsigned int, MPMarshallFormat ) {
|
||||
/** Generate a name for identification. */
|
||||
MPMarshallFormatJSON,
|
||||
|
||||
#if MPW_JSON
|
||||
MPMarshallFormatDefault = MPMarshallFormatJSON,
|
||||
#else
|
||||
MPMarshallFormatDefault = MPMarshallFormatFlat,
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef mpw_enum( unsigned int, MPMarshallErrorType ) {
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
project(mpw)
|
||||
project(mpw C)
|
||||
cmake_minimum_required(VERSION 3.0.2)
|
||||
|
||||
set(CMAKE_BUILD_TYPE Release)
|
||||
set(CMAKE_C_FLAGS "-O3 -DHAS_SODIUM=1")
|
||||
set(CMAKE_C_FLAGS "-O3 -DMPW_SODIUM=1 -DMPW_JSON=1")
|
||||
|
||||
include_directories(core cli)
|
||||
file(GLOB SOURCES "core/*.c" "cli/mpw-cli.c")
|
||||
file(GLOB SOURCES "core/*.c" "cli/mpw-cli*.c")
|
||||
add_executable(mpw ${SOURCES})
|
||||
|
||||
find_library(libsodium REQUIRED)
|
||||
target_link_libraries(mpw sodium)
|
||||
find_library(libjson-c REQUIRED)
|
||||
target_link_libraries(mpw sodium json-c)
|
||||
|
||||
@@ -55,9 +55,9 @@ echo 2>&1 "Current mpw source version ${mpw_version:-<unknown>}..."
|
||||
### TARGET: MPW
|
||||
mpw() {
|
||||
# dependencies
|
||||
use_mpw_sodium
|
||||
use_mpw_color
|
||||
use_mpw_json
|
||||
use_mpw_sodium required
|
||||
use_mpw_color optional
|
||||
use_mpw_json optional
|
||||
|
||||
# target
|
||||
cflags=(
|
||||
@@ -82,7 +82,7 @@ mpw() {
|
||||
### TARGET: MPW-BENCH
|
||||
mpw-bench() {
|
||||
# dependencies
|
||||
use_mpw_sodium
|
||||
use_mpw_sodium required
|
||||
|
||||
# target
|
||||
cflags=(
|
||||
@@ -107,8 +107,8 @@ mpw-bench() {
|
||||
### TARGET: MPW-TESTS
|
||||
mpw-tests() {
|
||||
# dependencies
|
||||
use_mpw_xml
|
||||
use_mpw_sodium
|
||||
use_mpw_xml required
|
||||
use_mpw_sodium required
|
||||
|
||||
# target
|
||||
cflags=(
|
||||
@@ -132,7 +132,7 @@ mpw-tests() {
|
||||
|
||||
### TOOLS
|
||||
haslib() {
|
||||
cc -l"$1" -x c -o /dev/null - <<< 'int main() { return 0; }'
|
||||
cc -x c "${ldflags[@]}" -l"$1" -o /dev/null - <<< 'int main() { return 0; }' &>/dev/null
|
||||
}
|
||||
cc() {
|
||||
if hash llvm-gcc 2>/dev/null; then
|
||||
@@ -149,49 +149,40 @@ cc() {
|
||||
|
||||
|
||||
### DEPENDENCIES
|
||||
use_mpw_sodium() {
|
||||
! (( mpw_sodium )) && return
|
||||
|
||||
if ! haslib sodium; then
|
||||
echo >&2 "WARNING: mpw_sodium enabled but missing sodium library, will disable mpw_sodium."
|
||||
use() {
|
||||
local option=$1 requisite=$2 lib=$3
|
||||
local enabled=${!option}
|
||||
|
||||
if (( enabled )) && haslib "$lib"; then
|
||||
echo >&2 "Enabled $option (lib$lib)."
|
||||
ldflags+=( -l"$lib" )
|
||||
return 0
|
||||
elif [[ $requisite != required ]]; then
|
||||
echo >&2 "WARNING: $option was enabled but is missing $lib library. Will continue with $option disabled!"
|
||||
return 1
|
||||
elif (( enabled )); then
|
||||
echo >&2 "ERROR: $option was enabled but is missing $lib library. Please install this library before continuing."
|
||||
exit 1
|
||||
else
|
||||
echo >&2 "Enabled mpw_sodium (libsodium)."
|
||||
cflags+=( -D"MPW_SODIUM=1" ) ldflags+=( -l"sodium" )
|
||||
echo >&2 "ERROR: $option was required but is not enabled. Please enable the option or remove this target before continuing."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
use_mpw_sodium() {
|
||||
local requisite=$1
|
||||
use mpw_sodium "$requisite" sodium && cflags+=( -D"MPW_SODIUM=1" ) ||:
|
||||
}
|
||||
use_mpw_color() {
|
||||
! (( mpw_color )) && return
|
||||
|
||||
if ! haslib curses; then
|
||||
echo >&2 "WARNING: mpw_color enabled but missing curses library, will disable mpw_color."
|
||||
|
||||
else
|
||||
echo >&2 "Enabled mpw_color (libcurses)."
|
||||
cflags+=( -D"MPW_COLOR=1" ) ldflags+=( -l"curses" )
|
||||
fi
|
||||
local requisite=$1
|
||||
use mpw_color "$requisite" curses && cflags+=( -D"MPW_COLOR=1" ) ||:
|
||||
}
|
||||
use_mpw_json() {
|
||||
! (( mpw_json )) && return
|
||||
|
||||
if ! haslib json-c; then
|
||||
echo >&2 "WARNING: mpw_json enabled but missing json-c library, will disable mpw_json."
|
||||
|
||||
else
|
||||
echo >&2 "Enabled mpw_json (libjson-c)."
|
||||
cflags+=( -D"MPW_JSON=1" ) ldflags+=( -l"json-c" )
|
||||
fi
|
||||
local requisite=$1
|
||||
use mpw_json "$requisite" json-c && cflags+=( -D"MPW_JSON=1" ) ||:
|
||||
}
|
||||
use_mpw_xml() {
|
||||
! (( mpw_xml )) && return
|
||||
|
||||
if ! haslib xml2; then
|
||||
echo >&2 "WARNING: mpw_xml enabled but missing xml2 library, will disable mpw_xml."
|
||||
|
||||
else
|
||||
echo >&2 "Enabled mpw_xml (libxml2)."
|
||||
cflags+=( -D"MPW_XML=1" -I"/usr/include/libxml2" -I"/usr/local/include/libxml2" ) ldflags+=( -l"xml2" )
|
||||
fi
|
||||
local requisite=$1
|
||||
use mpw_xml "$requisite" xml2 && cflags+=( -D"MPW_XML=1" -I"/usr/include/libxml2" -I"/usr/local/include/libxml2" ) ||:
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,21 @@
|
||||
//==============================================================================
|
||||
// This file is part of Master Password.
|
||||
// Copyright (c) 2011-2017, Maarten Billemont.
|
||||
//
|
||||
// Master Password is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Master Password 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 General Public License for more details.
|
||||
//
|
||||
// You can find a copy of the GNU General Public License in the
|
||||
// LICENSE file. Alternatively, see <http://www.gnu.org/licenses/>.
|
||||
//==============================================================================
|
||||
|
||||
//
|
||||
// mpw-bench.c
|
||||
// MasterPassword
|
||||
|
||||
@@ -1,3 +1,21 @@
|
||||
//==============================================================================
|
||||
// This file is part of Master Password.
|
||||
// Copyright (c) 2011-2017, Maarten Billemont.
|
||||
//
|
||||
// Master Password is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Master Password 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 General Public License for more details.
|
||||
//
|
||||
// You can find a copy of the GNU General Public License in the
|
||||
// LICENSE file. Alternatively, see <http://www.gnu.org/licenses/>.
|
||||
//==============================================================================
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -1,3 +1,21 @@
|
||||
//==============================================================================
|
||||
// This file is part of Master Password.
|
||||
// Copyright (c) 2011-2017, Maarten Billemont.
|
||||
//
|
||||
// Master Password is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Master Password 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 General Public License for more details.
|
||||
//
|
||||
// You can find a copy of the GNU General Public License in the
|
||||
// LICENSE file. Alternatively, see <http://www.gnu.org/licenses/>.
|
||||
//==============================================================================
|
||||
|
||||
//
|
||||
// mpw-tests-util.c
|
||||
// MasterPassword
|
||||
|
||||
@@ -1,3 +1,21 @@
|
||||
//==============================================================================
|
||||
// This file is part of Master Password.
|
||||
// Copyright (c) 2011-2017, Maarten Billemont.
|
||||
//
|
||||
// Master Password is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Master Password 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 General Public License for more details.
|
||||
//
|
||||
// You can find a copy of the GNU General Public License in the
|
||||
// LICENSE file. Alternatively, see <http://www.gnu.org/licenses/>.
|
||||
//==============================================================================
|
||||
|
||||
//
|
||||
// mpw-tests-util.h
|
||||
// MasterPassword
|
||||
|
||||
@@ -1,3 +1,21 @@
|
||||
//==============================================================================
|
||||
// This file is part of Master Password.
|
||||
// Copyright (c) 2011-2017, Maarten Billemont.
|
||||
//
|
||||
// Master Password is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Master Password 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 General Public License for more details.
|
||||
//
|
||||
// You can find a copy of the GNU General Public License in the
|
||||
// LICENSE file. Alternatively, see <http://www.gnu.org/licenses/>.
|
||||
//==============================================================================
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
mpw-2.5-cli-2-0-g3ed6b937.tar.gz
|
||||
mpw-2.6-cli-1-0-g895df637.tar.gz
|
||||
@@ -1 +1 @@
|
||||
mpw-2.5-cli-2-0-g3ed6b937.tar.gz.sig
|
||||
mpw-2.6-cli-1-0-g895df637.tar.gz.sig
|
||||
BIN
public/site/2013-05/mpw-2.6-cli-1-0-g895df637.tar.gz
Normal file
BIN
public/site/2013-05/mpw-2.6-cli-1-0-g895df637.tar.gz
Normal file
Binary file not shown.
BIN
public/site/2013-05/mpw-2.6-cli-1-0-g895df637.tar.gz.sig
Normal file
BIN
public/site/2013-05/mpw-2.6-cli-1-0-g895df637.tar.gz.sig
Normal file
Binary file not shown.
Reference in New Issue
Block a user