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 #include <iomanip>
00028 #include "VestaSource.H"
00029 #include "Recovery.H"
00030 
00031 using std::ostream;
00032 using std::setw;
00033 using std::setfill;
00034 using std::hex;
00035 using std::dec;
00036 
00037 ostream&
00038 operator<<(ostream& s, const LongId& longid)
00039 {
00040     int i;
00041     int len = longid.length();
00042     for (i=0; i<len; i++) {
00043         s << setw(2) << setfill('0') << hex
00044           << (int) (longid.value.byte[i] & 0xff);
00045     }
00046     s << setfill(' ') << dec;
00047     return s;
00048 }
00049 
00050 
00051 ostream&
00052 PutQuotedString(ostream& s, const char* string)
00053 {
00054     s << '\"';
00055     while (*string) {
00056         if (*string == '\"' || *string == '\\') {
00057             s << '\\';
00058         }
00059         s << *string++;
00060     }
00061     s << '\"';
00062     return s;
00063 }
00064 
00065 ostream&
00066 PutFPTag(ostream& s, const FP::Tag& fptag)
00067 {
00068     const Bit8 *p = (Bit8*)((FP::Tag&)fptag).Words();
00069     int i;
00070     for (i=0; i<FP::ByteCnt; i++) {
00071         s << setw(2) << setfill('0') << hex << (int) (p[i] & 0xff);
00072     }
00073     s << setfill(' ') << dec;
00074     return s;
00075 }
00076 
00077 void
00078 LogPutQuotedString(VestaLog& log, const char* string)
00079 {
00080     log.put("\"");
00081     while (*string) {
00082       if (*string == '\"' || *string == '\\') {
00083         log.put('\\');
00084       }
00085       log.put(*string++);
00086     }
00087     log.put("\"");
00088 }
00089 
00090 void
00091 GetFPTag(RecoveryReader* rr, char& c, FP::Tag& fptag)
00092 {
00093     int i, j;
00094     char chr[3];
00095     chr[2] = '\000';
00096     Bit8* p = (Bit8*)fptag.Words();
00097     rr->skipWhite(c);
00098     for (i=0; i<FP::ByteCnt; i++) {
00099         for (j=0; j<2; j++) {
00100             if (!isxdigit(c)) {
00101                 throw VestaLog::Error(0, Text("RecoveryReader::getFPTag: ") +
00102                                       "bad hex digit: " + c);
00103             }
00104             chr[j] = c;
00105             rr->get(c);
00106         }
00107         p[i] = strtol(chr, NULL, 16);
00108     }
00109 }
00110