From patchwork Wed Nov 18 14:44:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anders Roxell X-Patchwork-Id: 56942 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp2603800lbb; Wed, 18 Nov 2015 06:49:38 -0800 (PST) X-Received: by 10.55.71.146 with SMTP id u140mr1799539qka.17.1447858178221; Wed, 18 Nov 2015 06:49:38 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id d3si2569055qhd.1.2015.11.18.06.49.37; Wed, 18 Nov 2015 06:49:38 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dkim=neutral (body hash did not verify) header.i=@linaro-org.20150623.gappssmtp.com Received: by lists.linaro.org (Postfix, from userid 109) id BF67661D8F; Wed, 18 Nov 2015 14:49:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 3F05661A1E; Wed, 18 Nov 2015 14:49:34 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 34FAB61CD4; Wed, 18 Nov 2015 14:49:32 +0000 (UTC) Received: from mail-lf0-f51.google.com (mail-lf0-f51.google.com [209.85.215.51]) by lists.linaro.org (Postfix) with ESMTPS id 3BA0661A1C for ; Wed, 18 Nov 2015 14:49:30 +0000 (UTC) Received: by lfaz4 with SMTP id z4so27947324lfa.0 for ; Wed, 18 Nov 2015 06:49:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=Sbyf7oSxNPCc9CBWh3lfJUV/i0UjXtVLrGIvi54BMfw=; b=KNHY43A+J0wOfW4F6mDOkli6In100OWd+GacBlEG7WboxyCzEyd8wTixaJURvkL+ut LWAupDub2qal/SvUp0eDTAFktnmKq6nhmozsspsLbjwHPOxaiOOQcTEa85XYY+4UgtgE RSjMvpvDub3k7lYpFKCPXzNIaqwJpzl4kF/lWaaZdBtApByp4RkqiKkKCp6QZNL6rJLp SE7nMtYeWeUyVYl/VFqIoJw2oc7R61j0nPAqYckgydR3cW8qWeTE/kgFeEGWFdyxfiRK eIXcMA5E2VuXyXhvvhSSts9XTqi4lfcjnSAavS8EAY3gLBIrvDMfPErz/FpMYWcKieC8 uO2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Sbyf7oSxNPCc9CBWh3lfJUV/i0UjXtVLrGIvi54BMfw=; b=RGRLexEfYjuV7FdihfeHGI4dm9RG4C6acVCRwzNx1VQ+STfg215BFq5CBnRvAgbFpf v4MKCDmx0xcFQGOxPj99HQC7lTm+QZJUxF9lx+TqDnzghXM3PfgM/TgUoi50ZwRetIzM o/9fKguzXVFZoqZpx+eyDEVQIrWllw/WWPyQQE+uzVyCvO+WZvV+8uk7LHhtSKujDhKd KRTmq0+SJc6MxGJ1X2ols6Z03ncZJ8ymdmfu6XtD4nsfKk5gHuktMDVLMvaRMftu4z1k 1Z+kZBW5igEV4EmpzSAHLGVvasSJX4Bq9O1nAPkEJCmbPUYE/LkhnoFxlKPgvQxUPAu+ vvPA== X-Gm-Message-State: ALoCoQm2YBnLaiyYtmX8jwI+h2cPXvS5ydtt7zaFTZtm8l7kX9e4FCE5zuWP3uUm1UBmZ732/DDU X-Received: by 10.25.18.93 with SMTP id h90mr891205lfi.7.1447858169050; Wed, 18 Nov 2015 06:49:29 -0800 (PST) Received: from localhost (c-aa3470d5.07-21-73746f28.cust.bredbandsbolaget.se. [213.112.52.170]) by smtp.gmail.com with ESMTPSA id zz9sm470830lbb.32.2015.11.18.06.49.28 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Nov 2015 06:49:28 -0800 (PST) From: Anders Roxell To: lng-odp@lists.linaro.org Date: Wed, 18 Nov 2015 15:44:56 +0100 Message-Id: <1447857896-11510-1-git-send-email-anders.roxell@linaro.org> X-Mailer: git-send-email 2.1.4 X-Topics: patch Subject: [lng-odp] [PATCH] example/webserver: pick up the www_dir from the environment X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Signed-off-by: Anders Roxell --- example/webserver/httpd.c | 7 ++++--- scripts/start_webserver.sh | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/example/webserver/httpd.c b/example/webserver/httpd.c index d4e37fa..98753a4 100644 --- a/example/webserver/httpd.c +++ b/example/webserver/httpd.c @@ -14,9 +14,6 @@ void httpd_main(uint32_t addr); int sigreceived = 0; static uint32_t myaddr; -/* Set www_dir to point to your web directory. */ -static const char *www_dir = "/home/hjokinen/Dropbox/kolumbus-web"; - /* Table of concurrent connections */ #define NUM_CONNECTIONS 16 static struct { @@ -62,6 +59,8 @@ static int sendf(int fd, const char *fmt, ...) /* Send one file. */ static void get_file(int s, char *url) { + /* Set www_dir to point to your web directory. */ + char *www_dir = NULL; char bufo[512]; int n, w; @@ -88,6 +87,8 @@ static void get_file(int s, char *url) else if (!strcmp(p2, "js")) mime = "text/javascript"; } + www_dir = getenv("www_dir"); + snprintf(bufo, sizeof(bufo), "%s/%s", www_dir, p); FILE *f = fopen(bufo, "rb"); diff --git a/scripts/start_webserver.sh b/scripts/start_webserver.sh index ac9b66d..ced4ac1 100755 --- a/scripts/start_webserver.sh +++ b/scripts/start_webserver.sh @@ -7,6 +7,8 @@ fi intf=$1 echo Starting Web Server on interface $intf +www_dir="${www_dir:-"/var/www/"}" +export www_dir ./example/webserver/webserver -i $intf -c 2 & sleep 1