Changeset fd11144 in mainline for uspace/app/barber/barber.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/barber/barber.c

    re79a025 rfd11144  
    4040#include <loc.h>
    4141#include <stats.h>
     42#include <str.h>
    4243#include <fibril_synch.h>
    4344#include <io/pixel.h>
     
    247248}
    248249
     250static void print_syntax(void)
     251{
     252        printf("Syntax: %s [-d <display>]\n", NAME);
     253}
     254
    249255int main(int argc, char *argv[])
    250256{
    251         if (argc < 2) {
    252                 printf("Compositor server not specified.\n");
    253                 return 1;
     257        const char *display_svc = DISPLAY_DEFAULT;
     258        int i;
     259
     260        i = 1;
     261        while (i < argc) {
     262                if (str_cmp(argv[i], "-d") == 0) {
     263                        ++i;
     264                        if (i >= argc) {
     265                                printf("Argument missing.\n");
     266                                print_syntax();
     267                                return 1;
     268                        }
     269
     270                        display_svc = argv[i++];
     271                } else {
     272                        printf("Invalid option '%s'.\n", argv[i]);
     273                        print_syntax();
     274                        return 1;
     275                }
    254276        }
    255277
     
    277299
    278300        winreg = argv[1];
    279         window_t *main_window = window_open(argv[1], NULL,
     301        window_t *main_window = window_open(display_svc, NULL,
    280302            WINDOW_MAIN | WINDOW_DECORATED, "barber");
    281303        if (!main_window) {
Note: See TracChangeset for help on using the changeset viewer.