Changeset 0d23cc0 in mainline


Ignore:
Timestamp:
2013-09-11T23:51:57Z (11 years ago)
Author:
Martin Sucha <sucha14@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2c9f6dd3
Parents:
3482bcc
Message:

Allow rfb parameters to be specified on the command line

Location:
uspace/srv/hid/rfb
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/rfb/main.c

    r3482bcc r0d23cc0  
    140140static void syntax_print(void)
    141141{
    142         fprintf(stderr, "Usage: %s <service-name> [port]\n", NAME);
     142        fprintf(stderr, "Usage: %s <name> <width> <height> [port]\n", NAME);
    143143}
    144144
     
    158158int main(int argc, char **argv)
    159159{
    160         if (argc <= 1) {
     160        if (argc <= 3) {
    161161                syntax_print();
    162162                return 1;
    163163        }
    164164
    165         const char *service_name = argv[1];
     165        const char *rfb_name = argv[1];
     166       
     167        char *endptr;
     168        unsigned long width = strtoul(argv[2], &endptr, 0);
     169        if (*endptr != 0) {
     170                fprintf(stderr, "Invalid width\n");
     171                syntax_print();
     172                return 1;
     173        }
     174       
     175        unsigned long height = strtoul(argv[3], &endptr, 0);
     176        if (*endptr != 0) {
     177                fprintf(stderr, "Invalid height\n");
     178                syntax_print();
     179                return 1;
     180        }
     181       
    166182        unsigned long port = 5900;
    167        
    168         if (argc > 2) {
    169                 char *endptr;
    170                 port = strtoul(argv[2], &endptr, 0);
     183        if (argc > 4) {
     184                port = strtoul(argv[4], &endptr, 0);
    171185                if (*endptr != 0) {
    172186                        fprintf(stderr, "Invalid port number\n");
     
    176190        }
    177191       
    178         rfb_init(&rfb, 800, 600);
     192        rfb_init(&rfb, width, height, rfb_name);
    179193       
    180194        vis = malloc(sizeof(visualizer_t));
     
    211225                printf("%s: Unable to register server.\n", NAME);
    212226                return rc;
    213         }
     227        }
     228
     229        char *service_name;
     230        rc = asprintf(&service_name, "rfb/%s", rfb_name);
     231        if (rc < 0) {
     232                printf(NAME ": Unable to create service name\n");
     233                return rc;
     234        }
    214235
    215236        service_id_t service_id;
     237       
    216238        rc = loc_service_register(service_name, &service_id);
    217239        if (rc != EOK) {
     
    219241                return rc;
    220242        }
     243       
     244        free(service_name);
    221245
    222246        category_id_t visualizer_category;
  • uspace/srv/hid/rfb/rfb.c

    r3482bcc r0d23cc0  
    161161}
    162162
    163 int rfb_init(rfb_t *rfb, uint16_t width, uint16_t height)
     163int rfb_init(rfb_t *rfb, uint16_t width, uint16_t height, const char *name)
    164164{
    165165        memset(rfb, 0, sizeof(rfb_t));
     
    178178        pf->b_shift = 16;
    179179       
    180         rfb->name = "HelenOS";
     180        rfb->name = str_dup(name);
    181181       
    182182        return rfb_set_size(rfb, width, height);
  • uspace/srv/hid/rfb/rfb.h

    r3482bcc r0d23cc0  
    142142
    143143
    144 extern int rfb_init(rfb_t *, uint16_t, uint16_t);
     144extern int rfb_init(rfb_t *, uint16_t, uint16_t, const char *);
    145145extern int rfb_set_size(rfb_t *, uint16_t, uint16_t);
    146146extern int rfb_listen(rfb_t *, uint16_t);
Note: See TracChangeset for help on using the changeset viewer.