+void
+TerminalSpeeds(ispeed, ospeed)
+long *ispeed;
+long *ospeed;
+{
+ /*
+ * The order here is important. The index of each speed needs to
+ * correspond with the sgtty structure value for that speed.
+ *
+ * Additionally, the search algorithm assumes the table is in
+ * ascending sequence.
+ */
+ static int ttyspeeds[] = {
+ 0, 50, 75, 110, 134, 150, 200, 300,
+ 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400 };
+#define NUMSPEEDS sizeof ttyspeeds/sizeof ttyspeeds[0]
+
+ if ((ottyb.sg_ospeed < 0) || (ottyb.sg_ospeed > NUMSPEEDS) ||
+ (ottyb.sg_ispeed < 0) || (ottyb.sg_ispeed > NUMSPEEDS)) {
+ ExitString("Invalid terminal speed.");
+ /*NOTREACHED*/
+ } else {
+ *ispeed = ttyspeeds[ottyb.sg_ispeed];
+ *ospeed = ttyspeeds[ottyb.sg_ospeed];
+ }
+}