ReactOS 0.4.16-dev-329-g9223134
clnt_perror.c File Reference
#include <wintirpc.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <rpc/rpc.h>
#include <rpc/types.h>
#include <rpc/auth.h>
#include <rpc/clnt.h>
Include dependency graph for clnt_perror.c:

Go to the source code of this file.

Macros

#define CLNT_PERROR_BUFLEN   256
 

Functions

static char_buf (void)
 
static charauth_errmsg (enum auth_stat)
 
charclnt_sperror (CLIENT *rpch, const char *s)
 
void clnt_perror (CLIENT *rpch, const char *s)
 
charclnt_sperrno (enum clnt_stat stat)
 
void clnt_perrno (enum clnt_stat num)
 
charclnt_spcreateerror (char *s) const
 
void clnt_pcreateerror (char *s) const
 

Variables

static charbuf
 
static const char *const rpc_errlist []
 
static const char *const auth_errlist []
 

Macro Definition Documentation

◆ CLNT_PERROR_BUFLEN

#define CLNT_PERROR_BUFLEN   256

Definition at line 52 of file clnt_perror.c.

Function Documentation

◆ _buf()

static char * _buf ( void  )
static

Definition at line 55 of file clnt_perror.c.

56{
57
58 if (buf == 0)
59 buf = (char *)malloc(CLNT_PERROR_BUFLEN);
60 return (buf);
61}
#define CLNT_PERROR_BUFLEN
Definition: clnt_perror.c:52
#define malloc
Definition: debug_ros.c:4
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751

Referenced by __write_formatted_timeT(), clnt_spcreateerror(), and clnt_sperror().

◆ auth_errmsg()

static char * auth_errmsg ( enum auth_stat  stat)
static

Definition at line 329 of file clnt_perror.c.

331{
332 unsigned int errnum = stat;
333
334 if (errnum < (sizeof(auth_errlist)/sizeof(auth_errlist[0])))
335 /* LINTED interface problem */
336 return (char *)auth_errlist[errnum];
337
338 return(NULL);
339}
#define stat
Definition: acwin.h:99
static const char *const auth_errlist[]
Definition: clnt_perror.c:317
#define NULL
Definition: types.h:112

Referenced by clnt_sperror().

◆ clnt_pcreateerror()

void clnt_pcreateerror ( char s) const

Definition at line 307 of file clnt_perror.c.

309{
310
311 if (s == NULL)
312 return;
313
315}
char * clnt_spcreateerror(char *s) const
Definition: clnt_perror.c:239
GLdouble s
Definition: gl.h:2039
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)

Referenced by getclnthandle(), and nfs41_rpc_clnt_create().

◆ clnt_perrno()

void clnt_perrno ( enum clnt_stat  num)

Definition at line 231 of file clnt_perror.c.

233{
234 (void) fprintf(stderr, "%s\n", clnt_sperrno(num));
235}
char * clnt_sperrno(enum clnt_stat stat)
Definition: clnt_perror.c:218
GLuint GLuint num
Definition: glext.h:9618

◆ clnt_perror()

void clnt_perror ( CLIENT rpch,
const char s 
)

Definition at line 181 of file clnt_perror.c.

184{
185
186 if (rpch == NULL || s == NULL)
187 return;
188
189 (void) fprintf(stderr, "%s\n", clnt_sperror(rpch,s));
190}
char * clnt_sperror(CLIENT *rpch, const char *s)
Definition: clnt_perror.c:67

Referenced by pmap_getmaps().

◆ clnt_spcreateerror()

char * clnt_spcreateerror ( char s) const

Definition at line 239 of file clnt_perror.c.

