예제 #1
0
파일: sp_session.c 프로젝트: paraler/bashrc
/**************************************************************************
 * 
 * Function: SessionInit(char *, OptTreeNode *)
 *
 * Purpose: Initialize the sesion plugin, parsing the rule parameters and
 *          setting up any necessary data structures.
 *
 * Arguments: data => rule arguments/data
 *            otn => pointer to the current rule option list node
 *
 * Returns: void function
 *
 *************************************************************************/
void SessionInit(char *data, OptTreeNode *otn, int protocol)
{

    /*
     * Theoretically we should only all this plugin to be used when there's a 
     * possibility of a session happening (i.e. TCP), but I get enough 
     * requests that I'm going to pull the verifier so that things should work
     * for everyone
     */
/*    if(protocol != IPPROTO_TCP)
    {
        FatalError("ERROR line %s (%d): Session keyword can not be used in non-TCP rule\n",
                file_name, file_line);
    }*/

    /* allocate the data structure and attach it to the
       rule's data struct list */
    otn->ds_list[PLUGIN_SESSION] = (SessionData *) calloc(sizeof(SessionData), sizeof(char));

    /* be sure to check that the protocol that is passed in matches the
       transport layer protocol that you're using for this rule! */

    /* this is where the keyword arguments are processed and placed into 
       the rule option's data structure */
    ParseSession(data, otn);

    /* finally, attach the option's detection function to the rule's 
       detect function pointer list */
    AddOptFuncToList(LogSessionData, otn);
}
예제 #2
0
bool ParseSession(const std::string& session_json, SessionData& session)
{
	Json::Value values;
	Json::Reader reader;
	if (reader.parse(session_json, values) && values.isObject())
	{
		ParseSession(values, session);
		return true;
	}
	return false;
}
예제 #3
0
static void CallbackSessionChange(int rescode, const char *result, int total_unread_counts, const char *json_extension, const void *user_data)
{
	if (user_data)
	{
		Session::DeleteRecentSessionCallabck* cb_pointer = (Session::DeleteRecentSessionCallabck*)user_data;
		if (*cb_pointer)
		{
			SessionData session;
			ParseSession(PCharToString(result), session);
			PostTaskToUIThread(std::bind((*cb_pointer), (nim::NIMResCode)rescode, session, total_unread_counts));
			//(*cb_pointer)((nim::NIMResCode)rescode, session, total_unread_counts);
		}
	}
}
예제 #4
0
bool ParseSessionList(const std::string& sessions_json, SessionDataList& session_list)
{
	Json::Value values;
	Json::Reader reader;
	if (reader.parse(sessions_json, values) && values.isObject())
	{
		session_list.count_ = values[kNIMSessionListCount].asUInt();
		session_list.unread_count_ = values[kNIMSessionListUnreadCount].asUInt();
		Json::Value sessions = values[kNIMSessionListContent];
		int len = sessions.size();
		for (int i = 0; i < len; i++)
		{
			SessionData session;
			ParseSession(sessions[i], session);
			session_list.sessions_.push_back(session);
		}
		return true;
	}
	return false;
}