P4CGI.html #2

  • //
  • guest/
  • heather_van_steenburgh/
  • perforce/
  • utils/
  • p4db_0.99f/
  • P4CGI.html
  • View
  • Commits
  • Open Download .zip Download (13 KB)
<HTML>
<HEAD>
<TITLE>P4CGI - Support for CGI's that interface p4. Written specifically for P4DB</TITLE>
<LINK REV="made" HREF="mailto:[email protected]">
</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(&lt;EM&gt;result&lt;/EM&gt;,&lt;EM&gt;command&lt;/EM&gt;)</A>
		<LI><A HREF="#P4CGI_start_page_I_title_I_le">P4CGI::start_page(&lt;EM&gt;title&lt;/EM&gt;[,&lt;EM&gt;legend&lt;/EM&gt;])</A>
		<LI><A HREF="#P4CGI_end_page_">P4CGI::end_page()</A>
		<LI><A HREF="#P4CGI_bail_I_message_">P4CGI::bail(&lt;EM&gt;message&lt;/EM&gt;)</A>
		<LI><A HREF="#P4CGI_start_table_I_table_attri">P4CGI::start_table(&lt;EM&gt;table_attribute_text&lt;/EM&gt;)</A>
		<LI><A HREF="#P4CGI_end_table_">P4CGI::end_table()</A>
		<LI><A HREF="#P4CGI_table_row_I_options_I_li">P4CGI::table_row(&lt;EM&gt;options&lt;/EM&gt;,&lt;EM&gt;listOfValues&lt;/EM&gt;)</A>
		<LI><A HREF="#P4CGI_ul_list_I_list_">P4CGI::ul_list(&lt;EM&gt;list&lt;/EM&gt;)</A>
		<LI><A HREF="#P4CGI_dl_list_I_list_of_pairs_">P4CGI::dl_list(&lt;EM&gt;list_of_pairs&lt;/EM&gt;)</A>
		<LI><A HREF="#P4CGI_fixSpecChar_I_str_">P4CGI::fixSpecChar(&lt;EM&gt;str&lt;/EM&gt;)</A>
		<LI><A HREF="#P4CGI_rmTabs_I_str_">P4CGI::rmTabs(&lt;EM&gt;str&lt;/EM&gt;)</A>
		<LI><A HREF="#P4CGI_ahref_I_options_I_parame">P4CGI::ahref(&lt;EM&gt;options&lt;/EM&gt;,&lt;EM&gt;parameters&lt;/EM&gt;,&lt;EM&gt;text&lt;/EM&gt;)</A>
		<LI><A HREF="#P4CGI_magic_I_text_">P4CGI::magic(&lt;EM&gt;text&lt;/EM&gt;)</A>
		<LI><A HREF="#P4CGI_fixspaces_I_text_">P4CGI::fixspaces(&lt;EM&gt;text&lt;/EM&gt;)</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()-&gt;param(&quot;file&quot;) ;
    print &quot;Parameter \&quot;file\&quot; value: $file\n&quot; ;
</PRE>
<P>
<HR>
<H2><A NAME="P4CGI_p4call_I_result_I_comman">P4CGI::p4call(&lt;EM&gt;result&lt;/EM&gt;,&lt;EM&gt;command&lt;/EM&gt;)</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 ;
    &amp;P4CGI::p4call(\$d,&quot;changes -m 1&quot;) ;
    $d =~ /Change (\d+)/ or &amp;bail(&quot;No contact with P4 server&quot;) ;
    $currentChangeLevel=$1 ;    
</PRE>
<P>
<HR>
<H2><A NAME="P4CGI_start_page_I_title_I_le">P4CGI::start_page(&lt;EM&gt;title&lt;/EM&gt;[,&lt;EM&gt;legend&lt;/EM&gt;])</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(&quot;Title of page&quot;,
                               &amp;P4CGI::dl_list(&quot;This&quot;,&quot;Goto this&quot;,
                                               &quot;That&quot;,&quot;Goto that&quot;)) ;
 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(&lt;EM&gt;message&lt;/EM&gt;)</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) { 
     &amp;P4CGI::bail(&quot;was not defined&quot;) ; 
 } ;
</PRE>
<P>
<HR>
<H2><A NAME="P4CGI_start_table_I_table_attri">P4CGI::start_table(&lt;EM&gt;table_attribute_text&lt;/EM&gt;)</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(&quot;align=center border&quot;) ;
</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(&lt;EM&gt;options&lt;/EM&gt;,&lt;EM&gt;listOfValues&lt;/EM&gt;)</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 &lt;TR&gt;-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 &lt;TD&gt;-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 &lt;TD&gt;
or &lt;TH&gt; tag.

