Release 4.1
[unix-history] / usr / src / usr.bin / tn3270 / ctlr / screen.h
index 9da2209..27f7462 100644 (file)
@@ -1,5 +1,20 @@
 /*
 /*
- * @(#)screen.h        3.1 (Berkeley) %G%
+ * Copyright (c) 1988 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ *     @(#)screen.h    4.1 (Berkeley) %G%
  */
 
 #define        INCLUDED_SCREEN
  */
 
 #define        INCLUDED_SCREEN
 #define FieldAttributesPointer(p)      (IsStartFieldPointer(p)? \
                                    GetHostPointer(p): \
                                    GetHost(WhereAttrByte((p)-&Host[0])))
 #define FieldAttributesPointer(p)      (IsStartFieldPointer(p)? \
                                    GetHostPointer(p): \
                                    GetHost(WhereAttrByte((p)-&Host[0])))
-#define TurnOffMdt(x)  ModifyHost(WhereAttrByte(x), &= ~ATTR_MDT)
-#define TurnOnMdt(x)   ModifyHost(WhereAttrByte(x), |= ATTR_MDT)
-#define HasMdt(x)      (GetHost(x)&ATTR_MDT)   /* modified tag */
+
+/*
+ * The MDT functions need to protect against the case where the screen
+ * is unformatted (sigh).
+ */
+
+/* Turn off the Modified Data Tag */
+#define TurnOffMdt(x) \
+    if (HasMdt(WhereAttrByte(x))) { \
+       ModifyMdt(x, 0); \
+    }
+
+/* Turn on the Modified Data Tag */
+#define TurnOnMdt(x) \
+    if (!HasMdt(WhereAttrByte(x))) { \
+       ModifyMdt(x, 1); \
+    }
+
+/* If this location has the MDT bit turned on (implies start of field) ... */
+#define HasMdt(x) \
+    ((GetHost(x)&(ATTR_MDT|ATTR_MASK)) == (ATTR_MDT|ATTR_MASK))
 
        /*
         * Is the screen formatted?  Some algorithms change depending
 
        /*
         * Is the screen formatted?  Some algorithms change depending