Changeset fd11144 in mainline for uspace/app/vterm/vterm.c


Ignore:
Timestamp:
2020-07-04T21:52:35Z (4 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
fc4abca
Parents:
e79a025
Message:

Make display service argument optional

File:
1 edited

Legend:

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

    re79a025 rfd11144  
    11/*
     2 * Copyright (c) 2020 Jiri Svoboda
    23 * Copyright (c) 2012 Petr Koupy
    34 * All rights reserved.
     
    4243#define NAME  "vterm"
    4344
     45static void print_syntax(void)
     46{
     47        printf("Syntax: %s [-d <display>]\n", NAME);
     48}
     49
    4450int main(int argc, char *argv[])
    4551{
    46         if (argc < 2) {
    47                 printf("%s: Compositor server not specified.\n", NAME);
    48                 return 1;
     52        const char *display_svc = DISPLAY_DEFAULT;
     53        int i;
     54
     55        i = 1;
     56        while (i < argc) {
     57                if (str_cmp(argv[i], "-d") == 0) {
     58                        ++i;
     59                        if (i >= argc) {
     60                                printf("Argument missing.\n");
     61                                print_syntax();
     62                                return 1;
     63                        }
     64
     65                        display_svc = argv[i++];
     66                } else {
     67                        printf("Invalid option '%s'.\n", argv[i]);
     68                        print_syntax();
     69                        return 1;
     70                }
    4971        }
    5072
    51         window_t *main_window = window_open(argv[1], NULL,
     73        window_t *main_window = window_open(display_svc, NULL,
    5274            WINDOW_MAIN | WINDOW_DECORATED, "vterm");
    5375        if (!main_window) {
Note: See TracChangeset for help on using the changeset viewer.