My Simple code is:
switch(event)
{
case EVENT_XXXX:
name = "EVENT_XXXX";
break;
}
And all the events are defined on a web page as:
<td class="tg-cly1">EVENT_XXXX(OtaStateId, OK/FAIL)</td>
<td class="tg-cly1">EVENT_YYYY</td>
<td class="tg-cly1">EVENT_OOOO(PwrModeId)</td>
<td class="tg-cly1">EVENT_PPPP(PwrModeId)</td>
And there are many events and they might be changed in the feature. If I manucally type it, looks stupid.
So first step is save the web page to a file webpage.txt:
Second step is get all the lines of EVENT_XXXX
grep EVENT webpage.txt | sort > temp.txt
then remove head and tail as following.
sed 's/<\/td>//' temp.txt | sed 's/<.*>//'| sed 's/(\(.*\))//' > temp4.txt
first sed remove end </td>
second sed remove head <td class="tg-cly1">
last sed remove (xxxx)
Then I got temp4.txt which has only EVENT_XXXX
Now we can create the simple C code by python.
#!/bin/python
f=open("temp4.txt")
for eachline in f:
event = eachline.strip('\n')
event = event.lstrip()
print("case %s: name=\"%s\";break;\n" % (event,event))
for each line, remove left spaces and right enter.
then I can get the simple C code.