241{
242 char *str, *err;
243 size_t len, i;
244
245 if (s == NULL)
246 return(0);
247
248 str = _buf(); /* side effect: sets CLNT_PERROR_BUFLEN */
249 if (str == 0)
250 return(0);
252 snprintf(str, len, "%s: ", s);
253 i = strlen(str);
254 if (i > 0)
255 len -= i;
257 switch (rpc_createerr.cf_stat) {
258 case RPC_PMAPFAILURE:
259 (void) strncat(str, " - ", len - 1);
261 if (err)
262 (void) strncat(str, err+5, len-5);
263 switch(rpc_createerr.cf_error.re_status) {
264 case RPC_CANTSEND:
265 case RPC_CANTRECV:
266 i = strlen(str);
267 len -= i;
268 snprintf(str+i, len, ": errno %d (%s)",
269 rpc_createerr.cf_error.re_errno,
270 strerror(rpc_createerr.cf_error.re_errno));
271 break;
272 default:
273 break;
274 }
275 break;
276
277 case RPC_SYSTEMERROR:
278 (void)strncat(str, " - ", len - 1);
280 len - 4);
281 break;
282
283 case RPC_CANTSEND:
286 case RPC_SUCCESS:
287 case RPC_UNKNOWNPROTO:
289 case RPC_FAILED:
290 case RPC_UNKNOWNHOST:
292 case RPC_PROCUNAVAIL:
294 case RPC_PROGUNAVAIL:
295 case RPC_AUTHERROR:
296 case RPC_VERSMISMATCH:
297 case RPC_TIMEDOUT:
298 case RPC_CANTRECV:
299 default:
300 break;
301 }
302 str[CLNT_PERROR_BUFLEN-1] = '\0';
303 return (str);
304}
char * strncat(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:605
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static char * _buf(void)
Definition: clnt_perror.c:55
#define RPC_PMAPFAILURE
Definition: clnt_stat.h:57
@ RPC_SUCCESS
Definition: clnt_stat.h:22
@ RPC_CANTDECODERES
Definition: clnt_stat.h:27
@ RPC_TIMEDOUT
Definition: clnt_stat.h:31
@ RPC_PROGNOTREGISTERED
Definition: clnt_stat.h:58
@ RPC_AUTHERROR
Definition: clnt_stat.h:38
@ RPC_PROGUNAVAIL
Definition: clnt_stat.h:39
@ RPC_CANTSEND
Definition: clnt_stat.h:28
@ RPC_FAILED
Definition: clnt_stat.h:68
@ RPC_CANTDECODEARGS
Definition: clnt_stat.h:42
@ RPC_UNKNOWNHOST
Definition: clnt_stat.h:48
@ RPC_CANTRECV
Definition: clnt_stat.h:29
@ RPC_CANTENCODEARGS
Definition: clnt_stat.h:26
@ RPC_UNKNOWNPROTO
Definition: clnt_stat.h:49
@ RPC_PROGVERSMISMATCH
Definition: clnt_stat.h:40
@ RPC_SYSTEMERROR
Definition: clnt_stat.h:43
@ RPC_PROCUNAVAIL
Definition: clnt_stat.h:41
@ RPC_VERSMISMATCH
Definition: clnt_stat.h:37
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
const char * strerror(int err)
Definition: compat_str.c:23
#define err(...)
const WCHAR * str
struct rpc_err cf_error
Definition: clnt.h:497
enum clnt_stat cf_stat
Definition: clnt.h:496
#define snprintf
Definition: wintirpc.h:48

Referenced by clnt_pcreateerror().

◆ clnt_sperrno()

char * clnt_sperrno ( enum clnt_stat  stat)

Definition at line 218 of file clnt_perror.c.

220{
221 unsigned int errnum = stat;
222
223 if (errnum < (sizeof(rpc_errlist)/sizeof(rpc_errlist[0])))
224 /* LINTED interface problem */
225 return (char *)rpc_errlist[errnum];
226
227 return ("RPC: (unknown error code)");
228}
static const char *const rpc_errlist[]
Definition: clnt_perror.c:192

Referenced by clnt_perrno(), clnt_spcreateerror(), and clnt_sperror().

◆ clnt_sperror()

char * clnt_sperror ( CLIENT rpch,
const char s 
)

Definition at line 67 of file clnt_perror.c.

70{
71 struct rpc_err e;
72 char *err;
73 char *str;
74 char *strstart;
75 size_t len, i;
76
77 if (rpch == NULL || s == NULL)
78 return(0);
79
80 str = _buf(); /* side effect: sets CLNT_PERROR_BUFLEN */
81 if (str == 0)
82 return (0);
84 strstart = str;
85 CLNT_GETERR(rpch, &e);
86
87 if (snprintf(str, len, "%s: ", s) > 0) {
88 i = strlen(str);
89 str += i;
90 len -= i;
91 }
92
93 (void)strncpy(str, clnt_sperrno(e.re_status), len - 1);
94 i = strlen(str);
95 str += i;
96 len -= i;
97
98 switch (e.re_status) {
99 case RPC_SUCCESS:
102 case RPC_TIMEDOUT:
103 case RPC_PROGUNAVAIL:
104 case RPC_PROCUNAVAIL:
106 case RPC_SYSTEMERROR:
107 case RPC_UNKNOWNHOST:
108 case RPC_UNKNOWNPROTO:
109 case RPC_PMAPFAILURE:
111 case RPC_FAILED:
112 break;
113
114 case RPC_CANTSEND:
115 case RPC_CANTRECV:
116 snprintf(str, len, "; errno = %s", strerror(e.re_errno));
117 i = strlen(str);
118 if (i > 0) {
119 str += i;
120 len -= i;
121 }
122 break;
123
124 case RPC_VERSMISMATCH:
125 snprintf(str, len, "; low version = %u, high version = %u",
126 e.re_vers.low, e.re_vers.high);
127 i = strlen(str);
128 if (i > 0) {
129 str += i;
130 len -= i;
131 }
132 break;
133
134 case RPC_AUTHERROR:
135 err = auth_errmsg(e.re_why);
136 snprintf(str, len, "; why = ");
137 i = strlen(str);
138 if (i > 0) {
139 str += i;
140 len -= i;
141 }
142 if (err != NULL) {
143 snprintf(str, len, "%s",err);
144 } else {
146 "(unknown authentication error - %d)",
147 (int) e.re_why);
148 }
149 i = strlen(str);
150 if (i > 0) {
151 str += i;
152 len -= i;
153 }
154 break;
155
157 snprintf(str, len, "; low version = %u, high version = %u",
158 e.re_vers.low, e.re_vers.high);
159 i = strlen(str);
160 if (i > 0) {
161 str += i;
162 len -= i;
163 }
164 break;
165
166 default: /* unknown */
167 snprintf(str, len, "; s1 = %u, s2 = %u",
168 e.re_lb.s1, e.re_lb.s2);
169 i = strlen(str);
170 if (i > 0) {
171 str += i;
172 len -= i;
173 }
174 break;
175 }
176 strstart[CLNT_PERROR_BUFLEN-1] = '\0';
177 return(strstart) ;
178}
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
#define CLNT_GETERR(rh, errp)
Definition: clnt.h:219
static char * auth_errmsg(enum auth_stat)
Definition: clnt_perror.c:329
#define e
Definition: ke_i.h:82
Definition: clnt.h:95

