File: dmxadmin.c

package info (click to toggle)
dmx4linux 2.5%2Bdfsg-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,660 kB
  • ctags: 2,835
  • sloc: ansic: 23,341; yacc: 918; asm: 846; makefile: 614; sh: 439
file content (131 lines) | stat: -rw-r--r-- 3,635 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
 * Copyright (C) Michael Stickel <michael@cubic.org>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

/* Create and delete interfaces and universes using the ioctl interface. */

#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>

#include <dmx/dmxioctl.h>

#include <dmx/dmx.h>


static int create_interface (int dmx, const char *name, const char *options)
{
  struct dmx_createinterface_parm parm;

  strcpy (parm.name, name);
  strcpy (parm.properties, options ? options : "");

  if (ioctl(dmx, DMX_IOCTL_CREATE_INTERFACE, &parm) >= 0)
    {
      /* parm.id; return id of interface. */
      return 0;
    }
  return -1;
}

void display_interfaces_drivers (int dmx)
{
  struct dmx_info info;

  if (ioctl (dmx, DMX_IOCTL_GET_INFO, &info) >= 0 && info.num_entries > 0)
    {
      char *family_name = info.family_names;
      int i;

      printf ("dmx4linux version %d.%d\n", info.version_major, info.version_minor);
      printf ("  max-output-universes: %d\n",  info.max_out_universes);
      printf ("  max-input-universes: %d\n",   info.max_in_universes);
      printf ("  used-output-universes: %d\n", info.used_out_universes);
      printf ("  used-input-universes: %d\n",  info.used_in_universes);

      for (i=0; i<info.num_entries; i++, family_name += (strlen(family_name)+1))
	{
	  struct dmx_family_info dinfo;

	  strcpy (dinfo.familyname, family_name);
	  dinfo.offset = 0; /* start at offset 0 */

	  printf ("%s\n", family_name);

	  if (ioctl(dmx, DMX_IOCTL_GET_DRIVERS, &dinfo) >= 0 && dinfo.num_entries > 0)
	    {
	      char *driver_name = dinfo.driver_names;
	      int j;

	      for (j=0; j<dinfo.num_entries; j++, driver_name += (strlen(driver_name)+1))
		printf ("  %c- %s\n", (j<dinfo.num_entries-1)?'|':'\'', driver_name);
	    }
	}
    }
}


#if 0
get_universe_list
struct dmx_capabilities
{
    /* The following two are the primary key for pointing to a unique universe */
    int  universe;     /* index to the universe  */
    char direction;    /* DMX_IN, DMX_OUT or may be DMX_THRU */

    char family[20];   /* name of the driver that accesses the card */
    char driver[20];   /* name of the card that is used (detected)  */

    char connector[20]; /* name of the connector that the universe uses */
    int  conn_id;       /* interface wide id of the connector the universe uses */

    int  breaksize;    /* in uS */
    int  mabsize;      /* in uS */
    int  maxSlots;     /* in number of slots (channels) */
};
#endif


int main (int argc, const char **argv)
{
  const char *s=DMXdev(&argc, argv);
  int  dmx = open (s, O_RDONLY);
  if (dmx<0)
    {
      fprintf (stderr, "unable to open dmx-device\n");
      return 1;
    }

  if (argc > 1)
    {
      create_interface (dmx, argv[1], (argc > 2) ? argv[2] : NULL);
    }
  else
    {
      display_interfaces_drivers (dmx);

    }

  close (dmx);
  return 0;
}