예제 #1
0
void PrintLogBuffer(bool log)
{
    qtss_printf(gLogBuff);
    if (log) LogBuffer();
    *gLogBuff =0;
    gBuffUsed = strlen(gLogBuff);
}
예제 #2
0
void WritePacketToLog(void *data, int len)
{
    gLogNumPackets ++;
    LogUInt("Packet:", (UInt32) gLogNumPackets,"\n");
    LogBuffer();
    WriteToLog(data, len);
}
예제 #3
0
파일: LogDB.cpp 프로젝트: nurozhikun/cpp
void  CLogDB::FlushBuffer()
{
    EnterCriticalSection(&g_loggerdb);
    LogBuffer();
    LogInfo();
    LogServerManager();
    LeaveCriticalSection(&g_loggerdb);
}
예제 #4
0
		void AudioError::reset ()
		{
			ALint error = AL_NO_ERROR;

			while ((error = alGetError()) != AL_NO_ERROR) {
				logger()->log(LOG_ERROR, LogBuffer() << "Unhandled audio error #" << error << ": " << alGetString(error));
			}
		}
예제 #5
0
		Source::~Source ()
		{
			AudioError::reset();

			logger()->log(LOG_INFO, LogBuffer() << "Deleting audio source: " << _source_id);

			alDeleteSources(1, &_source_id);

			AudioError::check("Deallocating Source");
		}
예제 #6
0
파일: Renderer.cpp 프로젝트: DerDolch/dream
			GLuint RendererState::compile_shader_of_type (GLenum type, const Path & name) {
				Ref<IData> data = resource_loader->data_for_resource(name);

				if (data) {
					logger()->log(LOG_DEBUG, LogBuffer() << "Loading " << name);
					return shader_manager->compile(type, data->buffer().get());
				} else {
					return 0;
				}
			}
예제 #7
0
파일: LogDB.cpp 프로젝트: nurozhikun/cpp
void  CLogDB::LogBuffer(char* pBuffer,  unsigned int nLen, unsigned int cmdType, int ID)
{
    if( pBuffer == NULL)
        return ;
    EnterCriticalSection(&g_loggerdb);
    v_cmds.push_back(CMD_BUFF(ID, cmdType, nLen, pBuffer));
    if( v_cmds.size() >= FLUSH_SIZE)
    {
        LogBuffer();
        v_cmds.clear();
    }
    LeaveCriticalSection(&g_loggerdb);
}
예제 #8
0
		void check_graphics_error()
		{
#ifdef DREAM_DEBUG
			GLenum error = GL_NO_ERROR;

			while ((error = glGetError()) != GL_NO_ERROR) {
				logger()->log(LOG_ERROR, LogBuffer() << "OpenGL Error #" << error);

				// Abort due to error
				DREAM_ASSERT(error == GL_NO_ERROR);
			}

#endif
		}
