remove getenv() function.
[platform/core/uifw/libtbm.git] / src / tbm_backend.c
1 /**************************************************************************
2
3 libtbm
4
5 Copyright 2018 Samsung Electronics co., Ltd. All Rights Reserved.
6
7 Contact: SooChan Lim <sc1.lim@samsung.com>,
8                  Sangjin Lee <lsj119@samsung.com>,
9                  Boram Park <boram1288.park@samsung.com>,
10                  Changyeon Lee <cyeon.lee@samsung.com>
11
12 Permission is hereby granted, free of charge, to any person obtaining a
13 copy of this software and associated documentation files (the
14 "Software"), to deal in the Software without restriction, including
15 without limitation the rights to use, copy, modify, merge, publish,
16 distribute, sub license, and/or sell copies of the Software, and to
17 permit persons to whom the Software is furnished to do so, subject to
18 the following conditions:
19
20 The above copyright notice and this permission notice (including the
21 next paragraph) shall be included in all copies or substantial portions
22 of the Software.
23
24 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
27 IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
28 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
29 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
30 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31
32 **************************************************************************/
33
34 #include "config.h"
35 #include "tbm_bufmgr_int.h"
36
37 /* LCOV_EXCL_START */
38 int
39 tbm_backend_bufmgr_query_display_server(tbm_bufmgr bufmgr, tbm_error_e *error)
40 {
41         if (!bufmgr) {
42                 if (error)
43                         *error = TBM_ERROR_INVALID_PARAMETER;
44                 return 0;
45         }
46
47         if (gBufMgr->display_server) {
48                 if (error)
49                         *error = TBM_ERROR_NONE;
50                 return 1;
51         }
52
53         if (error)
54                 *error = TBM_ERROR_NONE;
55
56         return 0;
57 }
58
59 tbm_backend_bufmgr_func *
60 tbm_backend_bufmgr_alloc_bufmgr_func(tbm_bufmgr bufmgr, tbm_error_e *error)
61 {
62         tbm_backend_bufmgr_func *bufmgr_func;
63
64         bufmgr_func = calloc(1, sizeof(struct _tbm_backend_bufmgr_func));
65         if (!bufmgr_func) {
66                 TBM_ERR("error: fail to allocate the tbm_backend_bufmgr_func\n");
67                 if (error)
68                         *error = TBM_ERROR_OUT_OF_MEMORY;
69                 return NULL;
70         }
71
72         if (error)
73                 *error = TBM_ERROR_NONE;
74
75         return bufmgr_func;
76 }
77
78 void
79 tbm_backend_bufmgr_free_bufmgr_func(tbm_bufmgr bufmgr, tbm_backend_bufmgr_func *func)
80 {
81         TBM_RETURN_IF_FAIL(bufmgr);
82
83         if (func)
84                 free(func);
85 }
86
87 tbm_error_e
88 tbm_backend_bufmgr_register_bufmgr_func(tbm_bufmgr bufmgr, tbm_backend_bufmgr_func *func)
89 {
90         TBM_RETURN_VAL_IF_FAIL(bufmgr, TBM_ERROR_INVALID_PARAMETER);
91         TBM_RETURN_VAL_IF_FAIL(func, TBM_ERROR_INVALID_PARAMETER);
92
93         bufmgr->bufmgr_func = func;
94
95         return TBM_ERROR_NONE;
96 }
97
98 tbm_backend_bo_func *
99 tbm_backend_bufmgr_alloc_bo_func(tbm_bufmgr bufmgr, tbm_error_e *error)
100 {
101         tbm_backend_bo_func *bufmgr_bo;
102
103         bufmgr_bo = calloc(1, sizeof(struct _tbm_backend_bo_func));
104         if (!bufmgr_bo) {
105                 TBM_ERR("error: fail to allocate the tbm_backend_bo_func\n");
106                 if (error)
107                         *error = TBM_ERROR_OUT_OF_MEMORY;
108                 return NULL;
109         }
110
111         if (error)
112                 *error = TBM_ERROR_NONE;
113
114         return bufmgr_bo;
115 }
116
117 void
118 tbm_backend_bufmgr_free_bo_func(tbm_bufmgr bufmgr, tbm_backend_bo_func *func)
119 {
120         TBM_RETURN_IF_FAIL(bufmgr);
121
122         if (func)
123                 free(func);
124 }
125
126 tbm_error_e
127 tbm_backend_bufmgr_register_bo_func(tbm_bufmgr bufmgr, tbm_backend_bo_func *func)
128 {
129         TBM_RETURN_VAL_IF_FAIL(bufmgr, TBM_ERROR_INVALID_PARAMETER);
130         TBM_RETURN_VAL_IF_FAIL(func, TBM_ERROR_INVALID_PARAMETER);
131
132         bufmgr->bo_func = func;
133
134         return TBM_ERROR_NONE;
135 }
136
137 /* LCOV_EXCL_STOP */