mmap works for output waveforms now.
[comedilib.git] / lib / calib.c
index 565ac4a1d943ed3ce37ec1043152058b4f00c49e..87fc6340484653692c58ecd8f2791a234de0b348 100644 (file)
@@ -161,12 +161,25 @@ int _comedi_apply_parsed_calibration( comedi_t *dev, unsigned int subdev, unsign
        return retval;
 }
 
+/* munge characters in board name that will cause problems with file paths */
+static void fixup_board_name( char *name )
+{
+       while( ( name = strchr( name, '/' ) ) )
+       {
+               if( name )
+               {
+                       *name = '-';
+                       name++;
+               }
+       }
+}
+
 EXPORT_ALIAS_DEFAULT(_comedi_get_default_calibration_path,comedi_get_default_calibration_path,0.7.20);
 char* _comedi_get_default_calibration_path( comedi_t *dev )
 {
        struct stat file_stats;
        char *file_path;
-       char *board_name;
+       char *board_name, *temp;
        char *driver_name;
 
        if( fstat( comedi_fileno( dev ), &file_stats ) < 0 )
@@ -175,19 +188,23 @@ char* _comedi_get_default_calibration_path( comedi_t *dev )
                return NULL;
        }
 
-       board_name = comedi_get_board_name( dev );
-       if( board_name == NULL )
+       driver_name = comedi_get_driver_name( dev );
+       if( driver_name == NULL )
        {
                return NULL;
        }
-       driver_name = comedi_get_driver_name( dev );
-       if( driver_name == NULL )
+       temp = comedi_get_board_name( dev );
+       if( temp == NULL )
        {
                return NULL;
        }
-       asprintf( &file_path, "/etc/comedi/calibrations/%s_%s_comedi%li",
+       board_name = strdup( temp );
+
+       fixup_board_name( board_name );
+       asprintf( &file_path, LOCALSTATEDIR "/lib/comedi/calibrations/%s_%s_comedi%li",
                driver_name, board_name, ( unsigned long ) minor( file_stats.st_rdev ) );
 
+       free( board_name );
        return file_path;
 }