* src/devices/dev.c, src/devices/dev.h: Added first_device()

and next_device() to abstract manipulations to the devices
	list.  Now change all the code that uses direct access to
	these functions...
This commit is contained in:
arno 2000-07-05 13:10:16 +00:00
parent fe8d08d0a9
commit f1953e2885
3 changed files with 38 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2000-07-05 Arno W. Peters <A.W.Peters@ieee.org>
* src/devices/dev.c: Added first_device() and next_device() to
abstract manipulations to the devices list. Now change all the
code that uses direct access to these functions...
2000-07-03 Arno W. Peters <A.W.Peters@ieee.org>
* src/parser/alias.c, src/parser/alias.h: contain frontend alias

View File

@ -158,14 +158,43 @@ num_devices(void)
return sizeof(DEVices)/sizeof(SPICEdev *);
}
IFdevice **
devices_ptr(void)
{
return (IFdevice **) DEVices;
}
SPICEdev **
devices(void)
{
return DEVices;
}
/* Returns the first device in the list, or NULL if the list is empty */
SPICEdev *
first_device(void)
{
return DEVices[0];
}
/* Returns the next device on the list, or NULL if no more devices
left. */
SPICEdev *
next_device(SPICEdev *current)
{
SPICEdev *ret;
int index;
index = (current - first_device()) / sizeof(SPICEdev *);
if (index < num_devices()) {
ret = DEVices[index + 1];
} else {
ret = NULL;
}
return ret;
}

View File

@ -1,9 +1,12 @@
#ifndef _DEV_H
#define _DEV_H
int num_devices(void);
IFdevice **devices_ptr(void);
SPICEdev **devices(void);
SPICEdev *first_device(void);
SPICEdev *next_device(SPICEdev *current);
#endif