<HTML>
<HEAD>
<TITLE>P4CGI - Support for CGI's that interface p4. Written specifically for P4DB</TITLE>
<LINK REV="made" HREF="mailto:feedback@suse.de">
</HEAD>
<BODY>
<!-- INDEX BEGIN -->
<UL>
<LI><A HREF="#CONSTANTS">CONSTANTS</A>
<UL>
<LI><A HREF="#Url_s">Url's</A>
</UL>
<LI><A HREF="#SUBROUTINES">SUBROUTINES</A>
<UL>
<LI><A HREF="#P4CGI_cgi_">P4CGI::cgi()</A>
<LI><A HREF="#P4CGI_p4call_I_result_I_comman">P4CGI::p4call(<EM>result</EM>,<EM>command</EM>)</A>
<LI><A HREF="#P4CGI_start_page_I_title_I_le">P4CGI::start_page(<EM>title</EM>[,<EM>legend</EM>])</A>
<LI><A HREF="#P4CGI_end_page_">P4CGI::end_page()</A>
<LI><A HREF="#P4CGI_bail_I_message_">P4CGI::bail(<EM>message</EM>)</A>
<LI><A HREF="#P4CGI_start_table_I_table_attri">P4CGI::start_table(<EM>table_attribute_text</EM>)</A>
<LI><A HREF="#P4CGI_end_table_">P4CGI::end_table()</A>
<LI><A HREF="#P4CGI_table_row_I_options_I_li">P4CGI::table_row(<EM>options</EM>,<EM>listOfValues</EM>)</A>
<LI><A HREF="#P4CGI_ul_list_I_list_">P4CGI::ul_list(<EM>list</EM>)</A>
<LI><A HREF="#P4CGI_dl_list_I_list_of_pairs_">P4CGI::dl_list(<EM>list_of_pairs</EM>)</A>
<LI><A HREF="#P4CGI_fixSpecChar_I_str_">P4CGI::fixSpecChar(<EM>str</EM>)</A>
<LI><A HREF="#P4CGI_rmTabs_I_str_">P4CGI::rmTabs(<EM>str</EM>)</A>
<LI><A HREF="#P4CGI_ahref_I_options_I_parame">P4CGI::ahref(<EM>options</EM>,<EM>parameters</EM>,<EM>text</EM>)</A>
<LI><A HREF="#P4CGI_magic_I_text_">P4CGI::magic(<EM>text</EM>)</A>
<LI><A HREF="#P4CGI_fixspaces_I_text_">P4CGI::fixspaces(<EM>text</EM>)</A>
</UL>
</UL>
<!-- INDEX END -->
<HR>
<P>
<HR>
<H1><A NAME="CONSTANTS">CONSTANTS</A></H1>
<P>
The constants are defined as perl subroutines.
<P>
<HR>
<H2><A NAME="Url_s">Url's</A></H2>
<DL>
<DT><STRONG><A NAME="item_P4CGI">P4CGI::MAIN_URL()</A></STRONG><DD>
<P>
Main entry point.
<DT><STRONG><A NAME="item_P4CGI">P4CGI::DTB_URL()</A></STRONG><DD>
<P>
URL to depot tree browser.
<DT><STRONG><A NAME="item_P4CGI">P4CGI::CHB_URL()</A></STRONG><DD>
<P>
URL to change browser.
<DT><STRONG><A NAME="item_P4CGI">P4CGI::CHV_URL()</A></STRONG><DD>
<P>
URL to change viewer.
<DT><STRONG><A NAME="item_P4CGI">P4CGI::FV_URL()</A></STRONG><DD>
<P>
URL to file viewer.
<DT><STRONG><A NAME="item_P4CGI">P4CGI::SFV_URL()</A></STRONG><DD>
<P>
URL to special file viewer.
<DT><STRONG><A NAME="item_P4CGI">P4CGI::SFV_HTML_URL()</A></STRONG><DD>
<P>
URL to special file viewer for HTML
<DT><STRONG><A NAME="item_P4CGI">P4CGI::FLV_URL()</A></STRONG><DD>
<P>
URL to file log viewer.
<DT><STRONG><A NAME="item_P4CGI">P4CGI::FDV_URL()</A></STRONG><DD>
<P>
URL to file diff viewer.
<DT><STRONG><A NAME="item_P4CGI">P4CGI::LDV_URL()</A></STRONG><DD>
<P>
URL to label diff viewer.
<DT><STRONG><A NAME="item_P4CGI">P4CGI::SFF_URL()</A></STRONG><DD>
<P>
URL to search for file.
<DT><STRONG><A NAME="item_P4CGI">P4CGI::LAU_URL()</A></STRONG><DD>
<P>
URL to list all users.
<DT><STRONG><A NAME="item_P4CGI">P4CGI::LU_URL()</A></STRONG><DD>
<P>
URL to view a user.
<DT><STRONG><A NAME="item_P4CGI">P4CGI::LAB_URL()</A></STRONG><DD>
<P>
URL to list all branches.
<DT><STRONG><A NAME="item_P4CGI">P4CGI::LAL_URL()</A></STRONG><DD>
<P>
URL to list all labels.
<DT><STRONG><A NAME="item_P4CGI">P4CGI::LV_URL()</A></STRONG><DD>
<P>
URL to view a labels.
</DL>
<P>
<HR>
<H1><A NAME="SUBROUTINES">SUBROUTINES</A></H1>
<P>
<HR>
<H2><A NAME="P4CGI_cgi_">P4CGI::cgi()</A></H2>
<P>
Return CGI reference
<P>
Example:
<P>
<PRE> my $file = P4CGI::cgi()->param("file") ;
print "Parameter \"file\" value: $file\n" ;
</PRE>
<P>
<HR>
<H2><A NAME="P4CGI_p4call_I_result_I_comman">P4CGI::p4call(<EM>result</EM>,<EM>command</EM>)</A></H2>
<P>
Request data from p4. Calls p4 with command <EM>command</EM> and returns data in <EM>result</EM>.
<P>
This function is really three different functions depeding in the type of
the
<EM>result</EM> parameter.
<DL>
<DT><STRONG><A NAME="item_result">result</A></STRONG><DD>
<P>
This parameter can be of three different types:
<DL>
<DT><STRONG><A NAME="item_Filehandle">Filehandle (typeglob)</A></STRONG><DD>
<P>
Data from command can be read from filehandle. NOTE! File must be closed by
caller.
<DT><STRONG><A NAME="item_Reference">Reference to array</A></STRONG><DD>
<P>
Returns result from command in array (newlines stripped)
<DT><STRONG>Reference to scalar</STRONG><DD>
<P>
Returns result from command in scalar. (lines separated by newline)
</DL>
<P>
Any other type of parameter will abort operation
<DT><STRONG><A NAME="item_command">command</A></STRONG><DD>
<P>
Command to send to p4 command line client.
</DL>
<P>
Example:
<P>
<PRE> my $d ;
&P4CGI::p4call(\$d,"changes -m 1") ;
$d =~ /Change (\d+)/ or &bail("No contact with P4 server") ;
$currentChangeLevel=$1 ;
</PRE>
<P>
<HR>
<H2><A NAME="P4CGI_start_page_I_title_I_le">P4CGI::start_page(<EM>title</EM>[,<EM>legend</EM>])</A></H2>
<P>
Start a page. Print http header and first part of HTML.
<DL>
<DT><STRONG><A NAME="item_title">title</A></STRONG><DD>
<P>
Title of page
<DT><STRONG><A NAME="item_legend">legend (Optional)</A></STRONG><DD>
<P>
Short help text to be displayed at top of page
</DL>
<P>
Example:
<P>
<PRE> my $start = P4CGI::start_page("Title of page",
&P4CGI::dl_list("This","Goto this",
"That","Goto that")) ;
print $start ;
</PRE>
<P>
<HR>
<H2><A NAME="P4CGI_end_page_">P4CGI::end_page()</A></H2>
<P>
End a page. Print HTML trailer.
<P>
Example:
<P>
<PRE> print P4CGI::end_page() ;
</PRE>
<P>
<HR>
<H2><A NAME="P4CGI_bail_I_message_">P4CGI::bail(<EM>message</EM>)</A></H2>
<P>
Report an error. This routine will emit HTML code for an error message and
exit.
<DL>
<DT><STRONG><A NAME="item_message">message
Message that will be displayed to user</A></STRONG><DD>
</DL>
<P>
Example:
<P>
<PRE> unless(defined $must_be_defined) {
&P4CGI::bail("was not defined") ;
} ;
</PRE>
<P>
<HR>
<H2><A NAME="P4CGI_start_table_I_table_attri">P4CGI::start_table(<EM>table_attribute_text</EM>)</A></H2>
<P>
Start a table with optional table attributes
<DL>
<DT><STRONG><A NAME="item_table_attribute_text">table_attribute_text</A></STRONG><DD>
<P>
This text will be inserted as attributes to table tag
</DL>
<P>
Example:
<P>
<PRE> print P4CGI::start_table("align=center border") ;
</PRE>
<P>
<HR>
<H2><A NAME="P4CGI_end_table_">P4CGI::end_table()</A></H2>
<P>
Return end of table string. (trivial function included mostly for symmetry)
<P>
<HR>
<H2><A NAME="P4CGI_table_row_I_options_I_li">P4CGI::table_row(<EM>options</EM>,<EM>listOfValues</EM>)</A></H2>
<P>
Insert a row in table.
<DL>
<DT><STRONG><A NAME="item_options">options</A></STRONG><DD>
<P>
A list of key/value pairs (a hash will do just fine) containing options for
the row.
<P>
The key must start with a ``-''.
<P>
Most key/value pairs are treated as attributes to the <TR>-tag. The
following keys are recognized as special:
<DL>
<DT><STRONG><A NAME="item__type">-type</A></STRONG><DD>
<P>
Type of cells. Default is <TD>-type.
<DT><STRONG><A NAME="item__anykey">-anykey</A></STRONG><DD>
<P>
<EM>anykey</EM> will be assumed to be a row option and will be inserted in the TR-tag. The
value for the option is the key value, unless value is empty or undefined,
in which case the option anykey is assumed to have no value.
</DL>
<DT><STRONG><A NAME="item_listOfValues">listOfValues</A></STRONG><DD>
<P>
Row data. Remaining values are assumed to be data for each cell. The data
is typically the text in the cell but can also be:
<DL>
<DT><STRONG><A NAME="item_undef">undef</A></STRONG><DD>
<P>
An undefined value indicates that the next cell spans more than one column.
<DT><STRONG>Reference to a hash</STRONG><DD>
<P>
The has contains two keys: ``-text'' for cell text and ``-type'' for cell
type. All other key/value pairs are treated as attributes to the <TD>
or <TH> tag.
</DL>
</DL>
<P>
Example:
<P>
<PRE> print P4CGI::start_table("align=center") ;
### print header row
print P4CGI::table_row(-type => "th",
-valign => "top",
-align => "left",
"Heading 1","Heading 2",undef,"Heading 3") ;
### print data
my %h = (-text => "text in hash",
-bgcolor => "blue") ;
print P4CGI::table_row(-valign => "top",
-bgcolor => "white",
"Cell 1",
{-text => "Cell 2",
-bgcolor => "red"},
\%h,
"Cell 3-2") ;
print P4CGI::end_table() ;
</PRE>
<P>
<HR>
<H2><A NAME="P4CGI_ul_list_I_list_">P4CGI::ul_list(<EM>list</EM>)</A></H2>
<P>
Return a bulleted list.
<DL>
<DT><STRONG><A NAME="item_list">list</A></STRONG><DD>
<P>
Lits of data to print as bulleted list
</DL>
<P>
Example:
<P>
<PRE> print P4CGI::ul_list("This","is","a","bulleted","list") ;
</PRE>
<P>
<HR>
<H2><A NAME="P4CGI_dl_list_I_list_of_pairs_">P4CGI::dl_list(<EM>list_of_pairs</EM>)</A></H2>
<P>
Returns a definition list.
<DL>
<DT><STRONG><A NAME="item_list_of_pairs">list_of_pairs</A></STRONG><DD>
<P>
List of data pairs to print as a definition list. A hash will do just fine,
only that You have no control of the order in the list.
</DL>
<P>
Example:
<P>
<PRE> print P4CGI::dl_list("This","Description of this",
"That","Description of that") ;
</PRE>
<P>
<HR>
<H2><A NAME="P4CGI_fixSpecChar_I_str_">P4CGI::fixSpecChar(<EM>str</EM>)</A></H2>
<P>
Convert all '>' to ``<CODE>&amp;gt;</CODE>'', '<' to ``<CODE>&amp;lt;</CODE>'' and '&' to ``<CODE>&amp;amp;</CODE>''.
<DL>
<DT><STRONG><A NAME="item_str">str</A></STRONG><DD>
<P>
String to convert
</DL>
<P>
Example:
<P>
<PRE> my $cvstr = &P4CGI::fixSpecChar("String containing <,> and &") ;
</PRE>
<P>
<HR>
<H2><A NAME="P4CGI_rmTabs_I_str_">P4CGI::rmTabs(<EM>str</EM>)</A></H2>
<P>
Convert tabs to spaces
<DL>
<DT><STRONG>str</STRONG><DD>
<P>
String to convert
</DL>
<P>
<HR>
<H2><A NAME="P4CGI_ahref_I_options_I_parame">P4CGI::ahref(<EM>options</EM>,<EM>parameters</EM>,<EM>text</EM>)</A></H2>
<P>
Create a <A HREF...>...</A> tag pair.
<DL>
<DT><STRONG>options</STRONG><DD>
<P>
Optional list of option-value pairs. Valid options are:
<DL>
<DT><STRONG><A NAME="item__url">-url</A></STRONG><DD>
<P>
Url for link. Default is current.
<DT><STRONG><A NAME="item__anchor">-anchor</A></STRONG><DD>
<P>
Anchor in url. Default is none.
</DL>
<P>
Any non-valid option marks the end of the options
<DT><STRONG><A NAME="item_parameters">parameters</A></STRONG><DD>
<P>
Optional list of parameters for link.
<DT><STRONG><A NAME="item_text">text</A></STRONG><DD>
<P>
The last parameter is used as text for link.
</DL>
<P>
Example:
<P>
<PRE> print &P4CGI::ahref("Back to myself") ; # link to this. No parameters.
</PRE>
<P>
<PRE> print &P4CGI::ahref("-url","www.perforce.com",
"To perforce") ; # link to perforce
</PRE>
<P>
<PRE> print &P4CGI::ahref("-anchor","THERE",
"Go there") ; # link to anchor THERE
</PRE>
<P>
<PRE> print &P4CGI::ahref("-url","chb.cgi",
"FSPC=//.../doc/...",
"Changes for all documentation") ; # url with parameter
</PRE>
<P>
<HR>
<H2><A NAME="P4CGI_magic_I_text_">P4CGI::magic(<EM>text</EM>)</A></H2>
<P>
Substitutes magic phrases in <EM>text</EM> with links.
<P>
Currently the pattern ``change <EM>number</EM>'' is replaced with a link to the change browser.
<P>
Example:
<P>
<PRE> my $t = "This change is the same as change 4711, but with a twist" ;
</PRE>
<P>
<PRE> print &P4CGI::magic($t) ; # inserts a link to change 4711
</PRE>
<P>
<HR>
<H2><A NAME="P4CGI_fixspaces_I_text_">P4CGI::fixspaces(<EM>text</EM>)</A></H2>
<P>
Return parameter with spaces substituted with <CODE>%20</CODE>
<P>
Example:
<P>
<PRE> my $t = "/File with spaces" ;
</PRE>
<P>
<PRE> print &P4CGI::fixspaces($t) ; # prints: /File%20with%20spaces
</PRE>
</BODY>
</HTML>
| # | Change | User | Description | Committed | |
|---|---|---|---|---|---|
| #2 | 382 | heather_van_steenburgh | Bring up to 0.99f level | ||
| #1 | 381 | heather_van_steenburgh |
The version of P4DB in the public depot isn't 0.99f. Branch for 0.99f |
||
| //guest/heather_van_steenburgh/perforce/utils/p4db/P4CGI.html | |||||
| #1 | 380 | heather_van_steenburgh | P4DB baseline | ||
| //guest/perforce_software/utils/p4db/P4CGI.html | |||||
| #1 | 11 | Perforce maintenance | Add Fredric Fredricson's depot browser, P4DB. | ||