1282 mypath = xstrcat(mypath, (char *)"brewco.xml"); |
1282 mypath = xstrcat(mypath, (char *)"brewco.xml"); |
1283 |
1283 |
1284 /* |
1284 /* |
1285 * Make upto 10 backups of the configuration. |
1285 * Make upto 10 backups of the configuration. |
1286 */ |
1286 */ |
1287 fpath = calloc(1024, sizeof(char)); |
1287 fpath = calloc(PATH_MAX, sizeof(char)); |
1288 tpath = calloc(1024, sizeof(char)); |
1288 tpath = calloc(PATH_MAX, sizeof(char)); |
1289 |
1289 |
1290 for (i = 9; i > 0; i--) { |
1290 for (i = 9; i > 0; i--) { |
1291 snprintf(tpath, 1023, "%s.%d", mypath, i+1); |
1291 snprintf(tpath, PATH_MAX, "%s.%d", mypath, i+1); |
1292 snprintf(fpath, 1023, "%s.%d", mypath, i); |
1292 snprintf(fpath, PATH_MAX, "%s.%d", mypath, i); |
1293 if (file_exist(fpath, R_OK) == 0) { |
1293 if (file_exist(fpath, R_OK) == 0) { |
1294 unlink(tpath); |
1294 unlink(tpath); |
1295 if (file_cp(fpath, tpath)) { |
1295 if (file_cp(fpath, tpath)) { |
1296 syslog(LOG_NOTICE, "rdconfig file_cp(%s, %s): %s", fpath, tpath, strerror(errno)); |
1296 syslog(LOG_NOTICE, "rdconfig file_cp(%s, %s): %s", fpath, tpath, strerror(errno)); |
1297 } |
1297 } |
1298 } |
1298 } |
1299 } |
1299 } |
1300 snprintf(tpath, 1023, "%s.1", mypath); |
1300 snprintf(tpath, PATH_MAX, "%s.1", mypath); |
1301 snprintf(fpath, 1023, "%s", mypath); |
1301 snprintf(fpath, PATH_MAX, "%s", mypath); |
1302 if (file_exist(fpath, R_OK) == 0) { |
1302 if (file_exist(fpath, R_OK) == 0) { |
1303 unlink(tpath); |
1303 unlink(tpath); |
1304 if (file_cp(fpath, tpath)) { |
1304 if (file_cp(fpath, tpath)) { |
1305 syslog(LOG_NOTICE, "rdconfig file_cp(%s, %s): %s", fpath, tpath, strerror(errno)); |
1305 syslog(LOG_NOTICE, "rdconfig file_cp(%s, %s): %s", fpath, tpath, strerror(errno)); |
1306 } |
1306 } |