/*************************************************************************** * This file is part of "libaiml" * * Copyright (C) 2005 by V01D * * * * "libaiml" is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * "libaiml" is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with "libaiml"; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef __LIBAIML_CORE_H__ #define __LIBAIML_CORE_H__ #define LIBAIML_MAX_LINE_SIZE 16384 // max size a line of text can be (doesn't apply to .aiml files) #define LIBAIML_POPEN_BUFFER_SIZE 256 // buffer size used when reading data from popen() #define LIBAIML_VERSION_STRING ("libaiml 0.4") #define LIBAIML_VERSION (0.4) #include #include #include #include #include #include #include "global.h" #include "errors.h" #include "aiml_parser.h" namespace _aiml { class cCore { public: cCore(void); ~cCore(void); bool initialize(const std::string& file); void deinitialize(void); bool respond(const std::string& input, const std::string& username, std::string& output); void unregister_user(const std::string& user_id); AIMLError get_error(void); const char* get_error_str(AIMLError error_num); private: friend class cGraphMaster; /** Error handling **/ AIMLError last_error; static const char* error_str[AIMLERR_MAX]; void set_error(AIMLError); /** Utility Functions **/ bool load_substitutions(void); bool load_botvars(void); void load_aiml_files(void); void learn_file(const std::string& filename, bool at_runtime = false); bool load_userlist(void); void save_userlist(void); std::string doSystemCall(const std::string& cmd); std::string doJavaScriptCall(const std::string& cmd); /** ADD: implement this **/ bool load_defvars(void); const std::string& getBotVar(const std::string& key) const; StringMAP botvars_map; /** Internal modules **/ cGraphMaster graphmaster; AIMLparser aiml_parser; /** Configuration options/vars **/ std_util::cConfig cfg; std::ofstream file_gossip_stream; std::string aiml_path, file_substitute, file_gossip, file_botvars, aiml_files, user_dir; bool should_trim_blanks, allow_system; /** User management **/ typedef std::map UserMap; typedef std::list UserIDS; UserMap user_map; UserIDS user_ids; bool get_free_uid(UserID* ptr); }; } /** * Public Interface */ namespace aiml { using _aiml::cCore; using _aiml::AIMLError; } #endif // __LIBAIML_CORE_H__