Weblessen.nl - Voor iedereen die wat wil leren..


C

Index
C Index
Voorwoord
De eerste stap
Een inleiding tot C
Programma besturing
Toekennen en Logisch vergelijken
Funkties en Variabelen
Defines en Macros
Strings en Tabellen
Pointers
Standaard Invoer / Uitvoer
Bestands Invoer / Uitvoer
Structuren en Unions
Dynamisch ngeheugen aanvragen
Karakter- en bitmanipulatie

Appendix
Hungarian Notation
Voorbeeldprogramma's
Totaal programma
Scherm- en bestands beschrijvingen
Aanpassingen voor VM/CMS

Aanpassingen voor VM/CMS



VM3270.H

1 /********************************************************************/ 2 /* VM3270.H - Header file for VM/CMS 3270 protocol support */ 3 /********************************************************************/ 4 #pragma linkage(ISPLINK,OS) 5 6 extern ISPLINK(); 7 8 #define VOID void 9 #define FALSE (1!=1) 10 #define TRUE (1==1) 11 12 /********************************************************************/ 13 /* Highligting */ 14 /********************************************************************/ 15 #define NORMAL 0 16 #define BRIGHT 1 17 #define UNDERSCORE 4 18 #define BLINK 5 19 #define REVERSE 7 20 #define HIDDEN 8 21 22 /********************************************************************/ 23 /* Colors */ 24 /********************************************************************/ 25 #define RED 0x31 26 #define GREEN 0x32 27 #define YELLOW 0x33 28 #define BLUE 0x34 29 #define PINK 0x35 30 #define TURQUOISE 0x36 31 #define WHITE 0x37 32 33 /********************************************************************/ 34 /* ISPF keywords */ 35 /********************************************************************/ 36 #define CONTROL "CONTROL " 37 #define DISPLAY "DISPLAY " 38 #define ERRORS "ERRORS " 39 #define PROFILE "PROFILE " 40 #define RETURN "RETURN " 41 #define VDEFINE "VDEFINE " 42 #define VGET "VGET " 43 #define VPUT "VPUT " 44 45 /********************************************************************/ 46 /* Macro for C/ISPF interface */ 47 /********************************************************************/ 48 #define C_VARIABLE(varname) \ 49 varname, "CHAR ", sizeof(varname) - 1 50 51 /********************************************************************/ 52 /* Key codes */ 53 /********************************************************************/ 54 #define PF1 0x01 55 #define PF2 0x02 56 #define PF3 0x03 57 #define PF4 0x04 58 #define PF5 0x05 59 #define PF6 0x06 60 #define PF7 0x07 61 #define PF8 0x08 62 #define PF9 0x09 63 #define PF10 0x0A 64 #define PF11 0x0B 65 #define PF12 0x0C 66 #define ENTER 0x0D 67 68 /********************************************************************/ 69 /* Function name redefinitions for VM (max 8 character support) */ 70 /********************************************************************/ 71 #define ConField CONFIELD 72 #define ControleerBackward CNTRBACK 73 #define ControleerForward CNTRFORW 74 #define ControleerYahtzee CNTRYAHT 75 #define Display DISPSCRN 76 #define DropField DRPFIELD 77 #define DropScreen DROPSCRN 78 #define InitScreen INITSCRN 79 #define LeesScherm LEESSCRN 80 #define ProgrammmaInit PROGINIT 81 #define VarField VARFIELD 82 #define VerwerkBackward VERWBACK 83 #define VerwerkForward VERWFORW 84 #define VerwerkHelp VERWHELP 85 #define VerwerkQuit VERWQUIT 86 #define VerwerkSpel VERWSPEL 87 #define VerwerkWorp VERWWORP 88 #define VerwerkYahtzee VERWYAHT 89 #define ZendScherm ZENDSCRN 90 91 /********************************************************************/ 92 /* Type definitions */ 93 /********************************************************************/ 94 typedef int BOOL; 95 96 typedef int SHORT; 97 98 typedef char CHAR; 99 typedef char *PSZ; 100 101 typedef char COLOR; 102 103 typedef int INTENSITY; 104 105 typedef int KEY; 106 typedef KEY *PKEY; 107 108 typedef struct _field { 109 struct _field *pFieldPrev; /* pointer to prev field */ 110 struct _field *pFieldNext; /* pointer to next field */ 111 SHORT sRow; /* field row */ 112 SHORT sColumn; /* field column */ 113 INTENSITY Intensity; /* intensity attribute */ 114 COLOR Color; /* color attribute */ 115 PSZ pszString; /* pointer to string data */ 116 SHORT sLength; /* field length */ 117 } FIELD; 118 typedef FIELD *PFIELD; /* pointer to field struct */ 119 120 typedef struct _screen { 121 PFIELD pFieldFirst; /* pointer to first field */ 122 PFIELD pFieldLast; /* pointer to last field */ 123 SHORT sNrOfFields; /* number of fields in list */ 124 SHORT sRows; /* number of rows on screen */ 125 SHORT sColumns; /* number of cols on screen */ 126 CHAR szDatArea[24*80+1]; /* ISPF display buffer */ 127 CHAR szCursor[8+1]; /* ISPF display buffer name */ 128 CHAR szCsrPos[8+1]; /* ISPF cursor position */ 129 CHAR szPFkey[8+1]; /* ISPF PF-key pressed */ 130 } SCREEN; 131 typedef SCREEN *PSCREEN; /* pointer to screen struct */ 132 133 134 /********************************************************************/ 135 /* Function prototypes */ 136 /********************************************************************/ 137 VOID InitScreen (PSCREEN); 138 139 VOID ConField (PSCREEN, SHORT, SHORT, INTENSITY, COLOR, PSZ); 140 141 VOID VarField (PSCREEN, SHORT, SHORT, INTENSITY, COLOR, PSZ, SHORT); 142 143 VOID Display (PSCREEN, SHORT, SHORT, PKEY); 144 145 VOID DropField (PSCREEN, SHORT, SHORT); 146 147 VOID DropScreen (PSCREEN); 148 149 /***** (C) Frans Fokkenrood - Januari 1993 **************************/

