Changeset dda2602 in mainline for uspace/srv/sysman/util.c


Ignore:
Timestamp:
2019-08-03T09:41:07Z (5 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
dd5c623
Parents:
c0e4fc50
git-author:
Michal Koutný <xm.koutny+hos@…> (2015-05-08 11:10:06)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2019-08-03 09:41:07)
Message:

sysman: Create units to start up to compositor

  • add necessary units to support basic GUI (barber, vterm)
  • lacking autostart is compensated with explicit dependencies
  • IPC_FLAG_AUTOSTART in compositor and locsrv fix
  • paths to v* binaries
  • refactored job closure creation

Conflicts:

boot/Makefile.common
uspace/app/vlaunch/vlaunch.c
uspace/srv/hid/compositor/compositor.c
uspace/srv/locsrv/locsrv.c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/sysman/util.c

    rc0e4fc50 rdda2602  
    3838 * @return      NULL on error
    3939 */
    40 char *compose_path(const char *dirname, const char *filename)
     40char *util_compose_path(const char *dirname, const char *filename)
    4141{
    4242        size_t size = str_size(dirname) + str_size(filename) + 2;
     
    5151        return result;
    5252}
     53
     54/** Parse command line
     55 *
     56 * @param[out]  dst      pointer to command_t
     57 *                       path and zeroth argument are the equal
     58 *
     59 * @return  true   on success
     60 * @return  false  on (low memory) error
     61 */
     62bool util_parse_command(const char *string, void *dst, text_parse_t *parse,
     63    size_t lineno)
     64{
     65        command_t *command = dst;
     66        util_command_deinit(command);
     67
     68        command->buffer = str_dup(string);
     69        if (!command->buffer) {
     70                return false;
     71        }
     72
     73        command->argc = 0;
     74        char *to_split = command->buffer;
     75        char *cur_tok;
     76        bool has_path = false;
     77
     78        while ((cur_tok = str_tok(to_split, " ", &to_split)) &&
     79            command->argc < MAX_COMMAND_ARGS) {
     80                if (!has_path) {
     81                        command->path = cur_tok;
     82                        has_path = true;
     83                }
     84                command->argv[command->argc++] = cur_tok;
     85        }
     86        command->argv[command->argc] = NULL;
     87
     88
     89        if (command->argc > MAX_COMMAND_ARGS) {
     90                text_parse_raise_error(parse, lineno,
     91                    CONFIGURATION_ELIMIT);
     92                return false;
     93        } else {
     94                return true;
     95        }
     96}
     97
     98
     99void util_command_init(command_t *command)
     100{
     101        memset(command, 0, sizeof(*command));
     102}
     103
     104void util_command_deinit(command_t *command)
     105{
     106        free(command->buffer);
     107        memset(command, 0, sizeof(*command));
     108}
Note: See TracChangeset for help on using the changeset viewer.