# pcb-rnd - plugin development - local default conf file

Each plugin can have a config file, pluginname.conf, stored locally and also installed. When this file is available, it specifies the default value for the plugin-local config nodes. It also allows users to create user config under ~/.pcb-rnd/ using the same file name, modularizing the config.

## create the config file

Copy the template and rename it to pluginname.conf, replace pluginname and the config nodes to match the plugin's conf.h.

Create an empty file called conf_internal.c (but do not commit it).

## include the internal version of the config file

Insert the following lines in the main plugin c source:

    #include "../src_plugins/pluginname/conf_internal.c"

## Register the custom conf file

Define the file name (will be used twice) somewhere around the top of the main source file, then in plugin init callback issue a conf_reg_file():

    #define PLUGINNAME_CONF_FN "pluginname.conf"

    int pplg_init_pluginname(void)
    {
    	PCB_API_CHK_VER;
    	conf_reg_file(PLUGINNAME_CONF_FN, pluginname_conf_internal);
    	...

The conf_reg_file() call should be before the conf fields initialization.

## Unregister the custom conf file

In the uninit callback of the plugin, insert the following line:

    	conf_unreg_file(PLUGINNAME_CONF_FN, pluginname_conf_internal);

## make dep

After finishing all these, before the commit, you will need to run make dep in src/. Before committing that, double check svn diff: it must not have any unrelated change, only files related to your plugin.

When done, the build system knows how to generate conf_internal.c - remove the dummy empty file and run make to get it generated.

The file will contain one large character array, holding the internal version of pluginname.conf