home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / libnet / robotxt.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.7 KB  |  104 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. /*** robotxt.h ****************************************************/
  19. /*   description:        parses the robots.txt file                */
  20. /*                      - not dependent on the crawler            */
  21.   
  22.  
  23.  /********************************************************************
  24.     See the robots.txt specification at:
  25.  
  26.     http://info.webcrawler.com/mak/projects/robots/norobots.html (original spec)
  27.     http://info.webcrawler.com/mak/projects/robots/norobots-rfc.html
  28.  
  29.     Note: the original spec says that at least one Disallow field must be present
  30.     in a record. That is what I am following.
  31.  
  32.   $Revision: 3.1 $
  33.   $Date: 1998/03/28 03:31:59 $
  34.  
  35.  *********************************************************************/
  36.  
  37. #ifndef robotctl_h___
  38. #define robotctl_h___
  39.  
  40. #include "prtypes.h"
  41. #include "ntypes.h"
  42. #include "net.h"
  43.  
  44. typedef uint8 CRAWL_RobotControlStatus;
  45. #define CRAWL_ROBOT_DISALLOWED            ((CRAWL_RobotControlStatus)0x00)
  46. #define CRAWL_ROBOT_ALLOWED                ((CRAWL_RobotControlStatus)0x01)
  47. #define CRAWL_ROBOTS_TXT_NOT_QUERIED    ((CRAWL_RobotControlStatus)0x02)
  48.  
  49. typedef struct _CRAWL_RobotControlStruct *CRAWL_RobotControl;
  50.  
  51. /*
  52.  * Typedef for function callback called after robots.txt is read.
  53.  */
  54.  typedef void
  55. (PR_CALLBACK *CRAWL_RobotControlStatusFunc)(void *data);
  56.  
  57. /* stream function */
  58. PUBLIC NET_StreamClass*
  59. CRAWL_RobotsTxtConverter(int format_out,
  60.                         void *data_object,
  61.                         URL_Struct *URL_s,
  62.                         MWContext  *window_id);
  63.  
  64. /****************************************************************************************/
  65. /* public API                                                                            */
  66. /****************************************************************************************/
  67.  
  68. NSPR_BEGIN_EXTERN_C
  69.  
  70. /* Creates a robot control for the site. 
  71.  Parameters:
  72.     context - context for libnet
  73.     site - protocol and host portion of url. "/robots.txt" will be appended to this to get the
  74.         location of robots.txt.
  75. */
  76. PR_EXTERN(CRAWL_RobotControl) 
  77. CRAWL_MakeRobotControl(MWContext *context, char *site);
  78.  
  79. /* Destroys a robot control and all memory associated with it (except for the context or the
  80.    opaque data supplied to CRAWL_ReadRobotControlFile)
  81. */
  82. PR_EXTERN(void) 
  83. CRAWL_DestroyRobotControl(CRAWL_RobotControl control);
  84.  
  85. /* Parses the robots.txt at the site specified in the control, and performs a callback when
  86.    it is done. This function returns after issuing a request to netlib.
  87.    Parameters:
  88.     control - the robot control for the site
  89.     func - completion callback
  90.     data - data to provide to the callback which is opaque to the robots.txt parser
  91.     freeData - if true, frees data (previous param) on completion
  92. */
  93. PR_EXTERN(PRBool) 
  94. CRAWL_ReadRobotControlFile(CRAWL_RobotControl control, CRAWL_RobotControlStatusFunc func, void *data, PRBool freeData);
  95.  
  96. /* Returns a status code indicating the robot directive for the url supplied */
  97. PR_EXTERN(CRAWL_RobotControlStatus) 
  98. CRAWL_GetRobotControl(CRAWL_RobotControl, char *url);
  99.  
  100. NSPR_END_EXTERN_C
  101.  
  102. #endif
  103.  
  104.