2012-05-09 09:35:15 +00:00
|
|
|
/**
|
|
|
|
* Copyright (C) 2011 The Serval Project
|
|
|
|
*
|
|
|
|
* This file is part of Serval Software (http://www.servalproject.org)
|
|
|
|
*
|
|
|
|
* Serval Software 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.
|
|
|
|
*
|
|
|
|
* This source code 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 should have received a copy of the GNU General Public License
|
|
|
|
* along with this source code; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
2012-04-24 07:36:48 +00:00
|
|
|
package org.servalproject.servald;
|
|
|
|
|
2012-04-30 08:15:24 +00:00
|
|
|
import java.util.List;
|
|
|
|
import java.util.LinkedList;
|
2012-04-24 07:36:48 +00:00
|
|
|
|
|
|
|
class ServalD
|
|
|
|
{
|
2012-04-30 08:15:24 +00:00
|
|
|
int status;
|
2012-11-07 06:42:04 +00:00
|
|
|
List<byte[]> outv;
|
2012-04-30 08:15:24 +00:00
|
|
|
|
2013-01-23 04:10:19 +00:00
|
|
|
static
|
2012-04-24 07:36:48 +00:00
|
|
|
{
|
2013-01-23 04:10:19 +00:00
|
|
|
String property = System.getProperty("java.library.path");
|
|
|
|
System.err.println("Attempting to load libservald.so from "+property);
|
2012-04-24 07:36:48 +00:00
|
|
|
System.loadLibrary("servald");
|
|
|
|
}
|
|
|
|
|
2013-01-23 04:10:19 +00:00
|
|
|
private static native int rawCommand(IJniResults outv, String[] args);
|
2012-04-30 08:15:24 +00:00
|
|
|
|
|
|
|
public void command(String... args)
|
|
|
|
{
|
2012-11-07 06:42:04 +00:00
|
|
|
this.outv = new LinkedList<byte[]>();
|
2013-01-23 04:10:19 +00:00
|
|
|
IJniResults results = new JniResultsList(outv);
|
|
|
|
this.status = this.rawCommand(results, args);
|
2012-04-30 08:15:24 +00:00
|
|
|
}
|
2012-04-24 07:36:48 +00:00
|
|
|
|
|
|
|
public static void main(String[] args)
|
|
|
|
{
|
2012-04-30 08:15:24 +00:00
|
|
|
ServalD servald = new ServalD();
|
|
|
|
servald.command(args);
|
2012-11-07 06:42:04 +00:00
|
|
|
for (byte[] a: servald.outv) {
|
|
|
|
System.out.println(new String(a));
|
2012-04-24 07:36:48 +00:00
|
|
|
}
|
2012-04-30 08:15:24 +00:00
|
|
|
System.exit(servald.status);
|
2012-04-24 07:36:48 +00:00
|
|
|
}
|
|
|
|
}
|