Browse Source

Remove API.java example (no copyright license)

Luke Dashjr 12 years ago
parent
commit
a9c6ce1fcc
6 changed files with 1 additions and 175 deletions
  1. BIN
      API.class
  2. 0 166
      API.java
  3. 1 1
      Makefile.am
  4. 0 6
      README.RPC
  5. 0 1
      debian/bfgminer.docs
  6. 0 1
      make-release

BIN
API.class


+ 0 - 166
API.java

@@ -1,166 +0,0 @@
-/*
- *
- * Copyright (C) Andrew Smith 2012-2013
- *
- * Usage: java API command ip port
- *
- * If any are missing or blank they use the defaults:
- *
- *	command = 'summary'
- *	ip	= '127.0.0.1'
- *	port	= '4028'
- *
- */
-
-import java.net.*;
-import java.io.*;
-
-class API
-{
-	static private final int MAXRECEIVESIZE = 65535;
-
-	static private Socket socket = null;
-
-	private void closeAll() throws Exception
-	{
-		if (socket != null)
-		{
-			socket.close();
-			socket = null;
-		}
-	}
-
-	public void display(String result) throws Exception
-	{
-		String value;
-		String name;
-		String[] sections = result.split("\\|", 0);
-
-		for (int i = 0; i < sections.length; i++)
-		{
-			if (sections[i].trim().length() > 0)
-			{
-				String[] data = sections[i].split(",", 0);
-
-				for (int j = 0; j < data.length; j++)
-				{
-					String[] nameval = data[j].split("=", 2);
-
-					if (j == 0)
-					{
-						if (nameval.length > 1
-						&&  Character.isDigit(nameval[1].charAt(0)))
-							name = nameval[0] + nameval[1];
-						else
-							name = nameval[0];
-
-						System.out.println("[" + name + "] =>");
-						System.out.println("(");
-					}
-
-					if (nameval.length > 1)
-					{
-						name = nameval[0];
-						value = nameval[1];
-					}
-					else
-					{
-						name = "" + j;
-						value = nameval[0];
-					}
-
-					System.out.println("   ["+name+"] => "+value);
-				}
-				System.out.println(")");
-			}
-		}
-	}
-
-	public void process(String cmd, InetAddress ip, int port) throws Exception
-	{
-		StringBuffer sb = new StringBuffer();
-		char buf[] = new char[MAXRECEIVESIZE];
-		int len = 0;
-
-System.out.println("Attempting to send '"+cmd+"' to "+ip.getHostAddress()+":"+port);
-
-		try
-		{
-			socket = new Socket(ip, port);
-			PrintStream ps = new PrintStream(socket.getOutputStream());
-			ps.print(cmd.toLowerCase().toCharArray());
-			ps.flush();
-
-			InputStreamReader isr = new InputStreamReader(socket.getInputStream());
-			while (0x80085 > 0)
-			{
-				len = isr.read(buf, 0, MAXRECEIVESIZE);
-				if (len < 1)
-					break;
-				sb.append(buf, 0, len);
-				if (buf[len-1] == '\0')
-					break;
-			}
-
-			closeAll();
-		}
-		catch (IOException ioe)
-		{
-			System.err.println(ioe.toString());
-			closeAll();
-			return;
-		}
-
-		String result = sb.toString();
-
-		System.out.println("Answer='"+result+"'");
-
-		display(result);
-	}
-
-	public API(String command, String _ip, String _port) throws Exception
-	{
-		InetAddress ip;
-		int port;
-
-		try
-		{
-			ip = InetAddress.getByName(_ip);
-		}
-		catch (UnknownHostException uhe)
-		{
-			System.err.println("Unknown host " + _ip + ": " + uhe);
-			return;
-		}
-
-		try
-		{
-			port = Integer.parseInt(_port);
-		}
-		catch (NumberFormatException nfe)
-		{
-			System.err.println("Invalid port " + _port + ": " + nfe);
-			return;
-		}
-
-		process(command, ip, port);
-	}
-
-	public static void main(String[] params) throws Exception
-	{
-		String command = "summary";
-		String ip = "127.0.0.1";
-		String port = "4028";
-
-		if (params.length > 0 && params[0].trim().length() > 0)
-			command = params[0].trim();
-
-		if (params.length > 1 && params[1].trim().length() > 0)
-			ip = params[1].trim();
-
-		if (params.length > 2 && params[2].trim().length() > 0)
-			port = params[2].trim();
-
-		new API(command, ip, port);
-	}
-}

+ 1 - 1
Makefile.am

@@ -27,7 +27,7 @@ dist_doc_DATA = \
 rpcexamplesdir = $(docdir)/rpc-examples
 dist_rpcexamples_DATA = \
 		  api-example.php miner.php \
-		  API.class API.java api-example.c \
+		  api-example.c \
                   api-example.py
 
 SUBDIRS		= lib ccan

+ 0 - 6
README.RPC

@@ -390,12 +390,6 @@ api-example.php - a PHP script to access the API
  You must modify the line "$socket = getsock('127.0.0.1', 4028);" at the
  beginning of "function request($cmd)" to change where it looks for BFGMiner
 
-API.java/API.class
- a java program to access the API (with source code)
-  usage is: java API command address port
- Any missing or blank parameters are replaced as if you entered:
-  java API summary 127.0.0.1 4028
-
 api-example.c - a 'C' program to access the API (with source code)
   usage: api-example [command [ip/host [port]]]
  again, as above, missing or blank parameters are replaced as if you entered:

+ 0 - 1
debian/bfgminer.docs

@@ -1,4 +1,3 @@
-API.java
 api-example.c
 api-example.php
 api-example.py

+ 0 - 1
make-release

@@ -113,7 +113,6 @@ for build in "${builds[@]}"; do
 		*.cl \
 		example.conf \
 		windows-build.txt \
-		API.class \
 		miner.php \
 		"$PKGDIR/"
 	make clean