static const char* const errTexts[] = {
"Unexpected EOF from peer",
"Generic error",
- "Protocol parse error",
- "Compulsory element not found in message",
+ "Cannot parse protocol messages",
+ "Obligatory element not found in message",
"Unknown protocol command",
"SSL error",
"Error from Myproxy server",
const char *
edg_wlpr_GetErrorText(int code)
{
- return code ?
- (code <= EDG_WLPR_ERROR_BASE ?
- strerror(code) :
- errTexts[code - EDG_WLPR_ERROR_BASE - 1]
- ) :
- NULL;
+ if (code == 0)
+ return "No error";
+ if (code <= EDG_WLPR_ERROR_BASE)
+ return strerror(code);
+ if (code == EDG_WLPR_ERROR_ERRNO)
+ return strerror(errno);
+ return errTexts[code - EDG_WLPR_ERROR_BASE - 1];
}
int
#ident "$Header$"
-static const char * const ErrorMsgs[] = {
- "Connection closed unexpectedly",
- "Generic error",
- "Cannot parse protocol messages",
- "Obligatory item not found in message",
- "Unkown command",
- "SSL error",
- "MyProxy error",
- "Proxy not registered",
- "Proxy expired",
- "VOMS error",
- "Operation timed out",
- "System error",
-};
-
/* nread() and nwrite() never return partial data */
static int
nread(int sock, struct timeval *to, char *buf, size_t buf_len, size_t *read_len)
memset(response, 0, sizeof(*response));
}
-const char *
-edg_wlpr_GetErrorString(int code)
-{
- if (code == 0)
- return "No error";
- if (code <= EDG_WLPR_ERROR_BASE)
- return strerror(code);
- return ErrorMsgs[code - EDG_WLPR_ERROR_BASE - 1];
-}
-
char *
edg_wlpr_EncodeInt(int num) /* long? time */
{
ret = edg_wlpr_Read(sock, &timeout, &buf, &buf_len);
if (ret) {
edg_wlpr_Log(ctx, LOG_ERR, "Error reading from client: %s",
- edg_wlpr_GetErrorString(ret));
+ edg_wlpr_GetErrorText(ret));
return ret;
}
free(buf);
if (ret) {
edg_wlpr_Log(ctx, LOG_ERR, "Error sending response to client: %s",
- edg_wlpr_GetErrorString(ret));
+ edg_wlpr_GetErrorText(ret));
goto end;
}
0, &request->version);
if (ret) {
edg_wlpr_Log(ctx, LOG_ERR, "Protocol error reading protocol specification: %s",
- edg_wlpr_GetErrorString(ret));
+ edg_wlpr_GetErrorText(ret));
return ret;
}
0, &value);
if (ret) {
edg_wlpr_Log(ctx, LOG_ERR, "Protocol error reading command specification: %s",
- edg_wlpr_GetErrorString(ret));
+ edg_wlpr_GetErrorText(ret));
goto err;
}
SEPARATORS, 0, &request->myproxy_server);
if (ret && ret != EDG_WLPR_ERROR_PROTO_PARSE_NOT_FOUND) {
edg_wlpr_Log(ctx, LOG_ERR, "Protocol error reading myproxy server specification: %s",
- edg_wlpr_GetErrorString(ret));
+ edg_wlpr_GetErrorText(ret));
goto err;
}
0, &request->proxy_filename);
if (ret && ret != EDG_WLPR_ERROR_PROTO_PARSE_NOT_FOUND) {
edg_wlpr_Log(ctx, LOG_ERR, "Protocol error reading proxy specification: %s",
- edg_wlpr_GetErrorString(ret));
+ edg_wlpr_GetErrorText(ret));
goto err;
}
0, &request->jobid);
if (ret && ret != EDG_WLPR_ERROR_PROTO_PARSE_NOT_FOUND) {
edg_wlpr_Log(ctx, LOG_ERR, "Protocol error reading JobId : %s",
- edg_wlpr_GetErrorString(ret));
+ edg_wlpr_GetErrorText(ret));
goto err;
}