chat.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #ifndef _DEV_CHAT_H_
  2. #define _DEV_CHAT_H_
  3. /*
  4. * Copyright (C) 2001-2004 by egnite Software GmbH. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the copyright holders nor the names of
  16. * contributors may be used to endorse or promote products derived
  17. * from this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
  20. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
  23. * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  25. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  27. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. * SUCH DAMAGE.
  31. *
  32. * For additional information see http://www.ethernut.de/
  33. */
  34. /*
  35. * $Log: chat.h,v $
  36. * Revision 1.9 2006/03/16 15:25:32 haraldkipp
  37. * Changed human readable strings from u_char to char to stop GCC 4 from
  38. * nagging about signedness.
  39. *
  40. * Revision 1.8 2005/04/30 16:42:41 chaac
  41. * Fixed bug in handling of NUTDEBUG. Added include for cfg/os.h. If NUTDEBUG
  42. * is defined in NutConf, it will make effect where it is used.
  43. *
  44. * Revision 1.7 2004/11/24 15:25:15 haraldkipp
  45. * Made options cnfigurable
  46. *
  47. * Revision 1.6 2004/03/17 11:29:20 haraldkipp
  48. * Bugfix for ICCAVR
  49. *
  50. * Revision 1.5 2004/03/16 16:48:28 haraldkipp
  51. * Added Jan Dubiec's H8/300 port.
  52. *
  53. * Revision 1.4 2004/03/08 11:18:54 haraldkipp
  54. * Debug output added.
  55. *
  56. * Revision 1.3 2004/01/06 18:12:36 drsung
  57. * Bugfix multiple define: '_chat_report' under ICCAVR
  58. *
  59. * Revision 1.2 2003/10/13 10:15:54 haraldkipp
  60. * Added Jelle's report function
  61. *
  62. * Revision 1.1.1.1 2003/05/09 14:41:05 haraldkipp
  63. * Initial using 3.2.1
  64. *
  65. * Revision 1.1 2003/03/31 14:53:23 harald
  66. * Prepare release 3.1
  67. *
  68. */
  69. #include <cfg/os.h>
  70. #include <cfg/chat.h>
  71. #define CHAT_ARG_SEND 0
  72. #define CHAT_ARG_ABORT 1
  73. #define CHAT_ARG_TIMEOUT 2
  74. #define CHAT_ARG_REPORT 3
  75. /*!
  76. * \brief Maximum number of abort strings.
  77. */
  78. #ifndef CHAT_MAX_ABORTS
  79. #define CHAT_MAX_ABORTS 10
  80. #endif
  81. /*!
  82. * \brief Maximum size of report strings.
  83. */
  84. #ifndef CHAT_MAX_REPORT_SIZE
  85. #define CHAT_MAX_REPORT_SIZE 32
  86. #endif
  87. /*!
  88. * \brief Default timeout.
  89. */
  90. #ifndef CHAT_DEFAULT_TIMEOUT
  91. #define CHAT_DEFAULT_TIMEOUT 45
  92. #endif
  93. typedef struct {
  94. int chat_fd;
  95. u_char chat_arg;
  96. u_char chat_aborts;
  97. char *chat_abort[CHAT_MAX_ABORTS];
  98. u_char chat_abomat[CHAT_MAX_ABORTS];
  99. char *chat_report_search;
  100. u_char chat_repmat;
  101. char chat_report_state;
  102. } NUTCHAT;
  103. extern u_char *chat_report;
  104. #ifdef NUTDEBUG
  105. #include <stdio.h>
  106. #endif
  107. __BEGIN_DECLS
  108. #ifdef NUTDEBUG
  109. void NutTraceChat(FILE * stream, u_char flags);
  110. #endif
  111. int NutChatExpectString(NUTCHAT *ci, char *str);
  112. int NutChatExpect(NUTCHAT *ci, char *str);
  113. int NutChatSend(NUTCHAT *ci, char *str);
  114. NUTCHAT *NutChatCreate(int fd);
  115. void NutChatDestroy(NUTCHAT *ci);
  116. int NutChat(int fd, CONST char *script);
  117. #ifdef __HARVARD_ARCH__
  118. int NutChat_P(int fd, PGM_P script);
  119. #endif
  120. __END_DECLS
  121. #endif