Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

VLogHelp.C

Go to the documentation of this file.
00001 // Copyright (C) 2001, Compaq Computer Corporation
00002 // 
00003 // This file is part of Vesta.
00004 // 
00005 // Vesta is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 // 
00010 // Vesta is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with Vesta; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019 //
00020 // VLogHelp.C
00021 // Last modified on Thu Jul 29 14:23:30 EDT 2004 by ken@xorian.net
00022 //      modified on Wed Jul 18 19:30:49 PDT 2001 by mann
00023 //
00024 // Helpful functions for logging
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 

Generated on Mon May 8 00:48:53 2006 for Vesta by  doxygen 1.4.2