wm_strSwitch function


#1

I read that wm_strSwitch function compares different strings, but could these strings be parameters?, that is to say:
test_a= “match”;
test_b=“point”;
test=“match”;
result=wm_strSwitch(test, test_a, test_b, NULL);

or should I write: result=wm_strSwitch(test, “match”, “point”, NULL)?

In the other hand, is there any limited number of parameters which I can compare to?
result= wm_strSwitch (test, test_a, test_b, test_c, test_d,…, NULL)

Is there another way to make it easier?
Thanks a lot!


#2

Easier? That depends entirely on what you want to do.

As for number of arguments to wm_strSwitch it should only be limited by stack size. I’m not quite sure how vararg is normally implemented by compilers.


#3

If the function does not fit your needs you can simple do it for your own…

I had to do similar for an ‘universal’ UNSO-Routine…

e.g.

enum {
	ue_WVMI =0,//  0 voice mail indicator
	ue_WDCI,	//  1 wavecom diverted call indicator
	ue_WBCI,	//  2 battery charge indicator
	ue_WDIA,	//  3 wavecom diagnose
	ue_WIND,	//  4 general indications
	ue_RING,	//  5 ringing
	ue_CLIP,	//  6 calling line identification
	ue_CREG,	//  7 network registration state
	ue_CNMI,	//  8 new msg indicator
	ue_CBMI,	//  9 new msg
	ue_CBM,		// 10 new msg
	ue_CDSI,	// 11 sms status report
	ue_CDS,		// 12 sms status report
	ue_CCWA,	// 13 call waiting
	ue_CCCM,	// 14 advice of charge
	ue_CSSU,	// 15 supplementary service notification
	ue_CRIN,	// 16 CRing

	ue_count	// 17 dummy; insert BEFORE this
} Unso_e;

const ascii *UnSoStrings[ue_count][6] = { "+WVMI",
										  "+WDCI",
										  "+WBCI",
										  "+WDIA",
										  "+WIND",
										  "+RING",
										  "+CLIP",
										  "+CREG",
										  "+CNMI",
										  "+CBMI",
										  "+CBM:",
										  "+CDSI",
										  "+CDS:",
										  "+CCWA",
										  "+CCCM",
										  "+CSSU",
										  "+CRIN" };

and a search in the list is simply done by a loop…

for (msg_id=0; msg_id<ue_count; msg_id++)
	{
		if ( strncmp(str2searchfor, (char*)UnSoStrings[msg_id], 5) == 0 )
			break;
	}

	// act on incoming UnSoMessage
	switch ( msg_id ) {
	.....
	}

hth,
Heinz