home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / libnet / mkformat.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.2 KB  |  99 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.  * cinfo.h: Content Information for a file, i.e. its type, etc.
  20.  * 
  21.  * See cinfo.c for dependency information. 
  22.  * 
  23.  * Rob McCool
  24.  */
  25.  
  26. #ifndef MKFORMAT_H
  27. #define MKFORMAT_H
  28.  
  29. #ifndef MKSTREAM_H
  30. #include "mkstream.h"
  31. #endif /* MKSTREAM_H */
  32.  
  33. /* ------------------------------ Constants ------------------------------- */
  34.  
  35.  
  36. /*
  37.  * This will be the first string in the file, followed by x.x version
  38.  * where x is an integer.
  39.  * 
  40.  * If this magic string is not found, cinfo_merge will try to parse
  41.  * the file as a NCSA httpd mime.types file.
  42.  */
  43.  
  44. #define MCC_MT_MAGIC "#--MCOM MIME Information"
  45. #define MCC_MT_MAGIC_LEN 24
  46.  
  47. #define NCC_MT_MAGIC "#--Netscape Communications Corporation MIME Information"
  48. #define NCC_MT_MAGIC_LEN 40    /* Don't bother to check it all */
  49.  
  50. /* The character which separates extensions with cinfo_find */
  51.  
  52. #define CINFO_SEPARATOR '.'
  53.  
  54. /* The maximum length of a line in this file */
  55.  
  56. #define CINFO_MAX_LEN 1024
  57.  
  58. /* The hash function for the database. Hashed on extension. */
  59. #include <ctype.h>
  60. #define CINFO_HASH(s) (isalpha(s[0]) ? tolower(s[0]) - 'a' : 26)
  61.  
  62. /* The hash table size for that function */
  63. #define CINFO_HASHSIZE 27
  64.  
  65.  
  66. /* ------------------------------ Structures ------------------------------ */
  67.  
  68. /* see ../include/net.h for the NET_cinfo struct */
  69.  
  70. /* ------------------------------ Prototypes ------------------------------ */
  71.  
  72. /*
  73.  * cinfo_find finds any content information for the given uri. The file name
  74.  * is the string following the last / in the uri. Multiple extensions are
  75.  * separated by CINFO_SEPARATOR. You may pass in a filename instead of uri.
  76.  *
  77.  * Returns a newly allocated cinfo structure with the information it
  78.  * finds. The elements of this structure are coming right out of the types 
  79.  * database and so if you change it or want to keep it around for long you
  80.  * should strdup it. You should free only the structure itself when finished
  81.  * with it.
  82.  *
  83.  * If there is no information for any one of the extensions it
  84.  * finds, it will ignore that extension. If it cannot find information for
  85.  * any of the extensions, it will return NULL.
  86.  */
  87. extern NET_cinfo *NET_cinfo_find(char *uri);
  88. extern NET_cinfo *NET_cinfo_find_type(char *uri);
  89. extern NET_cinfo *NET_cinfo_find_enc (char *uri);
  90.  
  91.  
  92. /*
  93.  * cinfo_lookup finds the information about the given content-type, and 
  94.  * returns a cinfo structure so you can look up description and icon.
  95.  */
  96. NET_cinfo *NET_cinfo_lookup(char *type);
  97.  
  98. #endif /* MKFORMAT_H */
  99.