- int ret, check = FALSE;
- uint32 checkmask;
- char *tmp;
- SilcServerConfigParse pc = parse_config;
- SilcBuffer line;
-
- SILC_LOG_DEBUG(("Parsing configuration lines"));
-
- if (!config)
- return FALSE;
-
- checkmask = 0;
- while(pc) {
- check = FALSE;
- line = pc->line;
-
- /* Get number of tokens in line */
- ret = silc_config_check_num_token(line);
- if (ret != pc->section->maxfields) {
- /* Bad line */
- fprintf(stderr, "%s:%d: Missing tokens, %d tokens (should be %d)\n",
- config->filename, pc->linenum, ret,
- pc->section->maxfields);
- break;
- }
-
- /* Parse the line */
- switch(pc->section->type) {
- case SILC_CONFIG_SERVER_SECTION_TYPE_CIPHER:
-
- SILC_SERVER_CONFIG_LIST_ALLOC(config->cipher);
-
- /* Get cipher name */
- ret = silc_config_get_token(line, &config->cipher->alg_name);
- if (ret < 0)
- break;
- if (ret == 0) {
- fprintf(stderr, "%s:%d: Cipher name not defined\n",
- config->filename, pc->linenum);
- break;
- }
-
- /* Get module name */
- config->cipher->sim_name = NULL;
- ret = silc_config_get_token(line, &config->cipher->sim_name);
- if (ret < 0)
- break;
-
- /* Get key length */
- ret = silc_config_get_token(line, &tmp);
- if (ret < 0)
- break;
- if (ret == 0) {
- fprintf(stderr, "%s:%d: Cipher key length not defined\n",
- config->filename, pc->linenum);
- break;
- }
- config->cipher->key_len = atoi(tmp);
- silc_free(tmp);
-
- /* Get block length */
- ret = silc_config_get_token(line, &tmp);
- if (ret < 0)
- break;
- if (ret == 0) {
- fprintf(stderr, "%s:%d: Cipher block length not defined\n",
- config->filename, pc->linenum);
- break;
- }
- config->cipher->block_len = atoi(tmp);
- silc_free(tmp);
-
- check = TRUE;
- checkmask |= (1L << pc->section->type);
- break;
-
- case SILC_CONFIG_SERVER_SECTION_TYPE_PKCS:
-
- SILC_SERVER_CONFIG_LIST_ALLOC(config->pkcs);
-
- /* Get PKCS name */
- ret = silc_config_get_token(line, &config->pkcs->alg_name);
- if (ret < 0)
- break;
- if (ret == 0) {
- fprintf(stderr, "%s:%d: PKCS name not defined\n",
- config->filename, pc->linenum);
- break;
- }
-
- /* Get key length */
- ret = silc_config_get_token(line, &tmp);
- if (ret < 0)
- break;
- if (ret == 0) {
- fprintf(stderr, "%s:%d: PKCS key length not defined\n",
- config->filename, pc->linenum);
- break;
- }
- config->pkcs->key_len = atoi(tmp);
- silc_free(tmp);
-
- check = TRUE;
- checkmask |= (1L << pc->section->type);
- break;
-
- case SILC_CONFIG_SERVER_SECTION_TYPE_HASH_FUNCTION:
-
- SILC_SERVER_CONFIG_LIST_ALLOC(config->hash_func);
-
- /* Get Hash function name */
- ret = silc_config_get_token(line, &config->hash_func->alg_name);
- if (ret < 0)
- break;
- if (ret == 0) {
- fprintf(stderr, "%s:%d: Hash function name not defined\n",
- config->filename, pc->linenum);
- break;
- }
-
- /* Get Hash function module name */
- config->hash_func->sim_name = NULL;
- ret = silc_config_get_token(line, &config->hash_func->sim_name);
- if (ret < 0)
- break;
-
- /* Get block length */
- ret = silc_config_get_token(line, &tmp);
- if (ret < 0)
- break;
- if (ret == 0) {
- fprintf(stderr, "%s:%d: Hash function block length not defined\n",
- config->filename, pc->linenum);
- break;
- }
- config->hash_func->block_len = atoi(tmp);
- silc_free(tmp);
-
- /* Get hash length */
- ret = silc_config_get_token(line, &tmp);
- if (ret < 0)
- break;
- if (ret == 0) {
- fprintf(stderr, "%s:%d: Hash function hash length not defined\n",
- config->filename, pc->linenum);
- break;
- }
- config->hash_func->key_len = atoi(tmp);
- silc_free(tmp);
-
- check = TRUE;
- checkmask |= (1L << pc->section->type);
- break;
-
- case SILC_CONFIG_SERVER_SECTION_TYPE_HMAC:
-
- SILC_SERVER_CONFIG_LIST_ALLOC(config->hmac);
-
- /* Get HMAC name */
- ret = silc_config_get_token(line, &config->hmac->alg_name);
- if (ret < 0)
- break;
- if (ret == 0) {
- fprintf(stderr, "%s:%d: HMAC name not defined\n",
- config->filename, pc->linenum);
- break;
- }
-
- /* Get hash name */
- ret = silc_config_get_token(line, &config->hmac->sim_name);
- if (ret < 0)
- break;
- if (ret == 0) {
- fprintf(stderr, "%s:%d: Hash function name not defined\n",
- config->filename, pc->linenum);
- break;
- }
-
- /* Get MAC length */
- ret = silc_config_get_token(line, &tmp);
- if (ret < 0)
- break;
- if (ret == 0) {
- fprintf(stderr, "%s:%d: HMAC's MAC length not defined\n",
- config->filename, pc->linenum);
- break;
- }
- config->hmac->key_len = atoi(tmp);
- silc_free(tmp);
-
- check = TRUE;
- checkmask |= (1L << pc->section->type);
- break;
-
- case SILC_CONFIG_SERVER_SECTION_TYPE_SERVER_INFO:
-
- if (!config->server_info)
- config->server_info = silc_calloc(1, sizeof(*config->server_info));
-
- /* Get server name */
- ret = silc_config_get_token(line, &config->server_info->server_name);
- if (ret < 0)
- break;
- if (ret == 0) {
- /* Server name not defined */
-
- }
-
- /* Get server IP */
- ret = silc_config_get_token(line, &config->server_info->server_ip);
- if (ret < 0)
- break;
- if (ret == 0) {
- /* Server IP not defined */
-
- }
-
- /* Get server location */
- ret = silc_config_get_token(line, &config->server_info->location);
- if (ret < 0)
- break;
-
- /* Get server port */
- /* XXX: Need port here??? */
- ret = silc_config_get_token(line, &tmp);
- if (ret < 0)
- break;
- if (ret == 0) {
- /* Port not defined */
-
- }
- config->server_info->port = atoi(tmp);
- silc_free(tmp);
-
- check = TRUE;
- checkmask |= (1L << pc->section->type);
- break;
-
- case SILC_CONFIG_SERVER_SECTION_TYPE_ADMIN_INFO:
-
- if (!config->admin_info)
- config->admin_info = silc_calloc(1, sizeof(*config->admin_info));
-
- /* Get location */
- ret = silc_config_get_token(line, &config->admin_info->location);
- if (ret < 0)
- break;
-
- /* Get server type */
- ret = silc_config_get_token(line, &config->admin_info->server_type);
- if (ret < 0)
- break;
-
- /* Get admins name */
- ret = silc_config_get_token(line, &config->admin_info->admin_name);
- if (ret < 0)
- break;
-
- /* Get admins email address */
- ret = silc_config_get_token(line, &config->admin_info->admin_email);
- if (ret < 0)
- break;
-
- check = TRUE;
- checkmask |= (1L << pc->section->type);
- break;
-
- case SILC_CONFIG_SERVER_SECTION_TYPE_LISTEN_PORT:
-
- SILC_SERVER_CONFIG_LIST_ALLOC(config->listen_port);
-
- /* Get host */
- ret = silc_config_get_token(line, &config->listen_port->host);
- if (ret < 0)
- break;
-
- /* Get remote IP */
- ret = silc_config_get_token(line, &config->listen_port->remote_ip);
- if (ret < 0)
- break;
-
- /* Get port */
- ret = silc_config_get_token(line, &tmp);
- if (ret < 0)
- break;
- if (ret == 0) {
- /* Any port */
- config->listen_port->port = 0;
- } else {
- config->listen_port->port = atoi(tmp);
- silc_free(tmp);
- }
-
- check = TRUE;
- checkmask |= (1L << pc->section->type);
- break;
-
- case SILC_CONFIG_SERVER_SECTION_TYPE_IDENTITY:
-
- if (!config->identity)
- config->identity = silc_calloc(1, sizeof(*config->identity));
-
- /* Get user */
- ret = silc_config_get_token(line, &config->identity->user);
- if (ret < 0)
- break;
- /* Get group */
- ret = silc_config_get_token(line, &config->identity->group);
- if (ret < 0)
- break;
-
- check = TRUE;
- checkmask |= (1L << pc->section->type);
-
- case SILC_CONFIG_SERVER_SECTION_TYPE_CONNECTION_CLASS:
-
- SILC_SERVER_CONFIG_LIST_ALLOC(config->conn_class);
-
- /* Get class number */
- ret = silc_config_get_token(line, &tmp);
- if (ret < 0)
- break;
- if (ret == 0) {
- /* Class number not defined */