summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Beisert <j.beisert@pengutronix.de>2007-10-02 10:44:57 +0000
committerJuergen Beisert <j.beisert@pengutronix.de>2007-10-02 10:44:57 +0000
commit68c784b4843a032908f38427e3446cf594da12c0 (patch)
tree86de37c3159d523a3ac71e561be646493c6d880d
parenta9b6c20792e7765ca736618e8d87ce136dd3dcc7 (diff)
downloadcanutils-68c784b4843a032908f38427e3446cf594da12c0.tar.gz
using more interface specific config files
git-svn-id: https://iocaste.extern.pengutronix.de/svn/canutils/trunks/canutils-2.0-trunk@75 5fd5a299-6ef2-0310-aa18-8b01d7c39d8c
-rw-r--r--src/canconfig.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/canconfig.c b/src/canconfig.c
index 9c33cf3..8a6f630 100644
--- a/src/canconfig.c
+++ b/src/canconfig.c
@@ -45,7 +45,7 @@
#define kHz 1000
#define CONFIG_FILE_NAME "/etc/canconfig.conf"
-/* #define CONFIG_FILE_NAME "./canconfig.conf" */
+#define CONFIG_FILE_NAME_SP "/etc/canconfig-%s.conf"
int s;
struct ifreq ifr;
@@ -177,6 +177,7 @@ static void tweak_from_command_line(int argc, char *argv[])
static void tweak_from_config_file(int argc, char *argv[])
{
FILE *config_file;
+ char file_name[MAX_PATH];
int first_char,cnt,line = 1;
uint32_t bit_rate;
uint32_t sync_seg;
@@ -185,11 +186,15 @@ static void tweak_from_config_file(int argc, char *argv[])
uint32_t phase_seg2;
uint32_t sjw;
- config_file = fopen(CONFIG_FILE_NAME, "r");
+ sprintf(file_name, CONFIG_FILE_NAME_SP, argv[1]);
+ config_file = fopen(file_name, "r");
if (config_file == NULL) {
- perror("Config file (" CONFIG_FILE_NAME ")");
- exit(EXIT_FAILURE);
- }
+ sprintf(file_name, CONFIG_FILE_NAME,);
+ config_file = fopen(file_name, "r");
+ if (config_file == NULL) {
+ perror("Config file (" CONFIG_FILE_NAME ")");
+ exit(EXIT_FAILURE);
+ }
while(!feof(config_file)) {
first_char = fgetc(config_file);
@@ -212,7 +217,7 @@ static void tweak_from_config_file(int argc, char *argv[])
&sjw);
if (cnt != 6) {
fprintf(stderr,"Wrong data format in line %d in %s\n",
- line, CONFIG_FILE_NAME);
+ line, file_name);
exit(EXIT_FAILURE);
}
line ++;