add RPC.strerror

This commit is contained in:
Doug MacEachern 2006-02-27 01:47:41 +00:00
parent f0cdd946c5
commit 9f1fa65239
4 changed files with 26 additions and 1 deletions

View File

@ -439,6 +439,16 @@ JNIEXPORT jint SIGAR_JNI(RPC_ping)
#endif
}
JNIEXPORT jstring SIGAR_JNI(RPC_strerror)
(JNIEnv *env, jclass cls_obj, jint err)
{
#ifdef WIN32
return NULL;
#else
return JENV->NewStringUTF(env, sigar_rpc_strerror(err));
#endif
}
JNIEXPORT jobjectArray SIGAR_JNI(Sigar_getCpuInfoList)
(JNIEnv *env, jobject sigar_obj)
{

View File

@ -16,6 +16,8 @@ public class RPC {
long program,
long version);
public static native String strerror(int status);
public static int ping(String hostname,
int protocol,
String program,
@ -66,4 +68,10 @@ public class RPC {
return num.longValue();
}
public static void main(String[] args) throws Exception {
Sigar.load();
int retval = RPC.ping(args[0], args[1]);
System.out.println("(" + retval + ") " + RPC.strerror(retval));
}
}

View File

@ -620,6 +620,8 @@ SIGAR_DECLARE(int) sigar_rpc_ping(char *hostname,
unsigned long program,
unsigned long version);
SIGAR_DECLARE(char *) sigar_rpc_strerror(int err);
SIGAR_DECLARE(char *) sigar_password_get(const char *prompt);
#ifdef __cplusplus

View File

@ -510,6 +510,11 @@ static enum clnt_stat get_sockaddr(struct sockaddr_in *addr, char *host)
return RPC_SUCCESS;
}
char *sigar_rpc_strerror(int err)
{
return clnt_sperrno(err);
}
SIGAR_DECLARE(int) sigar_rpc_ping(char *host,
int protocol,
unsigned long program,
@ -534,7 +539,7 @@ SIGAR_DECLARE(int) sigar_rpc_ping(char *host,
client = clntudp_create(&addr, program, version,
interval, &sock);
if (!client) {
return RPC_FAILED;
return rpc_createerr.cf_stat;
}
timeout.tv_sec = 10;