gs_error.c

Go to the documentation of this file.
00001 
00008 /* $Id: gs_error.c,v 1.4 2007/03/01 22:52:31 seymour Exp $ */
00009 /* $UTK_Copyright: $ */
00010 
00011 #include <stdio.h>
00012 
00013 #include "idl_export.h"
00014 #include "grpc.h"
00015 
00027 IDL_VPTR
00028 gs_error_string(int argc, IDL_VPTR* argv_idl)
00029 {
00030   grpc_error_t retval;
00031   int status;
00032 
00033   IDL_ENSURE_SCALAR(argv_idl[0]);
00034 
00035   status = IDL_LongScalar(argv_idl[0]);
00036 
00037   /* Initialize GridRPC system */
00038   retval = grpc_initialize(NULL);
00039   if((retval != GRPC_NO_ERROR) && (retval != GRPC_ALREADY_INITIALIZED)) {
00040     IDL_Message(IDL_M_GENERIC, IDL_MSG_INFO, "Error: cannot initialize!");
00041     return IDL_StrToSTRING("Init failed.");
00042   }
00043   
00044   return IDL_StrToSTRING(grpc_error_string((grpc_error_t)status));
00045 }
00046 
00059 IDL_VPTR
00060 gs_get_last_error(int argc, IDL_VPTR* argv_idl)
00061 {
00062   grpc_sessionid_t id;
00063   grpc_error_t retval;
00064 
00065   /* Initialize GridRPC system */
00066   retval = grpc_initialize(NULL);
00067   if((retval != GRPC_NO_ERROR) && (retval != GRPC_ALREADY_INITIALIZED)) {
00068     IDL_Message(IDL_M_GENERIC, IDL_MSG_INFO, "Error: cannot initialize!");
00069     return IDL_GettmpLong(retval);
00070   }
00071 
00072   if(grpc_get_failed_sessionid(&id) != GRPC_NO_ERROR) {
00073     IDL_Message(IDL_M_GENERIC, IDL_MSG_INFO, 
00074       "Error: could not get last failed session ID.");
00075     return IDL_GettmpLong(0);
00076   }
00077 
00078   return IDL_GettmpLong(grpc_get_error(id));
00079 }