session.c (128080) | session.c (137868) |
---|---|
1/* 2 * session.c 3 * 4 * Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com> 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 --- 11 unchanged lines hidden (view full) --- 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * | 1/* 2 * session.c 3 * 4 * Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com> 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 --- 11 unchanged lines hidden (view full) --- 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * |
28 * $Id: session.c,v 1.1 2004/02/12 22:46:59 max Exp $ 29 * $FreeBSD: head/usr.sbin/bluetooth/bthidd/session.c 128080 2004-04-10 00:18:00Z emax $ | 28 * $Id: session.c,v 1.2 2004/11/17 21:59:42 max Exp $ 29 * $FreeBSD: head/usr.sbin/bluetooth/bthidd/session.c 137868 2004-11-18 18:05:15Z emax $ |
30 */ 31 32#include <sys/queue.h> 33#include <assert.h> 34#include <bluetooth.h> 35#include <stdio.h> 36#include <stdlib.h> 37#include <string.h> 38#include <unistd.h> 39#include "bthidd.h" | 30 */ 31 32#include <sys/queue.h> 33#include <assert.h> 34#include <bluetooth.h> 35#include <stdio.h> 36#include <stdlib.h> 37#include <string.h> 38#include <unistd.h> 39#include "bthidd.h" |
40#include "kbd.h" |
|
40 41/* 42 * Create new session 43 */ 44 45bthid_session_p 46session_open(bthid_server_p srv, bdaddr_p bdaddr) 47{ 48 bthid_session_p s = NULL; 49 50 assert(srv != NULL); 51 assert(bdaddr != NULL); 52 53 if ((s = (bthid_session_p) malloc(sizeof(*s))) != NULL) { 54 s->srv = srv; 55 memcpy(&s->bdaddr, bdaddr, sizeof(s->bdaddr)); | 41 42/* 43 * Create new session 44 */ 45 46bthid_session_p 47session_open(bthid_server_p srv, bdaddr_p bdaddr) 48{ 49 bthid_session_p s = NULL; 50 51 assert(srv != NULL); 52 assert(bdaddr != NULL); 53 54 if ((s = (bthid_session_p) malloc(sizeof(*s))) != NULL) { 55 s->srv = srv; 56 memcpy(&s->bdaddr, bdaddr, sizeof(s->bdaddr)); |
56 s->ctrl = s->intr = -1; | 57 s->ctrl = -1; 58 s->intr = -1; |
57 s->state = CLOSED; | 59 s->state = CLOSED; |
58 59 LIST_INSERT_HEAD(&srv->sessions, s, next); | 60 s->keys = bit_alloc(kbd_maxkey()); 61 if (s->keys == NULL) { 62 free(s); 63 s = NULL; 64 } else 65 LIST_INSERT_HEAD(&srv->sessions, s, next); |
60 } 61 62 return (s); 63} 64 65/* 66 * Lookup session by bdaddr 67 */ --- 57 unchanged lines hidden (view full) --- 125 FD_CLR(s->ctrl, &s->srv->rfdset); 126 FD_CLR(s->ctrl, &s->srv->wfdset); 127 close(s->ctrl); 128 129 if (s->srv->maxfd == s->ctrl) 130 s->srv->maxfd --; 131 } 132 | 66 } 67 68 return (s); 69} 70 71/* 72 * Lookup session by bdaddr 73 */ --- 57 unchanged lines hidden (view full) --- 131 FD_CLR(s->ctrl, &s->srv->rfdset); 132 FD_CLR(s->ctrl, &s->srv->wfdset); 133 close(s->ctrl); 134 135 if (s->srv->maxfd == s->ctrl) 136 s->srv->maxfd --; 137 } 138 |
139 free(s->keys); 140 |
|
133 memset(s, 0, sizeof(*s)); 134 free(s); 135} 136 | 141 memset(s, 0, sizeof(*s)); 142 free(s); 143} 144 |