WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPROSE. See the GNU
Affero General Public License for more details.
-
+
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ SPDX-License-Identifier: AGPL3.0-or-later
*/
/**
struct CommandContext *cc = cls;
GNUNET_SPEEDUP_start_(cc->cfg);
- GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
+ GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
+ NULL);
GNUNET_RESOLVER_connect (cc->cfg);
- cc->task (cc->task_cls, cc->args, cc->cfgfile, cc->cfg);
+ cc->task (cc->task_cls,
+ cc->args,
+ cc->cfgfile,
+ cc->cfg);
}
* @param a2 second command line option
*/
static int
-cmd_sorter (const void *a1, const void *a2)
+cmd_sorter (const void *a1,
+ const void *a2)
{
const struct GNUNET_GETOPT_CommandLineOption *c1 = a1;
const struct GNUNET_GETOPT_CommandLineOption *c2 = a2;
GNUNET_free (lpfx);
goto cleanup;
}
- if (NULL == cc.cfgfile)
- cc.cfgfile = GNUNET_strdup (cfg_fn);
- if (GNUNET_YES ==
- GNUNET_DISK_file_test (cc.cfgfile))
+ if (NULL != cc.cfgfile)
{
- if (GNUNET_SYSERR ==
- GNUNET_CONFIGURATION_load (cfg,
- cc.cfgfile))
+ if ( (GNUNET_YES !=
+ GNUNET_DISK_file_test (cc.cfgfile)) ||
+ (GNUNET_SYSERR ==
+ GNUNET_CONFIGURATION_load (cfg,
+ cc.cfgfile)) )
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Malformed configuration file `%s', exit ...\n"),
- cc.cfgfile);
+ _("Unreadable or malformed configuration file `%s', exit ...\n"),
+ cc.cfgfile);
ret = GNUNET_SYSERR;
GNUNET_free (allopts);
GNUNET_free (lpfx);
}
else
{
- if (0 != strcmp (cc.cfgfile,
- cfg_fn))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Could not access configuration file `%s'\n"),
- cc.cfgfile);
- if (GNUNET_SYSERR ==
- GNUNET_CONFIGURATION_load (cfg,
- NULL))
+ if (GNUNET_YES ==
+ GNUNET_DISK_file_test (cfg_fn))
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Malformed configuration, exit ...\n"));
- ret = GNUNET_SYSERR;
- GNUNET_free (allopts);
- GNUNET_free (lpfx);
- goto cleanup;
+ if (GNUNET_SYSERR ==
+ GNUNET_CONFIGURATION_load (cfg,
+ cfg_fn))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Unreadable or malformed default configuration file `%s', exit ...\n"),
+ cfg_fn);
+ ret = GNUNET_SYSERR;
+ GNUNET_free (allopts);
+ GNUNET_free (lpfx);
+ goto cleanup;
+ }
+ }
+ else
+ {
+ GNUNET_free (cfg_fn);
+ cfg_fn = NULL;
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_load (cfg,
+ NULL))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Unreadable or malformed configuration, exit ...\n"));
+ ret = GNUNET_SYSERR;
+ GNUNET_free (allopts);
+ GNUNET_free (lpfx);
+ goto cleanup;
+ }
}
}
GNUNET_free (allopts);
has little business with ARM-specific options. */
if (GNUNET_YES !=
GNUNET_CONFIGURATION_have_value (cfg,
- "arm",
- "CONFIG"))
+ "arm",
+ "CONFIG"))
{
- GNUNET_CONFIGURATION_set_value_string (cfg,
- "arm",
- "CONFIG",
- cc.cfgfile);
+ if (NULL != cc.cfgfile)
+ GNUNET_CONFIGURATION_set_value_string (cfg,
+ "arm",
+ "CONFIG",
+ cc.cfgfile);
+ else if (NULL != cfg_fn)
+ GNUNET_CONFIGURATION_set_value_string (cfg,
+ "arm",
+ "CONFIG",
+ cfg_fn);
}
/* run */
cc.args = &argv[ret];
+ if ( (NULL == cc.cfgfile) &&
+ (NULL != cfg_fn) )
+ cc.cfgfile = GNUNET_strdup (cfg_fn);
if (GNUNET_NO == run_without_scheduler)
{
- GNUNET_SCHEDULER_run (&program_main, &cc);
+ GNUNET_SCHEDULER_run (&program_main,
+ &cc);
}
else
{
cleanup:
GNUNET_CONFIGURATION_destroy (cfg);
GNUNET_free_non_null (cc.cfgfile);
- GNUNET_free (cfg_fn);
+ GNUNET_free_non_null (cfg_fn);
GNUNET_free_non_null (loglev);
GNUNET_free_non_null (logfile);
return ret;