Changes in uspace/srv/hid/display/display.c [e90019d:5d380b6] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/display/display.c
re90019d r5d380b6 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2023 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 41 41 #include <memgfx/memgc.h> 42 42 #include <stdlib.h> 43 #include <str.h>44 43 #include "client.h" 45 44 #include "clonegc.h" … … 47 46 #include "cursor.h" 48 47 #include "display.h" 49 #include "idevcfg.h"50 48 #include "seat.h" 51 49 #include "window.h" … … 102 100 list_initialize(&disp->cfgclients); 103 101 disp->next_wnd_id = 1; 104 disp->next_seat_id = 1;105 102 list_initialize(&disp->ddevs); 106 103 list_initialize(&disp->idevcfgs); … … 140 137 gfx_color_delete(disp->bg_color); 141 138 free(disp); 142 }143 144 /** Load display configuration from SIF file.145 *146 * @param display Display147 * @param cfgpath Configuration file path148 *149 * @return EOK on success or an error code150 */151 errno_t ds_display_load_cfg(ds_display_t *display, const char *cfgpath)152 {153 sif_doc_t *doc = NULL;154 sif_node_t *rnode;155 sif_node_t *ndisplay;156 sif_node_t *nseats;157 sif_node_t *nseat;158 ds_seat_t *seat;159 sif_node_t *nidevcfgs;160 sif_node_t *nidevcfg;161 const char *ntype;162 ds_idevcfg_t *idevcfg;163 errno_t rc;164 165 rc = sif_load(cfgpath, &doc);166 if (rc != EOK)167 goto error;168 169 rnode = sif_get_root(doc);170 ndisplay = sif_node_first_child(rnode);171 ntype = sif_node_get_type(ndisplay);172 if (str_cmp(ntype, "display") != 0) {173 rc = EIO;174 goto error;175 }176 177 nseats = sif_node_first_child(ndisplay);178 ntype = sif_node_get_type(nseats);179 if (str_cmp(ntype, "seats") != 0) {180 rc = EIO;181 goto error;182 }183 184 /* Load individual seats */185 nseat = sif_node_first_child(nseats);186 while (nseat != NULL) {187 ntype = sif_node_get_type(nseat);188 if (str_cmp(ntype, "seat") != 0) {189 rc = EIO;190 goto error;191 }192 193 rc = ds_seat_load(display, nseat, &seat);194 if (rc != EOK)195 goto error;196 197 (void)seat;198 nseat = sif_node_next_child(nseat);199 }200 201 nidevcfgs = sif_node_next_child(nseats);202 ntype = sif_node_get_type(nidevcfgs);203 if (str_cmp(ntype, "idevcfgs") != 0) {204 rc = EIO;205 goto error;206 }207 208 /* Load individual input device configuration entries */209 nidevcfg = sif_node_first_child(nidevcfgs);210 while (nidevcfg != NULL) {211 ntype = sif_node_get_type(nidevcfg);212 if (str_cmp(ntype, "idevcfg") != 0) {213 rc = EIO;214 goto error;215 }216 217 /*218 * Load device configuration entry. If the device219 * is not currently connected (ENOENT), skip it.220 */221 rc = ds_idevcfg_load(display, nidevcfg, &idevcfg);222 if (rc != EOK && rc != ENOENT)223 goto error;224 225 (void)idevcfg;226 nidevcfg = sif_node_next_child(nidevcfg);227 }228 229 sif_delete(doc);230 return EOK;231 error:232 if (doc != NULL)233 sif_delete(doc);234 235 seat = ds_display_first_seat(display);236 while (seat != NULL) {237 ds_seat_destroy(seat);238 seat = ds_display_first_seat(display);239 }240 return rc;241 }242 243 /** Save display configuration to SIF file.244 *245 * @param display Display246 * @param cfgpath Configuration file path247 *248 * @return EOK on success or an error code249 */250 errno_t ds_display_save_cfg(ds_display_t *display, const char *cfgpath)251 {252 sif_doc_t *doc = NULL;253 sif_node_t *rnode;254 sif_node_t *ndisplay;255 sif_node_t *nseats;256 sif_node_t *nseat;257 ds_seat_t *seat;258 sif_node_t *nidevcfgs;259 sif_node_t *nidevcfg;260 ds_idevcfg_t *idevcfg;261 errno_t rc;262 263 rc = sif_new(&doc);264 if (rc != EOK)265 goto error;266 267 rnode = sif_get_root(doc);268 rc = sif_node_append_child(rnode, "display", &ndisplay);269 if (rc != EOK)270 goto error;271 272 rc = sif_node_append_child(ndisplay, "seats", &nseats);273 if (rc != EOK)274 goto error;275 276 /* Save individual seats */277 seat = ds_display_first_seat(display);278 while (seat != NULL) {279 rc = sif_node_append_child(nseats, "seat", &nseat);280 if (rc != EOK)281 goto error;282 283 rc = ds_seat_save(seat, nseat);284 if (rc != EOK)285 goto error;286 287 seat = ds_display_next_seat(seat);288 }289 290 rc = sif_node_append_child(ndisplay, "idevcfgs", &nidevcfgs);291 if (rc != EOK)292 goto error;293 294 /* Save individual input device configuration entries */295 idevcfg = ds_display_first_idevcfg(display);296 while (idevcfg != NULL) {297 rc = sif_node_append_child(nidevcfgs, "idevcfg", &nidevcfg);298 if (rc != EOK)299 goto error;300 301 rc = ds_idevcfg_save(idevcfg, nidevcfg);302 if (rc != EOK)303 goto error;304 305 idevcfg = ds_display_next_idevcfg(idevcfg);306 }307 308 rc = sif_save(doc, cfgpath);309 if (rc != EOK)310 goto error;311 312 sif_delete(doc);313 return EOK;314 error:315 if (doc != NULL)316 sif_delete(doc);317 return rc;318 139 } 319 140
Note:
See TracChangeset
for help on using the changeset viewer.