diff --git a/ChangeLog b/ChangeLog index 57959956a..39b5e23cf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2000-07-05 Arno W. Peters + + * 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 * src/parser/alias.c, src/parser/alias.h: contain frontend alias diff --git a/src/spicelib/devices/dev.c b/src/spicelib/devices/dev.c index 99e9731c5..722a3d63d 100644 --- a/src/spicelib/devices/dev.c +++ b/src/spicelib/devices/dev.c @@ -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; +} diff --git a/src/spicelib/devices/dev.h b/src/spicelib/devices/dev.h index b0fdbbc48..a49c3ca2a 100644 --- a/src/spicelib/devices/dev.h +++ b/src/spicelib/devices/dev.h @@ -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