source: branches/branch-1-0/include/helpers/level.h@ 315

Last change on this file since 315 was 14, checked in by umoeller, 25 years ago

Major updates; timers, LVM, miscellaneous.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 7.6 KB
Line 
1
2/*
3 *@@sourcefile level.h:
4 * header file for level.c. See remarks there.
5 *
6 *@@include #include "helpers\level.h"
7 */
8
9/*
10 * Copyright (C) 2000 Ulrich M”ller.
11 * Copyright (C) 1994 Martin Lafaix (EDM/2 2-05).
12 * This file is part of the "XWorkplace helpers" source package.
13 * This is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published
15 * by the Free Software Foundation, in version 2 as it comes in the
16 * "COPYING" file of the XWorkplace main distribution.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 */
22
23#if __cplusplus
24extern "C" {
25#endif
26
27#ifndef LEVEL_HEADER_INCLUDED
28 #define LEVEL_HEADER_INCLUDED
29
30 APIRET lvlOpenLevelFile(PSZ pszName, PHFILE phFile,
31 ULONG ulOpenMode, PSZ pszCID);
32 APIRET lvlQueryLevelFile(PSZ pszName, PSZ pszCID,
33 PVOID pBuffer, ULONG ulBufSize);
34 APIRET lvlQueryLevelFileData(HFILE hFile, ULONG ulWhat,
35 PVOID pBuffer, ULONG ulBufSize, PULONG pulSize);
36 APIRET lvlWriteLevelFileData(HFILE hFile, ULONG ulWhat,
37 PVOID pBuffer, ULONG ulBufSize, PULONG pulSize);
38
39 #define lvlCloseLevelFile DosClose
40
41 /***************************************************************************/
42 /* ulOpenMode values */
43 /***************************************************************************/
44 #define OLF_OPEN 0x00000001L /* scan from current dir*/
45 #define OLF_SCANDISKS 0x00000002L /* scan all disks */
46 #define OLF_CHECKID 0x00000004L /* check component ID */
47 #define OLF_CREATE 0x00000008L /* create syslevel file */
48
49 /***************************************************************************/
50 /* ulWhat values */
51 /***************************************************************************/
52 #define QLD_MAJORVERSION 1
53 #define QLD_MINORVERSION 2
54 #define QLD_REVISION 3
55 #define QLD_KIND 4
56 #define QLD_CURRENTCSD 5
57 #define QLD_PREVIOUSCSD 6
58 #define QLD_TITLE 7
59 #define QLD_ID 8
60 #define QLD_TYPE 9
61
62 /***************************************************************************/
63 /* kind values */
64 /***************************************************************************/
65 #define SLK_BASE 0 /* 'base' component */
66 #define SLK_EXTENSION 2 /* system extension */
67 #define SLK_STANDARD 15 /* 'normal' component */
68
69 #ifdef SYSLEVEL_PRIVATE
70 /***************************************************************************/
71 /* privates structures */
72 /***************************************************************************/
73 #pragma pack(1)
74
75 typedef struct _SYSLEVELHEADER { /* syslevel file header */
76 unsigned char h_magic[2]; /* magic cookie (0xFFFF)*/
77 unsigned char h_name[9]; /* SYSLEVEL string */
78 unsigned char h_reserved1[4]; /* unknown - set to zero*/
79 unsigned char h_updated; /* unknown, too */
80 unsigned char h_reserved2[17]; /* unknown, again */
81 ULONG h_data; /* data structure offset*/
82 } SYSLEVELHEADER, *PSYSLEVELHEADER;
83
84 typedef struct _SYSLEVELDATA { /* syslevel file data */
85 unsigned char d_reserved1[2]; /* unknown - set to zero*/
86 unsigned char d_kind[1]; /* component kind */
87 unsigned char d_version[2]; /* component version */
88 unsigned char d_reserved2[2]; /* unknown */
89 unsigned char d_clevel[7]; /* current CSD level */
90 unsigned char d_reserved3; /* unknown - 0x5F */
91 unsigned char d_plevel[7]; /* previous CSD level */
92 unsigned char d_reserved4; /* unknown - 0x5F */
93 unsigned char d_title[80]; /* component title */
94 unsigned char d_cid[9]; /* component ID */
95 unsigned char d_revision[1]; /* component revision */
96 unsigned char d_type[1+5]; /* component type */
97 } SYSLEVELDATA, *PSYSLEVELDATA;
98
99 #pragma pack()
100
101 /***************************************************************************/
102 /* local functions prototypes */
103 /***************************************************************************/
104 static APIRET _locatesysleveldata(HFILE hFile);
105 static APIRET _readsysleveldata(HFILE hFile, PSYSLEVELDATA psld);
106 static APIRET _writesysleveldata(HFILE hFile, PSYSLEVELDATA psld);
107 static APIRET _writesyslevelheader(HFILE hFile, PSYSLEVELHEADER pslh);
108 static PSYSLEVELDATA _allocsysleveldata(HFILE hFile);
109 static VOID _freesysleveldata(PSYSLEVELDATA psld);
110 static APIRET _findsyslevelfile(PSZ pszName, PSZ pszCID, PVOID pBuffer);
111 static APIRET _searchsubdirs(PSZ pszName, PSZ pszCID, PVOID pBuffer);
112 static ULONG _firstdrive(ULONG ulDriveMap);
113 static ULONG _nextdrive(ULONG ulDriveMap, ULONG ulCurrent);
114 static APIRET _getfullname(PVOID pBuffer, PSZ pszFileName);
115 static APIRET _findallsyslevelfiles(PSZ achFileName, PSZ pszCID,
116 PPVOID ppBuffer, PULONG pulBufSize);
117
118 /***************************************************************************/
119 /* useful macros */
120 /***************************************************************************/
121 // #define min(x, y) ((x) > (y) ? (y) : (x))
122 #define _setsize(s) if(pulSize) *pulSize = s
123 #define _getfield(f) if(ulBufSize >= sizeof(psld->f))\
124 memcpy(pBuffer, psld->f, sizeof(psld->f));\
125 else\
126 rc = 122; /* ERROR_INSUFFICIENT_BUFFER */\
127 _setsize(sizeof(psld->f))
128 #define _setfield(f) if(ulBufSize >= sizeof(psld->f))\
129 memcpy(psld->f, pBuffer, sizeof(psld->f));\
130 else\
131 rc = 122; /* ERROR_INSUFFICIENT_BUFFER */\
132 _setsize(sizeof(psld->f));
133 #define _achBuffer ((CHAR *)pBuffer)
134
135 #define ERROR_INSUFFICIENT_BUFFER 122
136 #define ERROR_INVALID_PARAMETER 87
137
138 #define trace printf("rc = %d\n", rc);
139
140 #endif // SYSLEVEL_PRIVATE
141
142#endif
143
144#if __cplusplus
145}
146#endif
147
Note: See TracBrowser for help on using the repository browser.