From mboxrd@z Thu Jan 1 00:00:00 1970 Delivered-To: chneukirchen@gmail.com Received: by 10.229.81.66 with SMTP id w2csp50875qck; Fri, 15 Jun 2012 22:52:45 -0700 (PDT) Return-Path: Received-SPF: pass (google.com: domain of rack-devel+bncCNiulu2PGhCsvvD-BBoE2t7IjA@googlegroups.com designates 10.216.137.17 as permitted sender) client-ip=10.216.137.17; Authentication-Results: mr.google.com; spf=pass (google.com: domain of rack-devel+bncCNiulu2PGhCsvvD-BBoE2t7IjA@googlegroups.com designates 10.216.137.17 as permitted sender) smtp.mail=rack-devel+bncCNiulu2PGhCsvvD-BBoE2t7IjA@googlegroups.com; dkim=pass header.i=rack-devel+bncCNiulu2PGhCsvvD-BBoE2t7IjA@googlegroups.com Received: from mr.google.com ([10.216.137.17]) by 10.216.137.17 with SMTP id x17mr1433144wei.83.1339825965303 (num_hops = 1); Fri, 15 Jun 2012 22:52:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=x-beenthere:received-spf:message-id:in-reply-to:references:date :subject:from:to:reply-to:user-agent:mime-version:x-priority :importance:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:x-google-group-id:list-post :list-help:list-archive:sender:list-subscribe:list-unsubscribe :content-type:content-transfer-encoding; bh=Nux+PLoQ+7wZ113kGd/HnOpMTG0s3/sFgrhCttIWEZ8=; b=JYe0Z/kiTHlmCRLI3DJCT61fEWz/qYBGyyB1A5yM31yfg8KUd+WZ4kBpMm8JbqDX83 XP+kqQZcY5ZOq20ynFrqIBC4VoIM7mb5JtupkFSbh/riuG/0KJrtd18t1hVclmeyemaO cmCTnp5JwoReHmlc89cgNs3ZK20QtWuc2s9lY= Received: by 10.216.137.17 with SMTP id x17mr248515wei.83.1339825964821; Fri, 15 Jun 2012 22:52:44 -0700 (PDT) X-BeenThere: rack-devel@googlegroups.com Received: by 10.180.8.42 with SMTP id o10ls1615620wia.3.canary; Fri, 15 Jun 2012 22:52:43 -0700 (PDT) Received: by 10.180.19.70 with SMTP id c6mr694210wie.4.1339825963125; Fri, 15 Jun 2012 22:52:43 -0700 (PDT) Received: by 10.180.19.70 with SMTP id c6mr694209wie.4.1339825963114; Fri, 15 Jun 2012 22:52:43 -0700 (PDT) Received: from sabretooth.unbit.it (sabretooth.unbit.it. [81.174.68.19]) by gmr-mx.google.com with ESMTP id a10si1477694wix.2.2012.06.15.22.52.42; Fri, 15 Jun 2012 22:52:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of roberto@unbit.it designates 81.174.68.19 as permitted sender) client-ip=81.174.68.19; Received: from magneto.unbit.it (unknown [192.168.0.61]) by sabretooth.unbit.it (Postfix) with ESMTP id A788C200D17D for ; Sat, 16 Jun 2012 07:52:42 +0200 (CEST) Received: by magneto.unbit.it (Postfix, from userid 33) id 8B8EDA23B82B; Sat, 16 Jun 2012 07:52:42 +0200 (CEST) Received: from 93.58.162.185 (SquirrelMail authenticated user robunbit) by manage.unbit.it with HTTP; Sat, 16 Jun 2012 07:52:42 +0200 Message-ID: In-Reply-To: References: Date: Sat, 16 Jun 2012 07:52:42 +0200 Subject: Re: Write an adapter in C From: "Roberto De Ioris" To: rack-devel@googlegroups.com Reply-To: rack-devel@googlegroups.com User-Agent: SquirrelMail/1.4.22 MIME-Version: 1.0 X-Priority: 3 (Normal) Importance: Normal X-Original-Sender: roberto@unbit.it X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: best guess record for domain of roberto@unbit.it designates 81.174.68.19 as permitted sender) smtp.mail=roberto@unbit.it 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: text/plain;charset=utf-8 Content-Transfer-Encoding: 8bit > 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? > Are you sure this is the best way to follow ? Just to give you an idea on the amount of code you need: http://projects.unbit.it/uwsgi/browser/plugins/rack/rack_plugin.c gwan can proxy to http service, why not simply using rackup,unicorn,uWSGI,thin behind gwan ? -- Roberto De Ioris http://unbit.it