Changeset 3e828ea in mainline for uspace/app


Ignore:
Timestamp:
2019-09-23T12:49:29Z (6 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9be2358
Parents:
9259d20 (diff), 1a4ec93f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Jiri Svoboda <jiri@…> (2019-09-22 12:49:07)
git-committer:
Jiri Svoboda <jiri@…> (2019-09-23 12:49:29)
Message:

Merge changes from master, especially Meson build

Location:
uspace/app
Files:
50 added
25 deleted
19 edited
29 moved

Legend:

Unmodified
Added
Removed
  • uspace/app/barber/barber.c

    r9259d20 r3e828ea  
    4545#include <window.h>
    4646#include <canvas.h>
    47 #include <surface.h>
    48 #include <codec/tga.gz.h>
     47#include <draw/surface.h>
     48#include <draw/codec.h>
    4949#include "images.h"
    5050
  • uspace/app/bdsh/cmds/modules/ls/ls.c

    r9259d20 r3e828ea  
    4242#include <vfs/vfs.h>
    4343#include <str.h>
     44#include <cap.h>
    4445
    4546#include "ls.h"
     
    5859        { "unsort", no_argument, 0, 'u' },
    5960        { "recursive", no_argument, 0, 'r' },
     61        { "exact-size", no_argument, 0, 'e' },
     62        { "single-column", no_argument, 0, '1' },
    6063        { 0, 0, 0, 0 }
    6164};
     
    6366/* Prototypes for the ls command, excluding entry points. */
    6467static unsigned int ls_start(ls_job_t *);
    65 static void ls_print(struct dir_elem_t *);
    66 static int ls_cmp(const void *, const void *);
     68static errno_t ls_print(struct dir_elem_t *);
     69static errno_t ls_print_single_column(struct dir_elem_t *);
     70static int ls_cmp_type_name(const void *, const void *);
     71static int ls_cmp_name(const void *, const void *);
    6772static signed int ls_scan_dir(const char *, DIR *, struct dir_elem_t **);
    6873static unsigned int ls_recursive(const char *, DIR *);
     
    7479        ls->sort = 1;
    7580
     81        ls->exact_size = false;
     82        ls->single_column = false;
     83        ls->printer = ls_print;
    7684        return 1;
    7785}
     
    8896 * @param de            Directory element.
    8997 */
    90 static void ls_print(struct dir_elem_t *de)
    91 {
    92         if (de->s.is_file)
    93                 printf("%-40s\t%llu\n", de->name, (long long) de->s.size);
    94         else if (de->s.is_directory)
    95                 printf("%-40s\t<dir>\n", de->name);
     98static errno_t ls_print(struct dir_elem_t *de)
     99{
     100        int width = 13;
     101
     102        if (de->s.is_file) {
     103                if (ls.exact_size) {
     104                        printf("%-40s\t%*llu\n", de->name, width, (long long) de->s.size);
     105                        return EOK;
     106                }
     107
     108                cap_spec_t cap;
     109                cap_from_blocks(de->s.size, 1, &cap);
     110                cap_simplify(&cap);
     111
     112                char *rptr;
     113                errno_t rc = cap_format(&cap, &rptr);
     114                if (rc != EOK) {
     115                        return rc;
     116                }
     117
     118                char *sep = str_rchr(rptr, ' ');
     119                if (sep == NULL) {
     120                        free(rptr);
     121                        return ENOENT;
     122                }
     123
     124                *sep = '\0';
     125
     126                printf("%-40s\t%*s %2s\n", de->name, width - 3, rptr, sep + 1);
     127                free(rptr);
     128        } else if (de->s.is_directory)
     129                printf("%-40s\t%*s\n", de->name, width, "<dir>");
    96130        else
    97131                printf("%-40s\n", de->name);
     132
     133        return EOK;
     134}
     135
     136static errno_t ls_print_single_column(struct dir_elem_t *de)
     137{
     138        if (de->s.is_file) {
     139                printf("%s\n", de->name);
     140        } else {
     141                printf("%s/\n", de->name);
     142        }
     143
     144        return EOK;
    98145}
    99146
     
    109156 * @return              -1 if a < b, 1 otherwise.
    110157 */
    111 static int ls_cmp(const void *a, const void *b)
     158static int ls_cmp_type_name(const void *a, const void *b)
    112159{
    113160        struct dir_elem_t const *da = a;
     
    120167        else
    121168                return 1;
     169}
     170
     171/** Compare directories/files per name
     172 *
     173 * This comparision ignores the type of
     174 * the node. Sorted will strictly by name.
     175 *
     176 */
     177static int ls_cmp_name(const void *a, const void *b)
     178{
     179        struct dir_elem_t const *da = a;
     180        struct dir_elem_t const *db = b;
     181
     182        return str_cmp(da->name, db->name);
    122183}
    123184
     
    192253        }
    193254
    194         if (ls.sort)
    195                 qsort(&tosort[0], nbdirs, sizeof(struct dir_elem_t), ls_cmp);
    196 
    197         for (i = 0; i < nbdirs; i++)
    198                 ls_print(&tosort[i]);
     255        if (ls.sort) {
     256                int (*compar)(const void *, const void *);
     257                compar = ls.single_column ? ls_cmp_name : ls_cmp_type_name;
     258                qsort(&tosort[0], nbdirs, sizeof(struct dir_elem_t), compar);
     259        }
     260
     261        for (i = 0; i < nbdirs; i++) {
     262                if (ls.printer(&tosort[i]) != EOK) {
     263                        cli_error(CL_ENOMEM, "%s: Out of memory", cmdname);
     264                        goto out;
     265                }
     266        }
    199267
    200268        /* Populate the directory list. */
     
    333401                    "If not path is given, the current working directory is used.\n"
    334402                    "Options:\n"
    335                     "  -h, --help       A short option summary\n"
    336                     "  -u, --unsort     Do not sort directory entries\n"
    337                     "  -r, --recursive  List subdirectories recursively\n",
     403                    "  -h, --help            A short option summary\n"
     404                    "  -u, --unsort          Do not sort directory entries\n"
     405                    "  -r, --recursive       List subdirectories recursively\n"
     406                    "  -e, --exact-size      File sizes will be unformatted (raw bytes count)\n"
     407                    "  -1, --single-column   Only the names will be returned\n",
    338408                    cmdname);
    339409        }
     
    364434
    365435        while (c != -1) {
    366                 c = getopt_long(argc, argv, "hur", long_options, &opt_ind);
     436                c = getopt_long(argc, argv, "hure1", long_options, &opt_ind);
    367437                switch (c) {
    368438                case 'h':
     
    375445                        ls.recursive = 1;
    376446                        break;
     447                case 'e':
     448                        ls.exact_size = true;
     449                        break;
     450                case '1':
     451                        ls.single_column = true;
     452                        ls.printer = ls_print_single_column;
     453                        break;
    377454                }
    378455        }
     
    400477        switch (scope) {
    401478        case LS_FILE:
    402                 ls_print(&de);
     479                if (ls.printer(&de) != EOK) {
     480                        cli_error(CL_ENOMEM, "%s: Out of memory", cmdname);
     481                        return CMD_FAILURE;
     482                }
    403483                break;
    404484        case LS_DIR:
  • uspace/app/bdsh/cmds/modules/ls/ls.h

    r9259d20 r3e828ea  
    88#define LS_FILE  1
    99#define LS_DIR   2
    10 
    11 typedef struct {
    12         /* Options set at runtime. */
    13         unsigned int recursive;
    14         unsigned int sort;
    15 
    16 } ls_job_t;
    1710
    1811/** Structure to represent a directory entry.
     
    2619};
    2720
     21typedef struct {
     22        /* Options set at runtime. */
     23        unsigned int recursive;
     24        unsigned int sort;
     25
     26        bool single_column;
     27        bool exact_size;
     28
     29        errno_t (*printer)(struct dir_elem_t *);
     30} ls_job_t;
     31
    2832#endif
  • uspace/app/bdsh/cmds/modules/modules.c

    r9259d20 r3e828ea  
    6363#include "echo/entry.h"
    6464#include "cmp/entry.h"
     65#include "alias/entry.h"
     66#include "unalias/entry.h"
    6567
    6668/*
     
    8890#include "echo/echo_def.inc"
    8991#include "cmp/cmp_def.inc"
     92#include "alias/alias_def.inc"
     93#include "unalias/unalias_def.inc"
    9094
    9195        { NULL, NULL, NULL, NULL }
  • uspace/app/bdsh/cmds/modules/modules.h

    r9259d20 r3e828ea  
    3131
    3232#include "../cmds.h"
    33 #include "modules.h"
    3433
    3534extern module_t modules[];
  • uspace/app/bdsh/compl.c

    r9259d20 r3e828ea  
    3535#include <vfs/vfs.h>
    3636#include <str.h>
    37 
     37#include <adt/odict.h>
     38
     39#include "scli.h"
    3840#include "cmds/cmds.h"
    3941#include "compl.h"
    4042#include "exec.h"
    4143#include "tok.h"
     44#include "util.h"
    4245
    4346static errno_t compl_init(wchar_t *text, size_t pos, size_t *cstart, void **state);
     
    6265        /** Length of string prefix (number of characters) */
    6366        size_t prefix_len;
     67
     68        /* Pointer to the current alias */
     69        odlink_t *alias_link;
    6470
    6571        /** Pointer inside list of modules */
     
    209215                }
    210216                *cstart += rpath_sep + 1 - prefix;
    211                 free(prefix);
    212                 prefix = NULL;
    213217
    214218                cs->path_list = malloc(sizeof(char *) * 2);
     
    217221                        goto error;
    218222                }
    219                 cs->path_list[0] = dirname;
     223
     224                if (!is_path(prefix) && cs->is_command) {
     225                        cs->path_list[0] = malloc(sizeof(char) * PATH_MAX);
     226                        if (cs->path_list[0] == NULL) {
     227                                retval = ENOMEM;
     228                                goto error;
     229                        }
     230
     231                        int ret = snprintf(cs->path_list[0], PATH_MAX, "%s/%s", search_dir[0], dirname);
     232                        if (ret < 0 || ret >= PATH_MAX) {
     233                                retval = ENOMEM;
     234                                goto error;
     235                        }
     236                } else {
     237                        cs->path_list[0] = dirname;
     238                }
     239
     240                free(prefix);
    220241                cs->path_list[1] = NULL;
    221242                /*
     
    227248        } else if (cs->is_command) {
    228249                /* Command without path */
     250                cs->alias_link = odict_first(&alias_dict);
    229251                cs->module = modules;
    230252                cs->builtin = builtins;
     
    305327        }
    306328
     329        /* Alias */
     330        if (cs->alias_link != NULL) {
     331                while (*compl == NULL && cs->alias_link != NULL) {
     332                        alias_t *data = odict_get_instance(cs->alias_link, alias_t, odict);
     333                        if (compl_match_prefix(cs, data->name)) {
     334                                asprintf(compl, "%s ", data->name);
     335                                cs->last_compl = *compl;
     336                                if (*compl == NULL)
     337                                        return ENOMEM;
     338                        }
     339                        cs->alias_link = odict_next(cs->alias_link, &alias_dict);
     340                }
     341        }
     342
    307343        /* Modules */
    308344        if (cs->module != NULL) {
    309345                while (*compl == NULL && cs->module->name != NULL) {
     346                        /* prevents multiple listing of an overriden cmd */
    310347                        if (compl_match_prefix(cs, cs->module->name)) {
    311                                 asprintf(compl, "%s ", cs->module->name);
    312                                 cs->last_compl = *compl;
    313                                 if (*compl == NULL)
    314                                         return ENOMEM;
     348                                odlink_t *alias_link = odict_find_eq(&alias_dict, (void *)cs->module->name, NULL);
     349                                if (alias_link == NULL) {
     350                                        asprintf(compl, "%s ", cs->module->name);
     351                                        cs->last_compl = *compl;
     352                                        if (*compl == NULL)
     353                                                return ENOMEM;
     354                                }
    315355                        }
    316356                        cs->module++;
     
    322362                while (*compl == NULL && cs->builtin->name != NULL) {
    323363                        if (compl_match_prefix(cs, cs->builtin->name)) {
    324                                 asprintf(compl, "%s ", cs->builtin->name);
    325                                 cs->last_compl = *compl;
    326                                 if (*compl == NULL)
    327                                         return ENOMEM;
     364                                /* prevents multiple listing of an overriden cmd */
     365                                odlink_t *alias_link = odict_find_eq(&alias_dict, (void *)cs->module->name, NULL);
     366                                if (alias_link == NULL) {
     367                                        asprintf(compl, "%s ", cs->builtin->name);
     368                                        cs->last_compl = *compl;
     369                                        if (*compl == NULL)
     370                                                return ENOMEM;
     371                                }
    328372                        }
    329373                        cs->builtin++;
     
    373417                                free(ent_path);
    374418
     419                                /* prevents multiple listing of an overriden cmd */
     420                                if (cs->is_command && !ent_stat.is_directory) {
     421                                        odlink_t *alias_link = odict_find_eq(&alias_dict, (void *)dent->d_name, NULL);
     422                                        if (alias_link != NULL) {
     423                                                continue;
     424                                        }
     425                                }
     426
    375427                                asprintf(compl, "%s%c", dent->d_name,
    376428                                    ent_stat.is_directory ? '/' : ' ');
  • uspace/app/bdsh/config.h

    r9259d20 r3e828ea  
    4242#endif
    4343
     44/* define maximal nested aliases */
     45#ifndef HUBS_MAX
     46#define HUBS_MAX 20
     47#endif
     48
    4449/* Used in many places */
    4550#define SMALL_BUFLEN 256
  • uspace/app/bdsh/exec.c

    r9259d20 r3e828ea  
    4747#include "errors.h"
    4848
    49 /* FIXME: Just have find_command() return an allocated string */
    50 static char *found;
    51 
    52 static char *find_command(char *);
     49static errno_t find_command(char *, char **);
    5350static int try_access(const char *);
    5451
     
    6865}
    6966
    70 /** Returns the full path of "cmd" if cmd is found
     67/** Returns EOK if no internal failure or else ENOMEM
    7168 *
    72  * else just hand back cmd as it was presented
     69 * When the parameter `cmd` can be found then the absolute path will be set in `found`.
     70 * Or else `found` will be NULL.
     71 * `found` will be newly allocated and must be freed by the caller
    7372 */
    74 static char *find_command(char *cmd)
     73static errno_t find_command(char *cmd, char **found)
    7574{
    76         size_t i;
     75        /* The user has specified a full or relative path, just give it back. */
     76        if (is_path(cmd)) {
     77                if (-1 != try_access(cmd)) {
     78                        *found = str_dup(cmd);
     79                        return EOK;
     80                }
    7781
    78         found = (char *)malloc(PATH_MAX);
     82                *found = NULL;
     83                return EOK;
     84        }
    7985
    80         /* The user has specified a full or relative path, just give it back. */
    81         if (-1 != try_access(cmd)) {
    82                 return (char *) cmd;
     86        *found = (char *)malloc(PATH_MAX);
     87        if (*found == NULL) {
     88                return ENOMEM;
    8389        }
    8490
    8591        /* We now have n places to look for the command */
     92        size_t i;
     93        size_t cmd_length = str_length(cmd);
    8694        for (i = 0; search_dir[i] != NULL; i++) {
    87                 memset(found, 0, PATH_MAX);
    88                 snprintf(found, PATH_MAX, "%s/%s", search_dir[i], cmd);
    89                 if (-1 != try_access(found)) {
    90                         return (char *) found;
     95                if (str_length(search_dir[i]) + cmd_length + 2 > PATH_MAX) {
     96                        free(*found);
     97                        return ENOMEM;
     98                }
     99
     100                memset(*found, 0, PATH_MAX);
     101                snprintf(*found, PATH_MAX, "%s/%s", search_dir[i], cmd);
     102                if (-1 != try_access(*found)) {
     103                        return EOK;
    91104                }
    92105        }
     106        free(*found);
     107        *found = NULL;
    93108
    94         /* We didn't find it, just give it back as-is. */
    95         return (char *) cmd;
     109        /* We didn't find it, return NULL */
     110        return EOK;
    96111}
    97112
     
    107122        FILE *files[3];
    108123
    109         tmp = str_dup(find_command(cmd));
    110         free(found);
     124        rc = find_command(cmd, &tmp);
     125        if (rc != EOK) {
     126                cli_error(CL_ENOMEM, "%s: failure executing find_command()", progname);
     127                return 1;
     128        }
     129
     130        if (tmp == NULL) {
     131                cli_error(CL_EEXEC, "%s: Command not found '%s'", progname, cmd);
     132                return 1;
     133        }
    111134
    112135        files[0] = io->stdin;
  • uspace/app/bdsh/input.c

    r9259d20 r3e828ea  
    33 * Copyright (c) 2011 Jiri Svoboda
    44 * Copyright (c) 2011 Martin Sucha
     5 * Copyright (c) 2018 Matthieu Riolo
    56 * All rights reserved.
    67 *
     
    4344#include <stdbool.h>
    4445#include <tinput.h>
     46#include <adt/odict.h>
     47#include <adt/list.h>
    4548
    4649#include "config.h"
     
    6265static void print_pipe_usage(void);
    6366
     67typedef struct {
     68        link_t alias_hup_link;
     69        alias_t *alias;
     70} alias_hup_t;
     71
     72static bool find_alias_hup(alias_t *alias, list_t *alias_hups)
     73{
     74        list_foreach(*alias_hups, alias_hup_link, alias_hup_t, link) {
     75                if (alias == link->alias) {
     76                        return true;
     77                }
     78        }
     79
     80        return false;
     81}
     82
    6483/*
    6584 * Tokenizes input from console, sees if the first word is a built-in, if so
     
    6786 * the handler
    6887 */
    69 errno_t process_input(cliuser_t *usr)
    70 {
     88static errno_t process_input_nohup(cliuser_t *usr, list_t *alias_hups, size_t count_executed_hups)
     89{
     90        if (count_executed_hups >= HUBS_MAX) {
     91                cli_error(CL_EFAIL, "%s: maximal alias hubs reached\n", PACKAGE_NAME);
     92                return ELIMIT;
     93        }
     94
    7195        token_t *tokens_buf = calloc(WORD_MAX, sizeof(token_t));
    7296        if (tokens_buf == NULL)
     
    171195        }
    172196
     197        /* test if the passed cmd is an alias */
     198        odlink_t *alias_link = odict_find_eq(&alias_dict, (void *)cmd[0], NULL);
     199        if (alias_link != NULL) {
     200                alias_t *data = odict_get_instance(alias_link, alias_t, odict);
     201                /* check if the alias already has been resolved once */
     202                if (!find_alias_hup(data, alias_hups)) {
     203                        alias_hup_t *hup = (alias_hup_t *)calloc(1, sizeof(alias_hup_t));
     204                        if (hup == NULL) {
     205                                cli_error(CL_EFAIL, "%s: cannot allocate alias structure\n", PACKAGE_NAME);
     206                                rc = ENOMEM;
     207                                goto finit;
     208                        }
     209
     210                        hup->alias = data;
     211                        list_append(&hup->alias_hup_link, alias_hups);
     212
     213                        char *oldLine = usr->line;
     214                        const size_t input_length = str_size(usr->line) - str_size(cmd[0]) + str_size(data->value) + 1;
     215                        usr->line = (char *)malloc(input_length);
     216                        if (usr->line == NULL) {
     217                                cli_error(CL_EFAIL, "%s: cannot allocate input structure\n", PACKAGE_NAME);
     218                                rc = ENOMEM;
     219                                goto finit;
     220                        }
     221
     222                        usr->line[0] = '\0';
     223
     224                        unsigned int cmd_replace_index = cmd_token_start;
     225                        for (i = 0; i < tokens_length; i++) {
     226                                if (i == cmd_replace_index) {
     227                                        /* if there is a pipe symbol than cmd_token_start will point at the SPACE after the pipe symbol */
     228                                        if (tokens[i].type == TOKTYPE_SPACE) {
     229                                                cmd_replace_index++;
     230                                                str_append(usr->line, input_length, tokens[i].text);
     231                                                continue;
     232                                        }
     233
     234                                        str_append(usr->line, input_length, data->value);
     235                                } else {
     236                                        str_append(usr->line, input_length, tokens[i].text);
     237                                }
     238                        }
     239
     240                        /* reprocess input after string replace */
     241                        rc = process_input_nohup(usr, alias_hups, count_executed_hups + 1);
     242                        usr->line = oldLine;
     243                        goto finit;
     244                }
     245        }
     246
    173247        iostate_t new_iostate = {
    174248                .stdin = stdin,
     
    225299}
    226300
     301errno_t process_input(cliuser_t *usr)
     302{
     303        list_t alias_hups;
     304        list_initialize(&alias_hups);
     305
     306        errno_t rc = process_input_nohup(usr, &alias_hups, 0);
     307
     308        list_foreach_safe(alias_hups, cur_link, next_link) {
     309                alias_hup_t *cur_item = list_get_instance(cur_link, alias_hup_t, alias_hup_link);
     310                free(cur_item);
     311        }
     312
     313        return rc;
     314}
     315
    227316void print_pipe_usage(void)
    228317{
  • uspace/app/bdsh/meson.build

    r9259d20 r3e828ea  
    2828#
    2929
    30 USPACE_PREFIX = ../..
    31 LIBS = clui fmtutil
    32 EXTRA_CFLAGS = -I. -Icmds/ -Icmds/builtins -Icmds/modules
    33 BINARY = bdsh
     30deps = [ 'clui', 'fmtutil' ]
     31includes += include_directories('.', 'cmds', 'cmds/builtins', 'cmds/modules')
     32src = files(
     33        'cmds/builtin_cmds.c',
     34        'cmds/builtins/batch/batch.c',
     35        'cmds/builtins/builtin_aliases.c',
     36        'cmds/builtins/builtins.c',
     37        'cmds/builtins/cd/cd.c',
     38        'cmds/builtins/exit/exit.c',
     39        'cmds/mod_cmds.c',
     40        'cmds/modules/alias/alias.c',
     41        'cmds/modules/cat/cat.c',
     42        'cmds/modules/cmp/cmp.c',
     43        'cmds/modules/cp/cp.c',
     44        'cmds/modules/echo/echo.c',
     45        'cmds/modules/help/help.c',
     46        'cmds/modules/kcon/kcon.c',
     47        'cmds/modules/ls/ls.c',
     48        'cmds/modules/mkdir/mkdir.c',
     49        'cmds/modules/mkfile/mkfile.c',
     50        'cmds/modules/module_aliases.c',
     51        'cmds/modules/modules.c',
     52        'cmds/modules/mount/mount.c',
     53        'cmds/modules/mv/mv.c',
     54        'cmds/modules/printf/printf.c',
     55        'cmds/modules/pwd/pwd.c',
     56        'cmds/modules/rm/rm.c',
     57        'cmds/modules/sleep/sleep.c',
     58        'cmds/modules/touch/touch.c',
     59        'cmds/modules/unalias/unalias.c',
     60        'cmds/modules/unmount/unmount.c',
     61        'compl.c',
     62        'errors.c',
     63        'exec.c',
     64        'input.c',
     65        'scli.c',
     66        'tok.c',
     67        'util.c',
     68)
    3469
    35 SOURCES = \
    36         cmds/modules/module_aliases.c \
    37         cmds/modules/modules.c \
    38         cmds/modules/help/help.c \
    39         cmds/modules/mkdir/mkdir.c \
    40         cmds/modules/mkfile/mkfile.c \
    41         cmds/modules/rm/rm.c \
    42         cmds/modules/cat/cat.c \
    43         cmds/modules/touch/touch.c \
    44         cmds/modules/ls/ls.c \
    45         cmds/modules/pwd/pwd.c \
    46         cmds/modules/sleep/sleep.c \
    47         cmds/modules/cp/cp.c \
    48         cmds/modules/mv/mv.c \
    49         cmds/modules/printf/printf.c \
    50         cmds/modules/echo/echo.c \
    51         cmds/modules/mount/mount.c \
    52         cmds/modules/unmount/unmount.c \
    53         cmds/modules/kcon/kcon.c \
    54         cmds/modules/cmp/cmp.c \
    55         cmds/builtins/builtin_aliases.c \
    56         cmds/builtins/builtins.c \
    57         cmds/builtins/batch/batch.c \
    58         cmds/builtins/exit/exit.c \
    59         cmds/builtins/cd/cd.c \
    60         cmds/mod_cmds.c \
    61         cmds/builtin_cmds.c \
    62         compl.c \
    63         errors.c \
    64         input.c \
    65         util.c \
    66         exec.c \
    67         scli.c \
    68         tok.c
     70test_src = files(
     71        'tok.c',
     72        'test/toktest.c',
     73)
    6974
    70 TEST_SOURCES = \
    71         tok.c \
    72         test/toktest.c
    73 
    74 include $(USPACE_PREFIX)/Makefile.common
     75# TODO: install this file somewhere sane
     76installed_data += { 'name': 'demo.txt', 'dir': '/' }
  • uspace/app/bdsh/scli.c

    r9259d20 r3e828ea  
    11/*
    22 * Copyright (c) 2008 Tim Post
     3 * Copyright (c) 2018 Matthieu Riolo
    34 * All rights reserved.
    45 *
     
    3132#include <stddef.h>
    3233#include <str.h>
     34#include <adt/odict.h>
    3335#include "config.h"
    3436#include "scli.h"
     
    4244static iostate_t *iostate;
    4345static iostate_t stdiostate;
     46
     47odict_t alias_dict;
    4448
    4549/*
     
    5559 */
    5660const char *progname = PACKAGE_NAME;
     61
     62static int alias_cmp(void *a, void *b)
     63{
     64        return str_cmp((char *)a, (char *)b);
     65}
     66
     67static void *alias_key(odlink_t *odlink)
     68{
     69        return (void *)odict_get_instance(odlink, alias_t, odict)->name;
     70}
    5771
    5872/* These are not exposed, even to builtins */
     
    108122        iostate = &stdiostate;
    109123
     124        odict_initialize(&alias_dict, alias_key, alias_cmp);
     125
    110126        if (cli_init(&usr))
    111127                exit(EXIT_FAILURE);
  • uspace/app/bdsh/scli.h

    r9259d20 r3e828ea  
    11/*
    22 * Copyright (c) 2008 Tim Post
     3 * Copyright (c) 2018 Matthieu Riolo
    34 * All rights reserved.
    45 *
     
    3435#include <stdint.h>
    3536#include <stdio.h>
     37#include <types/adt/odict.h>
    3638
    3739typedef struct {
     
    5456extern void set_iostate(iostate_t *);
    5557
     58extern odict_t alias_dict;
     59
     60typedef struct {
     61        odlink_t odict;
     62        char *name;
     63        char *value;
     64} alias_t;
     65
    5666#endif
  • uspace/app/bdsh/util.c

    r9259d20 r3e828ea  
    7474        return 0;
    7575}
     76
     77/*
     78 * Returns true if the string is a relative or an absolute path
     79 */
     80bool is_path(const char *cmd)
     81{
     82
     83        bool ret = str_lcmp(cmd, "/", 1) == 0;
     84        ret = ret || str_lcmp(cmd, "./", 2) == 0;
     85        ret = ret || str_lcmp(cmd, "../", 3) == 0;
     86
     87        return ret;
     88}
  • uspace/app/bdsh/util.h

    r9259d20 r3e828ea  
    3131
    3232#include "scli.h"
     33#include <stdbool.h>
    3334
    3435/* Utility functions */
    3536extern unsigned int cli_count_args(char **);
    3637extern unsigned int cli_set_prompt(cliuser_t *usr);
     38extern bool is_path(const char *cmd);
    3739
    3840#endif
  • uspace/app/blkdump/meson.build

    r9259d20 r3e828ea  
    2828#
    2929
    30 USPACE_PREFIX = ../..
    31 BINARY = klog
    32 
    33 SOURCES = \
    34         klog.c
    35 
    36 include $(USPACE_PREFIX)/Makefile.common
     30deps = [ 'block', 'scsi' ]
     31src = files('blkdump.c')
  • uspace/app/contacts/meson.build

    r9259d20 r3e828ea  
    11#
    2 # Copyright (c) 2010 Martin Decky
     2# Copyright (c) 2018 Jiri Svoboda
    33# All rights reserved.
    44#
     
    2727#
    2828
    29 BOOT_OUTPUT =
    30 RAW =
    31 JOB =
    32 MAP =
    33 PREBUILD =
    34 BUILD = Makefile.empty
     29deps = [ 'clui', 'sif' ]
     30src = files('contacts.c')
  • uspace/app/cpptest/main.cpp

    r9259d20 r3e828ea  
    121121    ts.add<std::test::functional_test>();
    122122    ts.add<std::test::algorithm_test>();
     123    ts.add<std::test::future_test>();
    123124
    124125    return ts.run(true) ? 0 : 1;
  • uspace/app/date/meson.build

    r9259d20 r3e828ea  
    2727#
    2828
    29 USPACE_PREFIX = ../..
    30 BINARY = date
    31 
    32 SOURCES = \
    33         date.c
    34 
    35 include $(USPACE_PREFIX)/Makefile.common
     29src = files('date.c')
  • uspace/app/devctl/meson.build

    r9259d20 r3e828ea  
    2727#
    2828
    29 USPACE_PREFIX = ../..
    30 BINARY = loc
    31 
    32 SOURCES = \
    33         loc.c
    34 
    35 include $(USPACE_PREFIX)/Makefile.common
     29src = files('devctl.c')
  • uspace/app/df/meson.build

    r9259d20 r3e828ea  
    2727#
    2828
    29 USPACE_PREFIX = ../..
    30 BINARY = df
    31 
    32 SOURCES = \
    33         df.c
    34 
    35 include $(USPACE_PREFIX)/Makefile.common
     29src = files('df.c')
  • uspace/app/download/main.c

    r9259d20 r3e828ea  
    4949#define NAME "download"
    5050#ifdef TIMESTAMP_UNIX
    51 #define VERSION STRING(RELEASE) "-" STRING(TIMESTAMP_UNIX)
     51#define VERSION STRING(HELENOS_RELEASE) "-" STRING(TIMESTAMP_UNIX)
    5252#else
    53 #define VERSION STRING(RELEASE)
     53#define VERSION STRING(HELENOS_RELEASE)
    5454#endif
    5555#define USER_AGENT "HelenOS-" NAME "/" VERSION
  • uspace/app/download/meson.build

    r9259d20 r3e828ea  
    2727#
    2828
    29 USPACE_PREFIX = ../../..
    30 LIBS = graph
    31 BINARY = rfb
    32 
    33 SOURCES = \
    34         main.c \
    35         rfb.c
    36 
    37 include $(USPACE_PREFIX)/Makefile.common
     29deps = [ 'http', 'uri' ]
     30c_args += ('-DRELEASE=' + HELENOS_RELEASE)
     31src = files('main.c')
  • uspace/app/edit/meson.build

    r9259d20 r3e828ea  
    2828#
    2929
    30 USPACE_PREFIX = ../..
    31 BINARY = stats
    32 
    33 SOURCES = \
    34         stats.c
    35 
    36 include $(USPACE_PREFIX)/Makefile.common
     30src = files(
     31        'edit.c',
     32        'search.c',
     33        'sheet.c',
     34)
  • uspace/app/fontviewer/fontviewer.c

    r9259d20 r3e828ea  
    4141#include <window.h>
    4242#include <canvas.h>
    43 #include <surface.h>
    44 #include <codec/tga.h>
     43#include <draw/surface.h>
     44#include <draw/codec.h>
    4545#include <task.h>
    46 #include <drawctx.h>
    47 #include <font/embedded.h>
    48 #include <font/pcf.h>
     46#include <draw/drawctx.h>
     47#include <draw/font.h>
    4948#include <stdarg.h>
    5049#include <io/verify.h>
  • uspace/app/getterm/version.c

    r9259d20 r3e828ea  
    3939#include "version.h"
    4040
    41 static const char *copyright = STRING(COPYRIGHT);
    42 static const char *release = STRING(RELEASE);
    43 static const char *name = STRING(NAME);
     41static const char *copyright = STRING(HELENOS_COPYRIGHT);
     42static const char *release = STRING(HELENOS_RELEASE);
     43static const char *name = STRING(HELENOS_CODENAME);
    4444static const char *arch = STRING(UARCH);
    4545
  • uspace/app/gfxdemo/meson.build

    r9259d20 r3e828ea  
    2727#
    2828
    29 USPACE_PREFIX = ../..
    30 BINARY = pci
    31 
    32 SOURCES = \
    33         pci.c
    34 
    35 include $(USPACE_PREFIX)/Makefile.common
     29deps = [ 'gfx' ]
     30src = files(
     31        'gfxdemo.c',
     32)
  • uspace/app/gunzip/meson.build

    r9259d20 r3e828ea  
    2727#
    2828
    29 USPACE_PREFIX = ../..
    30 BINARY = vol
    31 
    32 SOURCES = \
    33         vol.c
    34 
    35 include $(USPACE_PREFIX)/Makefile.common
     29deps = [ 'compress' ]
     30src = files('gunzip.c')
  • uspace/app/hbench/meson.build

    r9259d20 r3e828ea  
    2727#
    2828
    29 USPACE_PREFIX = ../..
    30 BINARY = contacts
    31 LIBS = clui sif
    32 
    33 SOURCES = \
    34         contacts.c
    35 
    36 include $(USPACE_PREFIX)/Makefile.common
     29deps = [ 'math' ]
     30src = files(
     31        'benchlist.c',
     32        'csv.c',
     33        'env.c',
     34        'main.c',
     35        'utils.c',
     36        'fs/dirread.c',
     37        'fs/fileread.c',
     38        'ipc/ns_ping.c',
     39        'ipc/ping_pong.c',
     40        'malloc/malloc1.c',
     41        'malloc/malloc2.c',
     42        'synch/fibril_mutex.c',
     43)
  • uspace/app/inet/meson.build

    r9259d20 r3e828ea  
    2727#
    2828
    29 USPACE_PREFIX = ../..
    30 BINARY = ping
    31 
    32 SOURCES = \
    33         ping.c
    34 
    35 include $(USPACE_PREFIX)/Makefile.common
     29src = files('inet.c')
  • uspace/app/init/meson.build

    r9259d20 r3e828ea  
    2828#
    2929
    30 USPACE_PREFIX = ../..
    31 BINARY = redir
    32 
    33 SOURCES = \
    34         redir.c
    35 
    36 include $(USPACE_PREFIX)/Makefile.common
     30deps = [ 'untar', 'block' ]
     31link_args += '-static'
     32src = files('init.c', 'untar.c')
  • uspace/app/killall/meson.build

    r9259d20 r3e828ea  
    2727#
    2828
    29 ENDIANESS = LE
     29src = files('killall.c')
  • uspace/app/logset/meson.build

    r9259d20 r3e828ea  
    2727#
    2828
    29 USPACE_PREFIX = ../..
    30 BINARY = logset
    31 
    32 SOURCES = \
    33         main.c
    34 
    35 include $(USPACE_PREFIX)/Makefile.common
     29src = files('main.c')
  • uspace/app/meson.build

    r9259d20 r3e828ea  
    11#
    2 # Copyright (c) 2005 Martin Decky
    3 # Copyright (c) 2007 Jakub Jermar
    4 # Copyright (c) 2012 Julia Medvedeva
     2# Copyright (c) 2019 Jiří Zárevúcky
    53# All rights reserved.
    64#
     
    2927#
    3028
    31 USPACE_PREFIX = ../../..
    32 LIBS = block fs
    33 BINARY = udf
     29apps = [
     30        'barber',
     31        'bdsh',
     32        'bithenge',
     33        'blkdump',
     34        'contacts',
     35        'corecfg',
     36        'cpptest',
     37        'date',
     38        'devctl',
     39        'df',
     40        'dnscfg',
     41        'dnsres',
     42        'download',
     43        'edit',
     44        'fdisk',
     45        'fontviewer',
     46        'getterm',
     47        'gfxdemo',
     48        'gunzip',
     49        'hbench',
     50        'inet',
     51        'init',
     52        'kill',
     53        'killall',
     54        'kio',
     55        'loc',
     56        'logset',
     57        'lprint',
     58        'mixerctl',
     59        'mkbd',
     60        'mkexfat',
     61        'mkext4',
     62        'mkfat',
     63        'mkmfs',
     64        'modplay',
     65        'netecho',
     66        'nic',
     67        'nterm',
     68        'pci',
     69        'ping',
     70        'pkg',
     71        'redir',
     72        'sbi',
     73        'sportdmp',
     74        'stats',
     75        'sysinfo',
     76        'sysinst',
     77        'taskdump',
     78        'tester',
     79        'testread',
     80        'testrunner',
     81        'testwrit',
     82        'tetris',
     83        'tmon',
     84        'top',
     85        'trace',
     86        'untar',
     87        'usbinfo',
     88        'vcalc',
     89        'vdemo',
     90        'viewer',
     91        'vlaunch',
     92        'vol',
     93        'vterm',
     94        'vuhid',
     95        'wavplay',
     96        'websrv',
     97        'wifi_supplicant',
     98]
    3499
    35 SOURCES = \
    36         udf.c \
    37         udf_volume.c \
    38         udf_ops.c \
    39         udf_osta.c \
    40         udf_cksum.c \
    41         udf_file.c \
    42         udf_idx.c
    43 
    44 include $(USPACE_PREFIX)/Makefile.common
     100if CONFIG_BUILD_SHARED_LIBS
     101        apps += [
     102                'dltest',
     103                'dltests',
     104        ]
     105endif
  • uspace/app/mkext4/meson.build

    r9259d20 r3e828ea  
    2727#
    2828
    29 USPACE_PREFIX = ../..
    30 BINARY = lprint
    31 
    32 SOURCES = \
    33         lprint.c
    34 
    35 include $(USPACE_PREFIX)/Makefile.common
     29# FIXME remove transitive deps
     30deps = [ 'ext4', 'fs', 'block', 'crypto' ]
     31src = files('mkext4.c')
  • uspace/app/modplay/meson.build

    r9259d20 r3e828ea  
    2727#
    2828
    29 USPACE_PREFIX = ../..
    30 LIBS = trackmod hound pcm
     29deps = [ 'trackmod', 'hound', 'pcm' ]
     30src = files('modplay.c')
    3131
    32 BINARY = modplay
    33 
    34 SOURCES = \
    35         modplay.c
    36 
    37 include $(USPACE_PREFIX)/Makefile.common
     32if install_nonessential_data
     33        # TODO: install this file somewhere sane
     34        installed_data += { 'name': 'demo.xm', 'dir': '/' }
     35endif
  • uspace/app/pkg/meson.build

    r9259d20 r3e828ea  
    2727#
    2828
    29 USPACE_PREFIX = ../..
    30 BINARY = pkg
    31 
    32 SOURCES = \
    33         pkg.c
    34 
    35 include $(USPACE_PREFIX)/Makefile.common
     29src = files('pkg.c')
  • uspace/app/redir/meson.build

    r9259d20 r3e828ea  
    11#
    22# Copyright (c) 2005 Martin Decky
     3# Copyright (c) 2007 Jakub Jermar
    34# All rights reserved.
    45#
     
    2728#
    2829
    29 ENDIANESS = LE
    30 
    31 BFD_NAME = elf64-littleriscv
    32 BFD_ARCH = riscv
     30src = files('redir.c')
  • uspace/app/sbi/meson.build

    r9259d20 r3e828ea  
    2727#
    2828
    29 USPACE_PREFIX = ../..
    30 LIBS =
    31 EXTRA_CFLAGS =
    32 BINARY = kill
    33 
    34 SOURCES = \
    35         kill.c
    36 
    37 include $(USPACE_PREFIX)/Makefile.common
     29deps = [ 'clui' ]
     30c_args += '-D__HELENOS__'
     31src = files(
     32        'src/builtin/bi_boxed.c',
     33        'src/builtin/bi_error.c',
     34        'src/builtin/bi_char.c',
     35        'src/builtin/bi_console.c',
     36        'src/builtin/bi_int.c',
     37        'src/builtin/bi_task.c',
     38        'src/builtin/bi_textfile.c',
     39        'src/builtin/bi_string.c',
     40        'src/os/helenos.c',
     41        'src/ancr.c',
     42        'src/bigint.c',
     43        'src/builtin.c',
     44        'src/cspan.c',
     45        'src/imode.c',
     46        'src/input.c',
     47        'src/intmap.c',
     48        'src/lex.c',
     49        'src/list.c',
     50        'src/main.c',
     51        'src/p_expr.c',
     52        'src/p_type.c',
     53        'src/parse.c',
     54        'src/program.c',
     55        'src/rdata.c',
     56        'src/run.c',
     57        'src/run_expr.c',
     58        'src/run_texpr.c',
     59        'src/stree.c',
     60        'src/strtab.c',
     61        'src/stype.c',
     62        'src/stype_expr.c',
     63        'src/symbol.c',
     64        'src/tdata.c',
     65)
  • uspace/app/sysinst/meson.build

    r9259d20 r3e828ea  
    2727#
    2828
    29 USPACE_PREFIX = ../..
    30 BINARY = nic
    31 LIBS = drv
    32 
    33 SOURCES = \
    34         nic.c
    35 
    36 include $(USPACE_PREFIX)/Makefile.common
     29deps = [ 'block', 'fdisk', 'sif' ]
     30src = files(
     31        'futil.c',
     32        'rdimg.c',
     33        'sysinst.c',
     34        'volume.c',
     35)
  • uspace/app/taskdump/meson.build

    r9259d20 r3e828ea  
    2727#
    2828
    29 USPACE_PREFIX = ../../..
    30 
    31 BINARY = s3c24xx_ts
    32 
    33 SOURCES = \
    34         s3c24xx_ts.c
    35 
    36 include $(USPACE_PREFIX)/Makefile.common
     29includes += include_directories('include')
     30src = files(
     31        'elf_core.c',
     32        'fibrildump.c',
     33        'taskdump.c',
     34        'symtab.c',
     35)
  • uspace/app/tetris/meson.build

    r9259d20 r3e828ea  
    2828#
    2929
    30 USPACE_PREFIX = ../..
    31 LIBRARY = libfs
    32 
    33 SOURCES = \
    34         libfs.c
    35 
    36 include $(USPACE_PREFIX)/Makefile.common
     30src = files(
     31        'shapes.c',
     32        'scores.c',
     33        'tetris.c',
     34        'screen.c',
     35)
  • uspace/app/usbinfo/meson.build

    r9259d20 r3e828ea  
    2727#
    2828
    29 USPACE_PREFIX = ../../..
    30 LIBS = drv
    31 BINARY = test1
    32 
    33 SOURCES = \
    34         test1.c
    35 
    36 include $(USPACE_PREFIX)/Makefile.common
     29deps = [ 'usbhid', 'usbdev', 'usb', 'drv' ]
     30src = files(
     31        'desctree.c',
     32        'dump.c',
     33        'hid.c',
     34        'info.c',
     35        'list.c',
     36        'main.c',
     37)
  • uspace/app/viewer/meson.build

    r9259d20 r3e828ea  
    2727#
    2828
    29 USPACE_PREFIX = ../..
     29deps = [ 'gui' ]
     30src = files('viewer.c')
    3031
    31 # TODO: Should be just "gui", rest is transitive dependencies.
    32 LIBS = gui draw softrend compress math
    33 
    34 BINARY = viewer
    35 
    36 SOURCES = \
    37         viewer.c
    38 
    39 include $(USPACE_PREFIX)/Makefile.common
     32if install_nonessential_data
     33        # TODO: install this file somewhere sane
     34        installed_data += { 'name': 'logo.tga', 'dir': '/' }
     35endif
  • uspace/app/viewer/viewer.c

    r9259d20 r3e828ea  
    4141#include <window.h>
    4242#include <canvas.h>
    43 #include <surface.h>
    44 #include <codec/tga.h>
     43#include <draw/surface.h>
     44#include <draw/codec.h>
    4545#include <task.h>
    4646#include <str.h>
  • uspace/app/vlaunch/meson.build

    r9259d20 r3e828ea  
    2727#
    2828
    29 USPACE_PREFIX = ../..
     29deps = [ 'gui' ]
    3030
    31 # TODO: Should be just "gui", rest is transitive dependencies.
    32 LIBS = gui draw softrend compress math
     31_images = files('gfx/helenos.tga')
    3332
    34 BINARY = vdemo
     33_images_zip = custom_target('vlaunch_images.zip',
     34        input : _images,
     35        output : [ 'images.zip' ],
     36        command : [ mkarray, '@OUTDIR@', 'images', 'image', uspace_as_prolog, '.data', '@INPUT@' ],
     37)
     38_imgs_s = custom_target('vlaunch_images.s',
     39        input : _images_zip,
     40        output : [ 'images.s' ],
     41        command : [ unzip, '-p', '@INPUT@', 'images.s' ],
     42        capture : true,
     43)
     44_imgs_h = custom_target('vlaunch_images.h',
     45        input : _images_zip,
     46        output : [ 'images.h' ],
     47        command : [ unzip, '-p', '@INPUT@', 'images.h' ],
     48        capture : true,
     49)
     50_imgs_desc_c = custom_target('vlaunch_images_desc.c',
     51        input : _images_zip,
     52        output : [ 'images_desc.c' ],
     53        command : [ unzip, '-p', '@INPUT@', 'images_desc.c' ],
     54        capture : true,
     55)
    3556
    36 SOURCES = \
    37         vdemo.c
    38 
    39 include $(USPACE_PREFIX)/Makefile.common
     57src = [ files('vlaunch.c'), _imgs_s, _imgs_h, _imgs_desc_c ]
  • uspace/app/vlaunch/vlaunch.c

    r9259d20 r3e828ea  
    4646#include <canvas.h>
    4747
    48 #include <surface.h>
    49 #include <source.h>
    50 #include <drawctx.h>
    51 #include <codec/tga.h>
     48#include <draw/surface.h>
     49#include <draw/source.h>
     50#include <draw/drawctx.h>
     51#include <draw/codec.h>
    5252
    5353#include "images.h"
  • uspace/app/vuhid/meson.build

    r9259d20 r3e828ea  
    2727#
    2828
    29 USPACE_PREFIX = ../../..
    30 
    31 LIBS = usbdev usb drv scsi
    32 
    33 BINARY = usbmast
    34 
    35 SOURCES = \
    36         bo_trans.c \
    37         cmdw.c \
    38         main.c \
    39         scsi_ms.c
    40 
    41 include $(USPACE_PREFIX)/Makefile.common
     29deps = [ 'usb', 'usbdev', 'usbhid', 'usbvirt', 'drv' ]
     30src = files(
     31        'main.c',
     32        'device.c',
     33        'ifaces.c',
     34        'life.c',
     35        'stdreq.c',
     36        'hids/bootkbd.c',
     37        'hids/logitech_wireless.c',
     38)
  • uspace/app/wavplay/meson.build

    r9259d20 r3e828ea  
    2727#
    2828
    29 USPACE_PREFIX = ../..
    30 EXTRA_CFLAGS = -Iinclude/pcm
    31 LIBRARY = libpcm
     29deps = [ 'drv', 'hound', 'pcm' ]
     30src = files(
     31        'dplay.c',
     32        'drec.c',
     33        'main.c',
     34        'wave.c',
     35)
    3236
    33 SOURCES = \
    34         src/format.c
    35 include $(USPACE_PREFIX)/Makefile.common
    36 
    37 
     37if install_nonessential_data
     38        # TODO: install this file somewhere sane
     39        installed_data += { 'name': 'demo.wav', 'dir': '/' }
     40endif
Note: See TracChangeset for help on using the changeset viewer.