aboutsummaryrefslogtreecommitdiffstats
path: root/libical/src/libicalss/icalcstp.h
blob: 78541f937e72c300c24698ad5b803a66e7762388 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/* -*- Mode: C -*- */
/*======================================================================
  FILE: icalcstp.h
  CREATOR: eric 20 April 1999
  
  $Id$


  (C) COPYRIGHT 1999 Eric Busboom 
  http://www.softwarestudio.org

  The contents of this file are subject to the Mozilla Public License
  Version 1.0 (the "License"); you may not use this file except in
  compliance with the License. You may obtain a copy of the License at
  http://www.mozilla.org/MPL/
 
  Software distributed under the License is distributed on an "AS IS"
  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
  the License for the specific language governing rights and
  limitations under the License.

  The original author is Eric Busboom
  The original code is icalcstp.h

======================================================================*/


#ifndef ICALCSTP_H
#define ICALCSTP_H

#include "ical.h"

typedef void* icalcstp;

typedef struct icalcstp_stubs;

icalcstp* icalcstp_new(icalcstp_stubs* stubs, 
                       int incoming, int outgoing);

void* icalcstp_free(icalcstp* cstp);

/* Send or recieve data directly to/from the network. These calls are
   needed for the AUTHENTICATE command and possibly others */
int icalcstp_send(char*);
char* icalcstp_recieve(char*);

int icalcstp_set_timeout(icalcstp* cstp, int sec);

typedef struct icalcstp_response {  
    icalrequeststatus code
    char caluid[1024];
    void* result;
} icalcstp_response;


/********************** Server (Reciever) Interfaces *************************/

/* On the server side, the caller will recieve data from the incoming
   socket and pass it to icalcstp_process_incoming. The caller then
   takes the return from _process_incoming and sends it out through
   the socket. This gives the caller a point of control. If the cstp
   code connected to the socket itself, it would be hard for the
   caller to do anything else after the cstp code was started.

   However, some commands will use the sockets directly, though the
   _send and _recieve routines. Example is Authenticate and Starttls,
   which need several exchanges of data*/

/* Process a single line of incomming data */
char* icalcstp_process_incoming(icalcstp* cstp, char* string);

/* Er, they aren't really stubs, but pointers to the rountines that
   icalcstp_process_incoming will call when it recognizes a CSTP
   command in the data. BTW, the CONTINUE command is named 'cont'
   because 'continue' is a C keyword */

struct icalcstp_stubs {
  icalcstp_response (*abort)(icalcstp* cstp);
  icalcstp_response (*authenticate)(icalcstp* cstp, char* mechanism, 
                                    char* data);
  icalcstp_response (*capability)(icalcstp* cstp);
  icalcstp_response (*cont)(icalcstp* cstp, unsigned int time);
  icalcstp_response (*disconnect)(icalcstp* cstp);
  icalcstp_response (*identify)(icalcstp* cstp, char* id);
  icalcstp_response (*starttls)(icalcstp* cstp, char* command, 
                                char* data);
  icalcstp_response (*sendata)(icalcstp* cstp, unsigned int time, 
                               icalcomponent *comp);
  icalcstp_response (*unknown)(icalcstp* cstp, char* command, char* data);
}

/********************** Client (Sender) Interfaces **************************/

/* On the client side, the cstp code is connected directly to the
   socket, because the callers point of control is at the interfaces
   below. */

icalcstp_response icalcstp_abort(icalcstp* cstp);
icalcstp_response icalcstp_authenticate(icalcstp* cstp, char* mechanism, 
                                        char* data);
icalcstp_response icalcstp_capability(icalcstp* cstp);
icalcstp_response icalcstp_continue(icalcstp* cstp, unsigned int time);
icalcstp_response icalcstp_disconnect(icalcstp* cstp);
icalcstp_response icalcstp_identify(icalcstp* cstp, char* id);
icalcstp_response icalcstp_starttls(icalcstp* cstp, char* command, 
                                    char* data);
icalcstp_response icalcstp_sendata(icalcstp* cstp, unsigned int time,
                                   icalcomponent *comp);

#endif /* !ICALCSTP_H */