~barry-leslie/s3daemon/trunk

« back to all changes in this revision

Viewing changes to src/config_s3.cc

  • Committer: Barry.Leslie at PrimeBase
  • Date: 2011-10-05 21:14:23 UTC
  • Revision ID: barry.leslie@primebase.com-20111005211423-45hoje09snj4xkkc
Switched to platform independed data types.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include <stddef.h>
28
28
#include <string.h>
29
29
#include <ctype.h>
 
30
#include <inttypes.h>
30
31
 
31
32
#include "config_s3.h"
32
33
 
40
41
#define SIZEOF_LOCATIONREC(n) (offsetof(LocationRec, data.pattern) + n)
41
42
 
42
43
static char error_msg[MAX_ERROR_MSG];
43
 
static unsigned int location_count = 0;
 
44
static int32_t location_count = 0;
44
45
static LocationRec *location_head = NULL, *next_location = NULL;
45
46
 
46
47
//-------------------------------------------------------------------
47
48
// This differs from the standard fgets() in that it works with Mac, PC
48
49
// and unix file formats. It also strips the line terminators from the line.
49
 
// Empty ines are skipped.
50
 
static int my_fgets(char *line, int size, FILE *fptr)
 
50
// Empty lines are skipped.
 
51
static uint32_t my_fgets(char *line, int32_t size, FILE *fptr)
51
52
{
52
 
int len = 0;
 
53
uint32_t len = 0;
53
54
char *ptr;
54
55
 
55
56
        if (size < 1)
95
96
}
96
97
 
97
98
//-----------------------------------------------------------
98
 
int S3LoadConfig(const char *config_file)
 
99
int32_t S3LoadConfig(const char *config_file)
99
100
{
100
101
        FILE *fptr;
101
 
        int line_no = 0, max_age;
 
102
        int32_t line_no = 0, max_age;
102
103
        char line[1024], *ptr, *base, *pattern, *bucket;
103
104
        const char *err;
104
105
        size_t min_size;
110
111
        fptr = fopen(config_file, "r");
111
112
        if (!fptr) {
112
113
                strerror_r(errno, error_msg, MAX_ERROR_MSG);
113
 
                return NULL;
 
114
                return -1;
114
115
        }
115
116
        
116
117
        while (my_fgets(line, 1024, fptr)) {