VM3270.C

1 /********************************************************************/ 2 /* VM3270.C - Functions for VM/CMS 3270 protocol support */ 3 /********************************************************************/ 4 5 #include <stdio.h> 6 #include <stdlib.h> 7 #include <string.h> 8 #include "vm3270.h" 9 10 /********************************************************************/ 11 /* Subroutine to Initialize the screen */ 12 /********************************************************************/ 13 14 VOID InitScreen (PSCREEN pScreen) 15 { 16 17 pScreen->pFieldFirst = NULL; 18 pScreen->pFieldLast = NULL; 19 pScreen->sNrOfFields = 0; 20 21 pScreen->sRows = 24; 22 pScreen->sColumns = 80; 23 24 memset (pScreen->szDatArea, ' ', (24 * 80)); 25 *(pScreen->szDatArea + (24 * 80)) = '\0'; 26 27 strcpy (pScreen->szCursor, "DATAREA "); 28 strcpy (pScreen->szCsrPos, "0 "); 29 strcpy (pScreen->szPFkey, " "); 30 31 ISPLINK (CONTROL, ERRORS, RETURN); 32 ISPLINK (VDEFINE, "DATAREA ", C_VARIABELE (pScreen->szDatArea)); 33 ISPLINK (VDEFINE, "CURSOR ", C_VARIABELE (pScreen->szCursor)); 34 ISPLINK (VDEFINE, "CSRPOS ", C_VARIABELE (pScreen->szCsrPos)); 35 ISPLINK (VDEFINE, "PFKEY ", C_VARIABELE (pScreen->szPFkey)); 36 37 return; 38 39 } /* End InitScreen */ 40 41 42 /********************************************************************/ 43 /* Subroutine to place Constant field on the screen */ 44 /********************************************************************/ 45 46 VOID ConField (PSCREEN pScreen, 47 SHORT sRow, 48 SHORT sColumn, 49 INTENSITY Intensity, 50 COLOR Color, 51 PSZ pszString) 52 { 53 54 sprintf (pScreen->szDatArea + (sRow*80) + sColumn - 1, "%c%s", 55 Color, pszString); 56 57 return; 58 59 } /* End ConField */ 60 61 62 /********************************************************************/ 63 /* Subroutine to place Variable field on the screen */ 64 /********************************************************************/ 65 66 VOID VarField (PSCREEN pScreen, 67 SHORT sRow, 68 SHORT sColumn, 69 INTENSITY Intensity, 70 COLOR Color, 71 PSZ pszString, 72 SHORT sLength) 73 { 74 PFIELD pField; 75 76 /******************************************************************/ 77 /* Find the location of the field structure within the list */ 78 /******************************************************************/ 79 for (pField = pScreen->pFieldFirst; 80 pField; 81 pField = pField->pFieldNext) { 82 if ((sRow == pField->sRow) && (sColumn == pField->sColumn)) { 83 break; 84 } /* endif */ 85 } /* endfor */ 86 87 88 /******************************************************************/ 89 /* If NOT found then add a new field at the end of linked list */ 90 /******************************************************************/ 91 if (pScreen->sNrOfFields == 0) { /* empty list */ 92 pField = (PFIELD) malloc (sizeof (FIELD)); 93 pField->pFieldPrev = NULL; 94 pField->pFieldNext = NULL; 95 pScreen->pFieldFirst = pField; 96 pScreen->pFieldLast = pField; 97 } 98 else if (pField == NULL) { /* end of list */ 99 pField = (PFIELD) malloc (sizeof (FIELD)); 100 pField->pFieldPrev = pScreen->pFieldLast; 101 pField->pFieldNext = NULL; 102 pScreen->pFieldLast->pFieldNext = pField; 103 pScreen->pFieldLast = pField; 104 } /* endif */ 105 106 107 /******************************************************************/ 108 /* Register the parameters of the variable field definition */ 109 /******************************************************************/ 110 pField->sRow = sRow; 111 pField->sColumn = sColumn; 112 pField->Intensity = Intensity; 113 pField->Color = Color - 0x10; /* Unprotected field */ 114 pField->pszString = pszString; 115 pField->sLength = sLength; 116 117 *(pField->pszString + sLength) = '\0'; 118 119 120 /******************************************************************/ 121 /* Update the Field counter in the screen structure */ 122 /******************************************************************/ 123 (pScreen->sNrOfFields)++; 124 125 return; 126 127 } /* End VarField */ 128 129 130 /********************************************************************/ 131 /* Subroutine to Display the screen */ 132 /********************************************************************/ 133 134 VOID Display (PSCREEN pScreen, 135 SHORT sRow, 136 SHORT sColumn, 137 PKEY pKeyPressed) 138 { 139 PFIELD pField; 140 SHORT sKey; 141 142 /******************************************************************/ 143 /* Print the content of the variable fields on the screen */ 144 /******************************************************************/ 145 for (pField = pScreen->pFieldFirst; 146 pField; 147 pField = pField->pFieldNext) { 148 sprintf (pScreen->szDatArea + pField->sRow * 80 149 + pField->sColumn - 1, 150 "%c%s", pField->Color, pField->pszString); 151 *(pScreen->szDatArea + pField->sRow * 80 152 + pField->sColumn + pField->sLength) = 0x36; 153 } /* endfor */ 154 155 /******************************************************************/ 156 /* Locate the cursor on its initial position */ 157 /* Display the screen by means of an ISPF panel */ 158 /******************************************************************/ 159 sprintf (pScreen->szCsrPos, "%-8d", (sRow*80) + sColumn + 1); 160 161 ISPLINK (DISPLAY, "YAHTZEE "); 162 163 /******************************************************************/ 164 /* Read the variable fields back from the screen */ 165 /******************************************************************/ 166 for (pField = pScreen->pFieldFirst; 167 pField; 168 pField = pField->pFieldNext) { 169 strncpy (pField->pszString, 170 pScreen->szDatArea + pField->sRow*80 + pField->sColumn, 171 pField->sLength); 172 } /* endfor */ 173 174 /******************************************************************/ 175 /* Determine the key type and its value */ 176 /******************************************************************/ 177 sKey = atoi (pScreen->szPFkey + 2); 178 if (sKey > 12) 179 sKey -= 12; 180 if (sKey == 0) 181 sKey = ENTER; 182 183 *pKeyPressed = sKey; 184 185 return; 186 187 } /* End Display */ 188 189 190 /********************************************************************/ 191 /* Subroutine to Drop a field from the list of fields */ 192 /********************************************************************/ 193 194 VOID DropField (PSCREEN pScreen, 195 SHORT sRow, 196 SHORT sColumn) 197 { 198 PFIELD pField; 199 200 /******************************************************************/ 201 /* If the list of fields is already empty then return */ 202 /******************************************************************/ 203 if (pScreen->sNrOfFields == 0) { 204 return; 205 } /* endif */ 206 207 208 /******************************************************************/ 209 /* Find the location of the field structure within the list */ 210 /******************************************************************/ 211 for (pField = pScreen->pFieldFirst; 212 pField; 213 pField = pField->pFieldNext) { 214 if ((sRow == pField->sRow) && (sColumn == pField->sColumn)) { 215 break; 216 } /* endif */ 217 } /* endfor */ 218 219 220 /******************************************************************/ 221 /* If no field could be found then return */ 222 /******************************************************************/ 223 if (!pField) { 224 return; 225 } /* endif */ 226 227 228 /******************************************************************/ 229 /* Else remove the field from the list depending on its position */ 230 /******************************************************************/ +++ if (pScreen->sNrOfFields == 1) { /* only one */ +++ pScreen->pFieldFirst = NULL: +++ pScreen->pFieldLast = NULL; +++ } 231 else if (pField == pScreen->pFieldFirst) { /* first one */ 232 pScreen->pFieldFirst = pField->pFieldNext; 233 pField->pFieldNext->pFieldPrev = NULL; 234 } 235 else if (pField == pScreen->pFieldLast) { /* last one */ 236 pScreen->pFieldLast = pField->pFieldPrev; 237 pField->pFieldPrev->pFieldNext = NULL; 238 } 239 else { /* intermediate */ 240 pField->pFieldPrev->pFieldNext = pField->pFieldNext; 241 pField->pFieldNext->pFieldPrev = pField->pFieldPrev; 242 } /* endif */ 243 244 245 /******************************************************************/ 246 /* Cleanup storage and update the Field counter screen structure */ 247 /******************************************************************/ +++ memset (szDatArea + pField->sRow * 80 + pField->sColumn - 1, +++ ' ', +++ pField->sLength + 1); 248 free (pField); 249 (pScreen->sNrOfFields)--; 250 251 return; 252 253 } /* End DropField */ 254 255 256 /********************************************************************/ 257 /* Subroutine to Drop the whole screen */ 258 /********************************************************************/ 259 260 VOID DropScreen (PSCREEN pScreen) 261 { 262 PFIELD pField; 263 264 /******************************************************************/ 265 /* Remove all fields from the list and cleanup storage */ 266 /******************************************************************/ 267 for (pField = pScreen->pFieldFirst; 268 pField; 269 pField = pScreen->pFieldFirst) { 270 271 pScreen->pFieldFirst = pScreen->pFieldFirst->pFieldNext; 272 273 free (pField); 274 275 } /* endfor */ 276 277 278 /******************************************************************/ 279 /* ReInitialize the screen structure and cleanup storage */ 280 /******************************************************************/ 281 pScreen->pFieldFirst = NULL; 282 pScreen->pFieldLast = NULL; 283 pScreen->sNrOfFields = 0; 284 285 return; 286 287 } /* End DropScreen */ 288 289 290 /***** (C) Frans Fokkenrood - Januari 1993 **************************/


Webdesign

Maak van Weblessen.nl uw startpagina!
Plaats Weblessen.nl bij uw favorieten. Neem contact met me op.
Heb je een Hosting?
Geef hier jouw mening over jouw web hosting

Webadres.info: Goede domeinnaam kiezen

Gesponsorde links:
Budget Webhosting
Web2host.nl
10eurohost.nl
Denit Hosting Solutions
YourHosting.nl
Starthosting.nl
Eduvision.nl
Educruitment.nl
Webadres.info


De link top 5:
Gratis Computercursussen
WebmasterStartpagina
MijnStartpagina.nu
Bluebird Animatie
Anouksweb
Link aanmelden
Alle Partners

Webmasterwoordenboek
A | B | C | D | E | F
G
| H | I | J | K | L | M
N
| O | P | Q | R | S | T
U | V | W | X | Y | Z

Films vanavond op Tv:

De klok:

(advertentie)

HTML leren
PHP cursus
XML lessen
XHTML les
CSS leer
leer C
REXX online
Red Hat Linux cursus