@@ -2697,6 +2697,7 @@ prepare_insert_variant_num(
26972697
26982698static int
26992699set_defaults (
2700+ const struct ejudge_cfg * config ,
27002701 const struct contest_desc * cnts ,
27012702 const unsigned char * config_file ,
27022703 serve_state_t state ,
@@ -2844,7 +2845,7 @@ set_defaults(
28442845 if (g -> stand_show_warn_number == -1 )
28452846 g -> stand_show_warn_number = DFLT_G_STAND_SHOW_WARN_NUMBER ;
28462847 if (g -> autoupdate_standings == -1 ) {
2847- if (ejudge_config -> disable_autoupdate_standings > 0 )
2848+ if (config && config -> disable_autoupdate_standings > 0 )
28482849 g -> autoupdate_standings = 0 ;
28492850 else
28502851 g -> autoupdate_standings = DFLT_G_AUTOUPDATE_STANDINGS ;
@@ -2930,10 +2931,10 @@ set_defaults(
29302931 if (!g -> root_dir || !g -> root_dir [0 ]) {
29312932 usprintf (& g -> root_dir , "%06d" , contest_id );
29322933 }
2933- if (!os_IsAbsolutePath (g -> root_dir ) && ejudge_config
2934- && ejudge_config -> contests_home_dir
2935- && os_IsAbsolutePath (ejudge_config -> contests_home_dir )) {
2936- usprintf (& g -> root_dir , "%s/%s" , ejudge_config -> contests_home_dir , g -> root_dir );
2934+ if (!os_IsAbsolutePath (g -> root_dir ) && config
2935+ && config -> contests_home_dir
2936+ && os_IsAbsolutePath (config -> contests_home_dir )) {
2937+ usprintf (& g -> root_dir , "%s/%s" , config -> contests_home_dir , g -> root_dir );
29372938 }
29382939#if defined EJUDGE_CONTESTS_HOME_DIR
29392940 if (!os_IsAbsolutePath (g -> root_dir )) {
@@ -2947,27 +2948,27 @@ set_defaults(
29472948
29482949 param_subst_2 (& g -> root_dir , subst_src , subst_dst );
29492950
2950- if ((!g -> clardb_plugin || !g -> clardb_plugin [0 ]) && ejudge_config
2951- && ejudge_config -> default_clardb_plugin
2952- && ejudge_config -> default_clardb_plugin [0 ]) {
2953- xstrdup3 (& g -> clardb_plugin , ejudge_config -> default_clardb_plugin );
2951+ if ((!g -> clardb_plugin || !g -> clardb_plugin [0 ]) && config
2952+ && config -> default_clardb_plugin
2953+ && config -> default_clardb_plugin [0 ]) {
2954+ xstrdup3 (& g -> clardb_plugin , config -> default_clardb_plugin );
29542955 }
2955- if ((!g -> rundb_plugin || !g -> rundb_plugin [0 ]) && ejudge_config
2956- && ejudge_config -> default_rundb_plugin
2957- && ejudge_config -> default_rundb_plugin [0 ]) {
2958- xstrdup3 (& g -> rundb_plugin , ejudge_config -> default_rundb_plugin );
2956+ if ((!g -> rundb_plugin || !g -> rundb_plugin [0 ]) && config
2957+ && config -> default_rundb_plugin
2958+ && config -> default_rundb_plugin [0 ]) {
2959+ xstrdup3 (& g -> rundb_plugin , config -> default_rundb_plugin );
29592960 }
2960- if ((!g -> xuser_plugin || !g -> xuser_plugin [0 ]) && ejudge_config
2961- && ejudge_config -> default_xuser_plugin && ejudge_config -> default_xuser_plugin [0 ]) {
2962- xstrdup3 (& g -> xuser_plugin , ejudge_config -> default_xuser_plugin );
2961+ if ((!g -> xuser_plugin || !g -> xuser_plugin [0 ]) && config
2962+ && config -> default_xuser_plugin && config -> default_xuser_plugin [0 ]) {
2963+ xstrdup3 (& g -> xuser_plugin , config -> default_xuser_plugin );
29632964 }
2964- if ((!g -> status_plugin || !g -> status_plugin [0 ]) && ejudge_config
2965- && ejudge_config -> default_status_plugin && ejudge_config -> default_status_plugin [0 ]) {
2966- xstrdup3 (& g -> status_plugin , ejudge_config -> default_status_plugin );
2965+ if ((!g -> status_plugin || !g -> status_plugin [0 ]) && config
2966+ && config -> default_status_plugin && config -> default_status_plugin [0 ]) {
2967+ xstrdup3 (& g -> status_plugin , config -> default_status_plugin );
29672968 }
2968- if ((!g -> variant_plugin || !g -> variant_plugin [0 ]) && ejudge_config
2969- && ejudge_config -> default_variant_plugin && ejudge_config -> default_variant_plugin [0 ]) {
2970- xstrdup3 (& g -> variant_plugin , ejudge_config -> default_variant_plugin );
2969+ if ((!g -> variant_plugin || !g -> variant_plugin [0 ]) && config
2970+ && config -> default_variant_plugin && config -> default_variant_plugin [0 ]) {
2971+ xstrdup3 (& g -> variant_plugin , config -> default_variant_plugin );
29712972 }
29722973
29732974 if (!g -> conf_dir || !g -> conf_dir [0 ]) {
@@ -3506,8 +3507,8 @@ set_defaults(
35063507 const unsigned char * ecd = g -> extra_compile_dirs [lang -> compile_dir_index - 1 ];
35073508 if (os_IsAbsolutePath (ecd )) {
35083509 usprintf (& lang -> compile_dir , "%s/var/compile" , ecd );
3509- } else if (ejudge_config && ejudge_config -> contests_home_dir ) {
3510- usprintf (& lang -> compile_dir , "%s/%s/var/compile" , ejudge_config -> contests_home_dir , ecd );
3510+ } else if (config && config -> contests_home_dir ) {
3511+ usprintf (& lang -> compile_dir , "%s/%s/var/compile" , config -> contests_home_dir , ecd );
35113512 } else {
35123513#if defined EJUDGE_CONTESTS_HOME_DIR
35133514 usprintf (& lang -> compile_dir , "%s/%s/var/compile" , EJUDGE_CONTESTS_HOME_DIR , ecd );
@@ -3553,11 +3554,11 @@ set_defaults(
35533554 err ("language.%d.cmd must be set" , i );
35543555 return -1 ;
35553556 }
3556- if (!os_IsAbsolutePath (lang -> cmd ) && ejudge_config && ejudge_config -> compile_home_dir ) {
3557- usprintf (& lang -> cmd , "%s/scripts/%s" , ejudge_config -> compile_home_dir , lang -> cmd );
3557+ if (!os_IsAbsolutePath (lang -> cmd ) && config && config -> compile_home_dir ) {
3558+ usprintf (& lang -> cmd , "%s/scripts/%s" , config -> compile_home_dir , lang -> cmd );
35583559 }
3559- if (!os_IsAbsolutePath (lang -> cmd ) && ejudge_config && ejudge_config -> contests_home_dir ) {
3560- usprintf (& lang -> cmd , "%s/compile/scripts/%s" , ejudge_config -> contests_home_dir , lang -> cmd );
3560+ if (!os_IsAbsolutePath (lang -> cmd ) && config && config -> contests_home_dir ) {
3561+ usprintf (& lang -> cmd , "%s/compile/scripts/%s" , config -> contests_home_dir , lang -> cmd );
35613562 }
35623563#if defined EJUDGE_CONTESTS_HOME_DIR
35633564 if (!os_IsAbsolutePath (lang -> cmd )) {
@@ -4501,11 +4502,11 @@ set_defaults(
45014502
45024503 if (tp -> start_cmd && tp -> start_cmd [0 ] && !os_IsAbsolutePath (tp -> start_cmd )) {
45034504 snprintf (start_path , sizeof (start_path ), "%s" , tp -> start_cmd );
4504- if (ejudge_config && ejudge_config -> compile_home_dir ) {
4505- pathmake2 (start_path , ejudge_config -> compile_home_dir ,
4505+ if (config && config -> compile_home_dir ) {
4506+ pathmake2 (start_path , config -> compile_home_dir ,
45064507 "/" , "scripts" , "/" , start_path , NULL );
4507- } else if (ejudge_config && ejudge_config -> contests_home_dir ) {
4508- pathmake2 (start_path , ejudge_config -> contests_home_dir ,
4508+ } else if (config && config -> contests_home_dir ) {
4509+ pathmake2 (start_path , config -> contests_home_dir ,
45094510 "/" , "compile" , "/" , "scripts" , "/" , start_path , NULL );
45104511 }
45114512#if defined EJUDGE_CONTESTS_HOME_DIR
@@ -4538,8 +4539,8 @@ set_defaults(
45384539 }
45394540 if (tp -> nwrun_spool_dir && tp -> nwrun_spool_dir [0 ]) {
45404541 if (!os_IsAbsolutePath (tp -> nwrun_spool_dir )) {
4541- if (ejudge_config && ejudge_config -> contests_home_dir ) {
4542- usprintf (& tp -> nwrun_spool_dir , "%s/%s" , ejudge_config -> contests_home_dir , tp -> nwrun_spool_dir );
4542+ if (config && config -> contests_home_dir ) {
4543+ usprintf (& tp -> nwrun_spool_dir , "%s/%s" , config -> contests_home_dir , tp -> nwrun_spool_dir );
45434544 } else {
45444545#if defined EJUDGE_CONTESTS_HOME_DIR
45454546 usprintf (& tp -> nwrun_spool_dir , "%s/%s" , EJUDGE_CONTESTS_HOME_DIR , tp -> nwrun_spool_dir );
@@ -4993,6 +4994,7 @@ parse_version_string(int *pmajor, int *pminor, int *ppatch, int *pbuild)
49934994
49944995int
49954996prepare (
4997+ const struct ejudge_cfg * config ,
49964998 const struct contest_desc * cnts ,
49974999 serve_state_t state ,
49985000 char const * config_file ,
@@ -5054,7 +5056,7 @@ prepare(
50545056 return -1;
50555057 }
50565058 */
5057- if (set_defaults (cnts , config_file , state , mode , subst_src , subst_dst ) < 0 ) return -1 ;
5059+ if (set_defaults (config , cnts , config_file , state , mode , subst_src , subst_dst ) < 0 ) return -1 ;
50585060 return 0 ;
50595061}
50605062
0 commit comments