Changeset 151 for sbliveos2/trunk/lib32/misc.c
- Timestamp:
- May 28, 2000, 6:50:46 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sbliveos2/trunk/lib32/misc.c
r142 r151 50 50 } 51 51 52 #define CR 0x0d 53 #define LF 0x0a 54 55 56 #define LEADING_ZEROES 0x8000 57 #define SIGNIFICANT_FIELD 0x0007 58 59 char *HexLongToASCII(char *StrPtr, unsigned long wHexVal, unsigned short Option); 60 char *DecLongToASCII(char *StrPtr, unsigned long lDecVal, unsigned short Option); 61 62 63 //SvL: Not safe to use in non-KEE driver 52 64 int sprintf (char *buffer, const char *format, ...) 53 65 { 54 return 0; 66 char *BuildPtr=buffer; 67 char *pStr = (char *) format; 68 char *SubStr; 69 union { 70 void *VoidPtr; 71 unsigned short *WordPtr; 72 unsigned long *LongPtr; 73 #ifdef KEE 74 unsigned long *StringPtr; 75 #else 76 double *StringPtr; 77 #endif 78 } Parm; 79 int wBuildOption; 80 81 Parm.VoidPtr=(void *) &format; 82 Parm.StringPtr++; // skip size of string pointer 83 84 while (*pStr) 85 { 86 switch (*pStr) 87 { 88 case '%': 89 wBuildOption=0; 90 pStr++; 91 if (*pStr=='0') 92 { 93 wBuildOption|=LEADING_ZEROES; 94 pStr++; 95 } 96 if (*pStr=='u') // always unsigned 97 pStr++; 98 99 switch(*pStr) 100 { 101 case 'x': 102 case 'X': 103 BuildPtr=HexLongToASCII(BuildPtr, *Parm.LongPtr++,wBuildOption); 104 pStr++; 105 continue; 106 107 case 'd': 108 BuildPtr=DecLongToASCII(BuildPtr, *Parm.LongPtr++,wBuildOption); 109 pStr++; 110 continue; 111 112 #ifdef KEE 113 case 's': 114 SubStr=(char *)*Parm.StringPtr; 115 while (*BuildPtr++ = *SubStr++); 116 Parm.StringPtr++; 117 BuildPtr--; // remove the \0 118 pStr++; 119 continue; 120 #endif 121 case 'l': 122 pStr++; 123 switch (*pStr) 124 { 125 case 'x': 126 case 'X': 127 BuildPtr=HexLongToASCII(BuildPtr, *Parm.LongPtr++,wBuildOption); 128 pStr++; 129 continue; 130 131 case 'd': 132 BuildPtr=DecLongToASCII(BuildPtr, *Parm.LongPtr++,wBuildOption); 133 pStr++; 134 continue; 135 } // end switch 136 continue; // dunno what he wants 137 138 case 0: 139 continue; 140 } // end switch 141 break; 142 143 case '\\': 144 pStr++; 145 switch (*pStr) 146 { 147 case 'n': 148 *BuildPtr++=LF; 149 pStr++; 150 continue; 151 152 case 'r': 153 *BuildPtr++=CR; 154 pStr++; 155 continue; 156 157 case 0: 158 continue; 159 break; 160 } // end switch 161 162 break; 163 } // end switch 164 165 *BuildPtr++=*pStr++; 166 } // end while 167 168 *BuildPtr=0; // cauterize the string 169 return 1; //not correct 55 170 } 56 171
Note:
See TracChangeset
for help on using the changeset viewer.