src/numeric2string.cxx

00001 // This program is free software; you can redistribute it and/or modify
00002 // it under the terms of the GNU General Public License as published by
00003 // the Free Software Foundation; either version 2 of the License, or
00004 // (at your option) any later version.
00005 // 
00006 // This program is distributed in the hope that it will be useful,
00007 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00008 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00009 // GNU Library General Public License for more details.
00010 // 
00011 // You should have received a copy of the GNU General Public License
00012 // along with this program; if not, write to the Free Software
00013 // Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
00014 
00015 #include "numeric2string.hpp"
00016 
00017 #include <string.h>
00018 #include <malloc.h>
00019 #include <stdio.h>
00020 
00021 static char *hexchars[]={
00022         "0","1","2","3","4","5","6","7","8","9",
00023         "A","B","C","D","E","F","G","H","J","K",
00024         "L","M","N","P","Q","R","S","T",
00025         "U","V","W","X","Y","Z"};
00026 
00027 static int maxHexIndex=-1;
00028 
00029 static char *starSizes[8]={
00030         "Ia","Ib","II","III","IV","V","VI","D"
00031 };
00032 
00033 static char *starTypes[7]={
00034         "O","B","A","F","G","K","M"
00035 };
00036 
00037 char* starSize(int x){
00038         return starSizes[x];
00039 }
00040 
00041 char* starType(int x){
00042         return starTypes[x];
00043 }
00044 
00045 char * itohex(int ix){
00046         if ( maxHexIndex == -1 ) {
00047                 maxHexIndex=0;
00048                 while(strcmp(hexchars[maxHexIndex],"Z") != 0 ){
00049                         maxHexIndex++;
00050                 }
00051         }
00052         if ( ix > maxHexIndex ) return hexchars[maxHexIndex];
00053         if ( ix < 0 ) return hexchars[0];
00054         
00055         return hexchars[ix];
00056 }
00057 
00058 int hextoi(char* p){
00059         int ix;
00060         for(ix=0;ix<=maxHexIndex;ix++){
00061                 if ( strcmp(p,hexchars[ix]) == 0 ) 
00062                         return ix;
00063         }
00064         return 0;
00065 }
00066 

Generated on Fri Mar 7 16:40:53 2008 for frpuniverse by  doxygen 1.4.7