TSTrafficServerVersionGet

Return Traffic Server version information.

Synopsis

include <ts/ts.h>

const char * TSTrafficServerVersionGet(void)

int TSTrafficServerVersionGetMajor(void)

int TSTrafficServerVersionGetMinor(void)

int TSTrafficServerVersionGetPatch(void)

Description

TSTrafficServerVersionGet() returns a pointer to a string of characters that indicates the Traffic Server release version. This string must not be modified.

The other APIs return an integer from the relevant component of the version number string.

Example

  1. #include <stdio.h>
  2. #include <ts/ts.h>
  3. int
  4. check_ts_version()
  5. {
  6. const char *ts_version = TSTrafficServerVersionGet();
  7. int result = 0;
  8. if (ts_version) {
  9. int major_ts_version = 0;
  10. int minor_ts_version = 0;
  11. int patch_ts_version = 0;
  12. if (sscanf(ts_version, "%d.%d.%d", &major_ts_version,
  13. &minor_ts_version, &patch_ts_version) != 3) {
  14. return 0;
  15. }
  16. /* We need at least Traffic Server 3.0 */
  17. if (major_ts_version >= 3) {
  18. result = 1;
  19. }
  20. }
  21. return result;
  22. }
  23. void
  24. TSPluginInit (int argc, const char *argv[])
  25. {
  26. TSPluginRegistrationInfo info;
  27. info.plugin_name = "hello-world";
  28. info.vendor_name = "MyCompany";
  29. info.support_email = "ts-api-support@MyCompany.com";
  30. if (TSPluginRegister(&info) != TS_SUCCESS) {
  31. TSError("Plugin registration failed. 0);
  32. }
  33. if (!check_ts_version()) {
  34. TSError("Plugin requires Traffic Server 3.0 or later0);
  35. return;
  36. }
  37. TSDebug("debug-hello", "Hello World!0);
  38. }

See Also

TSAPI(3ts)