mirror of
https://github.com/SEPPDROID/Digital-Research-Source-Code.git
synced 2025-10-25 01:14:21 +00:00
32 lines
1.1 KiB
C
32 lines
1.1 KiB
C
|
||
/*----------------------------------------------------------------------*\
|
||
| NAME : get_num |
|
||
| CREATED : 5-August-83 LAST MODIFIED : 7-October-83 |
|
||
| FUNCTION: Get_num retrieves a number appended to the end of |
|
||
| a string pointed to by option. If none is found the |
|
||
| default value, dflt, is returned. |
|
||
| INPUT : option -- pointer to command option string |
|
||
| dflt -- default value of number if none was found |
|
||
| OUTPUT : Returns number appened to option, or default if not |
|
||
| found. |
|
||
\*----------------------------------------------------------------------*/
|
||
|
||
#include <portab.h>
|
||
#include "utildef.h"
|
||
|
||
WORD get_num( option,dflt )
|
||
BYTE *option; /* ptr to current option */
|
||
WORD dflt; /* default number, if not found */
|
||
{
|
||
WORD num; /* number taken from option */
|
||
|
||
num = 0;
|
||
while( isalpha( *option ) ) /* skip alphabetic ch. */
|
||
option++;
|
||
if( !isdigit( *option ) ) /* no digits found */
|
||
num = dflt;
|
||
else /* extract number */
|
||
num = atoi( option );
|
||
return( num );
|
||
}
|
||
|