trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iga...@apache.org
Subject [2/2] git commit: TS-1953: close this by adding an example & CHANGES
Date Tue, 06 Aug 2013 11:13:25 GMT
TS-1953: close this by adding an example & CHANGES


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/a7708dfe
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/a7708dfe
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/a7708dfe

Branch: refs/heads/master
Commit: a7708dfe1f65f5ff0e2fe273c0165347e544c49c
Parents: bacb923
Author: Igor Galić <i.galic@brainsware.org>
Authored: Tue Aug 6 13:12:16 2013 +0200
Committer: Igor Galić <i.galic@brainsware.org>
Committed: Tue Aug 6 13:12:16 2013 +0200

----------------------------------------------------------------------
 CHANGES                   |  3 ++
 example/Makefile.am       |  4 ++-
 example/version/version.c | 67 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 73 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a7708dfe/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 4fe41e3..9cdb0f6 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 3.3.5
 
+  *) [TS-1953] remove version checks from plugins that don't use it and
+   add an example showing off the version API and partial compilation.
+
   *) [TS-2100] Initialize the SSL/NPN registration mutex.
 
   * [TS-1987, TS-2097]: Remove duplicate and unused string functions

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a7708dfe/example/Makefile.am
----------------------------------------------------------------------
diff --git a/example/Makefile.am b/example/Makefile.am
index a5593ff..024edd0 100644
--- a/example/Makefile.am
+++ b/example/Makefile.am
@@ -38,7 +38,8 @@ noinst_LTLIBRARIES = \
   replace-header.la \
   response-header-1.la \
   server-transform.la \
-  thread-1.la
+  thread-1.la \
+  version.la
 
 add_header_la_SOURCES = add-header/add-header.c
 append_transform_la_SOURCES = append-transform/append-transform.c
@@ -60,6 +61,7 @@ response_header_1_la_SOURCES = response-header-1/response-header-1.c
 server_transform_la_SOURCES = server-transform/server-transform.c
 thread_1_la_SOURCES = thread-1/thread-1.c
 psi_la_SOURCES = thread-pool/psi.c thread-pool/thread.c
+version_la_SOURCES = version/version.c
 
 # The following examples do not build:
 #

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a7708dfe/example/version/version.c
----------------------------------------------------------------------
diff --git a/example/version/version.c b/example/version/version.c
new file mode 100644
index 0000000..5512858
--- /dev/null
+++ b/example/version/version.c
@@ -0,0 +1,67 @@
+/** @file
+
+  an example plugin showing off how to use versioning
+
+  @section license License
+
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+
+#include <stdio.h>
+
+#include "ts/ts.h"
+#include "ink_defs.h"
+
+void
+TSPluginInit(int argc ATS_UNUSED, const char *argv[] ATS_UNUSED)
+{
+  TSPluginRegistrationInfo info;
+
+  // Get the version:
+  const char *ts_version = TSTrafficServerVersionGet();
+
+  if (!ts_version) {
+    TSError("Can't get Traffic Server verion.\n");
+    return;
+  }
+
+  // Split it in major, minor, patch:
+  int major_ts_version = 0;
+  int minor_ts_version = 0;
+  int patch_ts_version = 0;
+
+  if (sscanf(ts_version, "%d.%d.%d", &major_ts_version, &minor_ts_version, &patch_ts_version)
!= 3) {
+    TSError("Can't extract verions.\n");
+    return;
+  }
+
+  info.plugin_name = "version-plugin";
+  info.vendor_name = "MyCompany";
+  info.support_email = "ts-api-support@MyCompany.com";
+
+  // partial compilation
+#if (TS_VERSION_NUMBER < 3000000)
+  if (TSPluginRegister(TS_SDK_VERSION_2_0, &info) != TS_SUCCESS) {
+#else 
+  if (TSPluginRegister(TS_SDK_VERSION_3_0, &info) != TS_SUCCESS) {
+#endif
+    TSError("Plugin registration failed. \n");
+  }
+
+  TSDebug("debug-version-plugin", "Running in Apache Traffic Server: v%d.%d.%d\n", major_ts_version,
minor_ts_version, patch_ts_version);
+}
+


Mime
View raw message