Go to the documentation of this file.00001
00002 #ifdef HAVE_CONFIG_H
00003 #include "config.h"
00004 #include "gridsolve-config.h"
00005 #endif
00006
00007 #include "nsdsi.h"
00008 #include "grpc.h"
00009
00010 int
00011 ns_dsi_close(DSI_FILE *dsi_file)
00012 {
00013 if(grpc_dsi_close(dsi_file) != GRPC_NO_ERROR) {
00014 if(grpc_minor_errno == GRPC_DSI_MANAGE_ERROR)
00015 ns_errno = NetSolveIBPManageError;
00016 else if(grpc_minor_errno == GRPC_DSI_DISABLED)
00017 ns_errno = NetSolveDsiDisabled;
00018
00019 return -1;
00020 }
00021
00022 return 1;
00023 }
00024
00025 DSI_FILE *
00026 ns_dsi_open(char *host_name, int flag, int permissions, int size,
00027 dsi_type storage_system)
00028 {
00029 DSI_FILE *dfile;
00030
00031 if(grpc_dsi_open(&dfile, host_name, flag, permissions, size, storage_system)
00032 != GRPC_NO_ERROR)
00033 {
00034 if(grpc_minor_errno == GRPC_DSI_UNKNOWN_FILE)
00035 ns_errno = NetSolveUnknownDsiFile;
00036 else if(grpc_minor_errno == GRPC_DSI_DISABLED)
00037 ns_errno = NetSolveDsiDisabled;
00038 else if(grpc_minor_errno == GRPC_DSI_ALLOCATE_ERROR)
00039 ns_errno = NetSolveIBPAllocateError;
00040
00041 return NULL;
00042 }
00043
00044 return dfile;
00045 }
00046
00047 int
00048 ns_dsi_read_vector(DSI_OBJECT *dsi_obj, void *data,
00049 int count, enum datatype data_type)
00050 {
00051 int bytes_read = 0;
00052
00053 if(grpc_dsi_read_vector(dsi_obj, data, count, data_type, &bytes_read)
00054 != GRPC_NO_ERROR)
00055 {
00056 if(grpc_minor_errno == GRPC_DSI_LOAD_ERROR)
00057 ns_errno = NetSolveIBPLoadError;
00058 else if(grpc_minor_errno == GRPC_DSI_DISABLED)
00059 ns_errno = NetSolveDsiDisabled;
00060 else if(grpc_minor_errno == GRPC_DSI_EACCES)
00061 ns_errno = NetSolveDsiEACCESS;
00062
00063 return -1;
00064 }
00065
00066 return bytes_read;
00067 }
00068
00069 int
00070 ns_dsi_read_matrix(DSI_OBJECT *dsi_obj, void *data,
00071 int rows, int cols, enum datatype data_type)
00072 {
00073 return ns_dsi_read_vector(dsi_obj, data, rows*cols, data_type);
00074 }
00075
00076 DSI_OBJECT *
00077 ns_dsi_write_vector(DSI_FILE *dsi_file, void *data, int count,
00078 enum datatype data_type)
00079 {
00080 DSI_OBJECT *rv = NULL;
00081
00082 if(grpc_dsi_write_vector(&rv, dsi_file, data, count, data_type)
00083 != GRPC_NO_ERROR)
00084 {
00085 if((grpc_minor_errno == GRPC_DSI_STORE_ERROR) ||
00086 (grpc_minor_errno == GRPC_DSI_INTERNAL_ERROR))
00087 ns_errno = NetSolveIBPStoreError;
00088 else if(grpc_minor_errno == GRPC_DSI_DISABLED)
00089 ns_errno = NetSolveDsiDisabled;
00090 else if(grpc_minor_errno == GRPC_DSI_EACCES)
00091 ns_errno = NetSolveDsiEACCESS;
00092
00093 return NULL;
00094 }
00095
00096 return rv;
00097 }
00098
00099 DSI_OBJECT *
00100 ns_dsi_write_matrix(DSI_FILE *dsi_file, void *data, int rows,
00101 int cols, enum datatype data_type)
00102 {
00103 return ns_dsi_write_vector(dsi_file, data, rows*cols, data_type);
00104 }