1 // Copyright 2006 Alp Toker <alp@atoker.com>
2 // This software is made available under the MIT License
3 // See COPYING for details
6 using System
.Collections
.Generic
;
13 public enum MType
: byte
22 public enum Field
: byte
35 public enum Endian
: byte
42 public enum MFlag
: byte
45 NoReplyExpected
= 0x01,
49 public enum DType
: byte
64 ObjectPath
= (byte)'o',
65 Signature
= (byte)'g',
71 StructBegin
= (byte)'(',
72 StructEnd
= (byte)')',
74 DictEntry
= (byte)'e',
75 DictEntryBegin
= (byte)'{',
76 DictEntryEnd
= (byte)'}',
81 //protocol versions that we support
82 public const byte MinVersion
= 0;
83 public const byte Version
= 1;
84 public const byte MaxVersion
= Version
;
86 public const uint MaxMessageLength
= 134217728; //2 to the 27th power
87 public const uint MaxArrayLength
= 67108864; //2 to the 26th power
88 public const uint MaxSignatureLength
= 255;
89 public const uint MaxArrayDepth
= 32;
90 public const uint MaxStructDepth
= 32;
92 public static int PadNeeded (int pos
, int alignment
)
94 int pad
= pos
% alignment
;
95 pad
= pad
== 0 ? 0 : alignment
- pad
;
100 public static int Padded (int pos
, int alignment
)
102 int pad
= pos
% alignment
;
104 pos
+= alignment
- pad
;
109 public static int GetAlignment(DType dtype
)
131 case DType
.ObjectPath
:
133 case DType
.Signature
:
138 case DType
.StructBegin
:
139 case DType
.StructEnd
:
140 case DType
.DictEntry
:
141 case DType
.DictEntryBegin
:
142 case DType
.DictEntryEnd
:
148 throw new Exception("Cannot determine alignment of " + dtype
);
154 public class WvDbusError
: Exception
156 public WvDbusError() : base()
160 public WvDbusError(string msg
) : base(msg
)
164 public WvDbusError(string msg
, Exception inner
) : base(msg
, inner
)