Changeset 9546146 in mainline for uspace/srv/hid/display/seat.c
- Timestamp:
- 2024-08-23T18:02:06Z (3 months ago)
- Branches:
- master
- Children:
- 4af6fb1
- Parents:
- ca95ccd
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/display/seat.c
rca95ccd r9546146 38 38 #include <gfx/color.h> 39 39 #include <gfx/render.h> 40 #include <sif.h> 41 #include <stdio.h> 40 42 #include <stdlib.h> 41 43 #include <str.h> … … 117 119 free(seat->name); 118 120 free(seat); 121 } 122 123 /** Load seat from SIF node. 124 * 125 * @param display Display 126 * @param snode Seat node from which to load the seat 127 * @param rseat Place to store pointer to the newly loaded seat 128 * 129 * @return EOK on success or an error code 130 */ 131 errno_t ds_seat_load(ds_display_t *display, sif_node_t *snode, 132 ds_seat_t **rseat) 133 { 134 const char *sid; 135 const char *name; 136 char *endptr; 137 unsigned long id; 138 errno_t rc; 139 140 sid = sif_node_get_attr(snode, "id"); 141 if (sid == NULL) 142 return EIO; 143 144 name = sif_node_get_attr(snode, "name"); 145 if (name == NULL) 146 return EIO; 147 148 id = strtoul(sid, &endptr, 10); 149 if (*endptr != '\0') 150 return EIO; 151 152 rc = ds_seat_create(display, name, rseat); 153 if (rc != EOK) 154 return EIO; 155 156 (*rseat)->id = id; 157 return EOK; 158 } 159 160 /** Save seat to SIF node. 161 * 162 * @param seat Seat 163 * @param snode Seat node into which the seat should be saved 164 * 165 * @return EOK on success or an error code 166 */ 167 errno_t ds_seat_save(ds_seat_t *seat, sif_node_t *snode) 168 { 169 char *sid; 170 errno_t rc; 171 int rv; 172 173 rv = asprintf(&sid, "%lu", (unsigned long)seat->id); 174 if (rv < 0) { 175 rc = ENOMEM; 176 return rc; 177 } 178 179 rc = sif_node_set_attr(snode, "id", sid); 180 if (rc != EOK) { 181 free(sid); 182 return rc; 183 } 184 185 free(sid); 186 187 rc = sif_node_set_attr(snode, "name", seat->name); 188 if (rc != EOK) 189 return rc; 190 191 return EOK; 119 192 } 120 193
Note:
See TracChangeset
for help on using the changeset viewer.