Date: Wed, 29 May 1996 21:10:07 -0400 (EDT) From: ptownson@massis.lcs.mit.edu (Patrick A. Townson) Subject: Phone Number to Word Conversion Program Something we have not done for awhile here is a number => word <= number conversion program. A new one was given to me today and I am passing it along for you to play with. **I have not tested it, and make no guarentees how it will work** You'll need to fine tune it a little for your own computer, and of course you will need to remove the notes the author left to guide you. You'll need 'fone.h' which he includes. Have fun, and let me know how it works out for you. The author said to not include his email address since he did this on company time and does not want to be punished. :) PAT This is fone.h /*copyright mike diross may 1996 */ /*please feel free to use this code */ /*free free to give this code to other people */ /*just dont sell it */ /*the orginal version was written on a sun workstation*/ /*running unix/solaris */ /*this software 1 - tells you what your fone number */ /* spells */ /* 2 - converts a spelled fone number */ /* back to numeric digits */ /*many people out their have fone numbers that spell */ /*something ranging from really cool words to boring */ /*words that are easy to remember. some of the fone # */ /*i have owned over the years are */ /* TOY-BUGS */ /* HOT-FEET */ /* WINE-ALE */ /* 441-HEAT */ /* 441-LOST - a boss of mine at motorola */ /* 277-VOLT */ /* 273-GLAD */ /* 800-BAD-DEAL sales man nightmare */ /* 800-MY-ANI-IS */ /* 602-ASS-HOLE - a popular phoenix fish resturant*/ #ifndef ASCII #define ASCII 1 #define EBCDIC 2 #define UNIX 1 #define MSDOS 2 #define IBMMVS 3 #define INBVMCMS 4 #define MYCHAR ASCII #define MYOS UNIX #define MAXLETDI 3 #define MAXLINSIZ 0 #define MAXFONESIZE 500 #define BUGEND 0 #define TTY 1 /*to make the code run under tty devices or xwindows*/ #define XWINDOWSOUT 2 /*define the terminal type were using */ #define TERMINAL TTY #define MAXDIGI 999999999 /*max digits to process in a fone number set to 999999*/ #define FONELINE 3 /*lines on the users screen. pause after that many lines*/ int cleanit(unsigned char *,unsigned char *,unsigned long int ,unsigned char *,unsigned char *); /*removes garbage chars */ unsigned char *gnext(unsigned char *,unsigned char *); /*gets next fone # to analyize */ int recursive(int,int,unsigned char *,unsigned char [],int,unsigned char,unsigned char,int); /*tells ya what your fone spells*/ int vernum(unsigned char *,unsigned char); unsigned long int getulnum(unsigned char *); int pitout(unsigned char *,unsigned char *,unsigned long int,unsigned char *,unsigned char *, unsigned long int,unsigned char *,unsigned char,unsigned char,int,unsigned char,int *); unsigned char letter(unsigned char,int,unsigned char); unsigned char henter(); #endif -------------------- /*copyright mike diross may 1996 */ /*please feel free to use this code */ /*free free to give this code to other people */ /*just dont sell it */ /*the orginal version was written on a sun workstation*/ /*running unix/solaris */ /*this software 1 - tells you what your fone number */ /* spells */ /* 2 - converts a spelled fone number */ /* back to numeric digits */ /*many people out their have fone numbers that spell */ /*something ranging from really cool words to boring */ /*words that are easy to remember. some of the fone # */ /*i have owned over the years are */ /* TOY-BUGS */ /* HOT-FEET */ /* WINE-ALE */ /* 441-HEAT */ /* 441-LOST - a boss of mine at motorola */ /* i have had only 2 bosses in my */ /* life that were losers, duds, */ /* jerks, dopes etc so from the */ /* looks of his fone number do you */ /* think he was one of em */ /* 277-VOLT */ /* 273-GLAD */ /* 800-BAD-DEAL sales man nightmare */ /* 800-MY-ANI-IS */ /* 602-ASS-HOLE - a popular phoenix fish resturant*/ #include #include #include #include int bytesout; int *bytesout0; unsigned long int pagesize; unsigned long int linesout; unsigned char pageit; main(int args,unsigned char *text[]) { #include "fone.h" #define SIBUGFONE 1 /*por favor senor debug this routine*/ #define NOBUGFONE 2 /*por favor senor no debug this routine*/ #define BUGFONE BUGFONE unsigned char textbuffer[32766]; int thechar=0; unsigned char *me=(unsigned char *)"fone"; unsigned char oneopt[]="-1"; unsigned char wopt[]="-w"; unsigned char fopt[]="-f"; unsigned char lopt[]="-l"; unsigned char popt[]="-p"; unsigned char nopt[]="-n"; unsigned char t3opt[]="-3"; unsigned char t4opt[]="-4"; unsigned char numopt[]="-num"; unsigned char maxopt[]="-max"; unsigned char sepopt[]="-sep"; unsigned char optopt[]="-opt"; unsigned char dumpopts='n'; unsigned char numonly[]="-numonly"; unsigned char got34='n'; unsigned char gotmax='n'; unsigned char gotsep='n'; unsigned char got1w='n'; unsigned char gotl='n'; unsigned char gotf='n'; unsigned char gotp='n'; unsigned char gotbadsep='n'; unsigned char *p,*pp; unsigned char *seps=(unsigned char *)" ,;\n\r\t"; /*digits that can be used to seperate fone #s*/ unsigned char *onlydigits=(unsigned char *)"0123456789-()[]"; unsigned char *argisdata; int numargs=0; /*num args passed via parms*/ int numdata=0; /*num words read from stdin*/ int bytesread=0; unsigned char *file=(unsigned char *)""; /*file to read in and process*/ int fnum=0; /*file to read file number*/ unsigned char buffer[10]; unsigned char *mecopwr=(unsigned char *)"/*copyright mike diross may 1996*/"; #if MYCHAR==ASCII unsigned char *validd=(unsigned char *)" !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"; /*valid digits in a phone number*/ #else unsigned char *validd=(unsigned char *)"0123456789-()"; /*valid digits in a phone number*/ #endif int i,ii; int rc=0; int rc2=0; int onelines=80; /*size of the print line when we write a bunch of #s to one line*/ unsigned char fourdgts='n'; /*y=print # & letters for each fone. n=print only letters*/ unsigned char oneline='n'; /*print each fone number on a seperate line (y). write as many # on a line as you can fit (n)*/ unsigned char newline='n'; /*when mutiple numbers are fed into this routine start each new number on a new line*/ unsigned char alldigits[MAXFONESIZE]; unsigned char nojunk[MAXFONESIZE]; unsigned long int maxdigi=MAXDIGI; unsigned long int temp=0; bytesout=0; pagesize=FONELINE; linesout=0l; pageit='n'; if (args>1) { numargs++; argisdata=(unsigned char *)malloc(args+3); if (argisdata==0) { printf("malloc failed....dying\n"); return(1); } for (i=1;i i) { if (vernum((unsigned char *)text[i+1],(unsigned char)'n')==0) { *(argisdata+i+1)='o'; temp=getulnum((unsigned char *)text[i+1]); if (temp > 0 ) { pagesize=temp; } else { printf("%s option not given size. it defaults to %lu lines\n",popt,pagesize); } } } } if(strcmp((char *)text[i],(char *)maxopt)==0) /*any fone number that exceeds this many digits in length*/ { /*will not be analyized*/ *(argisdata+i)='o'; if (gotmax!='n') { printf("warning %s option used twice or more\n",maxopt); } gotmax='y'; if ((args-1) > i) { if (vernum((unsigned char *)text[i+1],(unsigned char)'n')==0) { *(argisdata+i+1)='o'; temp=getulnum((unsigned char *)text[i+1]); if (temp > 0 ) { maxdigi=temp; } else { printf("%s option requires a positive nonzero number \'%s\' is invalid. %lu will be used\n", maxopt,text[i+1],maxdigi); } } else { printf("error %s option must be followed by a positive number \'%s\' is invalid\n",maxopt,text[i+1]); } } else { printf("error a number must follow the %s option\n",maxopt); } } if(strcmp((char *)text[i],(char *)lopt)==0) /*get the length of the line to print fone #'s on */ { *(argisdata+i)='o'; if (gotl!='n') { printf("warning %s option used twice or more\n",lopt); } gotl='y'; if ((args-1) > i) { if (vernum((unsigned char *)text[i+1],(unsigned char)'n')==0) { *(argisdata+i+1)='o'; temp=getulnum((unsigned char *)text[i+1]); if (temp > 0 ) { onelines=(int)temp; } else { printf("%s option requires a positive nonzero number \'%s\' is invalid. %d will be used\n", lopt,text[i+1],onelines); } } else { printf("error %s option must be followed by a positive number \'%s\' is invalid\n",lopt,text[i+1]); } } else { printf("error a number must follow the %s option\n",lopt); } } if(strcmp((char *)text[i],(char *)sepopt)==0) /*characters to seperate fone numbers*/ { *(argisdata+i)='o'; if (gotsep!='n') { printf("warning %s option used twice or more\n",sepopt); } gotsep='y'; if ((args-1) > i) { *(argisdata+i+1)='o'; seps=text[i+1]; gotbadsep='n'; p=seps; while(*p && gotbadsep=='n') { if (*p>='0' && *p<='9') { printf("warning %s option seperator digits %s contain one or more numbers\n",sepopt,seps); gotbadsep='y'; } p++; } } else { printf("no characters follow %s option. no seperator characters will be used\n",sepopt); seps=(unsigned char *)""; } } if(strcmp((char *)text[i],(char *)fopt)==0) /*file to read in and process*/ { *(argisdata+i)='o'; if (gotf!='n') { printf("warning %s option used twice or more\n",fopt); } gotf='y'; if ((args-1) > i) { *(argisdata+i+1)='o'; file=text[i+1]; } else { printf("no file name given after %s option\n",fopt); } } } if (dumpopts=='y') { printf("%s=%c\n",optopt,dumpopts); printf("%s=file to read=\'%s\'%\n",fopt,file); printf("%s=%s\n",nopt,newline=='y'? "when analyzing a new fone # print its output on a new line" :"when analyzing a new fone # makes output continue on the current line"); printf("%s=characters that will be used to seperate fone #\'s are \'%s\'\n",sepopt,seps); printf("%s=line length=%d bytes\n",lopt,onelines); printf("%s=dont analyize any numbers which contain more then %lu digits\n",maxopt,maxdigi); printf("%s -%s\n",oneopt,oneline=='y'? "only print 1 spelling on each line": "print as many spelling as will fit on each line"); printf("%s -%s\n",wopt,oneline=='y'? "only print 1 spelling on each line": "print as many spelling as will fit on each line"); printf("%s - %s\n",t3opt,fourdgts=='n' ? "print 3 digits for each input number": (fourdgts=='y'? "print 4 digits for each input number": "print 1 digit for each input number")); printf("%s - %s\n",t4opt,fourdgts=='n' ? "print 3 digits for each input number": (fourdgts=='y'?"print 4 digits for each input number" :"print 1 digit for each input number")); printf("%s=%c - REVERSE SPELLING convert words into numbers %s\n",numopt,fourdgts, fourdgts=='o'?"convert WORDS into NUMBERS":"convert numbers into words"); printf("%s=%c lines on terminal=%lu (%s)\n",popt,pageit,pagesize,(pageit=='y'? "pause after printing each screen and wait for user to hit enter": "print with out stopping")); } /*for each argument entered print out all the possible things that */ /* number could spell */ /* the routine is called */ /* fone -options n1 n2 n3 .... */ /* where n1 is the 1st number to spell out */ /* n2 is the 2nd number to spell out */ /* n3 is the 3rd number */ /* and you can give it as many numbers as the opperating system your */ /* running on will allow you to specify */ bytesout0=&bytesout; for (i=1;i0) { bytesread=1; p=textbuffer; buffer[0]=0; buffer[1]=0; textbuffer[0]=0; textbuffer[1]=0; while (bytesread!=0) { bytesread=read(fnum,buffer,1); if (bytesread==1) { if (strchr((char *)seps,(char)buffer[0])!=0) { bytesout0=&bytesout; #if BUGFONE==SIBUGFONE printf("%s calling pitout buffer=\'%s\'\n",me,buffer); printf("%s testbuffer=\'%s\'\n",me,textbuffer); #endif pitout(textbuffer,nojunk,(unsigned long)sizeof(nojunk),validd, seps,maxdigi,alldigits, fourdgts,oneline,onelines,newline,bytesout0); p=textbuffer; textbuffer[0]=0; textbuffer[1]=0; } else { if (strchr((char *)validd,(char)buffer[0])!=0) { *p=buffer[0]; p++; *p=0; } else { /*printf("illegal character\n");*/ } } } } if(bytesout!=0) { printf("\n"); bytesout=0; henter(); } if (close(fnum)) { printf("error closing file %s fnum=%d\n",file,fnum); } } else { printf("%s open failed on \'%s\' rc=%d\n",me,file,fnum); } } } if (numargs==0 && numdata==0) { printf("Usage: fone [-options] fone-1 fone-2 ...... fone-n\n"); printf(" fone-1 thru fone-n will have their numbers converted to letters\n"); printf(" and every possible spelling of the fone number will be displayed\n"); printf("note - the digits 0 and 1 are not converted to letters\n"); printf(" - ma bell never gave 0 or 1 letters\n"); printf("note - upper or lower case letters may be entered as part of the\n"); printf(" fone number. they will be displayed as all possible other letters\n"); printf(" they could be used in place of it\n"); printf(" for example if \'a\' is entered it will be treated like\n"); printf(" the number 2 and all possible combinations it could\n"); printf(" take on such as \'a\', \'b\', and \'c\' will be displayed\n"); printf(" the letters Qq and Zz are invalid digits in a fone number\n"); printf(" and will be displayed as the digit ?\n"); printf(" any other letters digits will be displayed as entered\n"); printf("note - an option is avaible to convert a spelled fone to digits \n"); printf(" fone %s TOY-BUGS will display the numbers needed to dial TOP-BUGS\n",numopt); printf("note - an option is availble to force the program to display either\n"); printf(" only the 3 letters of each fone number or \n"); printf(" the 3 letters and digit of each fone number \n"); printf("note - normally when i test a fone number to see if it spells anything\n"); printf(" i will first run the last 4 digits of the number\n"); printf(" then the 1st 3 digits and finnally the \n"); printf(" 1st 4 digits of the number\n"); printf(" this reduces the number of different spellings the program\n"); printf(" generates down to a managable level and you can usually\n"); printf(" quickly tell if the fone spells anythign cool\n"); printf("you can process a whole file of fones with this program\n"); printf("and tell the program to remove all the krap that isnt\n"); printf("fone numbers by using these options\n"); printf("\n"); printf("fone -f file_name -max 7 -numonly\n"); printf("\n"); printf("the\n"); printf(" -f file_name\n"); printf("\n"); printf("tells the program the file to read\n"); printf("the\n"); printf("\n"); printf(" -max 7 \n"); printf("\n"); printf("tell the program to only spell fone numbers with 7 digits or less.\n"); printf("any numbers found longer then 7 characters are discarded.\n"); printf("\n"); printf("the\n"); printf(" -numonly\n"); printf("\n"); printf("option says dont process any characters other then numbers\n"); printf(" if you dont like my defination of numbers there is an option\n"); printf(" on the command you can supply your own defination of what numbers are\n"); printf("\n"); printf("so if the file had a line in it of\n"); printf("\n"); printf("note that spaces, line feeds, carrage returns, commas, semi-colens\n"); printf(" are the default characters what seperate fone numbers.\n"); printf(" their is an option on the command line where you specify different\n"); printf(" characters to seperate fone numbers\n"); printf("bob smith 2553425\n"); printf("\n"); printf("only the number 2553425 would be processed as a fone\n"); printf("the name bob and smith would not be processed as a fone.\n"); printf("\n"); printf("also any numbers with area codes as\n"); printf("800-555-1212 or 310-333-4050 \n"); printf("\n"); printf("would not be processed because if the -max 7 option was given\n"); printf("because they have over 7 digits\n"); printf("note - these are the number of values generated for a fone #\n"); printf(" digits 3 letter 3 letter & \n"); printf(" in listing 1 number\n"); printf(" fone listing\n"); printf(" 1 3 4\n"); printf(" 2 9 16\n"); printf(" 3 27 64\n"); printf(" 4 81 256\n"); printf(" 5 243 1024\n"); printf(" 6 729 4096\n"); printf(" 7 2187 11638\n"); printf(" 8 6561 65536\n"); printf(" 9 19683 262144\n"); printf(" 10 59049 1048576\n"); printf("\n"); printf("-options \n"); printf(" %s - print each fone # on a seperate line%s\n",oneopt, oneline=='n'?"":" (this is default option)"); printf(" %s - put as many fone #\'s on a line as will fit (w means wrap)%s\n",wopt, oneline!='n'?"":" (this is default option)"); printf(" %s num - set the length of the line the fone #\'s are printed on default is %d\n",lopt,onelines); printf(" if the size is too small it will be expanded so\n"); printf(" one fone # prints on a line \n"); printf(" %s - display all possible spelling using only LETTERS only 2->A,B,C%s\n", t3opt, fourdgts=='n'?" (is the default)":""); printf(" %s - display all possible spellings using LETTERS and NUMBERS 2->A,B,C,2%s\n", t4opt,fourdgts!='n'?" (is the default)":""); printf(" %s - convert a fone # with letters to its numeric format only\n",numopt); printf(" fone %s 1-800-BAD-DEAL returns 800-223-3325\n",numopt); printf(" %s - if mutiple fones are given start each series of new numbers on a new line\n",nopt); printf(" %s- only process the digits %s. discard all other characters\n",numonly,onlydigits); printf(" - this is usfull if you have a file full of names and numbers\n"); printf(" - and only want to see what the fone numbers spell\n"); printf(" %s chars - these characters are used to seperate fone numbers the defaults are %s\n",sepopt,seps); printf(" note a space is one of the default seperators\n"); printf(" under unix %s \"\" can be given to set no seperator digits\n",sepopt); printf(" under unix %s \" \" can be given to use a space\n",sepopt); printf(" if the comma (,) was given and the number\n"); printf(" fone %s , 946-3253,AL8-7600,368-4161 \n",sepopt); printf(" 1st all the spellings for 946-3253 would be given\n"); printf(" then all the spellings for AL8-7600 would be given\n"); printf(" last all the spellings for 368-4161 would be given\n"); printf(" %s n - n is max size fone # to process %d digits is default\n",maxopt,maxdigi); printf(" any strings that are longer then this number will not be processed\n"); printf(" %s - dump the options in effect before listing fones \n",optopt); printf(" %s file - read in file and process fone #\'s in it\n",fopt); printf(" %s n - pause after printing n lines. hit enter to continue printing %lu is default size\n",popt,pagesize); #if MYOS==UNIX printf("note 2 - under unix certain characters such as *[]()\\?\n"); printf(" are special and must be either quoted with \" or \'\n"); printf(" or be prefixed with a back slash \\ such as\n"); printf(" fone \'(310)555-1212\'\n"); printf(" fone \\(310\\)555-1212\n"); #endif printf("examples -\n"); printf(" fone 8658\n"); printf(" fone 869-2847\n"); printf(" fone %s 1dirfull\n",oneopt); printf(" fone 4uandme\n"); printf(" fone 869-2847\n"); printf(" fone %s 3103334030\n",t4opt); printf(" fone %s 310-333-4030\n",t3opt); printf(" fone %s 800-bad-deal\n",numopt); printf(" fone 800-BAD-DEAL\n"); printf(" fone 800-223-3325\n"); printf(" fone 345 4567 444-3333 800-222-4567 310-333-4030\n"); printf(" fone %s 7 %s , %s 132 %s #include int recursive(int max_digits,int cur_digit,unsigned char *phone_number,unsigned char alldigits[],int maxout,unsigned char fourdgts,unsigned char oneline,int onelines) { extern int bytesout; int i,times; /*char fourdgts;*/ /*char letter(char,int);*/ /*translates # to letter/# 2 -> a,b,c,2 */ /*unsigned char letter(char,int,char);*/ /*translates # to letter/# 2 -> a,b,c,2 */ unsigned char *mecopwr=(unsigned char *)"/*copyright mike diross may 1996*/"; if (cur_digit == max_digits) { /*print out the stinking spelling of the fone number */ if (toupper(oneline)=='Y') { printf("%s\n",alldigits); /*print the fone on a line by its self*/ bytesout=0; /*zero byte count in case other people use it*/ henter(); } else { /*if we have numbers on the line from a prior call*/ /* and we are now printing a new set of numbers */ /* that are longer in length then the last number */ /* we may not have room to print the number on the*/ /* end of the line */ if (bytesout > 0) /*is junk printed on current line*/ { if (bytesout+cur_digit > onelines) /* dont have room for this number*/ { printf("\n"); /*terminate the stinking line */ bytesout=0; /*zero bytes printed on next line*/ henter(); } } printf("%s",alldigits); /*print the next fone #*/ bytesout+=cur_digit; /*caculate total bytes printed on this line*/ if ((bytesout+1+cur_digit) > onelines) /*room for 1 more number*/ { printf("\n"); /*no room for more numbers. end line*/ bytesout=0; /*zero bytes printed on next line*/ henter(); } else { printf(" "); /*add a space to seperate the last fone from the next*/ bytesout++; /*add 1 to the bytes printed on this line*/ } } return(0); } else { /*digits like 2 thru 9 have 3 possible values to display */ /*digits 0 & 1 do not convert to letters */ /*figure out what we should do for this digit */ switch (*(phone_number+cur_digit)) { case '2':; case '3':; case '4':; case '5':; case '6':; case '7':; case '8':; case '9':; case 'a':; case 'b':; case 'c':; case 'd':; case 'e':; case 'f':; case 'g':; case 'h':; case 'i':; case 'j':; case 'k':; case 'l':; case 'm':; case 'n':; case 'o':; case 'p':; case 'r':; case 's':; case 't':; case 'u':; case 'v':; case 'w':; case 'x':; case 'y':; case 'A':; case 'B':; case 'C':; case 'D':; case 'E':; case 'F':; case 'G':; case 'H':; case 'I':; case 'J':; case 'K':; case 'L':; case 'M':; case 'N':; case 'O':; case 'P':; case 'R':; case 'S':; case 'T':; case 'U':; case 'V':; case 'W':; case 'X':; case 'Y':; if (toupper(fourdgts)=='N') { times=3; } else { if (toupper(fourdgts)=='Y') { times=4; } else { /*added to convert spelled fone #'s back into numbers*/ times=1; } } break; default:; times=1; break; } /*some digits have no letter translation and will be displayed only once */ /* for example 0,1, and - have no letter to display */ /*other digits are display 3 times */ /* for example 2 will be displayed as 'a', 'b', and 'c' */ for (i=0;i #include "fone.h" int cleanit(unsigned char *sin,unsigned char *sout,unsigned long int lensout,unsigned char *digits,unsigned char *seps) { #define ITSCOOL 1 #define ITSNOTCOOL 2 #define BUGLEGAL ITSNOTCOOL #define BUGLEGAL2 ITSNOTCOOL #define BUGLEGAL3 ITSNOTCOOL int rc=0; int bp; unsigned long int legal=0l; /*legal digits in the fone*/ /*al5-2345 has 7 legal digits in it*/ /* the dash doesnt count */ /*(800)bad-deal has 10 legal digits*/ /* in it the ()- dont count*/ /*()--) has 0 legal digits */ /*legal digits are numbers and */ /* letters which can be used in a */ /* fone number (any execpt q & z) */ unsigned char *legald=(unsigned char *)"0123456789ABCDEFGHIJKLMNOPRSTUVWXYabcdefghijklmnoprstuvwxy"; unsigned char *mecopwr=(unsigned char *)"/*copyright mike diross may 1996*/"; unsigned char gotmatch='n'; unsigned long int minstrsize=2; /*min length of output string*/ unsigned long int bytesout=0; unsigned char *me=(unsigned char *)"cleanit"; unsigned char *pp; unsigned char *sout1; sout1=sout; #if BUGLEGAL3==ITSCOOL printf("\n%s GeT string=\'%s\'\n",me,sin); #endif if (lensout unsigned long int getulnum(unsigned char *sin) { /*note this routine does not check for number overflow*/ unsigned char *me=(unsigned char *)"getulnum"; unsigned char *here; unsigned long int zerosblasted=0; unsigned long int factor=1; unsigned long int digits=0; unsigned long int rc=0; unsigned long int i=0; unsigned long int temp; unsigned char *mecopwr=(unsigned char *)"/*copyright mike diross may 1996*/"; if (*sin==0) /*null strings are evil says the frog*/ { fprintf(stderr,"logic error %s was passed a null string\n",me); goto done; } if (*sin=='+') /*this routine only returns positive numbers*/ { /*skip over plus + sign */ sin++; } while (*sin=='0') /*skip over leading zeros*/ { zerosblasted++; sin++; } here=sin; while (*sin) /*count digits in the number*/ { digits++; if (*sin>='0' && *sin<='9') { /*number is okie dokie*/ } else { fprintf(stderr,"error in %s. number \'%s\' contains non-numeric digit(s)\n",me,here); goto done; } sin++; } if (digits==0lu) /*number is all zeros*/ { goto done; } for (i=0lu;i #include #include "fone.h" unsigned char henter() { unsigned char rc; extern unsigned long int linesout; extern unsigned long int pagesize; extern unsigned char pageit; unsigned char buffer[1000]; unsigned char *mecopwr=(unsigned char *)"/*copyright mike diross may 1996*/"; rc='n'; linesout++; if (toupper(pageit)=='Y') { if (linesout>=(pagesize-1)) /*hit enter to continue is counted as one line*/ { printf("hit enter to continue"); scanf("%c",buffer); linesout=0; rc='y'; } } return(rc); } this is the begining of C function letter.c /*copyright mike diross may 1996 */ /*please feel free to use this code */ /*free free to give this code to other people */ /*just dont sell it */ /*the orginal version was written on a sun workstation*/ /*running unix/solaris */ /*this software 1 - tells you what your fone number */ /* spells */ /* 2 - converts a spelled fone number */ /* back to numeric digits */ /*many people out their have fone numbers that spell */ /*something ranging from really cool words to boring */ /*words that are easy to remember. some of the fone # */ /*i have owned over the years are */ /* TOY-BUGS */ /* HOT-FEET */ /* WINE-ALE */ /* 441-HEAT */ /* 441-LOST - a boss of mine at motorola */ /* 277-VOLT */ /* 273-GLAD */ /* 800-BAD-DEAL sales man nightmare */ /* 800-MY-ANI-IS */ /* 602-ASS-HOLE - a popular phoenix fish resturant*/ #include "fone.h" #include /*char letter(char digit, int part)*/ unsigned char letter(unsigned char digit, int part,unsigned char fourdgts) { int bo; static unsigned char nums[10][4]={'0','0','0','0', '1','1','1','1', 'A','B','C','2', 'D','E','F','3', 'G','H','I','4', 'J','K','L','5', 'M','N','O','6', 'P','R','S','7', 'T','U','V','8', 'W','X','Y','9' }; /*table to convert spelled words into numeric fone numbers*/ static unsigned char nums2[10][1]={'0','1','2','3','4','5','6','7','8','9' }; unsigned char *mecopwr=(unsigned char *)"/*copyright mike diross may 1996*/"; /*this if is not needed in the program */ /*is only use is if the programmer who wrote the code was a */ /* moron and called the function with a incorrect value and */ /* in that case we will print a error message */ if (part<0 || part > MAXLETDI) { /*part must be 0 - 2 */ /*this is because each number can be translated into 3 letters*/ /*the number 2 can be a,b,c which is 3 values */ /*the number 3 can be d,e,f which is 3 values */ /* so part must be 0,1, or 2 which is one of the 3 values */ bo=printf("logic error part must be 0 thru 2 part=%d\n",part); if (bo==1){bo=7;} return('?'); } /*pick the letter to display this time*/ /*for example the first time thru here 2 will display as 'A' */ /* 2nd time thru 2 'B' */ /* last time thru 2 'C' */ /*some digits such as 0,1,- will only display as one value */ /*because ma bell never gave those digits letters */ /*and any digits or letters that are not part of a fone number */ /*will be returned as a '?' */ switch (digit) { case '2':; case 'a':; case 'b':; case 'c':; case 'A':; case 'B':; case 'C':; if (fourdgts=='o') { return(nums2[2][part]); } else { return(nums[2][part]); } break; case '3':; case 'd':; case 'e':; case 'f':; case 'D':; case 'E':; case 'F':; if (fourdgts=='o') { return(nums2[3][part]); } else { return(nums[3][part]); } break; case '4':; case 'g':; case 'h':; case 'i':; case 'G':; case 'H':; case 'I':; if (fourdgts=='o') { return(nums2[4][part]); } else { return(nums[4][part]); } break; case '5':; case 'j':; case 'k':; case 'l':; case 'J':; case 'K':; case 'L':; if (fourdgts=='o') { return(nums2[5][part]); } else { return(nums[5][part]); } break; case '6':; case 'm':; case 'n':; case 'o':; case 'M':; case 'N':; case 'O':; if (fourdgts=='o') { return(nums2[6][part]); } else { return(nums[6][part]); } break; case '7':; case 'p':; case 'r':; case 's':; case 'P':; case 'R':; case 'S':; if (fourdgts=='o') { return(nums2[7][part]); } else { return(nums[7][part]); } break; case '8':; case 't':; case 'u':; case 'v':; case 'T':; case 'U':; case 'V':; if (fourdgts=='o') { return(nums2[8][part]); } else { return(nums[8][part]); } break; case '9':; case 'w':; case 'x':; case 'y':; case 'W':; case 'X':; case 'Y':; if (fourdgts=='o') { return(nums2[9][part]); } else { return(nums[9][part]); } break; case '0':; case '1':; case '_':; case '-':; case '+':; case ',':; case '.':; case ';':; case '@':; case '#':; case '$':; case '%':; case '&':; case '*':; case '(':; case ')':; case '=':; case ':':; case '>':; case '<':; case '?':; case '/':; case '\'':; case '\"':; #if MYCHAR==ASCII case '^':; /* cap */ case '[':; /*left square brace */ case ']':; /*right square brace*/ case '{':; /*left squigly bracket */ case '}':; /*right squigly bracket */ case '\\':; /*back slash */ case '~':; /*spanish anye. or the tilde that goes over the spanish n*/ case '`':; /*back quote*/ #endif #if MYCHAR==EBCDIC #endif return(digit); break; /*default is for unprintable characters and the letters Qq and Zz */ default:; return('?'); break; } } /*copyright mike diross may 1996 */ /*please feel free to use this code */ /*free free to give this code to other people */ /*just dont sell it */ /*the orginal version was written on a sun workstation*/ /*running unix/solaris */ /*this software 1 - tells you what your fone number */ /* spells */ /* 2 - converts a spelled fone number */ /* back to numeric digits */ /*many people out their have fone numbers that spell */ /*something ranging from really cool words to boring */ /*words that are easy to remember. some of the fone # */ /*i have owned over the years are */ /* TOY-BUGS */ /* HOT-FEET */ /* WINE-ALE */ /* 441-HEAT */ /* 441-LOST - a boss of mine at motorola */ /* 277-VOLT */ /* 273-GLAD */ /* 800-BAD-DEAL sales man nightmare */ /* 800-MY-ANI-IS */ /* 602-ASS-HOLE - a popular phoenix fish resturant*/ #include "fone.h" #include #define BUGIT 1 #define DONTBUGIT 2 #define DEBUGME1 DONTBUGIT #define DEBUGME2 DONTBUGIT #define DEBUGME3 DONTBUGIT pitout(unsigned char *text,unsigned char nojunk[],unsigned long int snojunk,unsigned char *validd, unsigned char *seps,unsigned long int maxdigi,unsigned char alldigits[], unsigned char fourdgts,unsigned char oneline,int onelines,unsigned char newline,int *bytesout) { int rc2; unsigned char *me=(unsigned char *)"pitout"; int i; unsigned char *p,*pp; unsigned char *mecopwr=(unsigned char *)"/*copyright mike diross may 1996*/"; #if DEBUGME3==BUGIT printf("\n%s ENTERING %s\n",me,text); #endif if (strlen((char *)text) > 0) /*dont process null strings*/ { #if DEBUGME2==BUGIT printf("%s calling - cleanup gets \'%s\'\n",me,text); #endif nojunk[0]=0; /*null terminate output string*/ rc2=cleanit(text,nojunk,snojunk,validd,seps); /*copy good digits into nojunk*/ if (rc2) { printf("%s error. cleanit had too small buffer to process whole string\n",me); printf("%s error. string will be truncated to buffer size\n",me); } p=nojunk; /*find all the different fone #'s in this string delimited*/ #if DEBUGME1==BUGIT printf("\n%s processing string \'%s\'\n",me,p); printf("%s seps=\'%s\'\n",me,seps); #endif while(p) /*by any of the delimiter characters in seps */ { pp=p; /*point to next fone # to analyize */ p=gnext(pp,seps); /*get address of fone # to alalize after doing the pp done*/ if (strlen((char *)pp)>0) /*if a string is empty dont process it 234,,,456 */ { if (strlen((char *)pp) <= maxdigi) /* */ { alldigits[0]='\0'; /*set 1st byte of output fone to a null */ recursive(strlen((char *)pp),0,pp,alldigits,sizeof(alldigits),fourdgts,oneline,onelines); /*if they want each new fone number to start on a new line do it here*/ if (toupper(newline)=='Y') { /*space remains on the current line to print more fone numbers*/ if (*bytesout!=0) { printf("\n"); *bytesout=0; henter(); } } } else { if (*bytesout != 0) { printf("\n"); *bytesout=0; henter(); } printf("%s not processed. too long\n",pp); henter(); } } } } else { /*they passed us a string of '' or "" */ /*this is legal in unix and c but we dont want to print out anything */ } #if DEBUGME3==BUGIT printf("\n%s LEAVING %s\n",me,text); #endif return(0); } /*copyright mike diross may 1996 */ /*please feel free to use this code */ /*free free to give this code to other people */ /*just dont sell it */ /*the orginal version was written on a sun workstation*/ /*running unix/solaris */ /*this software 1 - tells you what your fone number */ /* spells */ /* 2 - converts a spelled fone number */ /* back to numeric digits */ /*many people out their have fone numbers that spell */ /*something ranging from really cool words to boring */ /*words that are easy to remember. some of the fone # */ /*i have owned over the years are */ /* TOY-BUGS */ /* HOT-FEET */ /* WINE-ALE */ /* 441-HEAT */ /* 441-LOST - a boss of mine at motorola */ /* 277-VOLT */ /* 273-GLAD */ /* 800-BAD-DEAL sales man nightmare */ /* 800-MY-ANI-IS */ /* 602-ASS-HOLE - a popular phoenix fish resturant*/ #include int vernum(unsigned char *sin,unsigned char minus) { int rc=0; unsigned char *mecopwr=(unsigned char *)"/*copyright mike diross may 1996*/"; if (*sin==0) /*if string is null somethings hosed up*/ { rc=1; goto done; } if (*sin=='+') /* plus + is allowed in anycase*/ { sin++; } switch(toupper(minus)) { case 'N':; break; /*negetive signs not allowed*/ case 'Y':; /*negitive signs allowed */ if (*sin=='-') { sin++; } break; default:; /*routine called wrong. minus must be yYnN */ rc=2; /*maybe caller is on drugs */ goto done; } if (*sin==0) /*one or more digits must follow the sign*/ { rc=3; goto done; } while(*sin) /*verify each digit is numeric*/ { if (*sin>='0' && *sin<='9') { /*okie dokey. digit is a number*/ } else { rc=4; /*it aint a number. return to caller in error*/ goto done; } sin++; } done:; return(rc); } this is the end of all the source code for the fone software -------------------- That's it! Have fun. PAT