daemon: fix memory leaks on error conditions
[ladish.git] / daemon / cmd.h
blob02e2784aa68475a3a57b751ef714760ae92909e8
1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
2 /*
3 * LADI Session Handler (ladish)
5 * Copyright (C) 2009 Nedko Arnaudov <nedko@arnaudov.name>
7 **************************************************************************
8 * This file contains interface to the command queue stuff
9 **************************************************************************
11 * LADI Session Handler is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * LADI Session Handler is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
23 * or write to the Free Software Foundation, Inc.,
24 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
27 #ifndef CMD_H__28542C9B_7CB8_40F8_BBB6_DCE13CBB1E7F__INCLUDED
28 #define CMD_H__28542C9B_7CB8_40F8_BBB6_DCE13CBB1E7F__INCLUDED
30 #include "common.h"
32 #define LADISH_COMMAND_STATE_PREPARE 0
33 #define LADISH_COMMAND_STATE_PENDING 1
34 #define LADISH_COMMAND_STATE_WAITING 2
35 #define LADISH_COMMAND_STATE_DONE 3
37 struct ladish_command
39 struct list_head siblings;
41 unsigned int state;
42 bool cancel;
44 void * context;
45 bool (* run)(void * context);
46 void (* destructor)(void * context);
49 struct ladish_cqueue
51 bool cancel;
52 struct list_head queue;
55 void ladish_cqueue_init(struct ladish_cqueue * queue_ptr);
56 void ladish_cqueue_run(struct ladish_cqueue * queue_ptr);
57 void ladish_cqueue_cancel(struct ladish_cqueue * queue_ptr);
58 bool ladish_cqueue_add_command(struct ladish_cqueue * queue_ptr, struct ladish_command * command_ptr);
59 void ladish_cqueue_drop_command(struct ladish_cqueue * queue_ptr);
60 void ladish_cqueue_clear(struct ladish_cqueue * queue_ptr);
62 void * ladish_command_new(size_t size);
64 bool ladish_command_new_studio(void * call_ptr, struct ladish_cqueue * queue_ptr, const char * studio_name);
65 bool ladish_command_load_studio(void * call_ptr, struct ladish_cqueue * queue_ptr, const char * studio_name);
66 bool ladish_command_rename_studio(void * call_ptr, struct ladish_cqueue * queue_ptr, const char * studio_name);
67 bool ladish_command_save_studio(void * call_ptr, struct ladish_cqueue * queue_ptr, const char * new_studio_name);
68 bool ladish_command_start_studio(void * call_ptr, struct ladish_cqueue * queue_ptr);
69 bool ladish_command_stop_studio(void * call_ptr, struct ladish_cqueue * queue_ptr);
70 bool ladish_command_unload_studio(void * call_ptr, struct ladish_cqueue * queue_ptr);
71 bool ladish_command_exit(void * call_ptr, struct ladish_cqueue * queue_ptr);
73 #endif /* #ifndef CMD_H__28542C9B_7CB8_40F8_BBB6_DCE13CBB1E7F__INCLUDED */