Annotation of libwww/Library/src/HTMethod.c, revision 2.1
2.1 ! frystyk 1: /* HTMethod.c
! 2: ** MANAGES REQUEST METHODS
! 3: **
! 4: ** (c) COPYRIGHT MIT 1995.
! 5: ** Please first read the full copyright statement in the file COPYRIGH.
! 6: **
! 7: **
! 8: ** HISTORY:
! 9: ** 6 June 95 HFN Spawned off from HTAccess. Can be extended to allow
! 10: ** registration of new methods
! 11: */
! 12:
! 13: /* Library Include files */
! 14: #include "tcp.h"
! 15: #include "HTUtils.h"
! 16: #include "HTString.h"
! 17: #include "HTMethod.h" /* Implemented here */
! 18:
! 19: PRIVATE char *method_names[] =
! 20: {
! 21: "INVALID-METHOD",
! 22: "GET",
! 23: "HEAD",
! 24: "POST",
! 25: "PUT",
! 26: "DELETE",
! 27: "LINK",
! 28: "UNLINK",
! 29: NULL
! 30: };
! 31:
! 32: /* ------------------------------------------------------------------------- */
! 33:
! 34: /* Get method enum value
! 35: ** ---------------------
! 36: */
! 37: PUBLIC HTMethod HTMethod_enum ARGS1(CONST char *, name)
! 38: {
! 39: if (name) {
! 40: if (!strcasecomp(name, *(method_names+1)))
! 41: return METHOD_GET;
! 42: else if (!strcasecomp(name, *(method_names+2)))
! 43: return METHOD_HEAD;
! 44: else if (!strcasecomp(name, *(method_names+3)))
! 45: return METHOD_POST;
! 46: else if (!strcasecomp(name, *(method_names+4)))
! 47: return METHOD_PUT;
! 48: else if (!strcasecomp(name, *(method_names+5)))
! 49: return METHOD_DELETE;
! 50: else if (!strcasecomp(name, *(method_names+6)))
! 51: return METHOD_LINK;
! 52: else if (!strcasecomp(name, *(method_names+7)))
! 53: return METHOD_UNLINK;
! 54: }
! 55: return METHOD_INVALID;
! 56: }
! 57:
! 58:
! 59: /* Get method name
! 60: ** ---------------
! 61: ** Returns pointer to entry in static table in memory
! 62: */
! 63: PUBLIC CONST char * HTMethod_name ARGS1(HTMethod, method)
! 64: {
! 65: if (method & METHOD_GET)
! 66: return *(method_names+1);
! 67: else if (method == METHOD_HEAD)
! 68: return *(method_names+2);
! 69: else if (method == METHOD_POST)
! 70: return *(method_names+3);
! 71: else if (method == METHOD_PUT)
! 72: return *(method_names+4);
! 73: else if (method == METHOD_DELETE)
! 74: return *(method_names+5);
! 75: else if (method == METHOD_LINK)
! 76: return *(method_names+6);
! 77: else if (method == METHOD_UNLINK)
! 78: return *(method_names+7);
! 79: else
! 80: return *method_names;
! 81: }
! 82:
Webmaster