File: get_num.c

package info (click to toggle)
cti-ifhp 2.1.8-2
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 932 kB
  • ctags: 845
  • sloc: ansic: 6,036; sh: 1,524; makefile: 318
file content (37 lines) | stat: -rw-r--r-- 837 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**************************************************************************
 * LPRng IFHP Filter
 * Copyright 1994-1997 Patrick Powell, San Diego, CA <papowell@sdsu.edu>
 *
 * Based on the CTI printer filters.
 *  See COPYRIGHT for details.
 *
 * $Id: get_num.c,v 2.1 1997/01/05 18:41:39 papowell Exp $
 */

#include "portable.h"
#include "common.h"
#include "hp4.h"


/*
 * The passed argument is supposed to be a string starting off with any
 * pattern (such as "PAGES=" or "CODE=") and followed by a number.
 * The number is returned as this is the one of major concern.
 */
int get_num(s)
char *s;
{
	int i = -1;

	if( !s ) return(i);

	/* skip over whitespace */
	while( isspace(*s) ) s++;
	/* now we have either a number or bad info */
	/* return 0 if bad info, -1 if end of line */
	if( *s ){
		i = atoi( s );
	}
	return( i );
}