Changeset 768 in MondoRescue for trunk/mondo
- Timestamp:
- Aug 8, 2006, 3:51:12 PM (18 years ago)
- Location:
- trunk/mondo/mondo
- Files:
-
- 1 added
- 2 deleted
- 5 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/mondo/common/libmondo-string.c
r688 r768 1138 1138 return (type_of_backup); 1139 1139 } 1140 1141 1142 /* New functions safe from a memory manageemnt point of view */1143 /* Developped by Andree Leidenfrost */1144 1145 char *mr_strtok(char *instr, const char *delims, int *lastpos) {1146 1147 char *token = NULL;1148 char *strptr = NULL;1149 size_t pos1 = 0;1150 size_t pos2 = 0;1151 1152 if (strlen(instr) <= *lastpos) {1153 *lastpos = 0;1154 return token;1155 }1156 1157 strptr = instr + *lastpos;1158 pos2 = strspn(strptr, delims);1159 strptr += pos2;1160 pos1 = strcspn(strptr, delims);1161 token = malloc(sizeof(*token)*(pos1+1));1162 strncpy(token, strptr, pos1);1163 token[pos1] = '\0';1164 *lastpos = *lastpos + pos1 + pos2 + 1;1165 1166 return token;1167 }1168 /* @} - end of stringGroup */ -
trunk/mondo/mondo/lib/mr_conf.h
r767 r768 6 6 * Review for mondorescue (c) 2006 Bruno Cornec <bruno@mondorescue.org> 7 7 * 8 * Header file of libmondo-conf (mr_conf): a very small and simple8 * Header file of mr_conf: a very small and simple 9 9 * library for mondorescue configuration file reading 10 10 * -
trunk/mondo/mondo/lib/mr_string.c
r767 r768 2 2 $Id$ 3 3 */ 4 5 #include <stdio.h> 6 #include <string.h> 4 7 5 8 /* New functions safe from a memory manageemnt point of view */ -
trunk/mondo/mondo/test/mktest
r561 r768 6 6 # 7 7 8 gcc -O2 -I../common test-conf.c ../common/libmondo-conf.c ../common/libmondo-msg.c -o test-conf9 gcc -O2 -I../common test-string.c ../common/libmondo-string.c ../common/libmondo-msg.c -o test-string8 gcc -O2 -I../common -I../lib test-conf.c ../lib/mr_conf.c ../common/libmondo-msg.c -o test-conf 9 gcc -O2 -I../common -I../lib test-string.c ../lib/mr_string.c -o test-string 10 10 11 11 for f in "test-conf"; do -
trunk/mondo/mondo/test/test-conf.c
r531 r768 8 8 #include <stdio.h> 9 9 #include "my-stuff.h" 10 #include " libmondo-conf.h"10 #include "mr_conf.h" 11 11 12 12 int g_main_pid = 0; … … 19 19 char *s = NULL; 20 20 21 if ((ret = mr conf_open("mondo.conf")) != 0) {21 if ((ret = mr_conf_open("mondo.conf")) != 0) { 22 22 fprintf(stderr,"Unable to open conf file (%d)\n",ret); 23 23 exit(-1); 24 24 } 25 if ((i = mr conf_iread("testinteger")) == 0) {25 if ((i = mr_conf_iread("testinteger")) == 0) { 26 26 fprintf(stderr,"Unable to get integer\n"); 27 27 exit(-1); 28 28 } 29 29 fprintf(stdout, "Integer : ***%d***\n",i); 30 if ((f = mr conf_fread("testfloat")) == 0.0) {30 if ((f = mr_conf_fread("testfloat")) == 0.0) { 31 31 fprintf(stderr,"Unable to get float\n"); 32 32 exit(-1); 33 33 } 34 34 fprintf(stdout, "Float : ***%f***\n",f); 35 if (! (s = mr conf_sread("teststring"))) {35 if (! (s = mr_conf_sread("teststring"))) { 36 36 fprintf(stderr,"Unable to get string\n"); 37 37 exit(-1); … … 39 39 fprintf(stdout, "String : ***%s***\n",s); 40 40 paranoid_free(s); 41 mr conf_close();41 mr_conf_close(); 42 42 exit(0); 43 43 } -
trunk/mondo/mondo/test/test-string.c
r561 r768 10 10 #include <stdlib.h> 11 11 #include <stdio.h> 12 12 13 #include "my-stuff.h" 13 #include " libmondo-string.h"14 #include "mr_string.h" 14 15 15 16 main() {
Note:
See TracChangeset
for help on using the changeset viewer.