plugin.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * uhttpd - Tiny single-threaded httpd
  3. *
  4. * Copyright (C) 2010-2013 Jo-Philipp Wich <xm@subsignal.org>
  5. * Copyright (C) 2013 Felix Fietkau <nbd@openwrt.org>
  6. *
  7. * Permission to use, copy, modify, and/or distribute this software for any
  8. * purpose with or without fee is hereby granted, provided that the above
  9. * copyright notice and this permission notice appear in all copies.
  10. *
  11. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  12. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  13. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  14. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  15. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  16. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  17. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. #include "uhttpd.h"
  20. struct uhttpd_ops {
  21. void (*dispatch_add)(struct dispatch_handler *d);
  22. bool (*path_match)(const char *prefix, const char *url);
  23. bool (*create_process)(struct client *cl, struct path_info *pi, char *url,
  24. void (*cb)(struct client *cl, struct path_info *pi, char *url));
  25. struct env_var *(*get_process_vars)(struct client *cl, struct path_info *pi);
  26. void (*http_header)(struct client *cl, int code, const char *summary);
  27. void (*client_error)(struct client *cl, int code, const char *summary, const char *fmt, ...);
  28. void (*request_done)(struct client *cl);
  29. void (*chunk_write)(struct client *cl, const void *data, int len);
  30. void (*chunk_printf)(struct client *cl, const char *format, ...);
  31. int (*urlencode)(char *buf, int blen, const char *src, int slen);
  32. int (*urldecode)(char *buf, int blen, const char *src, int slen);
  33. };
  34. struct uhttpd_plugin {
  35. struct list_head list;
  36. int (*init)(const struct uhttpd_ops *ops, struct config *conf);
  37. void (*post_init)(void);
  38. };