home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / extgen.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  6.5 KB  |  107 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #ifndef __ExtensionGenerator_H
  20. #define __ExtensionGenerator_H
  21.  
  22. /*  Author:
  23.  *      Garrett Arch Blythe
  24.  *      blythe@netscape.com
  25.  */
  26.  
  27. /*--------------------------------------------------------------------------**
  28. ** Flags passed into the EXT_* functions.                                   **
  29. **                                                                          **
  30. ** EXT_PRESERVE_EXT        The generated extension must be based on the     **
  31. **                             provided file/url name.                      **
  32. ** EXT_PRESERVE_MIME       The generated extension must be based on the     **
  33. **                             provided mime type.                          **
  34. ** EXT_SHELL_EXECUTABLE    The generated extension must be ShellExecutable. **
  35. ** EXT_NO_PERIOD           The generated extension will not contain a       **
  36. **                             leading period.                              **
  37. ** EXT_DOT_THREE           Limit generated extension to 3 characters for    **
  38. **                             16 bit operating system compatibility.       **
  39. ** EXT_EXECUTABLE_IDENTITY Only has meaning when used in conjunction with   **
  40. **                             EXT_SHELL_EXECUTABLE.  When specified, it    **
  41. **                             will allow EXT_SHELL_EXECUTABLE flag to      **
  42. **                             succeed when the extension generated itself  **
  43. **                             is executable (.exe, .bat, .lnk, etc.).      **
  44. **                             This behavior is off by default.             **
  45. **--------------------------------------------------------------------------*/
  46. #define EXT_PRESERVE_EXT        0x00000001UL
  47. #define EXT_PRESERVE_MIME       0x00000002UL
  48. #define EXT_SHELL_EXECUTABLE    0x00000004UL
  49. #define EXT_NO_PERIOD           0x00000008UL
  50. #define EXT_DOT_THREE           0x00000010UL
  51. #define EXT_EXECUTABLE_IDENTITY 0x00000020UL
  52.  
  53. /*-----------------------------------------------------------------------**
  54. ** EXT_Invent      Autogenerate an extension from provided criteria.     **
  55. **                 Uses a complex approach, attempting to find the       **
  56. **                     best possible extension under any given           **
  57. **                     circumstance when an extension is abosulutely     **
  58. **                     needed.                                           **
  59. **                 This function mainly calls EXT_Generate will certain  **
  60. **                     combinations of flags in a certain priority.      **
  61. **                     READS:  Heuristic, don't muck with this casually. **
  62. **                                                                       **
  63. ** Returns size_t  0 on failure or no extension available.               **
  64. **                 Number of bytes written to pOutExtension on success.  **
  65. **                 If pOutExtension is NULL, then number of bytes needed **
  66. **                     not including terminating NULL character.         **
  67. **                                                                       **
  68. ** pOutExtension   Returned extension once generated.  Can be NULL if    **
  69. **                     querying size of buffer needed.                   **
  70. ** stExtBufSize    Size in bytes of pOutExtension.  Ignored if           **
  71. **                     pOutExtension is NULL.                            **
  72. ** dwFlags         Combination of flags indicating which algorithm to    **
  73. **                     use to generate the extension.  The only flags    **
  74. **                     currently allowed are EXT_NO_PERIOD and           **
  75. **                     EXT_DOT_THREE.                                    **
  76. ** pOrigName       File, URL, or .EXT which we are deriving the          **
  77. **                     extension from.  Can be NULL.                     **
  78. ** pMimeType       Mime type which we are deriving the extension from.   **
  79. **                     Can be NULL.                                      **
  80. **-----------------------------------------------------------------------*/
  81. size_t EXT_Invent(char *pOutExtension, size_t stExtBufSize, DWORD dwFlags, const char *pOrigName, const char *pMimeType);
  82.  
  83. /*-----------------------------------------------------------------------**
  84. ** EXT_Generate    Autogenerate an extension from provided criteria.     **
  85. **                                                                       **
  86. ** Returns size_t  0 on failure or no extension available.               **
  87. **                 Number of bytes written to pOutExtension on success.  **
  88. **                 If pOutExtension is NULL, then number of bytes needed **
  89. **                     not including terminating NULL character.         **
  90. **                                                                       **
  91. ** pOutExtension   Returned extension once generated.  Can be NULL if    **
  92. **                     querying size of buffer needed.                   **
  93. ** stExtBufSize    Size in bytes of pOutExtension.  Ignored if           **
  94. **                     pOutExtension is NULL.                            **
  95. ** dwFlags         Combination of flags indicating which algorithm to    **
  96. **                     use to generate the extension.  All flags are     **
  97. **                      allowed.                                         **
  98. ** pOrigName       File, URL, or .EXT which we are deriving the          **
  99. **                     extension from.  Can be NULL.                     **
  100. ** pMimeType       Mime type which we are deriving the extension from.   **
  101. **                     Can be NULL.                                      **
  102. **-----------------------------------------------------------------------*/
  103. size_t EXT_Generate(char *pOutExtension, size_t stExtBufSize, DWORD dwFlags, const char *pOrigName, const char *pMimeType);
  104.  
  105. #endif // __ExtensionGenerator_H
  106.  
  107.