Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
30fdb54e94 | ||
|
|
4f552be5a9 | ||
|
|
1439df9f9a | ||
|
|
e676a0e258 |
@@ -20,7 +20,9 @@
|
|||||||
#define _MPW_MARSHALL_UTIL_H
|
#define _MPW_MARSHALL_UTIL_H
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#if MPW_JSON
|
||||||
#include "json-c/json.h"
|
#include "json-c/json.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "mpw-algorithm.h"
|
#include "mpw-algorithm.h"
|
||||||
|
|
||||||
@@ -37,6 +39,7 @@ time_t mpw_mktime(
|
|||||||
|
|
||||||
/// JSON parsing.
|
/// JSON parsing.
|
||||||
|
|
||||||
|
#if MPW_JSON
|
||||||
/** Search for a JSON child object in a JSON object tree.
|
/** 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.
|
* @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. */
|
* @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. */
|
* @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(
|
bool mpw_get_json_boolean(
|
||||||
json_object *obj, const char *section, bool defaultValue);
|
json_object *obj, const char *section, bool defaultValue);
|
||||||
|
#endif
|
||||||
|
|
||||||
/// mpw.
|
/// mpw.
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,11 @@ typedef mpw_enum( unsigned int, MPMarshallFormat ) {
|
|||||||
/** Generate a name for identification. */
|
/** Generate a name for identification. */
|
||||||
MPMarshallFormatJSON,
|
MPMarshallFormatJSON,
|
||||||
|
|
||||||
|
#if MPW_JSON
|
||||||
MPMarshallFormatDefault = MPMarshallFormatJSON,
|
MPMarshallFormatDefault = MPMarshallFormatJSON,
|
||||||
|
#else
|
||||||
|
MPMarshallFormatDefault = MPMarshallFormatFlat,
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef mpw_enum( unsigned int, MPMarshallErrorType ) {
|
typedef mpw_enum( unsigned int, MPMarshallErrorType ) {
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
project(mpw)
|
project(mpw C)
|
||||||
cmake_minimum_required(VERSION 3.0.2)
|
cmake_minimum_required(VERSION 3.0.2)
|
||||||
|
|
||||||
set(CMAKE_BUILD_TYPE Release)
|
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)
|
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})
|
add_executable(mpw ${SOURCES})
|
||||||
|
|
||||||
find_library(libsodium REQUIRED)
|
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
|
### TARGET: MPW
|
||||||
mpw() {
|
mpw() {
|
||||||
# dependencies
|
# dependencies
|
||||||
use_mpw_sodium
|
use_mpw_sodium required
|
||||||
use_mpw_color
|
use_mpw_color optional
|
||||||
use_mpw_json
|
use_mpw_json optional
|
||||||
|
|
||||||
# target
|
# target
|
||||||
cflags=(
|
cflags=(
|
||||||
@@ -82,7 +82,7 @@ mpw() {
|
|||||||
### TARGET: MPW-BENCH
|
### TARGET: MPW-BENCH
|
||||||
mpw-bench() {
|
mpw-bench() {
|
||||||
# dependencies
|
# dependencies
|
||||||
use_mpw_sodium
|
use_mpw_sodium required
|
||||||
|
|
||||||
# target
|
# target
|
||||||
cflags=(
|
cflags=(
|
||||||
@@ -107,8 +107,8 @@ mpw-bench() {
|
|||||||
### TARGET: MPW-TESTS
|
### TARGET: MPW-TESTS
|
||||||
mpw-tests() {
|
mpw-tests() {
|
||||||
# dependencies
|
# dependencies
|
||||||
use_mpw_xml
|
use_mpw_xml required
|
||||||
use_mpw_sodium
|
use_mpw_sodium required
|
||||||
|
|
||||||
# target
|
# target
|
||||||
cflags=(
|
cflags=(
|
||||||
@@ -132,7 +132,7 @@ mpw-tests() {
|
|||||||
|
|
||||||
### TOOLS
|
### TOOLS
|
||||||
haslib() {
|
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() {
|
cc() {
|
||||||
if hash llvm-gcc 2>/dev/null; then
|
if hash llvm-gcc 2>/dev/null; then
|
||||||
@@ -149,49 +149,40 @@ cc() {
|
|||||||
|
|
||||||
|
|
||||||
### DEPENDENCIES
|
### DEPENDENCIES
|
||||||
use_mpw_sodium() {
|
use() {
|
||||||
! (( mpw_sodium )) && return
|
local option=$1 requisite=$2 lib=$3
|
||||||
|
local enabled=${!option}
|
||||||
if ! haslib sodium; then
|
|
||||||
echo >&2 "WARNING: mpw_sodium enabled but missing sodium library, will disable mpw_sodium."
|
|
||||||
|
|
||||||
|
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
|
else
|
||||||
echo >&2 "Enabled mpw_sodium (libsodium)."
|
echo >&2 "ERROR: $option was required but is not enabled. Please enable the option or remove this target before continuing."
|
||||||
cflags+=( -D"MPW_SODIUM=1" ) ldflags+=( -l"sodium" )
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
use_mpw_sodium() {
|
||||||
|
local requisite=$1
|
||||||
|
use mpw_sodium "$requisite" sodium && cflags+=( -D"MPW_SODIUM=1" ) ||:
|
||||||
|
}
|
||||||
use_mpw_color() {
|
use_mpw_color() {
|
||||||
! (( mpw_color )) && return
|
local requisite=$1
|
||||||
|
use mpw_color "$requisite" curses && cflags+=( -D"MPW_COLOR=1" ) ||:
|
||||||
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
|
|
||||||
}
|
}
|
||||||
use_mpw_json() {
|
use_mpw_json() {
|
||||||
! (( mpw_json )) && return
|
local requisite=$1
|
||||||
|
use mpw_json "$requisite" json-c && cflags+=( -D"MPW_JSON=1" ) ||:
|
||||||
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
|
|
||||||
}
|
}
|
||||||
use_mpw_xml() {
|
use_mpw_xml() {
|
||||||
! (( mpw_xml )) && return
|
local requisite=$1
|
||||||
|
use mpw_xml "$requisite" xml2 && cflags+=( -D"MPW_XML=1" -I"/usr/include/libxml2" -I"/usr/local/include/libxml2" ) ||:
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
// mpw-bench.c
|
||||||
// MasterPassword
|
// 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 <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.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
|
// mpw-tests-util.c
|
||||||
// MasterPassword
|
// 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
|
// mpw-tests-util.h
|
||||||
// MasterPassword
|
// 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 <stdio.h>
|
||||||
#include <stdlib.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