From mboxrd@z Thu Jan 1 00:00:00 1970 Delivered-To: chneukirchen@gmail.com Received: by 10.229.81.66 with SMTP id w2csp40073qck; Fri, 15 Jun 2012 16:22:54 -0700 (PDT) Return-Path: Received-SPF: pass (google.com: domain of rack-devel+bncCO6kxt-wDhDOh-_-BBoEL5-tWw@googlegroups.com designates 10.224.215.5 as permitted sender) client-ip=10.224.215.5; Authentication-Results: mr.google.com; spf=pass (google.com: domain of rack-devel+bncCO6kxt-wDhDOh-_-BBoEL5-tWw@googlegroups.com designates 10.224.215.5 as permitted sender) smtp.mail=rack-devel+bncCO6kxt-wDhDOh-_-BBoEL5-tWw@googlegroups.com; dkim=pass header.i=rack-devel+bncCO6kxt-wDhDOh-_-BBoEL5-tWw@googlegroups.com Received: from mr.google.com ([10.224.215.5]) by 10.224.215.5 with SMTP id hc5mr5082920qab.6.1339802574343 (num_hops = 1); Fri, 15 Jun 2012 16:22:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=x-beenthere:date:from:to:message-id:subject:mime-version :x-original-sender:reply-to:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:sender :list-subscribe:list-unsubscribe:content-type; bh=D6UcPioKPlleSssghtDojoauKev9HrAAsyQNiB/euf4=; b=dqVn3OlOzJR6w9GP8x7qj3osZkSPItQM7jspDbfknzT31jDc5p5ShtmZIFXij7FxM6 hOY7nK+xGrEWSPTKczpoG2CPONAKb61Ee2tIZ0ik9YwrrDntZL8lDP9AcX1EPtJLbYN6 gNBJcd1Z0LifLmRKcPwgG7zvUrOiVbi3PhP0I= Received: by 10.224.215.5 with SMTP id hc5mr983812qab.6.1339802574228; Fri, 15 Jun 2012 16:22:54 -0700 (PDT) X-BeenThere: rack-devel@googlegroups.com Received: by 10.224.116.146 with SMTP id m18ls3332361qaq.7.gmail; Fri, 15 Jun 2012 16:22:52 -0700 (PDT) Received: by 10.224.108.202 with SMTP id g10mr4981758qap.8.1339802572773; Fri, 15 Jun 2012 16:22:52 -0700 (PDT) Received: by 10.224.101.138 with SMTP id c10msqao; Fri, 15 Jun 2012 07:48:09 -0700 (PDT) Received: by 10.52.94.147 with SMTP id dc19mr449399vdb.17.1339771688125; Fri, 15 Jun 2012 07:48:08 -0700 (PDT) Date: Fri, 15 Jun 2012 07:48:07 -0700 (PDT) From: Riccardo Tacconi To: rack-devel@googlegroups.com Message-Id: Subject: Write an adapter in C MIME-Version: 1.0 X-Original-Sender: rtacconi@gmail.com Reply-To: rack-devel@googlegroups.com Precedence: list Mailing-list: list rack-devel@googlegroups.com; contact rack-devel+owners@googlegroups.com List-ID: X-Google-Group-Id: 486215384060 List-Post: , List-Help: , List-Archive: Sender: rack-devel@googlegroups.com List-Subscribe: , List-Unsubscribe: , Content-Type: multipart/alternative; boundary="----=_Part_2628_25262876.1339771687738" ------=_Part_2628_25262876.1339771687738 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi, I would try to write an adapter for G-WAN server, which can run c-scripts. This is a G-WAN handler: #include "gwan.h" // G-WAN exported functions#include // memcmp() int main(int argc, char *argv[]) { char *query = get_env(argv, QUERY_STRING, 0); // query: "start=200000" if(!query || memcmp(query, "start=", sizeof("start=") - 1)) // FLV query? return 200; // HTTP status (200:'OK') http_t *head = get_env(argv, HTTP_HEADERS, 0); // set HTTP bytes range head->h_range_from = atol(query + sizeof("start=") - 1); // checked by G-WAN #define FLV_HEAD "FLV\x1\x1\0\0\0\x9\0\0\0\x9" // insert the FLV Header http_header(HEAD_ADD | HEAD_AFTER, FLV_HEAD, sizeof(FLV_HEAD) - 1, argv); return 206; // HTTP status (206:'Partial Content') } I could exchange data with Rack from a module like that. I do not how to write a Rack adapter, is there any tutorial. Should I call Ruby code from C, so should I write an wrapper to Rack methods? ------=_Part_2628_25262876.1339771687738 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi, I would try to write an adapter for G-WAN server, which can run c-scrip= ts. This is a G-WAN handler:

  =20
   http_t *head =3D get_env(argv, HTTP_HEADERS, 0); =
// set HTTP bytes range
   head->h_range_from =3D atol(quer=
y + sizeof("start=3D") - 1); // checked by G-WAN

   #define FLV_HEAD "FLV\x1\x1\0\0\0\x9\0\0\0\x9"=
 // i=
nsert the FLV Header
   http_header(HEAD_ADD | HEAD_AFTER, FLV_HEAD, sizeof(FLV_HEAD) - 1, a=
rgv);
   return 206; // HTTP status (206:'Partial Content')     =20
}

I could exchange data with Rack from a modu=
le like that. I do not how to write a Rack adapter, is there any tutorial. =
Should I call Ruby code from C, so should I write an wrapper to Rack method=
s?
------=_Part_2628_25262876.1339771687738--