<?php
//temp folder for uploads
$tempfolder = "/home/ccan/upload-temp/";

//location of upload script (for posting uploads)
$uploadscript = "http://ccodearchive.net/uploader.php";

//ccan admin
$ccanadmin = "rusty@rustcorp.com.au";

//email from 
$frommail = "ccan@ozlabs.org";

//tar home dir
$tar_dir = 'tarballs';

//where repo is: attach module name to browse
$repo_base = 'http://git.ozlabs.org/?p=ccan;a=tree;f=ccan/';

function extract_field($field,$module)
{
   return htmlspecialchars(shell_exec('tools/doc_extract '.$field.' '.$module.'/_info'));
}

// Convert double line breaks into paragraphs, and blank spaces into preformat.
function htmlize_field($field,$module)
{
   $state="inpara";
   $result="<p>";
   $raw=extract_field($field,$module);
   foreach (explode("\n", $raw) as $line) {
      if ($line == "") {
         switch ($state) {
	 case "inpara":
	    $state="endpara";
	    $result .= "</p>";
	    break;
	 }
      } else if ($line[0] == " " || $line[0] == "\t") {
         switch ($state) {
	 case "literal":
	    break;
	 case "inpara":
	    $result .= "</p>";
	 case "endpara":
	    $result .= "<pre>";
	    $state = "literal";
	 }
      } else {
         switch ($state) {
	 case "literal":
	    $result .= "</pre>";
	 case "endpara":
	    $result .= "<p>";
	    $state = "inpara";
	 }
      }
      $result .= $line . "\n";
   }

   switch ($state) {
      case "literal":
         $result .= "</pre>";
         break;
      case "inpara":
	 $result .= "</p>";
         break;
   }
   return $result;
}   
?>
