Date: 10/21/02
- Next message: Jani Taskinen: "[PHP-DOC] About manual generation.."
- Previous message: Hartmut Holzgraefe: "[PHP-DOC] cvs: phpdoc /en/reference/fdf constants.xml reference.xml /en/reference/fdf/functions fdf-add-doc-javascript.xml fdf-close.xml fdf-create.xml fdf-errno.xml fdf-error.xml fdf-get-ap.xml fdf-get-attachment.xml fdf-get-encoding.xml fdf-get-file.xml fdf-get-status.xml fdf-get-value.xml fdf-get-version.xml fdf-next-field-name.xml fdf-open-string.xml fdf-open.xml fdf-save-string.xml fdf-save.xml fdf-set-ap.xml fdf-set-encoding.xml fdf-set-file.xml fdf-set-flags.xml fdf-set-javascript-action.xml fdf-set-opt.xml fdf-set-status.xml fdf-set-submit-form-action.xml fdf-set-target-frame.xml fdf-set-value.xml fdf-set-version.xml fdf_header.xml"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
ok, here's a php version ... I think it works ... hah
anyhow, you may want to get rid of the C version,
and just put this one in there ....
-Brad
Philip Olson wrote:
> Hi Brad-
>
> I think it's great that you worried about
> register_globals, I also worry about it and
> feel no public script (or my own for that
> matter) should rely on it being on. There
> is no need to.
>
> Anyway, just a "thanks" :)
>
> Philip
>
> P.S. http://www.php.net/features.commandline
>
> P.S.S. Oh dear, that man page assumes
> register_globals being on! Will change
> that sometime.
>
>
>
> On Mon, 21 Oct 2002, Brad House wrote:
>
>
>>found it:
>>http://www.php.net/manual/en/reserved.variables.php#reserved.variables.server
>>
>>it's $argc=$_SERVER["argc"];
>> $argv=$_SERVER["argv"];
>>for future reference...
>>
>>-Brad
>>
>>Gabor Hojtsy wrote:
>>
>>>>what I really meant, was is there a way to do
>>>>it if register_globals was off? There's
>>>>obviously $_COOKIE[""] $_POST[""] stuff
>>>>like that, is there $_ARGV[""] ?? want
>>>>to make sure it works no matter what if
>>>>I'm going to go through the trouble....
>>>
>>>
>>>I don't know anything about $_ARGV
>>>
>>>Goba
>>>
>>
>>
>>
>>--
>>PHP Documentation Mailing List (http://www.php.net/)
>>To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
<?php
$funclist=array();
$num_funcs=0;
function new_function()
{
global $funclist, $num_funcs;
$funclist[$num_funcs]["args"]=array();
$funclist[$num_funcs]["num_args"]=0;
$num_funcs++;
return($num_funcs-1);
}
function fix_name($name)
{
$ret="";
$len=strlen($name);
for ($i=0; $i<$len; $i++) {
$c=substr($name, $i, 1);
if ($c == '_') {
$ret .= '-';
} else {
$ret .= $c;
}
}
return($ret);
}
function function_add_name($num, $name)
{
global $funclist, $num_funcs;
$funclist[$num]["function_name"]=$name;
$funclist[$num]["function_name_fix"]=fix_name($name);
return(1);
}
function function_add_type($num, $type)
{
global $funclist, $num_funcs;
$funclist[$num]["function_type"]=$type;
return(1);
}
function function_add_purpose($num, $purpose)
{
global $funclist, $num_funcs;
$funclist[$num]["purpose"]=$purpose;
return(1);
}
function function_add_arg($num, $type, $argname)
{
global $funclist, $num_funcs;
$num_args=$funclist[$num]["num_args"];
$funclist[$num]["args"][$num_args]["type"]=$type;
$funclist[$num]["args"][$num_args]["variable"]=$argname;
$funclist[$num]["num_args"]++;
return(1);
}
function write_xml_files()
{
global $funclist, $num_funcs;
$filename="";
$fp=0;
for ($i=0; $i<$num_funcs; $i++) {
$filename= $funclist[$i]["function_name_fix"] . ".xml";
$fp=fopen($filename, "wb");
if (!$fp) {
echo "Failed writing: $filename\n";
continue;
}
$fixname=$funclist[$i]["function_name_fix"];
$funcname=$funclist[$i]["function_name"];
$purpose=$funclist[$i]["purpose"];
$functype=$funclist[$i]["function_type"];
fwrite($fp, "<?xml version='1.0' encoding='iso-8859-1'?>\n" .
"<!-- $Revision: 1.0 $ -->\n" .
" <refentry id=\"function." . $fixname . "\">\n" .
" <refnamediv>\n" .
" <refname>$funcname</refname>\n" .
" <refpurpose>$purpose</refpurpose>\n" .
" </refnamediv>\n" .
" <refsect1>\n" .
" <title>Description</title>\n" .
" <methodsynopsis>\n" .
" <type>$functype</type><methodname>$funcname</methodname>\n");
for ($j=0; $j<$funclist[$i]["num_args"]; $j++) {
$argtype=$funclist[$i]["args"][$j]["type"];
$argname=$funclist[$i]["args"][$j]["variable"];
fwrite($fp, " <methodparam><type>$argtype</type><parameter>$argname</parameter></methodparam>\n");
}
if ($funclist[$i]["num_args"] == 0){
fwrite($fp, " <void/>\n");
}
fwrite($fp, " </methodsynopsis>\n" .
" <para>\n" .
" &warn.undocumented.func;\n" .
" </para>\n" .
" </refsect1>\n" .
" </refentry>\n" .
"\n" .
"<!-- Keep this comment at the end of the file\n" .
"Local variables:\n" .
"mode: sgml\n" .
"sgml-omittag:t\n" .
"sgml-shorttag:t\n" .
"sgml-minimize-attributes:nil\n" .
"sgml-always-quote-attributes:t\n" .
"sgml-indent-step:1\n" .
"sgml-indent-data:t\n" .
"indent-tabs-mode:nil\n" .
"sgml-parent-document:nil\n" .
"sgml-default-dtd-file:\"../../../../manual.ced\"\n" .
"sgml-exposed-tags:nil\n" .
"sgml-local-catalogs:nil\n" .
"sgml-local-ecat-files:nil\n" .
"End:\n" .
"vim600: syn=xml fen fdm=syntax fdl=2 si\n" .
"vim: et tw=78 syn=sgml\n" .
"vi: ts=1 sw=1\n" .
"-->\n");
fclose($fp);
echo "Wrote: $filename\n";
}
return(1);
}
function read_file($filename)
{
$fp = fopen($filename, "rb");
if ($fp == 0) return("");
$buffer=fread($fp, filesize($filename));
fclose($fp);
return($buffer);
}
function parse_desc($func_num, $data)
{
$len=0;
$i=0;
$c=0;
$temp="";
$temp_len=0;
$spaces=0;
$len=strlen($data);
for ($i=0; $i<$len; $i++) {
$c=substr($data, $i, 1);
switch ($c) {
case '\r':
case '\n':
case ' ':
if (!$spaces) {
$spaces=1;
$temp .= ' ';
$temp_len++;
}
break;
default:
if ($c != '\r' && $c != '\n') {
$spaces=0;
$temp .= $c;
$temp_len++;
}
break;
}
}
function_add_purpose($func_num, $temp);
return(1);
}
function parse_proto($proto)
{
$len=0;
$i=0;
$c=0;
$done=0;
$start=0;
$func_number=-1;
$got_proto_def=0;
$got_proto_type=0;
$got_proto_name=0;
$got_arg_type=0;
$start_args=0;
$temp="";
$temp2="";
$temp_len=0;
$len=strlen($proto);
for ($i=0; $i<$len; $i++) {
$c=substr($proto, $i, 1);
switch ($c) {
case '\r':
case '\n':
case ' ':
if ($temp_len) {
if (!$got_proto_def) {
if (strcasecmp($temp, "proto") != 0) {
echo "Not a proper proto definition: $proto\n";
return(0);
} else {
$got_proto_def=1;
}
} else if (!$got_proto_type) {
$func_number=new_function();
function_add_type($func_number, $temp);
$got_proto_type=1;
} else if (!$got_proto_name) {
function_add_name($func_number, $temp);
$got_proto_name=1;
} else if ($start_args && !$got_arg_type) {
$got_arg_type=1;
$temp2=$temp;
} else if ($start_args && $got_arg_type) {
$got_arg_type=0;
function_add_arg($func_number, $temp2, $temp);
$temp2="";
}
$temp_len=0;
$temp="";
}
break;
case '(':
if ($got_proto_type && $got_proto_def &&!$got_proto_name) {
function_add_name($func_number, $temp);
$temp="";
$temp_len=0;
$start_args=1;
$got_proto_name=1;
} else {
echo "Not a proper proto definition -2: $proto\n";
return(0);
}
break;
case ')':
if ($start_args) {
if ($got_arg_type && $temp_len) {
function_add_arg($func_number, $temp2, $temp);
$temp="";
$temp_len=0;
}
$done=1;
} else {
echo "Not a proper proto definition -4: $proto\n";
return(0);
}
break;
case ',':
if ($start_args && $got_arg_type) {
$got_arg_type=0;
function_add_arg($func_number, $temp2, $temp);
$temp2="";
$temp="";
$temp_len=0;
} else {
echo "Not a proper proto definition -3: $proto\n";
return(0);
}
break;
default:
if ($c != '\r' && $c != '\n') {
$temp .= $c;
$temp_len++;
}
break;
}
if ($done) {
$start=$i+1;
break;
}
}
parse_desc($func_number, substr($proto, $start));
return(1);
}
function parse_file($buffer)
{
global $funclist, $num_funcs;
$temp1="";
$temp2="";
$ptr="";
$args="";
$ptr=$buffer;
while (1) {
$temp1=strstr($ptr, "{{{");
if ($temp1 == false) break;
$temp2=strstr($temp1, "*/");
if ($temp2 == false) break;
$args=substr($temp1, 3, strlen($temp1)-strlen($temp2)-3);
parse_proto($args);
$ptr=$temp2;
}
return(1);
}
function create_xml_docs($filename)
{
$contents=read_file($filename);
if ($contents == false || $contents == "") {
echo "Could not read $filename\n";
}
parse_file($contents);
write_xml_files();
return(1);
}
$myargc=$_SERVER["argc"];
$myargv=$_SERVER["argv"];
if ($myargc < 2) {
echo "Usage: " . $myargv[0] . " <extension.c>\n";
exit(1);
}
create_xml_docs($myargv[1]);
?>
-- PHP Documentation Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
- Next message: Jani Taskinen: "[PHP-DOC] About manual generation.."
- Previous message: Hartmut Holzgraefe: "[PHP-DOC] cvs: phpdoc /en/reference/fdf constants.xml reference.xml /en/reference/fdf/functions fdf-add-doc-javascript.xml fdf-close.xml fdf-create.xml fdf-errno.xml fdf-error.xml fdf-get-ap.xml fdf-get-attachment.xml fdf-get-encoding.xml fdf-get-file.xml fdf-get-status.xml fdf-get-value.xml fdf-get-version.xml fdf-next-field-name.xml fdf-open-string.xml fdf-open.xml fdf-save-string.xml fdf-save.xml fdf-set-ap.xml fdf-set-encoding.xml fdf-set-file.xml fdf-set-flags.xml fdf-set-javascript-action.xml fdf-set-opt.xml fdf-set-status.xml fdf-set-submit-form-action.xml fdf-set-target-frame.xml fdf-set-value.xml fdf-set-version.xml fdf_header.xml"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

