1 /* 2 * 3 * Copyright (c) 1994-2008 Carnegie Mellon University. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in 14 * the documentation and/or other materials provided with the 15 * distribution. 16 * 17 * 3. The name "Carnegie Mellon University" must not be used to 18 * endorse or promote products derived from this software without 19 * prior written permission. For permission or any legal 20 * details, please contact 21 * Carnegie Mellon University 22 * Center for Technology Transfer and Enterprise Creation 23 * 4615 Forbes Avenue 24 * Suite 302 25 * Pittsburgh, PA 15213 26 * (412) 268-7393, fax: (412) 268-7395 27 * innovation@andrew.cmu.edu 28 * 29 * 4. Redistributions of any form whatsoever must retain the following 30 * acknowledgment: 31 * "This product includes software developed by Computing Services 32 * at Carnegie Mellon University (http://www.cmu.edu/computing/)." 33 * 34 * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO 35 * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 36 * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE 37 * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 38 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 39 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 40 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 41 */ 42 /* 43 * Internal callback rock, used to invoke arbitrary Perl code via a CODE 44 * reference ( \&sub ). Allocate with Perl's New(), free with Safefree(). 45 * The Perl callback is a CODE reference; the rock is any Perl value. 46 * autofree is nonzero if the C callback routine should decrement the 47 * refcounts on the Perl objects and free the callback struct (used by the 48 * imclient_send() finish callback). 49 */ 50 51 struct xsccb { 52 SV *pcb; /* Perl callback PV */ 53 SV *prock; /* Perl rock SV */ 54 /* gack. but otherwise we're in even more pain */ 55 struct xscyrus *client; /* client object, pre-Perlization */ 56 int autofree; /* nonzero if callback should free it */ 57 }; 58 59 #ifdef CYRPERL_INTERNAL 60 #define rock_t struct xsccb * 61 #else 62 #define rock_t void * 63 #endif 64 65 /* 66 * our wrapper for the cyrus imclient struct. mainly exists so I can track 67 * callbacks without grotting around inside the struct imclient. 68 */ 69 70 struct xscb { 71 struct xscb *prev; 72 char *name; 73 int flags; 74 struct xsccb *rock; 75 struct xscb *next; 76 }; 77 78 #define NUM_SUPPORTED_CALLBACKS 4 79 80 struct xscyrus { 81 struct imclient *imclient; 82 char *class; 83 struct xscb *cb; 84 int flags; 85 int authenticated; 86 int cnt; /* hack */ 87 /* For holding per-connection information during authentication */ 88 /* We need to initialize this when we create a new connection */ 89 sasl_callback_t callbacks[NUM_SUPPORTED_CALLBACKS]; 90 const char *username, *authname; 91 sasl_secret_t *password; 92 }; 93 94 /* C callback to invoke a Perl callback on behalf of imclient */ 95 /*void imclient_xs_cb(struct imclient *, rock_t, struct imclient_reply *);*/ 96 97 /* C callback to invoke a Perl callback on behalf of imclient_send()'s cb */ 98 /*void imclient_xs_fcmdcb(struct imclient *, rock_t, 99 struct imclient_reply *);*/ 100 101 /* Clean up after a "self-freeing" Perl callback */ 102 /*void imclient_xs_callback_free(struct xsccb *);*/ 103