actube/src/wtp/enum2array.php

48 lines
731 B
PHP
Raw Normal View History

<?php
function enum2_array($data,$arrayname,$comment)
{
$str = "";
$values = explode(",",$data);
$str.=$comment;
$str.= "char * $arrayname"."[] = {\n";
$c="";
foreach($values as $val){
$str.= $c.'"'.trim($val).'"';
$c=",\n";
}
$str.= "\n};";
return $str;
}
$data = file_get_contents("nl80211attr.txt");
$arrayname="nlt_attrnames";
$comment = "/*
Generated by enum2array.php
Do not modify
*/
";
$r = enum2_array($data,$arrayname,$comment);
file_put_contents('nlt_attrnames.c',$r);
$data = file_get_contents("nl80211cmd.txt");
$arrayname="nlt_cmdnames";
$comment = "/*
Generated by enum2array.php
Do not modify
*/
";
$r = enum2_array($data,$arrayname,$comment);
file_put_contents('nlt_cmdnames.c',$r);