Browse code

str2sint() function is moved to ut.h

Miklos Tirpak authored on 30/01/2008 09:46:04
Showing 2 changed files
... ...
@@ -125,40 +125,6 @@ void cfg_notify_drivers(char *group_name, int group_name_len, cfg_def_t *def)
125 125
 			ctx->on_declare_cb(&gname, def);
126 126
 }
127 127
 
128
-/*
129
- * Convert an str into signed integer
130
- * this function should be moved to ../ut.h
131
- */
132
-static int str2sint(str* _s, int* _r)
133
-{
134
-	int i;
135
-	int sign;
136
-
137
-	if (_s->len == 0) return -1;
138
-
139
-	*_r = 0;
140
-	sign = 1;
141
-	i = 0;
142
-	if (_s->s[0] == '+') {
143
-		i++;
144
-	} else if (_s->s[0] == '-') {
145
-		sign = -1;
146
-		i++;
147
-	}
148
-	for(; i < _s->len; i++) {
149
-		if ((_s->s[i] >= '0') && (_s->s[i] <= '9')) {
150
-			*_r *= 10;
151
-			*_r += _s->s[i] - '0';
152
-		} else {
153
-			return -1;
154
-		}
155
-	}
156
-	*_r *= sign;
157
-
158
-	return 0;
159
-}
160
-
161
-
162 128
 /* placeholder for a temporary string */
163 129
 static char	*temp_string = NULL;
164 130
 
... ...
@@ -514,6 +514,38 @@ static inline int str2int(str* _s, unsigned int* _r)
514 514
 	return 0;
515 515
 }
516 516
 
517
+/*
518
+ * Convert an str to signed integer
519
+ */
520
+static inline int str2sint(str* _s, int* _r)
521
+{
522
+	int i;
523
+	int sign;
524
+
525
+	if (_s->len == 0) return -1;
526
+
527
+	*_r = 0;
528
+	sign = 1;
529
+	i = 0;
530
+	if (_s->s[0] == '+') {
531
+		i++;
532
+	} else if (_s->s[0] == '-') {
533
+		sign = -1;
534
+		i++;
535
+	}
536
+	for(; i < _s->len; i++) {
537
+		if ((_s->s[i] >= '0') && (_s->s[i] <= '9')) {
538
+			*_r *= 10;
539
+			*_r += _s->s[i] - '0';
540
+		} else {
541
+			return -1;
542
+		}
543
+	}
544
+	*_r *= sign;
545
+
546
+	return 0;
547
+}
548
+
517 549
 /* converts a username into uid:gid,
518 550
  * returns -1 on error & 0 on success */
519 551
 int user2uid(int* uid, int* gid, char* user);