</DL>
</DL>
<P>
Example:

<P>
<PRE> print P4CGI::start_table(&quot;align=center&quot;) ;
                                   ### print header row
 print P4CGI::table_row(-type   =&gt; &quot;th&quot;,
                        -valign =&gt; &quot;top&quot;,
                        -align  =&gt; &quot;left&quot;,
                        &quot;Heading 1&quot;,&quot;Heading 2&quot;,undef,&quot;Heading 3&quot;) ;
                                   ### print data
 my %h = (-text    =&gt; &quot;text in hash&quot;, 
          -bgcolor =&gt; &quot;blue&quot;) ;
 print P4CGI::table_row(-valign  =&gt; &quot;top&quot;,
                        -bgcolor =&gt; &quot;white&quot;,
                        &quot;Cell 1&quot;,
                        {-text    =&gt; &quot;Cell 2&quot;,
                         -bgcolor =&gt; &quot;red&quot;},
                        \%h,
                        &quot;Cell 3-2&quot;) ;
 print P4CGI::end_table() ;
</PRE>
<P>
<HR>
<H2><A NAME="P4CGI_ul_list_I_list_">P4CGI::ul_list(&lt;EM&gt;list&lt;/EM&gt;)</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(&quot;This&quot;,&quot;is&quot;,&quot;a&quot;,&quot;bulleted&quot;,&quot;list&quot;) ;
</PRE>
<P>
<HR>
<H2><A NAME="P4CGI_dl_list_I_list_of_pairs_">P4CGI::dl_list(&lt;EM&gt;list_of_pairs&lt;/EM&gt;)</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(&quot;This&quot;,&quot;Description of this&quot;,
                      &quot;That&quot;,&quot;Description of that&quot;) ;
</PRE>
<P>
<HR>
<H2><A NAME="P4CGI_fixSpecChar_I_str_">P4CGI::fixSpecChar(&lt;EM&gt;str&lt;/EM&gt;)</A></H2>
<P>
Convert all '&gt;' to ``<CODE>&amp;amp;gt;</CODE>'', '&lt;' to ``<CODE>&amp;amp;lt;</CODE>'' and '&amp;' to ``<CODE>&amp;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 = &amp;P4CGI::fixSpecChar(&quot;String containing &lt;,&gt; and &amp;&quot;) ;
</PRE>
<P>
<HR>
<H2><A NAME="P4CGI_rmTabs_I_str_">P4CGI::rmTabs(&lt;EM&gt;str&lt;/EM&gt;)</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(&lt;EM&gt;options&lt;/EM&gt;,&lt;EM&gt;parameters&lt;/EM&gt;,&lt;EM&gt;text&lt;/EM&gt;)</A></H2>
<P>
Create a &lt;A HREF...&gt;...&lt;/A&gt; 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 &amp;P4CGI::ahref(&quot;Back to myself&quot;) ; # link to this. No parameters.
</PRE>
<P>
<PRE>    print &amp;P4CGI::ahref(&quot;-url&quot;,&quot;www.perforce.com&quot;,
                        &quot;To perforce&quot;) ; # link to perforce
</PRE>
<P>
<PRE>    print &amp;P4CGI::ahref(&quot;-anchor&quot;,&quot;THERE&quot;,
                        &quot;Go there&quot;) ; # link to anchor THERE
</PRE>
<P>
<PRE>    print &amp;P4CGI::ahref(&quot;-url&quot;,&quot;chb.cgi&quot;,
                        &quot;FSPC=//.../doc/...&quot;,
                        &quot;Changes for all documentation&quot;) ; # url with parameter
</PRE>
<P>
<HR>
<H2><A NAME="P4CGI_magic_I_text_">P4CGI::magic(&lt;EM&gt;text&lt;/EM&gt;)</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 = &quot;This change is the same as change 4711, but with a twist&quot; ;
</PRE>
<P>
<PRE>    print &amp;P4CGI::magic($t) ; # inserts a link to change 4711
</PRE>
<P>
<HR>
<H2><A NAME="P4CGI_fixspaces_I_text_">P4CGI::fixspaces(&lt;EM&gt;text&lt;/EM&gt;)</A></H2>
<P>
Return parameter with spaces substituted with <CODE>%20</CODE>

<P>
Example:

<P>
<PRE>    my $t = &quot;/File with spaces&quot; ;
</PRE>
<P>
<PRE>    print &amp;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.