예제 #9
0
void EventTrace_Log (const Packet* p, OptTreeNode* otn, int action)
{
    int i;
    const char* acts = (action < RULE_TYPE__MAX) ? rule_type[action] : "ERROR";

    if ( !tlog )
        return;

    TextLog_Print(tlog,
        "\nEvt=%u, Gid=%u, Sid=%u, Rev=%u, Act=%s\n",
        event_id, otn->sigInfo.generator, 
        otn->sigInfo.id, otn->sigInfo.rev, acts
    );
    TextLog_Print(tlog,
        "Pkt=%lu, Sec=%u.%6u, Len=%u, Cap=%u\n",
        pc.total_from_daq, p->pkth->ts.tv_sec, p->pkth->ts.tv_usec,
        p->pkth->pktlen, p->pkth->caplen
    );
    TextLog_Print(tlog,
        "Pkt Bits: Flags=0x%X, PP=0x%X, PPR=0x%X, Proto=0x%X"
        ", Err=0x%X\n",
        p->packet_flags, p->preprocessor_bits, p->preproc_reassembly_pkt_bits,
        (unsigned)p->proto_bits, (unsigned)p->error_flags
    );
    TextLog_Print(tlog,
        "Pkt Cnts: Dsz=%u, Alt=%u, Uri=0x%X\n",
        (unsigned)p->dsize, (unsigned)p->alt_dsize, http_mask
    );
    TextLog_Print(tlog, "Detect: DoeFlags=0x%X, DetectFlags=0x%X, DetBuf=%u, B64=%u\n",
        doe_buf_flags, detect_flags, DetectBuffer.len, base64_decode_size
    );
    LogBuffer("Decode", DecodeBuffer.data, DecodeBuffer.len);
    LogBuffer("Detect", DetectBuffer.data, DetectBuffer.len);
    LogBuffer("FileData", file_data_ptr.data, file_data_ptr.len);
    LogBuffer("Base64", base64_decode_buf, base64_decode_size);
    if(mime_present)
        LogBuffer("Mime", file_data_ptr.data, file_data_ptr.len);

    for ( i = 0; i < HTTP_BUFFER_MAX; i++ )
    {
        const HttpBuffer* hb = GetHttpBuffer(i);

        if ( !hb )
            continue;

        TextLog_Print(tlog, "%s[%u] = 0x%X\n",
            http_buffer_name[i], hb->length, hb->encode_type);

        LogBuffer(http_buffer_name[i], hb->buf, hb->length);
    }
    nEvents++;
}
예제 #10
0
파일: u2spewfoo.c 프로젝트: anarey/snort
static void packet_dump(const u2record *record,FILE *out_file) {
    uint32_t counter;
    uint8_t *field;

    unsigned offset = sizeof(Serial_Unified2Packet)-4;
    unsigned reclen = record->length - offset;

    Serial_Unified2Packet packet;
    memcpy(&packet, record->data, sizeof(Serial_Unified2Packet));

    /* network to host ordering */
    /* The first 7 fields need to be convertted */
    field = (uint8_t*)&packet;
    for(counter=0; counter<7; counter++, field+=4) {
        *(uint32_t*)field = ntohl(*(uint32_t*)field);
    }
    /* done changing from network ordering */

    fprintf(out_file,"\nPacket\n"
            "\tsensor id: %u\tevent id: %u\tevent second: %u\n"
            "\tpacket second: %u\tpacket microsecond: %u\n"
            "\tlinktype: %u\tpacket_length: %u\n",
            packet.sensor_id, packet.event_id, packet.event_second,
            packet.packet_second, packet.packet_microsecond, packet.linktype,
            packet.packet_length);

    
    if ( record->length <= offset )
        return;

    if ( packet.packet_length != reclen )
    {
        fprintf(out_file,"ERROR: logged %u but packet_length = %u\n",
            record->length-offset, packet.packet_length);

        if ( packet.packet_length < reclen )
        {
            reclen = packet.packet_length;
            s_off = reclen + offset;
        }
    }
    LogBuffer(record->data+offset, reclen,out_file);
}
void DoChildStuff(int comm_sock)
{
	char read_buffer[1024];
	fd_set read_set, write_set;
	int select_retval;

	srand(time(NULL));

	FD_ZERO(&read_set);
	FD_SET(comm_sock, &read_set);

	// See if there is data to read
	select_retval = select(comm_sock+1, &read_set, NULL, NULL, NULL);
	if (select_retval <= 0)
	{
		// error
		fprintf(stderr, "Read select failed %d\n", errno);
		exit(1);
	}

	// Read the data
	int readct = read(comm_sock, read_buffer, 1024);
	read_buffer[readct] = 0;

	LogBuffer(read_buffer);

	int rand_val = rand();
	char *retstr;
	int oneThirdRand = RAND_MAX/Resp_count;
	int index = rand_val/oneThirdRand;
	retstr = Responses[index];

	// Return a message
	write(comm_sock, retstr, strlen(retstr)+1);
	shutdown(comm_sock, SHUT_RDWR);	
}