home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / OPENSTEP / Networking / msend-3.3-I / MSMessage.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-10-26  |  3.4 KB  |  118 lines

  1. /*
  2.   $Id: MSMessage.h,v 1.2 1997/10/26 08:41:13 lukeh Exp $
  3.  
  4.   Copyright (c) 1996, 1997 Luke Howard.
  5.   All rights reserved.
  6.  
  7.   Redistribution and use in source and binary forms, with or without
  8.   modification, are permitted provided that the following conditions
  9.   are met:
  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. All advertising materials mentioning features or use of this software
  16.      must display the following acknowledgement:
  17.          This product includes software developed by Luke Howard.
  18.   4. The name of the other may not be used to endorse or promote products
  19.      derived from this software without specific prior written permission.
  20.  
  21.   THIS SOFTWARE IS PROVIDED BY LUKE HOWARD ``AS IS'' AND
  22.   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23.   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24.   ARE DISCLAIMED.  IN NO EVENT SHALL LUKE HOWARD BE LIABLE
  25.   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26.   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27.   OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28.   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29.   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30.   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31.   SUCH DAMAGE.
  32.  */
  33.  
  34. #import <Foundation/NSObject.h>
  35.  
  36. @class NSString, NSMutableString, MSMessage;
  37.  
  38. #ifdef NeXT
  39. #import <libc.h>
  40. #endif
  41.  
  42. #ifdef WIN32
  43. #import <stdlib.h>
  44. #import <winsock.h>
  45. #endif
  46.  
  47. @protocol MSMessaging
  48. /* vend a new message object */
  49. + (MSMessage *)message;
  50. + (MSMessage *)messageTo:(NSString *)recipient;
  51. - init;
  52. - initWithRecipient:(NSString *)recipient; /* designated initialiser */
  53.  
  54. /* accessor methods for the recipient (eg. user@host) */
  55. - (void)setRecipient:(NSString *)aRecipient;
  56. - (NSString *)host;
  57. - (NSString *)user;
  58. - (NSString *)term;
  59.  
  60. /* set target UDP or TCP port */
  61. - (void)setPort:(short)port; /* host byte order */
  62. - (short)port; /* host byte order */
  63. - (void)setPortToDefault; /* lookup in NetInfo or default to 18 */
  64.  
  65. /* set protocol */
  66. - (void)setUseTcp:(BOOL)useTcp;
  67. - (BOOL)useTcp;
  68.  
  69. /* set broadcast flag */
  70. - (void)setBroadcasting:(BOOL)doBroadcast;
  71. - (BOOL)broadcasting;
  72.  
  73. /* accessor methods for the message itself */
  74. - (void)setMessage:(NSString *)message;
  75. - (void)appendMessage:(NSString *)message;
  76. - (NSString *)message;
  77.  
  78. /* got all the info we need? */
  79. - (BOOL)ready;
  80.  
  81. /* post the message */
  82. - (BOOL)post;
  83.  
  84. /* toggle debugging */
  85. - (void)setDebugging:(BOOL)flag;
  86.  
  87. /* retries */
  88. - (void)setRetries:(int)r;
  89. - (int)retries;
  90. @end
  91.  
  92. @protocol MSLogging <NSObject>
  93. - (void)log:(NSString *)msg;
  94. @end
  95.  
  96. #define INTERFACES 32
  97.  
  98. @interface MSMessage : NSObject <MSMessaging, MSLogging>
  99. {
  100.     char *host, *user, *term;
  101.     char *_recipient_ptr;
  102.     NSMutableString *messageBody;
  103.     BOOL use_tcp;
  104.     BOOL broadcasting;
  105.     struct sockaddr_in Sin;
  106.  
  107.     int retries;
  108.     int msg_len;
  109.     char *msg;
  110.  
  111.     int if_n;
  112.     struct sockaddr_in if_a[INTERFACES]; /* max no. interfaces */
  113.  
  114.     BOOL debug;
  115. }
  116. + (void)setLogDelegate:(id <MSLogging>)logDelegate;
  117. @end
  118.