View | Details | Raw Unified | Return to bug 15236
Collapse All | Expand All

(-)alterator-x11-0.13.7.orig/tools/xconf/Makefile (-1 / +1 lines)
Lines 1-4 Link Here
1
CFLAGS=$(RPM_OPT_FLAGS) -Wall -I/usr/X11R6/include/ -DVERSION=\"0.1\" -D_GNU_SOURCE=1 -g
1
CFLAGS=$(RPM_OPT_FLAGS) -Wall -I/usr/X11R6/include/ -DVERSION=\"0.2\" -D_GNU_SOURCE=1
2
LDLIBS=-lxf86config -lm -lXt
2
LDLIBS=-lxf86config -lm -lXt
3
3
4
all:xconf
4
all:xconf
(-)alterator-x11-0.13.7.orig/tools/xconf/xconf.c (-35 / +226 lines)
Lines 50-55 Link Here
50
  XtFree(p->x);					\
50
  XtFree(p->x);					\
51
  p->x=XtNewString("");
51
  p->x=XtNewString("");
52
52
53
#define AddListItem(type, head, new) \
54
    head = (type) xf86addListItem((GenericListPtr) (head), (GenericListPtr) (new));
55
56
#define LoadList conf->conf_modules->mod_load_lst
57
#define DisableList conf->conf_modules->mod_disable_lst
58
59
void get_loads(XF86ConfigPtr conf)
60
{
61
  XF86LoadPtr l;
62
63
  for (l = LoadList; l != NULL; l = l->list.next)
64
    if (l->load_type == XF86_LOAD_MODULE)
65
      printf("%s\n", l->load_name);
66
}
67
68
void inline set_module(XF86ConfigPtr conf, const char *module, int in, int out)
69
{
70
  XF86LoadPtr l;
71
  int f = 0;
72
73
  if (LoadList != DisableList)
74
    AddListItem(XF86LoadPtr, LoadList, DisableList);
75
  for (l = LoadList; l != NULL; l = l->list.next)
76
    if ((l->load_opt == NULL) && (strcmp(l->load_name, module) == 0))
77
      {
78
        if (l->load_type == in)
79
          {
80
            l->load_type = out;
81
            l->load_comment = NULL;
82
            l->ignore = 0;
83
          }
84
        f = 1;
85
      }
86
  if ((f == 0) && ((l = malloc(sizeof(XF86LoadRec))) != NULL))
87
    {
88
      l->load_name = (char*) module;
89
      l->load_opt = NULL;
90
      l->list.next = NULL;
91
      l->load_type = out;
92
      l->load_comment = NULL;
93
      l->ignore = 0;
94
      AddListItem(XF86LoadPtr, LoadList, l);
95
    }
96
}
97
98
void set_loads(XF86ConfigPtr conf, const char *module)
99
{
100
  set_module(conf, module, XF86_DISABLE_MODULE, XF86_LOAD_MODULE);
101
}
102
103
void get_disabled(XF86ConfigPtr conf)
104
{
105
  XF86LoadPtr l;
106
107
  for (l = DisableList; l != NULL; l = l->list.next)
108
      if (l->load_type == XF86_DISABLE_MODULE)
109
        printf("%s\n", l->load_name);
110
}
111
112
void set_disable(XF86ConfigPtr conf, const char *module)
113
{
114
  set_module(conf, module, XF86_LOAD_MODULE, XF86_DISABLE_MODULE);
115
}
116
117
#define ExtOptList conf->conf_extensions->ext_option_lst
118
119
void get_extopts(XF86ConfigPtr conf)
120
{
121
  if (conf->conf_extensions != NULL)
122
    {
123
      XF86OptionPtr p;
124
      for (p = ExtOptList; p != NULL; p = xf86nextOption(p))
125
        printf("%s=%s\n", xf86optionName(p), xf86optionValue(p));
126
    }
127
}
128
129
void get_extopt(XF86ConfigPtr conf, const char *name)
130
{
131
  if (conf->conf_extensions != NULL)
132
    {
133
      XF86OptionPtr p;
134
      if ((p = xf86findOption(ExtOptList, name)) != NULL)
135
        printf("%s\n", xf86optionValue(p));
136
    }
137
}
138
139
void set_extopt(XF86ConfigPtr conf, char *opt)
140
{
141
  char *c = strchr(opt, '=');
142
143
  if (c != NULL)
144
    {
145
      if (conf->conf_extensions == NULL)
146
        {
147
          conf->conf_extensions = malloc(sizeof(XF86ConfExtensionsRec));
148
          if (conf->conf_extensions == NULL) return;
149
          ExtOptList = NULL;
150
          conf->conf_extensions->extensions_comment = NULL;
151
        }
152
      *c = '\0';
153
      ExtOptList = xf86addNewOption(ExtOptList, opt, &(c[1]));
154
    }
155
}
156
53
void setup_monitor(XF86ConfigPtr conf,const char *monitor_name)
157
void setup_monitor(XF86ConfigPtr conf,const char *monitor_name)
54
{
158
{
55
  char * line = NULL;
159
  char * line = NULL;
Lines 335-341 Link Here
335
usage (int retcode)
439
usage (int retcode)
336
{
440
{
337
  fprintf (stdout,
441
  fprintf (stdout,
338
	   "Usage: %s <action> old_config [new_config] \n"
442
	   "Usage: %s <action> [<action>...] old_config [new_config] \n"
339
	   "\tnew_config is necessarily for all modifications",
443
	   "\tnew_config is necessarily for all modifications",
340
	   __progname);
444
	   __progname);
341
  fputs ("\nTree - utility to read and modify some xorg config section\n",
445
  fputs ("\nTree - utility to read and modify some xorg config section\n",
Lines 350-356 Link Here
350
	 "\t-c, --get-color-depth	get current default color depth value\n"
454
	 "\t-c, --get-color-depth	get current default color depth value\n"
351
	 "\t-C, --set-color-depth	set new default color depth value\n"
455
	 "\t-C, --set-color-depth	set new default color depth value\n"
352
	 "\t-r, --get-resolution	get current resolution list (mode list)\n"
456
	 "\t-r, --get-resolution	get current resolution list (mode list)\n"
353
	 "\t-R, --set-resolution	set new resolution list (mode list)\n",
457
	 "\t-R, --set-resolution	set new resolution list (mode list)\n"
458
	 "\t-l, --get-loads	get current modules list to load\n"
459
	 "\t-L, --set-loads	set new module to load\n"
460
	 "\t-a, --get-extopts	get options from Section Extensions (<name>=<value>)\n"
461
	 "\t-E, --set-extopt	set option in Section Extensions (<name>=<value>)\n"
462
	 "\t-e, --get-extopt	get specified option from Section Extensions\n"
463
	 "\t-m, --get-disable	get current modules list to disable\n"
464
	 "\t-M, --set-disable	set module to disable\n",
354
	 stdout);
465
	 stdout);
355
466
356
  fputs ("\nReport bugs to <inger@altlinux.org>\n", stdout);
467
  fputs ("\nReport bugs to <inger@altlinux.org>\n", stdout);
Lines 367-382 Link Here
367
   scolor,
478
   scolor,
368
   gres,
479
   gres,
369
   sres,
480
   sres,
370
   gdriver} action_type;
481
   gdriver,
482
   gloads,
483
   sloads,
484
   gextopts,
485
   sextopt,
486
   gextopt,
487
   gdisable,
488
   sdisable} action_type;
489
490
typedef struct ActionRec
491
  {
492
    GenericListRec list;
493
    action_type type;
494
    char *arg;
495
  } ActionRec, *ActionPtr;
496
497
ActionPtr add_action_to_list(ActionPtr actions, action_type a, const char *arg)
498
{
499
  ActionPtr action = malloc(sizeof(ActionRec));
500
501
  if (action != NULL)
502
    {
503
      action->list.next = NULL;
504
      action->type = a;
505
      action->arg = (char*) arg;
506
      return AddListItem(ActionPtr, actions, action);
507
    }
508
  else
509
    return actions;
510
}
511
512
#define add_action(a, arg) add_action_to_list(actions, (a), (arg))
513
#define add_info(a) add_action((a), NULL)
371
514
372
int main(int argc,char *argv[])
515
int main(int argc,char *argv[])
373
{
516
{
374
  action_type action;
375
  const char *filename;
517
  const char *filename;
376
  XF86ConfigPtr conf;
518
  XF86ConfigPtr conf;
377
  char *name = 0;
378
  char *oldconfig = 0;
519
  char *oldconfig = 0;
379
  char *newconfig = 0;
520
  char *newconfig = 0;
521
  ActionPtr actions = NULL;
522
  int write_config = 0;
380
523
381
  while (1)
524
  while (1)
382
    {
525
    {
Lines 392-402 Link Here
392
	{"set-color-depth", required_argument, 0, 'C'},
535
	{"set-color-depth", required_argument, 0, 'C'},
393
	{"get-resolution", no_argument, 0, 'r'},
536
	{"get-resolution", no_argument, 0, 'r'},
394
	{"set-resolution", required_argument, 0, 'R'},
537
	{"set-resolution", required_argument, 0, 'R'},
538
	{"get-loads", no_argument, 0, 'l'},
539
	{"set-loads", required_argument, 0, 'L'},
540
	{"get-extopts",no_argument, 0, 'a'},
541
	{"set-extopt", required_argument, 0, 'E'},
542
	{"get-extopt", required_argument, 0, 'e'},
543
	{"get-disable",no_argument, 0, 'm'},
544
	{"set-disable",required_argument, 0, 'M'},
395
	{0, 0, 0, 0}
545
	{0, 0, 0, 0}
396
      };
546
      };
397
      char c;
547
      char c;
398
548
399
      c = getopt_long (argc, argv, "hvdD:nN:cC:rR:", long_options, NULL);
549
      c = getopt_long (argc, argv, "hvdD:nN:cC:rR:lL:eE:a:mM:", long_options, NULL);
400
      if (c == -1)
550
      if (c == -1)
401
	break;
551
	break;
402
      switch (c)
552
      switch (c)
Lines 405-441 Link Here
405
	  usage (EXIT_SUCCESS);
555
	  usage (EXIT_SUCCESS);
406
	case 'v':
556
	case 'v':
407
	  fputs ("XConfig reader/changer " VERSION "\n"
557
	  fputs ("XConfig reader/changer " VERSION "\n"
408
		 "Written by Stanislav Ievlev\n\n"
558
		 "Written by Stanislav Ievlev\n"
409
		 "Copyright (C) 2005 ALT Linux Team\n",
559
		 "Completed by Led\n\n"
560
		 "Copyright (C) 2005,2008 ALT Linux Team\n",
410
		 stdout);
561
		 stdout);
411
	  exit (EXIT_SUCCESS);
562
	  exit (EXIT_SUCCESS);
412
	case 'd':
563
	case 'd':
413
	  action = gdevice;
564
	  actions = add_info(gdevice);
414
	  break;
565
	  break;
415
	case 'D':
566
	case 'D':
416
	  action = sdevice;
567
	  actions = add_action(sdevice, strdup(optarg));
417
	  name = strdup(optarg);
568
	  write_config++;
418
	  break;
569
	  break;
419
	case 'n':
570
	case 'n':
420
	  action = gmon;
571
	  actions = add_info(gmon);
421
	  break;
572
	  break;
422
	case 'N':
573
	case 'N':
423
	  action = smon;
574
	  actions = add_action(smon, strdup(optarg));
424
	  name=strdup(optarg);
575
	  write_config++;
425
	  break;
576
	  break;
426
	case 'c':
577
	case 'c':
427
	  action = gcolor;
578
	  actions = add_info(gcolor);
428
	  break;
579
	  break;
429
	case 'C':
580
	case 'C':
430
	  action = scolor;
581
	  actions = add_action(scolor, strdup(optarg));
431
	  name=strdup(optarg);
582
	  write_config++;
432
	  break;
583
	  break;
433
	case 'r':
584
	case 'r':
434
	  action = gres;
585
	  actions = add_info(gres);
435
	  break;
586
	  break;
436
	case 'R':
587
	case 'R':
437
	  action = sres;
588
	  actions = add_action(sres, strdup(optarg));
438
	  name=strdup(optarg);
589
	  write_config++;
590
	  break;
591
	case 'l':
592
	  actions = add_info(gloads);
593
	  break;
594
	case 'L':
595
	  actions = add_action(sloads, strdup(optarg));
596
	  write_config++;
597
	  break;
598
	case 'e':
599
	  actions = add_info(gextopts);
600
	  break;
601
	case 'E':
602
	  actions = add_action(sextopt, strdup(optarg));
603
	  write_config++;
604
	  break;
605
	case 'a':
606
	  actions = add_action(gextopt, strdup(optarg));
607
	  break;
608
	case 'm':
609
	  actions = add_info(gdisable);
610
	  break;
611
	case 'M':
612
	  actions = add_action(sdisable, strdup(optarg));
613
	  write_config++;
439
	  break;
614
	  break;
440
	default:
615
	default:
441
	  usage (EXIT_FAILURE);
616
	  usage (EXIT_FAILURE);
Lines 448-458 Link Here
448
623
449
  if (((argc - optind) > 2) ||
624
  if (((argc - optind) > 2) ||
450
      ((argc - optind) == 0) ||
625
      ((argc - optind) == 0) ||
451
      ((action == sdevice ||
626
      (write_config && ((argc - optind) == 1)))
452
	action == scolor ||
453
	action == sres ||
454
	action == smon) &&
455
       ((argc - optind) == 1)))
456
    usage(EXIT_FAILURE);
627
    usage(EXIT_FAILURE);
457
628
458
  oldconfig = argv[optind];
629
  oldconfig = argv[optind];
Lines 468-474 Link Here
468
    }
639
    }
469
  xf86closeConfigFile ();
640
  xf86closeConfigFile ();
470
641
471
  switch (action)
642
  for (; actions != NULL; actions = actions->list.next) {
643
  switch (actions->type)
472
    {
644
    {
473
    case gdevice:
645
    case gdevice:
474
      {
646
      {
Lines 478-484 Link Here
478
      }
650
      }
479
      break;
651
      break;
480
    case sdevice:
652
    case sdevice:
481
      setup_device(conf,name);
653
      setup_device(conf, actions->arg);
482
      break;
654
      break;
483
    case gmon:
655
    case gmon:
484
      {
656
      {
Lines 489-495 Link Here
489
      }
661
      }
490
      break;
662
      break;
491
    case smon:
663
    case smon:
492
      setup_monitor(conf,name);
664
      setup_monitor(conf, actions->arg);
493
      break;
665
      break;
494
    case gcolor:
666
    case gcolor:
495
      printf("%d\n",find_screen(conf)->scrn_defaultdepth);
667
      printf("%d\n",find_screen(conf)->scrn_defaultdepth);
Lines 498-504 Link Here
498
      {
670
      {
499
	XF86ConfScreenPtr screen;
671
	XF86ConfScreenPtr screen;
500
	for (screen = find_screen(conf); screen; screen = screen->list.next)
672
	for (screen = find_screen(conf); screen; screen = screen->list.next)
501
	  screen->scrn_defaultdepth = atoi(name);
673
	  screen->scrn_defaultdepth = atoi(actions->arg);
502
      }
674
      }
503
      break;
675
      break;
504
    case gres:
676
    case gres:
Lines 516-532 Link Here
516
	break;
688
	break;
517
      }
689
      }
518
    case sres:
690
    case sres:
519
      setup_resolution(conf,name);
691
      setup_resolution(conf, actions->arg);
692
      break;
693
    case gloads:
694
      get_loads(conf);
695
      break;
696
    case sloads:
697
      set_loads(conf, actions->arg);
698
      break;
699
    case gextopts:
700
      get_extopts(conf);
701
      break;
702
    case sextopt:
703
      set_extopt(conf, actions->arg);
704
      break;
705
    case gextopt:
706
      get_extopt(conf, actions->arg);
707
      break;
708
    case gdisable:
709
      get_disabled(conf);
710
      break;
711
    case sdisable:
712
      set_disable(conf, actions->arg);
520
      break;
713
      break;
521
    default:
714
    default:
522
      fprintf(stderr,"fatal:unknown action type\n");
715
      fprintf(stderr,"fatal:unknown action type\n");
523
      exit(EXIT_FAILURE);
716
      exit(EXIT_FAILURE);
524
    }
717
    }
525
	
718
    }
526
  if (action == sdevice ||
719
527
      action == smon ||
720
  if (write_config)
528
      action == sres ||
529
      action == scolor)
530
    xf86writeConfigFile (newconfig, conf);
721
    xf86writeConfigFile (newconfig, conf);
531
722
532
  return EXIT_SUCCESS;
723
  return EXIT_SUCCESS;

Return to bug 15236