Referenced by clnt_perror().

Variable Documentation

◆ auth_errlist

const char* const auth_errlist[]
static
Initial value:
= {
"Authentication OK",
"Invalid client credential",
"Server rejected credential",
"Invalid client verifier",
"Server rejected verifier",
"Client credential too weak",
"Invalid server verifier",
"Failed (unspecified error)"
}

Definition at line 317 of file clnt_perror.c.

Referenced by auth_errmsg().

◆ buf

char* buf
static

Definition at line 48 of file clnt_perror.c.

◆ rpc_errlist

const char* const rpc_errlist[]
static
Initial value:
= {
"RPC: Success",
"RPC: Can't encode arguments",
"RPC: Can't decode result",
"RPC: Unable to send",
"RPC: Unable to receive",
"RPC: Timed out",
"RPC: Incompatible versions of RPC",
"RPC: Authentication error",
"RPC: Program unavailable",
"RPC: Program/version mismatch",
"RPC: Procedure unavailable",
"RPC: Server can't decode arguments",
"RPC: Remote system error",
"RPC: Unknown host",
"RPC: Port mapper failure",
"RPC: Program not registered",
"RPC: Failed (unspecified error)",
"RPC: Unknown protocol"
}

Definition at line 192 of file clnt_perror.c.

Referenced by clnt_sperrno().