Changeset fd11144 in mainline for uspace/app/viewer/viewer.c
- Timestamp:
- 2020-07-04T21:52:35Z (4 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fc4abca
- Parents:
- e79a025
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/viewer/viewer.c
re79a025 rfd11144 176 176 } 177 177 178 static void print_syntax(void) 179 { 180 printf("Syntax: %s [-d <display>] <image-file>...\n", NAME); 181 } 182 178 183 int main(int argc, char *argv[]) 179 184 { 185 const char *display_svc = DISPLAY_DEFAULT; 180 186 window_flags_t flags; 181 187 surface_t *lsface; … … 183 189 sysarg_t dwidth; 184 190 sysarg_t dheight; 185 186 if (argc < 2) { 187 printf("Compositor server not specified.\n"); 191 int i; 192 193 i = 1; 194 while (i < argc && argv[i][0] == '-') { 195 if (str_cmp(argv[i], "-d") == 0) { 196 ++i; 197 if (i >= argc) { 198 printf("Argument missing.\n"); 199 print_syntax(); 200 return 1; 201 } 202 203 display_svc = argv[i++]; 204 } else { 205 printf("Invalid option '%s'.\n", argv[i]); 206 print_syntax(); 207 return 1; 208 } 209 } 210 211 if (i >= argc) { 212 printf("No image files specified.\n"); 213 print_syntax(); 188 214 return 1; 189 215 } 190 216 191 if (argc < 3) { 192 printf("No image files specified.\n"); 193 return 1; 194 } 195 196 imgs_count = argc - 2; 217 imgs_count = argc - i; 197 218 imgs = calloc(imgs_count, sizeof(char *)); 198 219 if (imgs == NULL) { … … 201 222 } 202 223 203 for (int i = 0; i < argc - 2; i++) {204 imgs[ i] = str_dup(argv[i + 2]);205 if (imgs[ i] == NULL) {224 for (int j = 0; j < argc - i; j++) { 225 imgs[j] = str_dup(argv[i + j]); 226 if (imgs[j] == NULL) { 206 227 printf("Out of memory.\n"); 207 228 return 3; … … 221 242 flags |= WINDOW_DECORATED; 222 243 223 main_window = window_open( argv[1], NULL, flags, "viewer");244 main_window = window_open(display_svc, NULL, flags, "viewer"); 224 245 if (!main_window) { 225 246 printf("Cannot open main window.\n");
Note:
See TracChangeset
for help on using the changeset viewer.