LD=ld
CFLAGS=-Wall -O2 -g
-RRDD_OBJS= main.o process.o draw_graphs.o parser.o scheduler.o
+RRDD_OBJS= main.o process.o draw_graphs.o parser.o scheduler.o string.o
rrdd: $(RRDD_OBJS)
@echo -e "\tLD\t" rrdd
#include "parser.h"
#include "process.h"
-
-static int dec_to_int(char *src, char **dst)
-{
- int ret;
-
- while(((*src < '0') || (*src > '9')) && *src)
- src++;
-
- ret = atoi(src);
-
- if (dst) {
- while(((*src >= '0') && (*src <= '9')) && *src)
- src++;
- *dst = src;
- }
-
- return ret;
-}
-
-static float dec_to_float(char *src, char **dst)
-{
- float ret;
-
- while(((*src < '0') || (*src > '9')) && *src)
- src++;
-
- ret = atof(src);
-
- if (dst) {
- while((((*src >= '0') && (*src <= '9')) || (*src =='.')) && *src)
- src++;
- *dst = src;
- }
-
- return ret;
-}
-
-/*
- * Copy white space separated stirng from *src to *word
- *
- * src: source
- * dst: place where store the end of word pointer from source string
- * word: destination where to copy the string
- * size: maximum size of bytes to copy to the output buffer
- *
- * return the number of bytes copied
- */
-
-static int get_word(char *src, char **dst, char *word, int size)
-{
- int ret = 0;
- while(((*src == ' ') || (*src == '\t') || (*src == '\n')) && *src)
- src++;
-
- while(((*src != ' ') && (*src != '\t') && (*src != '\n')) && *src && (ret < (size - 1))) {
- *word = *src;
- word++;
- src++;
- ret++;
- }
- *word = 0;
-
- if (dst)
- *dst = src;
-
- return ret;
-}
+#include "string.h"
#define STATFILE "/proc/stat"
--- /dev/null
+#include "string.h"
+
+int dec_to_int(char *src, char **dst)
+{
+ int ret;
+
+ while(((*src < '0') || (*src > '9')) && *src)
+ src++;
+
+ ret = atoi(src);
+
+ if (dst) {
+ while(((*src >= '0') && (*src <= '9')) && *src)
+ src++;
+ *dst = src;
+ }
+
+ return ret;
+}
+
+float dec_to_float(char *src, char **dst)
+{
+ float ret;
+
+ while(((*src < '0') || (*src > '9')) && *src)
+ src++;
+
+ ret = atof(src);
+
+ if (dst) {
+ while((((*src >= '0') && (*src <= '9')) || (*src =='.')) && *src)
+ src++;
+ *dst = src;
+ }
+
+ return ret;
+}
+
+/*
+ * Copy white space separated stirng from *src to *word
+ *
+ * src: source
+ * dst: place where store the end of word pointer from source string
+ * word: destination where to copy the string
+ * size: maximum size of bytes to copy to the output buffer
+ *
+ * return the number of bytes copied
+ */
+
+int get_word(char *src, char **dst, char *word, int size)
+{
+ int ret = 0;
+ while(((*src == ' ') || (*src == '\t') || (*src == '\n')) && *src)
+ src++;
+
+ while(((*src != ' ') && (*src != '\t') && (*src != '\n')) && *src && (ret < (size - 1))) {
+ *word = *src;
+ word++;
+ src++;
+ ret++;
+ }
+ *word = 0;
+
+ if (dst)
+ *dst = src;
+
+ return ret;
+}
+
--- /dev/null
+#ifndef __STRING_H
+#define __STRING_H
+
+#include <string.h>
+#include <stdlib.h>
+
+int dec_to_int(char *src, char **dst);
+float dec_to_float(char *src, char **dst);
+int get_word(char *src, char **dst, char *word, int size);
+
+#endif