initial commit
This commit is contained in:
commit
167e628126
14 changed files with 1228 additions and 0 deletions
24
.gitignore
vendored
Normal file
24
.gitignore
vendored
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
*.class
|
||||||
|
|
||||||
|
# Mobile Tools for Java (J2ME)
|
||||||
|
.mtj.tmp/
|
||||||
|
|
||||||
|
# Package Files #
|
||||||
|
*.jar
|
||||||
|
*.war
|
||||||
|
*.ear
|
||||||
|
|
||||||
|
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||||
|
hs_err_pid*
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
*.iml
|
||||||
|
.idea
|
||||||
|
|
||||||
|
# Maven
|
||||||
|
target/
|
||||||
|
|
||||||
|
# Gradle
|
||||||
|
build/
|
||||||
|
.gradle/
|
||||||
|
*~
|
202
LICENSE.txt
Normal file
202
LICENSE.txt
Normal file
|
@ -0,0 +1,202 @@
|
||||||
|
|
||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
122
build.gradle
Normal file
122
build.gradle
Normal file
|
@ -0,0 +1,122 @@
|
||||||
|
plugins {
|
||||||
|
id "org.sonarqube" version "2.6.1"
|
||||||
|
id "io.codearte.nexus-staging" version "0.11.0"
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'java'
|
||||||
|
apply plugin: 'maven'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation "com.nativelibs4java:bridj:${project.property('bridj.version')}"
|
||||||
|
testImplementation "org.junit.jupiter:junit-jupiter-api:${project.property('junit.version')}"
|
||||||
|
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${project.property('junit.version')}"
|
||||||
|
testImplementation "org.mockito:mockito-junit-jupiter:${project.property('mockito.version')}"
|
||||||
|
}
|
||||||
|
|
||||||
|
compileJava {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_11
|
||||||
|
targetCompatibility = JavaVersion.VERSION_11
|
||||||
|
}
|
||||||
|
|
||||||
|
compileTestJava {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_11
|
||||||
|
targetCompatibility = JavaVersion.VERSION_11
|
||||||
|
}
|
||||||
|
|
||||||
|
test {
|
||||||
|
enabled = true
|
||||||
|
useJUnitPlatform()
|
||||||
|
systemProperty 'jna.debug', 'true'
|
||||||
|
testLogging {
|
||||||
|
events 'PASSED', 'FAILED', 'SKIPPED'
|
||||||
|
}
|
||||||
|
afterSuite { desc, result ->
|
||||||
|
if (!desc.parent) {
|
||||||
|
println "\nTest result: ${result.resultType}"
|
||||||
|
println "Test summary: ${result.testCount} test, " +
|
||||||
|
"${result.successfulTestCount} succeeded, " +
|
||||||
|
"${result.failedTestCount} failed " +
|
||||||
|
"${result.skippedTestCount} skipped "
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task javadocJar(type: Jar, dependsOn: classes) {
|
||||||
|
from javadoc
|
||||||
|
into "build/tmp"
|
||||||
|
classifier 'javadoc'
|
||||||
|
}
|
||||||
|
|
||||||
|
task sourcesJar(type: Jar, dependsOn: classes) {
|
||||||
|
from sourceSets.main.allSource
|
||||||
|
into "build/tmp"
|
||||||
|
classifier 'sources'
|
||||||
|
}
|
||||||
|
|
||||||
|
artifacts {
|
||||||
|
archives javadocJar, sourcesJar
|
||||||
|
}
|
||||||
|
|
||||||
|
ext {
|
||||||
|
user = 'jprante'
|
||||||
|
projectDescription = 'Systemd journal bindings'
|
||||||
|
scmUrl = 'https://github.com/jprante/systemd-journal'
|
||||||
|
scmConnection = 'scm:git:git://github.com/jprante/systemd-journal.git'
|
||||||
|
scmDeveloperConnection = 'scm:git:git://github.com/jprante/systemd-journal.git'
|
||||||
|
}
|
||||||
|
|
||||||
|
task sonaTypeUpload(type: Upload) {
|
||||||
|
group = 'publish'
|
||||||
|
configuration = configurations.archives
|
||||||
|
uploadDescriptor = true
|
||||||
|
repositories {
|
||||||
|
if (project.hasProperty('ossrhUsername')) {
|
||||||
|
mavenDeployer {
|
||||||
|
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
|
||||||
|
repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2') {
|
||||||
|
authentication(userName: ossrhUsername, password: ossrhPassword)
|
||||||
|
}
|
||||||
|
snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots') {
|
||||||
|
authentication(userName: ossrhUsername, password: ossrhPassword)
|
||||||
|
}
|
||||||
|
pom.project {
|
||||||
|
groupId project.group
|
||||||
|
artifactId project.name
|
||||||
|
version project.version
|
||||||
|
name project.name
|
||||||
|
description description
|
||||||
|
packaging 'jar'
|
||||||
|
inceptionYear '2018'
|
||||||
|
url scmUrl
|
||||||
|
organization {
|
||||||
|
name 'xbib'
|
||||||
|
url 'http://xbib.org'
|
||||||
|
}
|
||||||
|
developers {
|
||||||
|
developer {
|
||||||
|
id user
|
||||||
|
name 'Jörg Prante'
|
||||||
|
email 'joergprante@gmail.com'
|
||||||
|
url 'https://github.com/jprante'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
scm {
|
||||||
|
url scmUrl
|
||||||
|
connection scmConnection
|
||||||
|
developerConnection scmDeveloperConnection
|
||||||
|
}
|
||||||
|
licenses {
|
||||||
|
license {
|
||||||
|
name 'The Apache License, Version 2.0'
|
||||||
|
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nexusStaging {
|
||||||
|
packageGroup = "org.xbib"
|
||||||
|
}
|
8
gradle.properties
Normal file
8
gradle.properties
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
group = org.xbib
|
||||||
|
name = systemd-journal
|
||||||
|
version = 1.0.0
|
||||||
|
|
||||||
|
bridj.version = 0.7.0
|
||||||
|
|
||||||
|
junit.version = 5.4.2
|
||||||
|
mockito.version = 2.27.0
|
0
gradle/publish.gradle
Normal file
0
gradle/publish.gradle
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#Mon Jul 29 11:55:05 CEST 2019
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-5.3.1-all.zip
|
||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
188
gradlew
vendored
Executable file
188
gradlew
vendored
Executable file
|
@ -0,0 +1,188 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright 2015 the original author or authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
##
|
||||||
|
## Gradle start up script for UN*X
|
||||||
|
##
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
PRG="$0"
|
||||||
|
# Need this for relative symlinks.
|
||||||
|
while [ -h "$PRG" ] ; do
|
||||||
|
ls=`ls -ld "$PRG"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
PRG="$link"
|
||||||
|
else
|
||||||
|
PRG=`dirname "$PRG"`"/$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
SAVED="`pwd`"
|
||||||
|
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
|
APP_NAME="Gradle"
|
||||||
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD="maximum"
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "`uname`" in
|
||||||
|
CYGWIN* )
|
||||||
|
cygwin=true
|
||||||
|
;;
|
||||||
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
NONSTOP* )
|
||||||
|
nonstop=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
|
else
|
||||||
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD="java"
|
||||||
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||||
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
|
if [ $? -eq 0 ] ; then
|
||||||
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
|
MAX_FD="$MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
ulimit -n $MAX_FD
|
||||||
|
if [ $? -ne 0 ] ; then
|
||||||
|
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Darwin, add options to specify how the application appears in the dock
|
||||||
|
if $darwin; then
|
||||||
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Cygwin, switch paths to Windows format before running java
|
||||||
|
if $cygwin ; then
|
||||||
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
|
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||||
|
SEP=""
|
||||||
|
for dir in $ROOTDIRSRAW ; do
|
||||||
|
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||||
|
SEP="|"
|
||||||
|
done
|
||||||
|
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||||
|
# Add a user-defined pattern to the cygpath arguments
|
||||||
|
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||||
|
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||||
|
fi
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
i=0
|
||||||
|
for arg in "$@" ; do
|
||||||
|
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||||
|
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||||
|
|
||||||
|
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||||
|
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||||
|
else
|
||||||
|
eval `echo args$i`="\"$arg\""
|
||||||
|
fi
|
||||||
|
i=$((i+1))
|
||||||
|
done
|
||||||
|
case $i in
|
||||||
|
(0) set -- ;;
|
||||||
|
(1) set -- "$args0" ;;
|
||||||
|
(2) set -- "$args0" "$args1" ;;
|
||||||
|
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
|
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
|
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
|
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
|
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
|
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
|
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Escape application args
|
||||||
|
save () {
|
||||||
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
|
echo " "
|
||||||
|
}
|
||||||
|
APP_ARGS=$(save "$@")
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
|
|
||||||
|
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||||
|
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
100
gradlew.bat
vendored
Normal file
100
gradlew.bat
vendored
Normal file
|
@ -0,0 +1,100 @@
|
||||||
|
@rem
|
||||||
|
@rem Copyright 2015 the original author or authors.
|
||||||
|
@rem
|
||||||
|
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@rem you may not use this file except in compliance with the License.
|
||||||
|
@rem You may obtain a copy of the License at
|
||||||
|
@rem
|
||||||
|
@rem http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@rem
|
||||||
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@rem See the License for the specific language governing permissions and
|
||||||
|
@rem limitations under the License.
|
||||||
|
@rem
|
||||||
|
|
||||||
|
@if "%DEBUG%" == "" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if "%ERRORLEVEL%" == "0" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:init
|
||||||
|
@rem Get command-line arguments, handling Windows variants
|
||||||
|
|
||||||
|
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||||
|
|
||||||
|
:win9xME_args
|
||||||
|
@rem Slurp the command line arguments.
|
||||||
|
set CMD_LINE_ARGS=
|
||||||
|
set _SKIP=2
|
||||||
|
|
||||||
|
:win9xME_args_slurp
|
||||||
|
if "x%~1" == "x" goto execute
|
||||||
|
|
||||||
|
set CMD_LINE_ARGS=%*
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
@rem Execute Gradle
|
||||||
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||||
|
|
||||||
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
|
rem the _cmd.exe /c_ return code!
|
||||||
|
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||||
|
exit /b 1
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
12
src/main/java/org/xbib/systemd/Syslog.java
Normal file
12
src/main/java/org/xbib/systemd/Syslog.java
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
package org.xbib.systemd;
|
||||||
|
|
||||||
|
public interface Syslog {
|
||||||
|
int LOG_EMERG = 0;
|
||||||
|
int LOG_ALERT = 1;
|
||||||
|
int LOG_CRIT = 2;
|
||||||
|
int LOG_ERR = 3;
|
||||||
|
int LOG_WARNING = 4;
|
||||||
|
int LOG_NOTICE = 5;
|
||||||
|
int LOG_INFO = 6;
|
||||||
|
int LOG_DEBUG = 7;
|
||||||
|
}
|
96
src/main/java/org/xbib/systemd/SystemdJournalConsumer.java
Normal file
96
src/main/java/org/xbib/systemd/SystemdJournalConsumer.java
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
package org.xbib.systemd;
|
||||||
|
|
||||||
|
import org.bridj.Pointer;
|
||||||
|
import org.bridj.SizeT;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
public class SystemdJournalConsumer implements Runnable {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(SystemdJournalConsumer.class.getName());
|
||||||
|
|
||||||
|
private final String match;
|
||||||
|
|
||||||
|
private final String field;
|
||||||
|
|
||||||
|
private final SystemdJournalListener listener;
|
||||||
|
|
||||||
|
public SystemdJournalConsumer(String match, String field, SystemdJournalListener listener) {
|
||||||
|
this.match = match;
|
||||||
|
this.field = field;
|
||||||
|
this.listener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
loop();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loop() {
|
||||||
|
Pointer<Pointer<SystemdJournalLibrary.sdJournal>> sdJournalPointer = Pointer.allocatePointer(SystemdJournalLibrary.sdJournal.class);
|
||||||
|
int r = SystemdJournalLibrary.sd_journal_open(sdJournalPointer, SystemdJournalLibrary.SD_JOURNAL_LOCAL_ONLY);
|
||||||
|
if (r < 0) {
|
||||||
|
logger.log(Level.WARNING, "error opening journal for read: " + r);
|
||||||
|
}
|
||||||
|
Pointer<SystemdJournalLibrary.sdJournal> sdJournal = sdJournalPointer.getPointer(SystemdJournalLibrary.sdJournal.class);
|
||||||
|
if (match != null) {
|
||||||
|
r = SystemdJournalLibrary.sd_journal_add_match(sdJournal, Pointer.pointerToCString(match), match.length());
|
||||||
|
if (r < 0) {
|
||||||
|
logger.log(Level.WARNING, "error in add_match: " + r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SystemdJournalLibrary.sd_journal_get_fd(sdJournal);
|
||||||
|
SystemdJournalLibrary.sd_journal_seek_tail(sdJournal);
|
||||||
|
SystemdJournalLibrary.sd_journal_previous(sdJournal);
|
||||||
|
SystemdJournalLibrary.sd_journal_next(sdJournal);
|
||||||
|
Pointer<Pointer<Byte>> cursorPointer = Pointer.allocatePointer(Byte.TYPE);
|
||||||
|
SystemdJournalLibrary.sd_journal_get_cursor(sdJournal, cursorPointer);
|
||||||
|
Pointer<Byte> existingCursor = cursorPointer.get();
|
||||||
|
while (true) {
|
||||||
|
do {
|
||||||
|
r = SystemdJournalLibrary.sd_journal_wait(sdJournal, -1);
|
||||||
|
} while (r == 0); // NOP
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
while (SystemdJournalLibrary.sd_journal_next(sdJournal) > 0) {
|
||||||
|
if (field != null) {
|
||||||
|
Pointer<Pointer<?>> dataPointer = Pointer.allocatePointer();
|
||||||
|
Pointer<SizeT> sizePointer = Pointer.allocateSizeT();
|
||||||
|
r = SystemdJournalLibrary.sd_journal_get_data(sdJournal, Pointer.pointerToCString(field), dataPointer, sizePointer);
|
||||||
|
if (r < 0) {
|
||||||
|
logger.log(Level.WARNING, "error in get_data: " + r);
|
||||||
|
}
|
||||||
|
Pointer<Byte> data = dataPointer.as(Byte.class);
|
||||||
|
list.add(data.getPointer(Byte.class).getCString());
|
||||||
|
} else {
|
||||||
|
cursorPointer = Pointer.allocatePointer(Byte.TYPE);
|
||||||
|
SystemdJournalLibrary.sd_journal_get_cursor(sdJournal, cursorPointer);
|
||||||
|
Pointer<Byte> newCursor = cursorPointer.get();
|
||||||
|
if (!existingCursor.getCString().equals(newCursor.getCString())) {
|
||||||
|
existingCursor = newCursor;
|
||||||
|
Pointer<Pointer<?>> dataPointer = Pointer.allocatePointer();
|
||||||
|
Pointer<SizeT> sizePointer = Pointer.allocateSizeT();
|
||||||
|
while (SystemdJournalLibrary.sd_journal_enumerate_data(sdJournal, dataPointer, sizePointer) > 0) {
|
||||||
|
Pointer<Byte> data = dataPointer.as(Byte.class);
|
||||||
|
String line = data.getPointer(Byte.class).getCString();
|
||||||
|
list.add(line);
|
||||||
|
}
|
||||||
|
SystemdJournalLibrary.sd_journal_restart_data(sdJournal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (listener != null) {
|
||||||
|
for (String string : list) {
|
||||||
|
try {
|
||||||
|
listener.handleMessage(string);
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.log(Level.WARNING, e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
402
src/main/java/org/xbib/systemd/SystemdJournalLibrary.java
Normal file
402
src/main/java/org/xbib/systemd/SystemdJournalLibrary.java
Normal file
|
@ -0,0 +1,402 @@
|
||||||
|
package org.xbib.systemd;
|
||||||
|
|
||||||
|
import org.bridj.BridJ;
|
||||||
|
import org.bridj.CRuntime;
|
||||||
|
import org.bridj.Pointer;
|
||||||
|
import org.bridj.SizeT;
|
||||||
|
import org.bridj.ann.Library;
|
||||||
|
import org.bridj.ann.Ptr;
|
||||||
|
import org.bridj.ann.Runtime;
|
||||||
|
|
||||||
|
@Library("systemd")
|
||||||
|
@Runtime(CRuntime.class)
|
||||||
|
public class SystemdJournalLibrary {
|
||||||
|
|
||||||
|
static {
|
||||||
|
BridJ.register();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final int SD_JOURNAL_LOCAL_ONLY = 1;
|
||||||
|
|
||||||
|
public static final int SD_JOURNAL_RUNTIME_ONLY = 2;
|
||||||
|
|
||||||
|
public static final int SD_JOURNAL_SYSTEM = 4;
|
||||||
|
|
||||||
|
public static final int SD_JOURNAL_CURRENT_USER = 8;
|
||||||
|
|
||||||
|
public static final int SD_JOURNAL_NOP = 0;
|
||||||
|
|
||||||
|
public static final int SD_JOURNAL_APPEND = 1;
|
||||||
|
|
||||||
|
public static final int SD_JOURNAL_INVALIDATE = 2;
|
||||||
|
|
||||||
|
public static final String SD_ID128_FORMAT_STR = "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x";
|
||||||
|
|
||||||
|
public static Pointer<Byte> sd_id128_to_string(sd_id128 id, Pointer<Byte> s) {
|
||||||
|
return Pointer.pointerToAddress(sd_id128_to_string(id, Pointer.getPeer(s)), Byte.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Ptr
|
||||||
|
protected native static long sd_id128_to_string(sd_id128 id, @Ptr long s);
|
||||||
|
|
||||||
|
public static int sd_id128_from_string(Pointer<Byte> s, Pointer<sd_id128> ret) {
|
||||||
|
return sd_id128_from_string(Pointer.getPeer(s), Pointer.getPeer(ret));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_id128_from_string(@Ptr long s, @Ptr long ret);
|
||||||
|
|
||||||
|
public static int sd_id128_randomize(Pointer<sd_id128> ret) {
|
||||||
|
return sd_id128_randomize(Pointer.getPeer(ret));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_id128_randomize(@Ptr long ret);
|
||||||
|
|
||||||
|
public static int sd_id128_get_machine(Pointer<sd_id128> ret) {
|
||||||
|
return sd_id128_get_machine(Pointer.getPeer(ret));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_id128_get_machine(@Ptr long ret);
|
||||||
|
|
||||||
|
public static int sd_id128_get_boot(Pointer<sd_id128> ret) {
|
||||||
|
return sd_id128_get_boot(Pointer.getPeer(ret));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_id128_get_boot(@Ptr long ret);
|
||||||
|
|
||||||
|
public static int sd_journal_print(int priority, Pointer<Byte> format, Object... varArgs1) {
|
||||||
|
return sd_journal_print(priority, Pointer.getPeer(format), varArgs1);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_print(int priority, @Ptr long format, Object... varArgs1);
|
||||||
|
|
||||||
|
public static int sd_journal_printv(int priority, Pointer<Byte> format, Object... ap) {
|
||||||
|
return sd_journal_printv(priority, Pointer.getPeer(format), ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_printv(int priority, @Ptr long format, Object... ap);
|
||||||
|
|
||||||
|
public static int sd_journal_send(Pointer<Byte> format, Object... varArgs1) {
|
||||||
|
return sd_journal_send(Pointer.getPeer(format), varArgs1);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_send(@Ptr long format, Object... varArgs1);
|
||||||
|
|
||||||
|
public static int sd_journal_sendv(Pointer iov, int n) {
|
||||||
|
return sd_journal_sendv(Pointer.getPeer(iov), n);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_sendv(@Ptr long iov, int n);
|
||||||
|
|
||||||
|
public static int sd_journal_perror(Pointer<Byte> message) {
|
||||||
|
return sd_journal_perror(Pointer.getPeer(message));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_perror(@Ptr long message);
|
||||||
|
|
||||||
|
public static int sd_journal_print_with_location(int priority, Pointer<Byte> file, Pointer<Byte> line,
|
||||||
|
Pointer<Byte> func, Pointer<Byte> format, Object... varArgs1) {
|
||||||
|
return sd_journal_print_with_location(priority, Pointer.getPeer(file), Pointer.getPeer(line),
|
||||||
|
Pointer.getPeer(func), Pointer.getPeer(format), varArgs1);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_print_with_location(int priority, @Ptr long file, @Ptr long line,
|
||||||
|
@Ptr long func, @Ptr long format, Object... varArgs1);
|
||||||
|
|
||||||
|
public static int sd_journal_printv_with_location(int priority, Pointer<Byte> file, Pointer<Byte> line,
|
||||||
|
Pointer<Byte> func, Pointer<Byte> format, Object... ap) {
|
||||||
|
return sd_journal_printv_with_location(priority, Pointer.getPeer(file), Pointer.getPeer(line),
|
||||||
|
Pointer.getPeer(func), Pointer.getPeer(format), ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_printv_with_location(int priority, @Ptr long file, @Ptr long line,
|
||||||
|
@Ptr long func, @Ptr long format, Object... ap);
|
||||||
|
|
||||||
|
public static int sd_journal_send_with_location(Pointer<Byte> file, Pointer<Byte> line, Pointer<Byte> func,
|
||||||
|
Pointer<Byte> format, Object... varArgs1) {
|
||||||
|
return sd_journal_send_with_location(Pointer.getPeer(file), Pointer.getPeer(line), Pointer.getPeer(func),
|
||||||
|
Pointer.getPeer(format), varArgs1);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_send_with_location(@Ptr long file, @Ptr long line, @Ptr long func,
|
||||||
|
@Ptr long format, Object... varArgs1);
|
||||||
|
|
||||||
|
public static int sd_journal_sendv_with_location(Pointer<Byte> file, Pointer<Byte> line, Pointer<Byte> func,
|
||||||
|
Pointer iov, int n) {
|
||||||
|
return sd_journal_sendv_with_location(Pointer.getPeer(file), Pointer.getPeer(line), Pointer.getPeer(func),
|
||||||
|
Pointer.getPeer(iov), n);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_sendv_with_location(@Ptr long file, @Ptr long line, @Ptr long func,
|
||||||
|
@Ptr long iov, int n);
|
||||||
|
|
||||||
|
public static int sd_journal_perror_with_location(Pointer<Byte> file, Pointer<Byte> line, Pointer<Byte> func,
|
||||||
|
Pointer<Byte> message) {
|
||||||
|
return sd_journal_perror_with_location(Pointer.getPeer(file), Pointer.getPeer(line), Pointer.getPeer(func),
|
||||||
|
Pointer.getPeer(message));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_perror_with_location(@Ptr long file, @Ptr long line, @Ptr long func,
|
||||||
|
@Ptr long message);
|
||||||
|
|
||||||
|
public static int sd_journal_stream_fd(Pointer<Byte> identifier, int priority, int level_prefix) {
|
||||||
|
return sd_journal_stream_fd(Pointer.getPeer(identifier), priority, level_prefix);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_stream_fd(@Ptr long identifier, int priority, int level_prefix);
|
||||||
|
|
||||||
|
public static int sd_journal_open(Pointer<Pointer<sdJournal>> ret, int flags) {
|
||||||
|
return sd_journal_open(Pointer.getPeer(ret), flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_open(@Ptr long ret, int flags);
|
||||||
|
|
||||||
|
public static int sd_journal_open_directory(Pointer<Pointer<sdJournal>> ret,
|
||||||
|
Pointer<Byte> path, int flags) {
|
||||||
|
return sd_journal_open_directory(Pointer.getPeer(ret), Pointer.getPeer(path), flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_open_directory(@Ptr long ret, @Ptr long path, int flags);
|
||||||
|
|
||||||
|
public static int sd_journal_open_files(Pointer<Pointer<sdJournal>> ret,
|
||||||
|
Pointer<Pointer<Byte>> paths, int flags) {
|
||||||
|
return sd_journal_open_files(Pointer.getPeer(ret), Pointer.getPeer(paths), flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_open_files(@Ptr long ret, @Ptr long paths, int flags);
|
||||||
|
|
||||||
|
public static void sd_journal_close(Pointer<sdJournal> j) {
|
||||||
|
sd_journal_close(Pointer.getPeer(j));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static void sd_journal_close(@Ptr long j);
|
||||||
|
|
||||||
|
public static int sd_journal_previous(Pointer<sdJournal> j) {
|
||||||
|
return sd_journal_previous(Pointer.getPeer(j));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_previous(@Ptr long j);
|
||||||
|
|
||||||
|
public static int sd_journal_next(Pointer<sdJournal> j) {
|
||||||
|
return sd_journal_next(Pointer.getPeer(j));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_next(@Ptr long j);
|
||||||
|
|
||||||
|
public static int sd_journal_previous_skip(Pointer<sdJournal> j, long skip) {
|
||||||
|
return sd_journal_previous_skip(Pointer.getPeer(j), skip);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_previous_skip(@Ptr long j, long skip);
|
||||||
|
|
||||||
|
public static int sd_journal_next_skip(Pointer<sdJournal> j, long skip) {
|
||||||
|
return sd_journal_next_skip(Pointer.getPeer(j), skip);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_next_skip(@Ptr long j, long skip);
|
||||||
|
|
||||||
|
public static int sd_journal_get_realtime_usec(Pointer<sdJournal> j, Pointer<Long> ret) {
|
||||||
|
return sd_journal_get_realtime_usec(Pointer.getPeer(j), Pointer.getPeer(ret));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_get_realtime_usec(@Ptr long j, @Ptr long ret);
|
||||||
|
|
||||||
|
public static int sd_journal_get_monotonic_usec(Pointer<sdJournal> j, Pointer<Long> ret,
|
||||||
|
Pointer<sd_id128> ret_boot_id) {
|
||||||
|
return sd_journal_get_monotonic_usec(Pointer.getPeer(j), Pointer.getPeer(ret), Pointer.getPeer(ret_boot_id));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_get_monotonic_usec(@Ptr long j, @Ptr long ret, @Ptr long ret_boot_id);
|
||||||
|
|
||||||
|
public static int sd_journal_set_data_threshold(Pointer<sdJournal> j, @Ptr long sz) {
|
||||||
|
return sd_journal_set_data_threshold(Pointer.getPeer(j), sz);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_set_data_threshold(@Ptr long j, @Ptr long sz);
|
||||||
|
|
||||||
|
public static int sd_journal_get_data_threshold(Pointer<sdJournal> j, Pointer<SizeT> sz) {
|
||||||
|
return sd_journal_get_data_threshold(Pointer.getPeer(j), Pointer.getPeer(sz));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_get_data_threshold(@Ptr long j, @Ptr long sz);
|
||||||
|
|
||||||
|
public static int sd_journal_get_data(Pointer<sdJournal> j, Pointer<Byte> field,
|
||||||
|
Pointer<Pointer<?>> data, Pointer<SizeT> l) {
|
||||||
|
return sd_journal_get_data(Pointer.getPeer(j), Pointer.getPeer(field), Pointer.getPeer(data), Pointer.getPeer(l));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_get_data(@Ptr long j, @Ptr long field, @Ptr long data, @Ptr long l);
|
||||||
|
|
||||||
|
public static int sd_journal_enumerate_data(Pointer<sdJournal> j, Pointer<Pointer<?>> data,
|
||||||
|
Pointer<SizeT> l) {
|
||||||
|
return sd_journal_enumerate_data(Pointer.getPeer(j), Pointer.getPeer(data), Pointer.getPeer(l));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_enumerate_data(@Ptr long j, @Ptr long data, @Ptr long l);
|
||||||
|
|
||||||
|
public static void sd_journal_restart_data(Pointer<sdJournal> j) {
|
||||||
|
sd_journal_restart_data(Pointer.getPeer(j));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static void sd_journal_restart_data(@Ptr long j);
|
||||||
|
|
||||||
|
public static int sd_journal_add_match(Pointer<sdJournal> j, Pointer<?> data,
|
||||||
|
@Ptr long size) {
|
||||||
|
return sd_journal_add_match(Pointer.getPeer(j), Pointer.getPeer(data), size);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_add_match(@Ptr long j, @Ptr long data, @Ptr long size);
|
||||||
|
|
||||||
|
public static int sd_journal_add_disjunction(Pointer<sdJournal> j) {
|
||||||
|
return sd_journal_add_disjunction(Pointer.getPeer(j));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_add_disjunction(@Ptr long j);
|
||||||
|
|
||||||
|
public static int sd_journal_add_conjunction(Pointer<sdJournal> j) {
|
||||||
|
return sd_journal_add_conjunction(Pointer.getPeer(j));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_add_conjunction(@Ptr long j);
|
||||||
|
|
||||||
|
public static void sd_journal_flush_matches(Pointer<sdJournal> j) {
|
||||||
|
sd_journal_flush_matches(Pointer.getPeer(j));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static void sd_journal_flush_matches(@Ptr long j);
|
||||||
|
|
||||||
|
public static int sd_journal_seek_head(Pointer<sdJournal> j) {
|
||||||
|
return sd_journal_seek_head(Pointer.getPeer(j));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_seek_head(@Ptr long j);
|
||||||
|
|
||||||
|
public static int sd_journal_seek_tail(Pointer<sdJournal> j) {
|
||||||
|
return sd_journal_seek_tail(Pointer.getPeer(j));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_seek_tail(@Ptr long j);
|
||||||
|
|
||||||
|
public static int sd_journal_seek_monotonic_usec(Pointer<sdJournal> j, sd_id128 boot_id,
|
||||||
|
long usec) {
|
||||||
|
return sd_journal_seek_monotonic_usec(Pointer.getPeer(j), boot_id, usec);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_seek_monotonic_usec(@Ptr long j, sd_id128 boot_id, long usec);
|
||||||
|
|
||||||
|
public static int sd_journal_seek_realtime_usec(Pointer<sdJournal> j, long usec) {
|
||||||
|
return sd_journal_seek_realtime_usec(Pointer.getPeer(j), usec);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_seek_realtime_usec(@Ptr long j, long usec);
|
||||||
|
|
||||||
|
public static int sd_journal_seek_cursor(Pointer<sdJournal> j, Pointer<Byte> cursor) {
|
||||||
|
return sd_journal_seek_cursor(Pointer.getPeer(j), Pointer.getPeer(cursor));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_seek_cursor(@Ptr long j, @Ptr long cursor);
|
||||||
|
|
||||||
|
public static int sd_journal_get_cursor(Pointer<sdJournal> j, Pointer<Pointer<Byte>> cursor) {
|
||||||
|
return sd_journal_get_cursor(Pointer.getPeer(j), Pointer.getPeer(cursor));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_get_cursor(@Ptr long j, @Ptr long cursor);
|
||||||
|
|
||||||
|
public static int sd_journal_test_cursor(Pointer<sdJournal> j, Pointer<Byte> cursor) {
|
||||||
|
return sd_journal_test_cursor(Pointer.getPeer(j), Pointer.getPeer(cursor));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_test_cursor(@Ptr long j, @Ptr long cursor);
|
||||||
|
|
||||||
|
public static int sd_journal_get_cutoff_realtime_usec(Pointer<sdJournal> j, Pointer<Long> from,
|
||||||
|
Pointer<Long> to) {
|
||||||
|
return sd_journal_get_cutoff_realtime_usec(Pointer.getPeer(j), Pointer.getPeer(from), Pointer.getPeer(to));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_get_cutoff_realtime_usec(@Ptr long j, @Ptr long from, @Ptr long to);
|
||||||
|
|
||||||
|
public static int sd_journal_get_cutoff_monotonic_usec(Pointer<sdJournal> j, sd_id128 boot_id,
|
||||||
|
Pointer<Long> from, Pointer<Long> to) {
|
||||||
|
return sd_journal_get_cutoff_monotonic_usec(Pointer.getPeer(j), boot_id, Pointer.getPeer(from), Pointer.getPeer(to));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_get_cutoff_monotonic_usec(@Ptr long j, sd_id128 boot_id, @Ptr long from,
|
||||||
|
@Ptr long to);
|
||||||
|
|
||||||
|
public static int sd_journal_get_usage(Pointer<sdJournal> j, Pointer<Long> bytes) {
|
||||||
|
return sd_journal_get_usage(Pointer.getPeer(j), Pointer.getPeer(bytes));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_get_usage(@Ptr long j, @Ptr long bytes);
|
||||||
|
|
||||||
|
public static int sd_journal_query_unique(Pointer<sdJournal> j, Pointer<Byte> field) {
|
||||||
|
return sd_journal_query_unique(Pointer.getPeer(j), Pointer.getPeer(field));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_query_unique(@Ptr long j, @Ptr long field);
|
||||||
|
|
||||||
|
public static int sd_journal_enumerate_unique(Pointer<sdJournal> j, Pointer<Pointer<?>> data,
|
||||||
|
Pointer<SizeT> l) {
|
||||||
|
return sd_journal_enumerate_unique(Pointer.getPeer(j), Pointer.getPeer(data), Pointer.getPeer(l));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_enumerate_unique(@Ptr long j, @Ptr long data, @Ptr long l);
|
||||||
|
|
||||||
|
public static void sd_journal_restart_unique(Pointer<sdJournal> j) {
|
||||||
|
sd_journal_restart_unique(Pointer.getPeer(j));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static void sd_journal_restart_unique(@Ptr long j);
|
||||||
|
|
||||||
|
public static int sd_journal_get_fd(Pointer<sdJournal> j) {
|
||||||
|
return sd_journal_get_fd(Pointer.getPeer(j));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_get_fd(@Ptr long j);
|
||||||
|
|
||||||
|
public static int sd_journal_get_events(Pointer<sdJournal> j) {
|
||||||
|
return sd_journal_get_events(Pointer.getPeer(j));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_get_events(@Ptr long j);
|
||||||
|
|
||||||
|
public static int sd_journal_get_timeout(Pointer<sdJournal> j, Pointer<Long> timeout_usec) {
|
||||||
|
return sd_journal_get_timeout(Pointer.getPeer(j), Pointer.getPeer(timeout_usec));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_get_timeout(@Ptr long j, @Ptr long timeout_usec);
|
||||||
|
|
||||||
|
public static int sd_journal_process(Pointer<sdJournal> j) {
|
||||||
|
return sd_journal_process(Pointer.getPeer(j));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_process(@Ptr long j);
|
||||||
|
|
||||||
|
public static int sd_journal_wait(Pointer<sdJournal> j, long timeout_usec) {
|
||||||
|
return sd_journal_wait(Pointer.getPeer(j), timeout_usec);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_wait(@Ptr long j, long timeout_usec);
|
||||||
|
|
||||||
|
public static int sd_journal_reliable_fd(Pointer<sdJournal> j) {
|
||||||
|
return sd_journal_reliable_fd(Pointer.getPeer(j));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_reliable_fd(@Ptr long j);
|
||||||
|
|
||||||
|
public static int sd_journal_get_catalog(Pointer<sdJournal> j, Pointer<Pointer<Byte>> text) {
|
||||||
|
return sd_journal_get_catalog(Pointer.getPeer(j), Pointer.getPeer(text));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_get_catalog(@Ptr long j, @Ptr long text);
|
||||||
|
|
||||||
|
public static int sd_journal_get_catalog_for_message_id(sd_id128 id, Pointer<Pointer<Byte>> ret) {
|
||||||
|
return sd_journal_get_catalog_for_message_id(id, Pointer.getPeer(ret));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected native static int sd_journal_get_catalog_for_message_id(sd_id128 id, @Ptr long ret);
|
||||||
|
|
||||||
|
public interface sdJournal {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package org.xbib.systemd;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public interface SystemdJournalListener {
|
||||||
|
|
||||||
|
void handleMessage(String message) throws IOException;
|
||||||
|
}
|
38
src/main/java/org/xbib/systemd/sd_id128.java
Normal file
38
src/main/java/org/xbib/systemd/sd_id128.java
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
package org.xbib.systemd;
|
||||||
|
|
||||||
|
import org.bridj.BridJ;
|
||||||
|
import org.bridj.Pointer;
|
||||||
|
import org.bridj.StructObject;
|
||||||
|
import org.bridj.ann.Array;
|
||||||
|
import org.bridj.ann.Field;
|
||||||
|
import org.bridj.ann.Library;
|
||||||
|
import org.bridj.ann.Union;
|
||||||
|
|
||||||
|
@Union
|
||||||
|
@Library("systemd")
|
||||||
|
public class sd_id128 extends StructObject {
|
||||||
|
|
||||||
|
static {
|
||||||
|
BridJ.register();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Array({16})
|
||||||
|
@Field(0)
|
||||||
|
public Pointer<Byte > bytes() {
|
||||||
|
return io.getPointerField(this, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Array({2})
|
||||||
|
@Field(1)
|
||||||
|
public Pointer<Long > qwords() {
|
||||||
|
return io.getPointerField(this, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public sd_id128() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public sd_id128(Pointer pointer) {
|
||||||
|
super(pointer);
|
||||||
|
}
|
||||||
|
}
|
22
src/test/java/org/xbib/systemd/SystemdJournalReaderTest.java
Normal file
22
src/test/java/org/xbib/systemd/SystemdJournalReaderTest.java
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
package org.xbib.systemd;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.condition.DisabledOnOs;
|
||||||
|
import org.junit.jupiter.api.condition.OS;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
@DisabledOnOs({OS.MAC, OS.WINDOWS})
|
||||||
|
public class SystemdJournalReaderTest {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(SystemdJournalReaderTest.class.getName());
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testConsumer() throws InterruptedException {
|
||||||
|
SystemdJournalConsumer consumer = new SystemdJournalConsumer("SYSLOG_IDENTIFIER=su", null,
|
||||||
|
logger::info);
|
||||||
|
Executors.newSingleThreadExecutor().submit(consumer);
|
||||||
|
Thread.sleep(60000L);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue