ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/libstatgrab/tools.c
Revision: 1.4
Committed: Sun Apr 6 11:57:54 2003 UTC (21 years, 1 month ago) by pajs
Content type: text/plain
Branch: MAIN
Changes since 1.3: +2 -1 lines
Log Message:
Make the functions that use atoll have a #ifdef HAVE_ATOLL around them.
I did this because freebsd doesn't have this function, and it doesn't
need to run any of the functions in tools.h that uses them.

File Contents

# User Rev Content
1 pajs 1.1 #include <stdio.h>
2     #include <string.h>
3 pajs 1.3 #include <stdlib.h>
4     #include <sys/types.h>
5     #include <regex.h>
6 pajs 1.1
7     char *f_read_line(FILE *f, const char *string){
8     /* Max line length. 8k should be more than enough */
9     static char line[8192];
10    
11 pajs 1.2 while((fgets(line, sizeof(line), f))!=NULL){
12 pajs 1.1 if(strncmp(string, line, strlen(string))==0){
13     return line;
14     }
15     }
16    
17     return NULL;
18 pajs 1.3 }
19    
20     char *get_string_match(char *line, regmatch_t *match){
21     int len=match->rm_eo - match->rm_so;
22     char *match_string=malloc(len+1);
23    
24     match_string=strncpy(match_string, line+match->rm_so, len);
25     match_string[len]='\0';
26    
27     return match_string;
28     }
29 pajs 1.4 #ifdef HAVE_ATOLL
30 pajs 1.3 long long get_ll_match(char *line, regmatch_t *match){
31     char *ptr;
32     long long num;
33    
34     ptr=line+match->rm_so;
35     num=atoll(ptr);
36    
37     return num;
38 pajs 1.1 }
39 pajs 1.4 #endif