| 
									
										
										
										
											2011-06-10 05:46:20 +01:00
										 |  |  | /* See LICENSE file for copyright and license details. */ | 
					
						
							|  |  |  | #include <stdio.h>
 | 
					
						
							|  |  |  | #include <stdlib.h>
 | 
					
						
							|  |  |  | #include "../util.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | long | 
					
						
							| 
									
										
										
										
											2011-06-10 14:55:01 +01:00
										 |  |  | estrtol(const char *s, int base) | 
					
						
							| 
									
										
										
										
											2011-06-10 05:46:20 +01:00
										 |  |  | { | 
					
						
							|  |  |  | 	char *end; | 
					
						
							|  |  |  | 	long n; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	n = strtol(s, &end, base); | 
					
						
							|  |  |  | 	if(*end != '\0') { | 
					
						
							|  |  |  | 		if(base == 0) | 
					
						
							|  |  |  | 			eprintf("%s: not a number\n", s); | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 			eprintf("%s: not a base %d number\n", s, base); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return n; | 
					
						
							|  |  |  | } |