src/config/config.cc
/*
 * Writes the current configuration to the given file.
 */
Writes the current configuration to the given file.
Writes the current configuration to the given file .
void Config::Save(const char *config_file) {
  FILE *config;
  if (config_file != NULL) {
    config = fopen(config_file, "w");
    if (config == NULL) {
      config_file = NULL;
      fprintf(stderr, "Error: Failed to open the specified config file\n");
    }
  }
  if (config_file == NULL) {
    config = fopen(default_config_, "w");
    if (config == NULL) {
      fprintf(stderr, "Error: Failed to open the default config file\n");
      return;
    }
  }
  for (size_t i = 0; i < DICT_SIZE; i++) {
    DictElem *elem = dict_[i];
    while (elem != NULL) {
      WriteElem(elem, config);
      elem = elem->next;
    }
  }
  fclose(config);
  return;
}
void Config :: Save ( const char * config_file ) { FILE * config ; if ( config_file != NULL ) { config = fopen ( config_file , " " ) ; if ( config == NULL ) { config_file = NULL ; fprintf ( stderr , " \n " ) ; } } if ( config_file == NULL ) { config = fopen ( default_config_ , " " ) ; if ( config == NULL ) { fprintf ( stderr , " \n " ) ; return ; } } for ( size_t i = 0 ; i < DICT_SIZE ; i ++ ) { DictElem * elem = dict_ [ i ] ; while ( elem != NULL ) { WriteElem ( elem , config ) ; elem = elem -> next ; } } fclose ( config ) ; return ; }
Writes the current configuration to the given file.
Writes the current configuration to the given file .
// Attempts to open the given configuration file. // If the given config file was NULL, or if it could not be opened, // a default is used. // Writes each element to the opened config file. // Close the file and return.