#include "server.h"
#include "auth.h"
#include "cqi.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <signal.h>
#include <strings.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include "../cl/cl.h"
#include "../cl/macros.h"
#include "../cqp/options.h"
#include "../cqp/corpmanag.h"
#include "../cqp/parse_actions.h"
#include "../cqp/hash.h"
#define ATTHASHSIZE 16384 |
Referenced by accept_connection().
#define GENERAL_ERROR_SIZE 1024 |
Referenced by cqi_general_error().
#define MSG_WAITALL 0 |
Referenced by cqi_recv_byte(), and cqi_recv_bytes().
#define NETBUFSIZE 512 |
typedef struct att_bucket AttBucket |
typedef struct att_hashtable* AttHashTable |
int accept_connection | ( | int | port | ) |
References ATTHASHSIZE, check_host(), client_addr, conn_out, connfd, CQI_PORT, localhost, make_attribute_hash(), private_server, remote_address, remote_host, server_debug, server_log, server_quit, and sockfd.
Referenced by main().
AttBucket* att_hash_lookup | ( | char * | str | ) |
References ATT_NONE, att_bucket::attribute, cl_strdup(), cqi_internal_error(), hash_string(), att_hashtable::size, att_hashtable::space, att_bucket::string, and att_bucket::type.
Referenced by cqi_drop_attribute(), and cqi_lookup_attribute().
int check_attribute_name | ( | char * | name | ) |
References cqi_errno, CQI_ERROR_SYNTAX_ERROR, cqi_id_lc, cqi_id_lc_first, and CQI_STATUS_OK.
Referenced by split_attribute_spec().
int check_corpus_name | ( | char * | name | ) |
References cqi_errno, CQI_ERROR_SYNTAX_ERROR, cqi_id_uc, cqi_id_uc_first, and CQI_STATUS_OK.
Referenced by cqi_find_corpus(), do_cqi_cqp_list_subcorpora(), split_attribute_spec(), and split_subcorpus_spec().
int check_subcorpus_name | ( | char * | name | ) |
References cqi_errno, CQI_ERROR_SYNTAX_ERROR, cqi_id_all, cqi_id_uc_first, and CQI_STATUS_OK.
Referenced by do_cqi_cqp_query(), and split_subcorpus_spec().
char* combine_subcorpus_spec | ( | char * | corpus, | |
char * | subcorpus | |||
) |
References cl_malloc(), and cl_strdup().
Referenced by do_cqi_cqp_query().
int cqi_activate_corpus | ( | char * | name | ) |
References cqi_find_corpus(), server_debug, and set_current_corpus().
Referenced by do_cqi_cqp_query().
void cqi_command | ( | int | command | ) |
References cqi_flush(), cqi_send_error(), and cqi_send_word().
Referenced by cqi_general_error(), do_cqi_cl_alg2cpos(), do_cqi_cl_attribute_size(), do_cqi_cl_cpos2alg(), do_cqi_cl_cpos2id(), do_cqi_cl_cpos2lbound(), do_cqi_cl_cpos2rbound(), do_cqi_cl_cpos2str(), do_cqi_cl_cpos2struc(), do_cqi_cl_id2cpos(), do_cqi_cl_id2freq(), do_cqi_cl_id2str(), do_cqi_cl_idlist2cpos(), do_cqi_cl_lexicon_size(), do_cqi_cl_regex2id(), do_cqi_cl_str2id(), do_cqi_cl_struc2cpos(), do_cqi_cl_struc2str(), do_cqi_corpus_attributes(), do_cqi_corpus_full_name(), do_cqi_corpus_structural_attribute_has_values(), do_cqi_cqp_drop_subcorpus(), do_cqi_cqp_dump_subcorpus(), do_cqi_cqp_fdist_1(), do_cqi_cqp_fdist_2(), do_cqi_cqp_list_subcorpora(), do_cqi_cqp_query(), do_cqi_cqp_subcorpus_has_field(), do_cqi_cqp_subcorpus_size(), interpreter(), main(), and send_cl_error().
void cqi_data_bool | ( | int | n | ) |
References CQI_DATA_BOOL, cqi_flush(), cqi_send_byte(), cqi_send_error(), and cqi_send_word().
Referenced by do_cqi_corpus_structural_attribute_has_values(), do_cqi_cqp_subcorpus_has_field(), and interpreter().
void cqi_data_bool_list | ( | cqi_byte * | list, | |
int | l | |||
) |
References CQI_DATA_BOOL_LIST, cqi_flush(), cqi_send_byte_list(), cqi_send_error(), and cqi_send_word().
void cqi_data_byte | ( | int | n | ) |
References CQI_DATA_BYTE, cqi_flush(), cqi_send_byte(), cqi_send_error(), and cqi_send_word().
void cqi_data_byte_list | ( | cqi_byte * | list, | |
int | l | |||
) |
References CQI_DATA_BYTE_LIST, cqi_flush(), cqi_send_byte_list(), cqi_send_error(), and cqi_send_word().
void cqi_data_int | ( | int | n | ) |
References CQI_DATA_INT, cqi_flush(), cqi_send_error(), cqi_send_int(), and cqi_send_word().
Referenced by do_cqi_cl_attribute_size(), do_cqi_cl_lexicon_size(), and do_cqi_cqp_subcorpus_size().
void cqi_data_int_int | ( | int | n1, | |
int | n2 | |||
) |
References CQI_DATA_INT_INT, cqi_flush(), cqi_send_error(), cqi_send_int(), and cqi_send_word().
Referenced by do_cqi_cl_struc2cpos().
void cqi_data_int_int_int_int | ( | int | n1, | |
int | n2, | |||
int | n3, | |||
int | n4 | |||
) |
References CQI_DATA_INT_INT_INT_INT, cqi_flush(), cqi_send_error(), cqi_send_int(), and cqi_send_word().
Referenced by do_cqi_cl_alg2cpos().
void cqi_data_int_list | ( | int * | list, | |
int | l | |||
) |
References CQI_DATA_INT_LIST, cqi_flush(), cqi_send_error(), cqi_send_int_list(), and cqi_send_word().
Referenced by do_cqi_cl_id2cpos(), do_cqi_cl_idlist2cpos(), and do_cqi_cl_regex2id().
void cqi_data_string | ( | char * | str | ) |
References CQI_DATA_STRING, cqi_flush(), cqi_send_error(), cqi_send_string(), and cqi_send_word().
Referenced by do_cqi_corpus_charset(), do_cqi_corpus_full_name(), and interpreter().
void cqi_data_string_list | ( | char ** | list, | |
int | l | |||
) |
References CQI_DATA_STRING_LIST, cqi_flush(), cqi_send_error(), cqi_send_string_list(), and cqi_send_word().
Referenced by do_cqi_corpus_properties().
int cqi_drop_attribute | ( | char * | name | ) |
References att_hash_lookup(), ATT_NONE, att_bucket::attribute, cl_delete_attribute, and att_bucket::type.
CorpusList* cqi_find_corpus | ( | char * | name | ) |
References access_corpus(), check_corpus_name(), corpus, CQI_CQP_ERROR_NO_SUCH_CORPUS, cqi_errno, CQI_STATUS_OK, findcorpus(), split_subcorpus_spec(), SUB, and SYSTEM.
Referenced by cqi_activate_corpus(), do_cqi_cqp_drop_subcorpus(), do_cqi_cqp_dump_subcorpus(), do_cqi_cqp_fdist_1(), do_cqi_cqp_fdist_2(), do_cqi_cqp_list_subcorpora(), do_cqi_cqp_query(), do_cqi_cqp_subcorpus_has_field(), and do_cqi_cqp_subcorpus_size().
int cqi_flush | ( | void | ) |
References conn_out, and snoop.
Referenced by cqi_command(), cqi_data_bool(), cqi_data_bool_list(), cqi_data_byte(), cqi_data_byte_list(), cqi_data_int(), cqi_data_int_int(), cqi_data_int_int_int_int(), cqi_data_int_list(), cqi_data_string(), cqi_data_string_list(), do_cqi_cl_cpos2alg(), do_cqi_cl_cpos2id(), do_cqi_cl_cpos2lbound(), do_cqi_cl_cpos2rbound(), do_cqi_cl_cpos2str(), do_cqi_cl_cpos2struc(), do_cqi_cl_id2freq(), do_cqi_cl_id2str(), do_cqi_cl_idlist2cpos(), do_cqi_cl_str2id(), do_cqi_cl_struc2str(), do_cqi_corpus_list_corpora(), do_cqi_cqp_dump_subcorpus(), do_cqi_cqp_fdist_1(), do_cqi_cqp_fdist_2(), do_cqi_cqp_list_subcorpora(), do_cqi_cqp_subcorpus_has_field(), and send_cqi_corpus_attributes().
void cqi_general_error | ( | char * | errstring | ) |
References cqi_command(), CQI_ERROR_GENERAL_ERROR, cqi_error_string, cqi_internal_error(), and GENERAL_ERROR_SIZE.
Referenced by do_cqi_cl_drop_attribute(), and do_cqi_corpus_attributes().
void cqi_internal_error | ( | char * | function, | |
char * | cause | |||
) |
Referenced by att_hash_lookup(), and cqi_general_error().
Attribute* cqi_lookup_attribute | ( | char * | name, | |
int | type | |||
) |
References access_corpus(), att_hash_lookup(), att_bucket::attribute, cl_new_attribute, cl::corpus, CQI_CL_ERROR_NO_SUCH_ATTRIBUTE, CQI_CL_ERROR_WRONG_ATTRIBUTE_TYPE, CQI_CQP_ERROR_NO_SUCH_CORPUS, cqi_errno, CQI_STATUS_OK, findcorpus(), server_debug, split_attribute_spec(), SYSTEM, and att_bucket::type.
Referenced by do_cqi_cl_alg2cpos(), do_cqi_cl_attribute_size(), do_cqi_cl_cpos2alg(), do_cqi_cl_cpos2id(), do_cqi_cl_cpos2lbound(), do_cqi_cl_cpos2rbound(), do_cqi_cl_cpos2str(), do_cqi_cl_cpos2struc(), do_cqi_cl_id2cpos(), do_cqi_cl_id2freq(), do_cqi_cl_id2str(), do_cqi_cl_idlist2cpos(), do_cqi_cl_lexicon_size(), do_cqi_cl_regex2id(), do_cqi_cl_str2id(), do_cqi_cl_struc2cpos(), do_cqi_cl_struc2str(), and do_cqi_corpus_structural_attribute_has_values().
int cqi_read_bool | ( | void | ) |
References cqi_recv_byte(), and cqi_recv_error().
int cqi_read_bool_list | ( | cqi_byte ** | list | ) |
References cl_malloc(), cqi_read_byte(), cqi_read_int(), and snoop.
int cqi_read_byte | ( | void | ) |
int cqi_read_byte_list | ( | cqi_byte ** | list | ) |
References cl_malloc(), cqi_read_byte(), cqi_read_int(), and snoop.
int cqi_read_command | ( | void | ) |
References CQI_PAD, cqi_read_byte(), and server_debug.
Referenced by interpreter(), and main().
int cqi_read_int | ( | void | ) |
int cqi_read_int_list | ( | int ** | list | ) |
char* cqi_read_string | ( | void | ) |
References cl_malloc(), cqi_read_word(), cqi_recv_bytes(), cqi_recv_error(), and snoop.
Referenced by cqi_read_string_list(), do_cqi_cl_alg2cpos(), do_cqi_cl_attribute_size(), do_cqi_cl_cpos2alg(), do_cqi_cl_cpos2id(), do_cqi_cl_cpos2lbound(), do_cqi_cl_cpos2rbound(), do_cqi_cl_cpos2str(), do_cqi_cl_cpos2struc(), do_cqi_cl_id2cpos(), do_cqi_cl_id2freq(), do_cqi_cl_id2str(), do_cqi_cl_idlist2cpos(), do_cqi_cl_lexicon_size(), do_cqi_cl_regex2id(), do_cqi_cl_str2id(), do_cqi_cl_struc2cpos(), do_cqi_cl_struc2str(), do_cqi_corpus_attributes(), do_cqi_corpus_charset(), do_cqi_corpus_full_name(), do_cqi_corpus_properties(), do_cqi_corpus_structural_attribute_has_values(), do_cqi_cqp_drop_subcorpus(), do_cqi_cqp_dump_subcorpus(), do_cqi_cqp_fdist_1(), do_cqi_cqp_fdist_2(), do_cqi_cqp_list_subcorpora(), do_cqi_cqp_query(), do_cqi_cqp_subcorpus_has_field(), do_cqi_cqp_subcorpus_size(), and main().
int cqi_read_string_list | ( | char *** | list | ) |
References cl_malloc(), cqi_read_int(), cqi_read_string(), and snoop.
Referenced by do_cqi_cl_str2id().
int cqi_read_word | ( | void | ) |
References cqi_read_byte(), and snoop.
Referenced by cqi_read_string().
int cqi_recv_byte | ( | void | ) |
References connfd, MSG_WAITALL, and snoop.
Referenced by cqi_read_bool(), and cqi_read_byte().
int cqi_recv_bytes | ( | cqi_byte * | buf, | |
int | bytes | |||
) |
References connfd, MSG_WAITALL, and snoop.
Referenced by cqi_read_string().
void cqi_recv_error | ( | char * | function | ) |
Referenced by cqi_read_bool(), cqi_read_byte(), and cqi_read_string().
int cqi_send_byte | ( | int | n | ) |
References conn_out, and snoop.
Referenced by cqi_data_bool(), cqi_data_byte(), and cqi_send_byte_list().
int cqi_send_byte_list | ( | cqi_byte * | list, | |
int | l | |||
) |
References cqi_send_byte(), and cqi_send_int().
Referenced by cqi_data_bool_list(), and cqi_data_byte_list().
void cqi_send_error | ( | char * | function | ) |
int cqi_send_int | ( | int | n | ) |
References conn_out, and snoop.
Referenced by cqi_data_int(), cqi_data_int_int(), cqi_data_int_int_int_int(), cqi_send_byte_list(), cqi_send_int_list(), cqi_send_minus_one_list(), cqi_send_string_list(), do_cqi_cl_cpos2alg(), do_cqi_cl_cpos2id(), do_cqi_cl_cpos2lbound(), do_cqi_cl_cpos2rbound(), do_cqi_cl_cpos2str(), do_cqi_cl_cpos2struc(), do_cqi_cl_id2freq(), do_cqi_cl_id2str(), do_cqi_cl_str2id(), do_cqi_cl_struc2str(), do_cqi_corpus_list_corpora(), do_cqi_cqp_dump_subcorpus(), do_cqi_cqp_fdist_1(), do_cqi_cqp_fdist_2(), do_cqi_cqp_list_subcorpora(), and send_cqi_corpus_attributes().
int cqi_send_int_list | ( | int * | list, | |
int | l | |||
) |
References cqi_send_int().
Referenced by cqi_data_int_list().
int cqi_send_string | ( | char * | str | ) |
References conn_out, cqi_send_word(), and snoop.
Referenced by cqi_data_string(), cqi_send_string_list(), do_cqi_cl_cpos2str(), do_cqi_cl_id2str(), do_cqi_cl_struc2str(), do_cqi_corpus_list_corpora(), do_cqi_cqp_list_subcorpora(), and send_cqi_corpus_attributes().
int cqi_send_string_list | ( | char ** | list, | |
int | l | |||
) |
References cqi_send_int(), and cqi_send_string().
Referenced by cqi_data_string_list().
int cqi_send_word | ( | int | n | ) |
References conn_out, and snoop.
Referenced by cqi_command(), cqi_data_bool(), cqi_data_bool_list(), cqi_data_byte(), cqi_data_byte_list(), cqi_data_int(), cqi_data_int_int(), cqi_data_int_int_int_int(), cqi_data_int_list(), cqi_data_string(), cqi_data_string_list(), cqi_send_string(), do_cqi_cl_cpos2alg(), do_cqi_cl_cpos2id(), do_cqi_cl_cpos2lbound(), do_cqi_cl_cpos2rbound(), do_cqi_cl_cpos2str(), do_cqi_cl_cpos2struc(), do_cqi_cl_id2freq(), do_cqi_cl_id2str(), do_cqi_cl_str2id(), do_cqi_cl_struc2str(), do_cqi_corpus_list_corpora(), do_cqi_cqp_dump_subcorpus(), do_cqi_cqp_fdist_1(), do_cqi_cqp_fdist_2(), do_cqi_cqp_list_subcorpora(), and send_cqi_corpus_attributes().
void free_attribute_hash | ( | void | ) |
References att_hashtable::space.
void make_attribute_hash | ( | int | size | ) |
References bytes, cl_malloc(), att_hashtable::code, find_prime(), att_hashtable::size, and att_hashtable::space.
Referenced by accept_connection().
int split_attribute_spec | ( | char * | spec, | |
char ** | corpus, | |||
char ** | attribute | |||
) |
References check_attribute_name(), check_corpus_name(), cl_strdup(), cqi_errno, CQI_ERROR_SYNTAX_ERROR, CQI_STATUS_OK, and strdupto().
Referenced by cqi_lookup_attribute().
int split_subcorpus_spec | ( | char * | spec, | |
char ** | corpus, | |||
char ** | subcorpus | |||
) |
References check_corpus_name(), check_subcorpus_name(), cl_free, cl_strdup(), cqi_errno, CQI_STATUS_OK, and strdupto().
Referenced by cqi_find_corpus(), do_cqi_cqp_drop_subcorpus(), and do_cqi_cqp_query().
char* strdupto | ( | char * | str, | |
char * | end | |||
) |
References cl_malloc().
Referenced by split_attribute_spec(), and split_subcorpus_spec().
AttHashTable AttHash = NULL |
int bytes |
Referenced by BFreadWord(), BFwriteWord(), make_attribute_hash(), and MakeMacroHash().
struct sockaddr_in my_addr client_addr |
Referenced by accept_connection().
FILE* conn_out |
Referenced by accept_connection(), cqi_flush(), cqi_send_byte(), cqi_send_int(), cqi_send_string(), and cqi_send_word().
int connfd |
Referenced by accept_connection(), cqi_recv_byte(), and cqi_recv_bytes().
int cqi_errno = CQI_STATUS_OK |
Referenced by check_attribute_name(), check_corpus_name(), check_subcorpus_name(), cqi_find_corpus(), cqi_lookup_attribute(), do_cqi_cl_alg2cpos(), do_cqi_cl_attribute_size(), do_cqi_cl_cpos2alg(), do_cqi_cl_cpos2id(), do_cqi_cl_cpos2lbound(), do_cqi_cl_cpos2rbound(), do_cqi_cl_cpos2str(), do_cqi_cl_cpos2struc(), do_cqi_cl_id2cpos(), do_cqi_cl_id2freq(), do_cqi_cl_id2str(), do_cqi_cl_idlist2cpos(), do_cqi_cl_lexicon_size(), do_cqi_cl_regex2id(), do_cqi_cl_str2id(), do_cqi_cl_struc2cpos(), do_cqi_cl_struc2str(), do_cqi_corpus_structural_attribute_has_values(), do_cqi_cqp_drop_subcorpus(), do_cqi_cqp_dump_subcorpus(), do_cqi_cqp_fdist_1(), do_cqi_cqp_fdist_2(), do_cqi_cqp_list_subcorpora(), do_cqi_cqp_query(), do_cqi_cqp_subcorpus_has_field(), do_cqi_cqp_subcorpus_size(), split_attribute_spec(), and split_subcorpus_spec().
char cqi_error_string[GENERAL_ERROR_SIZE] = "No error." |
Referenced by cqi_general_error(), and interpreter().
char cqi_id_all[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-0123456789" |
Referenced by check_subcorpus_name().
char cqi_id_lc[] = "abcdefghijklmnopqrstuvwxyz_-0123456789" |
Referenced by check_attribute_name().
char cqi_id_lc_first[] = "abcdefghijklmnopqrstuvwxyz_" |
Referenced by check_attribute_name().
char cqi_id_uc[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_-0123456789" |
Referenced by check_corpus_name().
char cqi_id_uc_first[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_" |
Referenced by check_corpus_name(), and check_subcorpus_name().
char* remote_address |
Referenced by accept_connection().
struct hostent* remote_host |
Referenced by accept_connection().
int sockfd |
Referenced by accept_connection().