home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tolkit45.zip / os2tk45 / samples / os2 / eaedit / eas.h < prev    next >
C/C++ Source or Header  |  1999-05-11  |  19KB  |  410 lines

  1. /*static char *SCCSID = "@(#)eas.h    6.12 92/02/18";*/
  2. /*==============================================================*\
  3.  *                                                              *
  4.  *  EAS.H - Sample PM application eas header file               *
  5.  *      (C) Copyright IBM Corporation 1992.                     *
  6.  *                                                              *
  7.  *--------------------------------------------------------------*
  8.  *                                                              *
  9.  *  This header file contains the application wide constants    *
  10.  *  and structure definitions.                                  *
  11.  *                                                              *
  12. \*==============================================================*/
  13. #define INCL_WIN
  14. #define INCL_HELP
  15. #define INCL_WINHEAP
  16. #define INCL_WINMENU               /* For menu control function */
  17. #define INCL_WINDIALOGS
  18. #define INCL_WINMESSAGEMGR
  19. #define INCL_DOSPROCESS                    /* For init function */
  20. #define INCL_GPIPRIMITIVES
  21. #define INCL_GPIBITMAPS
  22.  
  23. #include <os2.h>
  24. #include <malloc.h>
  25. #include <stdio.h>
  26. #include <string.h>
  27.  
  28. /*--------------------------------------------------------------*\
  29.  * Resource IDs                                                 *
  30. \*--------------------------------------------------------------*/
  31. #define ID_RESOURCE                            1
  32. #define IDR_BITMAP                             2
  33. #define ID_BMP                                 3
  34. #define ID_LOGOTEXT                            4
  35. #define IDC_BITMAP                             5
  36.  
  37. /*--------------------------------------------------------------*\
  38.  *  Menu item ids                                               *
  39. \*--------------------------------------------------------------*/
  40. #define IDM_HELPINDEX                       1010
  41. #define IDM_GENERALHELP                     1011
  42. #define IDM_TUTORIAL                        1012
  43. #define IDM_USINGHELP                       1013
  44. #define IDM_HELPPRODUCTINFO                 1014
  45. #define IDM_MSGBOX                          1015
  46.  
  47. #define IDM_OPEN                            1016
  48. #define IDM_SAVE                            1017
  49. #define IDM_EDIT                            1018
  50. #define IDM_ADD                             1019
  51. #define IDM_DELETE                          1020
  52.  
  53. /*--------------------------------------------------------------*\
  54.  *  Message item ids                                            *
  55. \*--------------------------------------------------------------*/
  56. #define IDD_ABOUTBOX                         151
  57. #define IDD_MULTILIST                        152
  58. #define IDD_ASCIIZ                           153
  59. #define IDD_MENU_MAIN                        154
  60. #define IDD_OPENBOX                          155
  61. #define IDD_PATH                             156
  62. #define IDD_FILEEDIT                         157
  63. #define IDD_DIRLIST                          158
  64. #define IDD_FILELIST                         159
  65. #define IDD_WINLBOX                          160
  66. #define IDD_LBOX                             161
  67. #define IDD_ADD                              162
  68. #define IDD_DELETE                           163
  69. #define IDD_EDIT                             164
  70. #define IDD_EATYPE                           165
  71. #define IDD_ADDEA                            166
  72. #define IDD_EANAME                           167
  73. #define IDD_NEW                              168
  74. #define IDD_EXISTING                         169
  75. #define IDD_ASCIIEDIT                        170
  76. #define IDD_EAVALUE                          171
  77. #define IDD_LOGO                             172
  78. #define IDD_ICON                             173
  79. #define IDD_MULTIBOX                         174
  80. #define DID_DONE                             175
  81. #define IDD_TITLE                            176
  82. #define IDD_LPDATA                           177
  83. #define IDD_NEEDBIT                          178
  84. #define IDD_CODEPAGE                         179
  85. #define IDD_PRODUCTINFO                      180
  86.  
  87. /*--------------------------------------------------------------*\
  88.  *  Help table and subtables                                    *
  89. \*--------------------------------------------------------------*/
  90. #define EAS_HELP_TABLE                      4000
  91.  
  92. /*--------------------------------------------------------------*\
  93.  *  Main window help panels                                     *
  94. \*--------------------------------------------------------------*/
  95. #define SUBTABLE_MAIN                       4100
  96. #define PANEL_MAIN                          4110
  97. #define PANEL_HELP                          4120
  98. #define PANEL_GENERALHELP                   4130
  99. #define PANEL_USINGHELP                     4140
  100. #define PANEL_TUTORIAL                      4150
  101. #define PANEL_HELPINDEX                     4160
  102. #define PANEL_HELPPRODUCTINFO               4170
  103. #define PANEL_KEYSHELP                      4180
  104.  
  105. #define PANEL_OPENHELP                      4190
  106. #define PANEL_SAVEHELP                      4191
  107. #define PANEL_ADDHELP                       4193
  108. #define PANEL_DELETEHELP                    4194
  109. #define PANEL_EDITHELP                      4195
  110.  
  111. /*--------------------------------------------------------------*\
  112.  *  Enter text dialog help subtable                             *
  113. \*--------------------------------------------------------------*/
  114. #define SUBTABLE_ABOUTBOXDLG                4200
  115. #define PANEL_ABOUTBOXDLG                   4210
  116. #define PANEL_ABOUTBOX_OK                   4220
  117.  
  118. #define SUBTABLE_OPENBOXDLG                 4225
  119. #define PANEL_OPENBOXDLG                    4226
  120. #define PANEL_OPENBOX_OK                    4227
  121.  
  122. #define SUBTABLE_ADDBOXDLG                  4230
  123. #define PANEL_ADDBOXDLG                     4231
  124. #define PANEL_ADDBOX_OK                     4232
  125.  
  126. #define SUBTABLE_MULTIBOXDLG                4235
  127. #define PANEL_MULTIBOXDLG                   4236
  128. #define PANEL_MULTIBOX_OK                   4237
  129.  
  130. #define SUBTABLE_PRODUCTINFODLG             4240
  131. #define PANEL_PRODUCTINFODLG                4241
  132. #define PANEL_PRODUCTINFO_OK                4242
  133.  
  134. /*--------------------------------------------------------------*\
  135.  *  Stringtable ids                                             *
  136. \*--------------------------------------------------------------*/
  137. #define IDS_APPNAME                          101
  138. #define IDS_HELPLIBRARYNAME                  102
  139. #define IDS_HELPWINDOWTITLE                  103
  140. #define IDS_TITLE                            104
  141. #define IDS_UNTITLED                         105
  142. /*--------------------------------------------------------------*\
  143.  *  Messagetable ids                                            *
  144. \*--------------------------------------------------------------*/
  145. #define IDMSG_FILECHANGED                    301
  146. #define IDMSG_ERROREANAME                    302
  147. #define IDMSG_DUPLICATENAME                  303
  148. #define IDMSG_ERRORVALUE                     304
  149. #define IDMSG_MEMORYFULL                     305
  150. #define IDMSG_ERRORSELECT                    306
  151. #define IDMSG_NOFILEOPEN                     307
  152. #define IDMSG_ERROREATYPE                    308
  153. #define IDMSG_WRITEERROR                     309
  154. #define IDMSG_WRITEOK                        310
  155. #define IDMSG_ERRORMULTIVALUE                311
  156. #define IDMSG_INITFAILED                     312
  157. #define IDMSG_MAINWINCREATEFAILED            313
  158. #define IDMSG_CANNOTGETHPS                   314
  159. #define IDMSG_CANNOTLOADSTRING               315
  160. #define IDMSG_CANNOTLOADEXITLIST             316
  161. #define IDMSG_HELPLOADERROR                  317
  162. #define IDMSG_HELPDISPLAYERROR               318
  163. #define IDMSG_ERRORMULTITYPE                 319
  164. #define IDMSG_ERRORFILEOPEN                  320
  165.  
  166. /*--------------------------------------------------------------*\
  167.  *  Macro constants                                             *
  168. \*--------------------------------------------------------------*/
  169. /* The HoldFEA is used to hold individual EAs.  The member names correspond
  170.    directly to those of the FEA structure.  Note however, that both szName
  171.    and aValue are pointers to the values.  An additional field, next, is
  172.    used to link the HoldFEA's together to form a linked list. */
  173.  
  174. struct _HoldFEA
  175. {
  176.    ULONG   oNextEntryOffset;                    /* new field */
  177.    BYTE       fEA;       /* Flag byte */
  178.    BYTE       cbName;
  179.    USHORT     cbValue;
  180.    CHAR      *szName;
  181.    CHAR      *aValue;
  182.    struct _HoldFEA *next;
  183. };
  184. typedef struct _HoldFEA HOLDFEA;
  185.  
  186. /* The DeleteList is used to hold the names of EAs that need to be explicitly
  187.    deleted before the current EAs are written.  This is necessary because
  188.    there does not exist a way to automatically delete all existing EAs
  189.    associated with a file.  The next field allows the structures to be
  190.    linked. */
  191.  
  192. struct _DeleteList
  193. {
  194.    CHAR *EAName;
  195.    struct _DeleteList *next;
  196. };
  197. typedef struct _DeleteList DELETELIST;
  198.  
  199. /* The PassData struct is used to pass data, especially as the user data
  200.    parameter for dialog box calls.  The Point field points to several types
  201.    of data throughout the program.  Usually it points to either an asciiz
  202.    name or a HoldData structure.  The rest of the fields are used for m-m
  203.    recursive calls.  cbMulti is the length of the m-m field currently being
  204.    considered.  usMultiOffset is the offset from the beginning of the
  205.    EA (->aValue) to the start of the current m-m field.  usIndex is a count
  206.    of the number of sub-fields in the current m-m.   */
  207.  
  208. struct _PassData
  209. {
  210.    CHAR   *Point;
  211.    USHORT cbMulti;
  212.    USHORT usMultiOffset;
  213.    USHORT usIndex;
  214.    BYTE   fFlag;
  215. };
  216. typedef struct _PassData PASSDATA;
  217. typedef PASSDATA FAR *PPASSDATA;
  218.  
  219. struct _MVSTdata
  220. {
  221.    CHAR   *szName;
  222.    USHORT usType;
  223. };
  224. typedef struct _MVSTdata MVSTDATA;
  225.  
  226. /* The ReEnter structure is used to keep track of the static data for
  227.    MultiTypeProc.  This structure is necessary since the proc is recursive
  228.    and the static data is only available during the initialize message.
  229.    The structure holds the two static variables and has a next field to
  230.    allow the list to be linked. */
  231.  
  232. struct _ReEnter
  233. {
  234.    HOLDFEA *pFEA;
  235.    PASSDATA FAR *pPDat;
  236.    struct _ReEnter *next;
  237. };
  238. typedef struct _ReEnter REENTER;
  239.  
  240. /* This struct holds the static data that allows translation between the
  241.    EA type and descriptor string, etc.  Data is global. */
  242.  
  243. struct _EADATA
  244. {
  245.    USHORT usPrefix;
  246.    CHAR   szFormat[36];
  247.    USHORT usFldType;
  248. };
  249. typedef struct _EADATA EADATA;
  250.  
  251. #define FreeMem(p)      DosFreeMem(p)
  252.  
  253. /*--------------------------------------------------------------*\
  254.  *  Entry point declarations                                    *
  255. \*--------------------------------------------------------------*/
  256. /* from easinit.c */
  257. BOOL    Init(VOID);
  258. VOID APIENTRY ExitProc(ULONG);
  259.  
  260. /* from eashelp.c */
  261. VOID    InitHelp(VOID);
  262. VOID    HelpHelpForHelp(MPARAM);
  263. VOID    HelpExtended(MPARAM);
  264. VOID    HelpKeys(MPARAM);
  265. VOID    HelpIndex(MPARAM);
  266. VOID    HelpAbout(MPARAM);
  267. VOID    DisplayHelpPanel(LONG);
  268. VOID    DestroyHelpInstance(VOID);
  269. VOID    FixSysMenu(HWND);
  270. MRESULT EXPENTRY AboutDlgProc(HWND, ULONG, MPARAM, MPARAM);
  271.  
  272. /* from eas.c */
  273. INT     main(int argc, char *argv[]);
  274. MRESULT EXPENTRY MainWndProc(HWND, ULONG, MPARAM, MPARAM);
  275. VOID    MainCommand(HWND, MPARAM, MPARAM);
  276. VOID    MainPaint(HWND);
  277. VOID    MainControl(HWND, MPARAM, MPARAM);
  278. VOID    UserCommand(HWND, MPARAM, MPARAM);
  279. VOID    ProcExit(HWND, MPARAM);
  280. LONG    MessageBox(HWND, LONG, PSZ, LONG, BOOL);
  281.  
  282. BOOL OpenFile(HWND,ULONG);
  283. BOOL AddEA(HWND);
  284. BOOL QueryEAs(CHAR *);
  285. BOOL EditEAValue(HWND, PPASSDATA);
  286. BOOL EAExists(CHAR *);
  287. BOOL EditEA(HWND);
  288. BOOL CheckEAIntegrity(CHAR *, ULONG);
  289. MRESULT EXPENTRY OpenFileProc  (HWND, ULONG, MPARAM, MPARAM);
  290. MRESULT EXPENTRY MainDlgProc   (HWND, ULONG, MPARAM, MPARAM);
  291. MRESULT EXPENTRY AddEAProc     (HWND, ULONG, MPARAM, MPARAM);
  292. MRESULT EXPENTRY AsciiEditProc (HWND, ULONG, MPARAM, MPARAM);
  293. MRESULT EXPENTRY IconDlgProc   (HWND, ULONG, MPARAM, MPARAM);
  294. MRESULT EXPENTRY MultiTypeProc (HWND, ULONG, MPARAM, MPARAM);
  295. MRESULT EXPENTRY MultiValueProc(HWND, ULONG, MPARAM, MPARAM);
  296. VOID    FillDirListBox  (HWND,CHAR *);
  297. VOID    FillFileListBox (HWND);
  298. VOID    Free_FEAList(HOLDFEA *,DELETELIST *);
  299. VOID    ShowEAType(HWND);
  300. VOID    DeleteCurEA(HWND);
  301. VOID    WriteEAs(VOID);
  302. VOID    ChangeName(HOLDFEA *,CHAR *);
  303. VOID    MultiAdd(HWND, HOLDFEA *, PPASSDATA);
  304. LONG    ParseFileName (CHAR *, CHAR *);
  305. ULONG   LookupEAType(ULONG);
  306. ULONG   CurEAType(HOLDFEA *);
  307. USHORT   GetUSHORT(HOLDFEA *,ULONG);
  308. HOLDFEA *GetCurFEA(HWND, HOLDFEA *);
  309. CHAR    *MultiTypeIndex(CHAR *, ULONG);
  310. CHAR    *EAValueString(CHAR *);
  311. VOID    GetMem(PVOID *pvMessage, ULONG ulSize);
  312. VOID    ResizeMem(PVOID *, ULONG, ULONG);
  313.  
  314. /*--------------------------------------------------------------*\
  315.  *  Other constants                                             *
  316. \*--------------------------------------------------------------*/
  317. #define RETURN_SUCCESS        0          /* successful return in DosExit    */
  318. #define RETURN_ERROR          1          /* error return in DosExit         */
  319. #define BEEP_WARN_FREQ       60          /* frequency of warning beep       */
  320. #define BEEP_WARN_DUR       100          /* duration of warning beep        */
  321. #define MAXAPPNAMELEN        15
  322. #define HELPLIBRARYNAMELEN   20          /* The length of library name      */
  323. #define MAX_EDIT_BUFF        21          /* length of string to query size  */
  324. #define BUFF_SIZE           200
  325.  
  326. #define MAXTEXTLEN           40          /* maximum text length for window  */
  327. #define MESSAGELEN           80          /* maximum length for messages     */
  328. #define HORZ_INDENT          10
  329. #define VERT_TEXT_POS        15          /* from top to display text info   */
  330.  
  331. #define ARGFILE               1
  332. #define MAX_GEA            500L  /* Max size for a GEA List                 */
  333. #define Ref_ASCIIZ            1  /* Reference type for DosEnumAttribute     */
  334. #define MAXEANAME           255  /* Maximum length an EA Name can be        */
  335. #define MAXEAVALUE         2048  /* Arbitrary max edit fld len of EA Val    */
  336. #define EATABLESIZE          12  /* Number of entries in ConvTable          */
  337. #define GROWSIZE            512  /* Minimum size to increase the heap by    */
  338. #define FILE_ALL         0x0007  /* Read-only, sys, hidden, & normal        */
  339. #define MAXSHOWSIZE          34  /* Number of chars to place in desc lbox   */
  340. #define LENUSHORTBUF          6  /* Buf size needed to for ascii USHORT     */
  341. #define MESSAGELEN           80  /* Maximum length for messages             */
  342. #define MSNUM                 5  /* Number of MVST data list                */
  343.  
  344. /* Return values from ParseFileName */
  345. #define FILE_INVALID          0  /* The filename was invalid                */
  346. #define FILE_PATH             1  /* The filename was a path                 */
  347. #define FILE_VALID            2  /* The filename was valid                  */
  348.  
  349. /* definition of level specifiers. required for File Info */
  350.  
  351. #define GetInfoLevel1         1            /* Get info from SFT             */
  352. #define GetInfoLevel2         2            /* Get size of FEAlist           */
  353. #define GetInfoLevel3         3            /* Get FEAlist given the GEAlist */
  354. #define GetInfoLevel4         4            /* Get whole FEAlist             */
  355. #define GetInfoLevel5         5            /* Get FSDname                   */
  356.  
  357. #define SetInfoLevel1         1            /* Set info in SFT               */
  358. #define SetInfoLevel2         2            /* Set FEAlist                   */
  359.  
  360. #define     OPENMODE    OM_DENY_NONE+OM_READ_WRITE
  361. #define     OPENFLAG    OF_OPEN_FILE
  362. #define     CREATFLAG   OF_CREATE_FILE+OF_FAIL
  363. #define     REPLFLG     OF_REPLACE_FILE
  364.  
  365. #define EA_LPBINARY      0xfffe       /* Length preceeded binary            */
  366. #define EA_LPASCII       0xfffd       /* Length preceeded ascii             */
  367. #define EA_ASCIIZ        0xfffc       /* Asciiz                             */
  368. #define EA_LPBITMAP      0xfffb       /* Length preceeded bitmap            */
  369. #define EA_LPMETAFILE    0xfffa       /* metafile                           */
  370. #define EA_LPICON        0xfff9       /* Length preceeded icon              */
  371. #define EA_ASCIIZFN      0xffef       /* Asciiz file name of associated dat */
  372. #define EA_ASCIIZEA      0xffee       /* Asciiz EA of associated data       */
  373. #define EA_MVMT          0xffdf       /* Multi-value multi-typed field      */
  374. #define EA_MVST          0xffde       /* Multy value single type field      */
  375. #define EA_ASN1          0xffdd       /* ASN.1 field                        */
  376.  
  377. #define HM_VALIDFLAGS    0x0003
  378.  
  379. /*--------------------------------------------------------------*\
  380.  *  Global variables                                            *
  381. \*--------------------------------------------------------------*/
  382. CHAR  szWindowText[MAXTEXTLEN];                     /* text drawn in window */
  383. HWND  hwndMainFrame;                     /* handle to the main frame window */
  384. HWND  hwndMain;                         /* handle to the main client window */
  385. HWND  hwndChild1;                                 /* handle to child window */
  386. HAB   hab;                                  /* anchor block for the process */
  387. HMQ   hmq;                          /* handle to the process' message queue */
  388. CHAR  szAppName[MAXAPPNAMELEN];       /* buffer for application name string */
  389. CHAR  szUntitled[MESSAGELEN];               /* buffer for "Untitled" string */
  390.       /* for help menu module */
  391. BOOL   fHelpEnabled;                /* flag to determine if help is enabled */
  392. static CHAR szLibName[HELPLIBRARYNAMELEN];
  393. static CHAR szWindowTitle[HELPLIBRARYNAMELEN];
  394. static HWND hwndHelpInstance;
  395.  
  396. CHAR    szFileName[CCHMAXPATH];                    /* Holds current EA file */
  397. CHAR    szEAName[MAXEANAME+1];    /* Used to return the EA name +1 for NULL */
  398. CHAR    szEAType[36];                              /* Store current EA type */
  399. USHORT  usRetEAType;                     /* Used to return selected EA Type */
  400. BOOL    FILE_ISOPEN;                                      /* File Open flag */
  401. BOOL    FILE_CHANGED;                                  /* File Changed flag */
  402. BOOL    COMMAND_LINE_FILE;     /* Flag to determine if a file was on the CL */
  403. PVOID   szAscii,szScratch;      /* 2 Pointer used to return misc. strings */
  404. CHAR    *pAlloc,*szEditBuf;
  405. HOLDFEA *pHoldFEA;                         /* Global EA linked-list pointer */
  406. DELETELIST *pDelList;                   /* Global ptr to l-l of deleted EAs */
  407. HAB     hab;                                /* Anchor block for the process */
  408. HMQ     hmq;
  409. MVSTDATA MSdata[MSNUM];                         /* MVST name & type stored */
  410.