struct StringsBase *StringsBase=0L; /*long ltoh(long zahl,char *kette);*/ /*#define RUN*/ #ifdef RUN long ltoh(s,zahl) register char *s; register long zahl; { register int i=0,ci,bi=32; if(s) { do { bi-=4; ci=((zahl>>bi)&0xF)+0x30; if(ci>0x39) ci+=0x7; *s++=ci; } while(bi>0); *s=0; i=8; } return i; } /* $VER: ltoh 0.3 */ #endif long test(l) long l; { long el=0; char *s[128]; el=ltoh(s,l); printf("%12ld %9s %ld\n",l,s,el); return el; } int main() { /* MAIN */ long el=0; char *p; puts(" Input Output Len "); StringsBase=(struct StringsBase *)OpenLibrary("Strings.library",0); test(1); test(0); test(-1); test(255); test(-256); test(65535); test(-65536); test(252645135); test(-252645136); test(2147483647); test(-2147483648); test(12); test(123456789); p=0; el=ltoh(p,el); printf("p = %x el = %ld\n",p,el); if(StringsBase) CloseLibrary(StringsBase); return el; } /* END */ /* Input Output Len 1 00000001 8 0 00000000 8 -1 FFFFFFFF 8 255 000000FF 8 -256 FFFFFF00 8 65535 0000FFFF 8 -65536 FFFF0000 8 252645135 0F0F0F0F 8 -252645136 F0F0F0F0 8 2147483647 7FFFFFFF 8 -2147483648 80000000 8 12 0000000C 8 123456789 075BCD15 8 p = 0 el = 0 */