title: C to Delphi/Pascal
body: <p>I need to translate a piece of C code into Delphi/Pascal code, however I'm having trouble understanding a couple of lines.</p>
  
  <p>C Code:</p>
  
  <pre><code>static char* get_boundary(apr_pool_t* p, const char* ctype) {
    char* ret = NULL ;
    if ( ctype ) {
      char* lctype = lccopy(p, ctype) ;
      char* bdy = strstr(lctype, "boundary") ;
      if ( bdy ) {
        char* ptr = strchr(bdy, '=') ;
        if ( ptr ) {
      // what is the following line supposed to do?
      bdy = (char*) ctype + ( ptr - lctype ) + 1;
      // and this? I understand it's a loop, but *ptr and ++ptr is ugly!
      for ( ptr = bdy; *ptr; ++ptr )
        if ( *ptr == ';' || isspace(*ptr) )
          *ptr = 0 ;
      ret = apr_pstrdup(p, bdy) ;
        }
      }
    }
    return ret ;
  }   
  </code></pre>
  
  <p>My current translation:</p>
  
  <pre><code>function get_boundary(p: Papr_pool_t; const ctype: PChar): PChar;
  var
    LCType: PChar;
    LBody: PChar;
  begin
    Result := NIL;
    LCType := lccopy(p, ctype);
    LBody := strpos(LCType, 'boundary');
    if LBody &lt;&gt; NIL then begin
      // now what? (:
    end; // if LBody &lt;&gt; NIL then begin
  end;
  </code></pre>
  
  <p>lccopy is creating a copy of the ctype parameter and make it lowercase.</p>
  
  <p>Some details regarding translation are highly appreciated, like 'bdy = (char*) ctype + ( ptr - lctype ) + 1;' and the for loop.</p>
  
  <p>FYI I'm translating mod_upload.c.</p>