BPicture: Fix archive constructor.
[haiku.git] / src / add-ons / kernel / file_systems / nfs4 / RPCReply.cpp
blobbca2eaa5bf4c6b7ce87aa6cfc6118df802cbce63
1 /*
2 * Copyright 2012 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Paweł Dziepak, pdziepak@quarnos.org
7 */
10 #include "RPCReply.h"
12 #include <debug.h>
13 #include <util/kernel_cpp.h>
15 #include "RPCDefs.h"
18 using namespace RPC;
21 Reply::Reply(void* buffer, int size)
23 fError(B_OK),
24 fStream(buffer, size),
25 fBuffer(buffer)
27 ASSERT(buffer != NULL);
29 fXID = fStream.GetUInt();
30 if (fStream.GetInt() != REPLY) {
31 fError = B_BAD_VALUE;
32 return;
35 if (fStream.GetInt() == MSG_ACCEPTED) {
36 fStream.GetInt();
37 fStream.GetOpaque(NULL);
39 switch (fStream.GetInt()) {
40 case SUCCESS:
41 return;
42 case PROG_UNAVAIL:
43 case PROG_MISMATCH:
44 case PROC_UNAVAIL:
45 fError = B_DEVICE_NOT_FOUND;
46 return;
47 case GARBAGE_ARGS:
48 fError = B_MISMATCHED_VALUES;
49 return;
50 case SYSTEM_ERR:
51 fError = B_ERROR;
52 return;
53 default:
54 fError = B_BAD_VALUE;
55 return;
57 } else { // MSG_DENIED
58 if (fStream.GetInt() == RPC_MISMATCH) {
59 fError = B_DEVICE_NOT_FOUND;
60 return;
61 } else { // AUTH_ERROR
62 fError = B_PERMISSION_DENIED;
63 return;
69 Reply::~Reply()
71 free(fBuffer);