00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "w_defines.h"
00031
00032
00033
00034 #define LID_T_C
00035
00036 #ifdef __GNUC__
00037 #pragma implementation
00038 #endif
00039
00040 #include <cstdlib>
00041 #include <w_stream.h>
00042 #include <cstring>
00043 #include "basics.h"
00044 #include "tid_t.h"
00045 #include "lid_t.h"
00046
00047 const lvid_t lvid_t::null;
00048
00049 ostream& operator<<(ostream& o, const lvid_t& lvid)
00050 {
00051 const u_char* p = (const u_char*) &lvid.high;
00052
00053
00054
00055 return o << u_int(p[0]) << '.' << u_int(p[1]) << '.'
00056 << u_int(p[2]) << '.' << u_int(p[3]) << ':'
00057 << lvid.low;
00058 }
00059
00060 istream& operator>>(istream& is, lvid_t& lvid)
00061 {
00062 is.clear();
00063 w_base_t::uint4_t i;
00064 char c;
00065 const w_base_t::uint4_t parts = sizeof(lvid.high);
00066 int temp[parts];
00067
00068
00069
00070 for (i=0; i<parts; i++) { temp[i] = 0; }
00071
00072
00073
00074 for (i=0, c='.'; i<parts && c!='\0'; i++) {
00075 is >> temp[i];
00076
00077 if (is.peek() == '.' || is.peek()== ':') {
00078 is >> c;
00079 } else {
00080 c = '\0';
00081 break;
00082 }
00083 }
00084 if (i==1) {
00085
00086
00087 lvid.low = temp[0];
00088 temp[0]=0;
00089 } else if (c == ':') {
00090
00091
00092
00093
00094 if(i!=parts) {
00095 is.clear(ios::badbit);
00096 } else {
00097 is >> lvid.low;
00098 }
00099 } else {
00100
00101
00102
00103
00104 is.clear(ios::badbit);
00105 }
00106
00107 ((char*)&lvid.high)[0] = temp[0];
00108 ((char*)&lvid.high)[1] = temp[1];
00109 ((char*)&lvid.high)[2] = temp[2];
00110 ((char*)&lvid.high)[3] = temp[3];
00111
00112 return is;
00113 }
00114
00115
00116
00117
00118
00119
00120
00121 extern "C" bool lvid_t_is_null(const lvid_t &x);
00122
00123 bool
00124 lvid_t_is_null(const lvid_t &x)
00125 {
00126 return x == lvid_t::null;
00127 }
00128