Go Back   EQEmulator Home > EQEmulator Forums > Archives > Archive::Development > Archive::Development

Archive::Development Archive area for Development's posts that were moved here after an inactivity period of 90 days.

Reply
 
Thread Tools Display Modes
  #1  
Old 05-27-2004, 12:37 PM
maaltan
Fire Beetle
 
Join Date: May 2004
Posts: 9
Default total recall

ok i got bored so i learned how to use variable parameters. here is the updated util.cpp file

This update will let you use this exactly like printf. for example:

Code:
opcode = 55;
info_report(SEV_WARN,"Unknown opcode: %d", opcode);
will print:

Code:
Warn [20:33:18] Unknown opcode: 55
all of printf's codes should work. Please let me know if wierdness happens. this is new ground for me.

Code:
#include "stdafx.h"
#include "util.h"
#include <time.h>
#include <stdarg.h>

//severity label array 
const char* severity_lookup[] = {	{"Null"},
								{"info"},
								{"Warn"},
								{"ERRO"},
								{"FATL"} };


int info_report(int severity, char* error, ...)
// return value as defined in util.h
{
	time_t timer;
	struct tm * curtime;

	if (severity > MAX_SEVERITY)
	{
		info_report(SEV_ERRO,"INVALID SEVERITY IN INFO_REPORT:  Please use valid severity value");
		return(RET_ERROR);
	} else
	{   
			// setup for variable argument list
			va_list arglist;
			va_start(arglist, error);
			//end setup

			timer=time(NULL);
			curtime = localtime(&timer);

			printf( "%s[%.2d:%.2d:%.2d] " ,
					severity_lookup[severity],
					(*curtime).tm_hour,
					(*curtime).tm_min,
					(*curtime).tm_sec);

			vprintf( error,arglist); //its maaaaagic

			printf("\n");
                                                va_end(arglist); //close the list up
			return(RET_NORMAL);
	}
	return(RET_NORMAL);
}
you will need to change the function prototype in util.h from:

int info_report(int severity, char* error);

to

int info_report(int severity, char* error, ...);
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 11:29 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3