예제 #1
0
void test5 (void)
{
  void * c = bless (WClient, makeS("127.0.0.1"), 8080, makeS ("warcserver"));

fprintf(stdout,"\n////////// test 5//////////\n");  
CU_ASSERT_PTR_NOT_EQUAL(c,NIL);

  if (WClient_getList (c, 0, makeS("cwarc.warc.gz"), makeS ("html"),
                        uS("./out51.html")))
     {
     CU_FAIL   ( "request not satisfied");
     }
  else
   CU_PASS ("request satisfied");

  if (WClient_getList (c, 0, makeS("cwarc.warc.gz"), makeS ("xml"),
                        uS("./out52.xml")))
     {
     CU_FAIL   ( "request not satisfied");
     }
  else
   CU_PASS ("request satisfied");

  if (WClient_getList (c, 0, makeS("cwarc.warc.gz"), makeS ("text"),
                        uS("./out53.txt")))
     {
     CU_FAIL   ( "request not satisfied");
     }
  else
   CU_PASS ("request satisfied");

  if (WClient_getList (c, 0, makeS("cwarc.warc.gz"), makeS ("json"),
                        uS("./out5.json")))
     {
     CU_FAIL   ( "request not satisfied");
     }
  else
   CU_PASS ("request satisfied");

  destroy (c);

}
예제 #2
0
void test2 (void)
{
  void * c = bless (WClient, makeS("127.0.0.1"), 8080, makeS ("warcserver"));
fprintf(stdout,"\n////////// test 2//////////\n");  
CU_ASSERT_PTR_NOT_EQUAL(c,NIL);

  if (WClient_getWFile (c, 0, makeS("cwarc.warc.gz"),
                        uS("./out2.warc.gz")))
     {
     CU_FAIL   ( "request not satisfied");
     }
  else
   CU_PASS ("request satisfied");
  destroy (c);

}
예제 #3
0
void test4 (void)
{

  void * c = bless (WClient, makeS("127.0.0.1"), 8080, makeS ("warcserver"));
fprintf(stdout,"\n////////// test 4//////////\n");
  CU_ASSERT_PTR_NOT_EQUAL(c,NIL);
  if (WClient_getFiltredWFile (c, 0, makeS ("recordtype"), makeS ("warcinfo"), makeS("ero1.warc"),
                        uS("./out4.warc")))
              
  {
   fprintf (stdout, "--------------\n");
   CU_FAIL   ( "request not satisfied");
  }
  else CU_PASS ("request satisfied");
  destroy (c);
  
}
예제 #4
0
파일: arc2warc.c 프로젝트: db48x/wget-warc
int main (int argc, const char ** argv)
{
  void           * p        = NIL; /* WGetOpt object */
  void           * a        = NIL; /* an ARC file object */
  void           * w        = NIL; /* a WARC file object */
  void           * u        = NIL; /* a UUID object */
  char           * aname    = NIL;
  afile_comp_t     amode    = ARC_FILE_DETECT_COMPRESSION;
  warc_bool_t      b        = WARC_FALSE;
  warc_i32_t       c        = 0;
  warc_u8_t      * flags    = uS ("ca:f:t:");
  char           * fname    = NIL;
  char           * wdir     = ".";
  wfile_comp_t     cmode    = WARC_FILE_UNCOMPRESSED;


  if (argc < 5 || argc > 9)
    {
      fprintf (stderr, "ARC to WARC convertor\n");
      fprintf (stderr, "Usage: %s -a <file.arc> -f <file.warc> [-c] [-t <working_dir>]\n",
               argv [0]);
      fprintf (stderr, "\t-a    : valid ARC file name\n");
      fprintf (stderr, "\t-f    : valid WARC file name\n");
      fprintf (stderr, "\t[-c]  : WARC file will be GZIP compressed (default no)\n");
      fprintf (stderr, "\t[-t]  : temporary working directory (default \".\")\n");
      return (2);
    }

  p = bless (WGetOpt, makeS (flags) );

  assert (p);

  /* parse command line parameters */

  while ( (c = WGetOpt_parse (p, argc, argv) ) != -1)
    {
      switch (c)
        {
          case 'f' :

            if (w_index (flags, c) [1] == ':')
              fname = WGetOpt_argument (p);

            break;

          case 'c' :
            cmode = WARC_FILE_COMPRESSED_GZIP;

            break;

          case 'a' :
            if (w_index (flags, c) [1] == ':')
              aname = WGetOpt_argument (p);

            break;

          case 't' :

            if (w_index (flags, c) [1] == ':')
              wdir = WGetOpt_argument (p);

            break;

          case '?' :  /* illegal option or missing argument */
            destroy (p);

            return (1);
        }
    }

  unless (aname)
  {
    fprintf (stderr, "missing ARC file name. Use -a option\n");
    destroy (p);
    return (1);
  }

  unless (fname)
  {
    fprintf (stderr, "missing WARC file name. Use -f option\n");
    destroy (p);
    return (1);
  }


  /* open an existing ARC file */
  a = bless (AFile, aname, amode, wdir);
  unless (a)
  {
    fprintf (stderr, "unable to create the Arc object\n");
    free_p;
    return (2);
  }

  /* open or create a WARC file */
  w = bless (WFile, fname, WARC_MAX_SIZE, 
             WARC_FILE_WRITER, cmode, wdir);
  unless (w)
  {
    fprintf (stderr, "unable to create the Warc object\n");
    free_p;
    free_a;
    return (3);
  }

  /* create a UUID object */
  u = bless (WUUID);
  unless (u)
  {
    fprintf (stderr, "unable to create a UUID object\n");
    free_p;
    free_w;
    free_a;
    return (4);
  }


  /* loop over all ARC records */

  while (AFile_hasMoreRecords (a) )
    {
      void * ar   = AFile_nextRecord (a);
      void * wr   = NIL;

      /* check the next ARC record */
      unless (ar)
      {
        fprintf (stderr, "corrupted ARC\n");
        free_err_out ( 5);
      }

      /* create an empty WARC record */
      wr = bless (WRecord);
      unless (wr)
      {
        fprintf (stderr, "unable to create the WARC record object\n");
        free_ar;
        free_err_out (6);
      }

      /* set the subject URI */
      b = WRecord_setTargetUri  (wr, makeS (ARecord_getUrl (ar) ) );

      if (b)
        free_err (7);

      /* set the record tyep */
      b = WRecord_setRecordType  (wr, WARC_RESPONSE_RECORD);

      if (b)
        free_err (8);


      /* set the creation date */
      b = WRecord_setDateFromArc (wr, makeS (ARecord_getCreationDate (ar) ) );

      if (b)
        free_err (9);

      /* set the content type */
      b = WRecord_setContentType  (wr, makeS (ARecord_getMimeType (ar) ) );

      if (b)
        free_err (10);

      /* Create a UUID (Universal Unique IDentifier) based on URL + Timestamp */
      WUUID_hash (u, makeU (ARecord_getUrl (ar) ) );

      WUUID_hash (u, makeU (ARecord_getCreationDate (ar) ) );

      b = WRecord_setRecordId (wr, makeS (WUUID_text (u) ) );

      if (b)
        free_err (11);

      WUUID_reinit (u); /* re-initialize the UUID object */

      /* add the ARC IP as an Anvl */
      b = WRecord_setIpAddress (wr, makeS (ARecord_getIpAddress (ar) ) );

      if (b)
        free_err (12);

      /* move the ARC record payload to the WARC record */
      b = ARecord_transferContent (ar, wr, a);

      if (b)
        free_err (13);

      /* save the WARC record into the WARC file */
      b = WFile_storeRecord (w, wr, NIL);

      if (b)
        free_err (14);

      /* free the ARC and the WARC records */
      free_in;

    } /* end of while */

  /* free the ARC and the WARC files */
  free_out;

  return (0);
}
예제 #5
0
파일: hp3000_clk.c 프로젝트: pkoning2/simh

#include "hp3000_defs.h"
#include "hp3000_io.h"



/* Program constants */

#define CLK_MULTIPLIER      10                          /* number of MPE clock ticks per service */
#define CLK_RATE            (1000 / CLK_MULTIPLIER)     /* MPE clock rate in ticks per second */


static const int32 delay [8] = {                /* clock delays, in event ticks per interval */
    0,                                          /*   000 = unused */
    uS (10),                                    /*   001 = 10 microseconds */
    uS (100),                                   /*   010 = 100 microseconds */
    mS (1),                                     /*   011 = 1 millisecond */
    mS (10),                                    /*   100 = 10 milliseconds */
    mS (100),                                   /*   101 = 100 milliseconds */
    S (1),                                      /*   110 = 1 second */
    S (10),                                     /*   111 = 10 seconds */
    };

static const int32 ticks [8] = {                /* clock ticks per second */
    0,                                          /*   000 = unused */
    100000,                                     /*   001 = 10 microseconds */
    10000,                                      /*   010 = 100 microseconds */
    1000,                                       /*   011 = 1 millisecond */
    100,                                        /*   100 = 10 milliseconds */
    10,                                         /*   101 = 100 milliseconds */