libadmin.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  3. * Copyright (C) 2005 Red Hat, Inc.
  4. * All rights reserved.
  5. *
  6. * License: GPL (version 3 or any later version).
  7. * See LICENSE for details.
  8. * END COPYRIGHT BLOCK **/
  9. #ifdef HAVE_CONFIG_H
  10. #include <config.h>
  11. #endif
  12. /*
  13. * libadmin.h - All functions contained in libadmin.a
  14. *
  15. * All blame goes to Mike McCool
  16. */
  17. #ifndef libadmin_h
  18. #define libadmin_h
  19. #include <stdio.h>
  20. #include <limits.h>
  21. #include "base/systems.h"
  22. #include "base/systhr.h"
  23. #include "base/util.h"
  24. #include <unistd.h>
  25. #include "prinit.h"
  26. #include "prthread.h"
  27. #include "prlong.h"
  28. #define NSPR_INIT(Program) (PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 8))
  29. NSPR_BEGIN_EXTERN_C
  30. /* error types */
  31. #define FILE_ERROR 0
  32. #define MEMORY_ERROR 1
  33. #define SYSTEM_ERROR 2
  34. #define INCORRECT_USAGE 3
  35. #define ELEM_MISSING 4
  36. #define REGISTRY_DATABASE_ERROR 5
  37. #define NETWORK_ERROR 6
  38. #define GENERAL_FAILURE 7
  39. #define WARNING 8
  40. /* The upper bound on error types */
  41. #define MAX_ERROR 9
  42. /* The default error type (in case something goes wrong */
  43. #define DEFAULT_ERROR 3
  44. #define INFO_IDX_NAME "infowin"
  45. #define INFO_TOPIC_NAME "infotopic"
  46. #define HELP_WIN_OPTIONS "'resizable=1,width=500,height=500'"
  47. /* Initialize libadmin. Should be called by EVERY CGI. */
  48. /* util.c */
  49. NSAPI_PUBLIC int ADM_Init(void);
  50. /* Since everyone seems to be doing this independently, at least centralize
  51. the code. Useful for onClicks and automatic help */
  52. NSAPI_PUBLIC char *helpJavaScript(void);
  53. NSAPI_PUBLIC char *helpJavaScriptForTopic(char *topic);
  54. /* Report an error. Takes 3 args: 1. Category of error
  55. * 2. Some more specific category info (opt)
  56. * 3. A short explanation of the error.
  57. *
  58. * report_warning: same thing except doesn't exit when done whining
  59. */
  60. /* error.c */
  61. NSAPI_PUBLIC void output_alert(int type, char *info, char *details, int wait);
  62. NSAPI_PUBLIC void report_error(int type, char *info, char *details);
  63. NSAPI_PUBLIC void report_warning(int type, char *info, char *details);
  64. /* Word wrap a string to fit into a JavaScript alert box. */
  65. /* str is the string, width is the width to wrap to, linefeed is the string
  66. * to use as a linefeed. */
  67. /* util.c */
  68. #define WORD_WRAP_WIDTH 80
  69. NSAPI_PUBLIC char *alert_word_wrap(char *str, int width, char *linefeed);
  70. /* Get the admin/userdb directory. */
  71. /* util.c */
  72. NSAPI_PUBLIC char *get_userdb_dir(void);
  73. NSAPI_PUBLIC char *cookieValue(char *, char *);
  74. NSPR_END_EXTERN_C
  75. #endif /* libadmin_h */