示例#1
0
文件: error.c 项目: skypjack/univ
void
error (const char *message)
{
  error_handler(-1, "ERROR", message);
}
/*---------------------------------------------------------------------------
 *
 *--------------------------------------------------------------------------*/
int 
scsi_init(char *devname) 
{
  char *inq_buf;

#ifdef DIXTRAC_LINUX_SG

#ifdef SG_NONBLOCKING
  int ictl_val;
#endif

#ifdef SG_NONBLOCKING
  int fd = open(devname, O_RDWR | O_NONBLOCK);
#else
  int fd = open(devname, O_RDWR);
#endif

  if (fd < 0) {
    error_handler("Device %s not defined or no R/W permmissions.\n",devname);
  }
#ifdef SG_NONBLOCKING
  ictl_val = 1;
  if ( 0 > ioctl(fd,SG_SET_COMMAND_Q,&ictl_val)) {
    if (errno == ENOTTY)
      ictl_val = 0;
    else
      error_handler("Problems with ioctl on device %s \n",devname);
  }
/*  #ifndef SILENT */
#if 0
  printf("Command queueing%s allowed.\n",(ictl_val == 1 ? "" : " not"));
#endif
  ictl_val = 0;
/*  if ( 0 > ioctl(fd,SG_SET_FORCE_PACK_ID,&ictl_val)) {
    error_handler("Could not set FORCE_PACK_ID  on device %s \n",devname);
  } */
  ictl_val = BIG_BUF_SIZE;
  if ( 0 > ioctl(fd,SG_SET_RESERVED_SIZE,&ictl_val)) {
    error_handler("Problems with ioctl on device %s!\n",devname);
  }
  ioctl(fd,SG_GET_RESERVED_SIZE,&ictl_val);
/*  #ifndef SILENT */
#if 0
  fprintf(stderr, "*** The size of the RESERVED kernel buffer: %d\n",ictl_val);
  /*  ioctl(fd,SG_GET_SG_TABLESIZE,&ictl_val); */
  /*  printf("TABLESIZE: %d\n",ictl_val); */
#endif

#endif

#ifdef STATE_THREADS
  if (st_init()) {
    error_handler("Problems with st_init!\n");
  }
  
  if (!(scsidev_fd = st_netfd_open(fd))) {
    error_handler("Opening sthread fd failed\n", devname);
  }
#else
  scsidev_fd = fd;
#endif

/* DIXTRAC_LINUX_SG */
#endif

#ifdef DIXTRAC_FREEBSD_CAM
  if (cam_open_pass(devname, O_RDWR, &cam_device) == NULL) {
    error_handler("Opening pass device (%s) failed\n", devname);
  }
#endif

  inq_buf = scsi_alloc_buffer();
  /* get_scsi_version */
  send_scsi_command(inq_buf, SCSI_inq_command(),0);
  recv_scsi_command(inq_buf);
  scsi_version = ((u_int8_t) inq_buf[2]);

  /* get the device block size (not all disks use 512-byte sector) */
  exec_scsi_command(inq_buf,SCSI_read_capacity(0,0));
  /* this is a global that is accessed through te SECT_SIZE macro */
  blksize = _4btol((u_int8_t *) &inq_buf[4]);
  return(0);

}
/******************************************************************************
MODULE:  convert_espa_to_gtif

PURPOSE: Converts the internal ESPA raw binary file to GeoTIFF file format.

RETURN VALUE:
Type = int
Value           Description
-----           -----------
ERROR           Error converting to GeoTIFF
SUCCESS         Successfully converted to GeoTIFF

HISTORY:
Date         Programmer       Reason
----------   --------------   -------------------------------------
1/9/2014     Gail Schmidt     Original development
4/2/2014     Gail Schmidt     Added support for a flag to delete the source
                              .img and .hdr files
4/3/2014     Gail Schmidt     Remove the .xml file as well if source files are
                              specified to be deleted
4/30/2014    Gail Schmidt     Remove the .tif.aux.xml files that were created
                              by GDAL in the conversion to GeoTIFF

NOTES:
  1. The GDAL tools will be used for converting the raw binary (ENVI format)
     files to GeoTIFF.
  2. An associated .tfw (ESRI world file) will be generated for each GeoTIFF
     file.
******************************************************************************/
int convert_espa_to_gtif
(
    char *espa_xml_file,   /* I: input ESPA XML metadata filename */
    char *gtif_file,       /* I: base output GeoTIFF filename */
    bool del_src           /* I: should the source files be removed after
                                 conversion? */
)
{
    char FUNC_NAME[] = "convert_espa_to_gtif";  /* function name */
    char errmsg[STR_SIZE];      /* error message */
    char gdal_cmd[STR_SIZE];    /* command string for GDAL call */
    char gtif_band[STR_SIZE];   /* name of the GeoTIFF file for this band */
    char hdr_file[STR_SIZE];    /* name of the header file for this band */
    char xml_file[STR_SIZE];    /* new XML file for the GeoTIFF product */
    char tmpfile[STR_SIZE];     /* filename of file.tif.aux.xml */
    char *cptr = NULL;          /* pointer to empty space in the band name */
    int i;                      /* looping variable for each band */
    int count;                  /* number of chars copied in snprintf */
    Espa_internal_meta_t xml_metadata;  /* XML metadata structure to be
                                   populated by reading the XML metadata file */

    /* Validate the input metadata file */
    if (validate_xml_file (espa_xml_file) != SUCCESS)
    {  /* Error messages already written */
        return (ERROR);
    }

    /* Initialize the metadata structure */
    init_metadata_struct (&xml_metadata);

    /* Parse the metadata file into our internal metadata structure; also
       allocates space as needed for various pointers in the global and band
       metadata */
    if (parse_metadata (espa_xml_file, &xml_metadata) != SUCCESS)
    {  /* Error messages already written */
        return (ERROR);
    }

    /* Loop through the bands in the XML file and convert them to GeoTIFF.
       The filenames will have the GeoTIFF base name followed by _ and the
       band name of each band in the XML file.  Blank spaced in the band name
       will be replaced with underscores. */
    for (i = 0; i < xml_metadata.nbands; i++)
    {
        /* Determine the output GeoTIFF band name */
        count = snprintf (gtif_band, sizeof (gtif_band), "%s_%s.tif",
            gtif_file, xml_metadata.band[i].name);
        if (count < 0 || count >= sizeof (gtif_band))
        {
            sprintf (errmsg, "Overflow of gtif_file string");
            error_handler (true, FUNC_NAME, errmsg);
            return (ERROR);
        }

        /* Loop through this filename and replace any occurances of blank
           spaces with underscores */
        while ((cptr = strchr (gtif_band, ' ')) != NULL)
            *cptr = '_';

        /* Convert the files */
        printf ("Converting %s to %s\n", xml_metadata.band[i].file_name,
            gtif_band);
        count = snprintf (gdal_cmd, sizeof (gdal_cmd),
            "gdal_translate -of Gtiff -a_nodata %ld -co \"TFW=YES\" -q %s %s",
            xml_metadata.band[i].fill_value, xml_metadata.band[i].file_name,
            gtif_band);
        if (count < 0 || count >= sizeof (gdal_cmd))
        {
            sprintf (errmsg, "Overflow of gdal_cmd string");
            error_handler (true, FUNC_NAME, errmsg);
            return (ERROR);
        }

        if (system (gdal_cmd) == -1)
        {
            sprintf (errmsg, "Running gdal_translate: %s", gdal_cmd);
            error_handler (true, FUNC_NAME, errmsg);
            return (ERROR);
        }

        /* Remove the {gtif_name}.tif.aux.xml file since it's not needed and
           clutters the results.  Don't worry about testing the unlink
           results.  If it doesn't unlink it's not fatal. */
        count = snprintf (tmpfile, sizeof (tmpfile), "%s.aux.xml", gtif_band);
        if (count < 0 || count >= sizeof (tmpfile))
        {
            sprintf (errmsg, "Overflow of tmpfile string");
            error_handler (true, FUNC_NAME, errmsg);
            return (ERROR);
        }
        unlink (tmpfile);

        /* Remove the source file if specified */
        if (del_src)
        {
            /* .img file */
            printf ("  Removing %s\n", xml_metadata.band[i].file_name);
            if (unlink (xml_metadata.band[i].file_name) != 0)
            {
                sprintf (errmsg, "Deleting source file: %s",
                    xml_metadata.band[i].file_name);
                error_handler (true, FUNC_NAME, errmsg);
                return (ERROR);
            }

            /* .hdr file */
            count = snprintf (hdr_file, sizeof (hdr_file), "%s",
                xml_metadata.band[i].file_name);
            if (count < 0 || count >= sizeof (hdr_file))
            {
                sprintf (errmsg, "Overflow of hdr_file string");
                error_handler (true, FUNC_NAME, errmsg);
                return (ERROR);
            }

            cptr = strrchr (hdr_file, '.');
            strcpy (cptr, ".hdr");
            printf ("  Removing %s\n", hdr_file);
            if (unlink (hdr_file) != 0)
            {
                sprintf (errmsg, "Deleting source file: %s", hdr_file);
                error_handler (true, FUNC_NAME, errmsg);
                return (ERROR);
            }
        }

        /* Update the XML file to use the new GeoTIFF band name */
        strcpy (xml_metadata.band[i].file_name, gtif_band);
    }

    /* Remove the source XML if specified */
    if (del_src)
    {
        printf ("  Removing %s\n", espa_xml_file);
        if (unlink (espa_xml_file) != 0)
        {
            sprintf (errmsg, "Deleting source file: %s", espa_xml_file);
            error_handler (true, FUNC_NAME, errmsg);
            return (ERROR);
        }
    }

    /* Create the XML file for the GeoTIFF product */
    count = snprintf (xml_file, sizeof (xml_file), "%s_gtif.xml", gtif_file);
    if (count < 0 || count >= sizeof (xml_file))
    {
        sprintf (errmsg, "Overflow of xml_file string");
        error_handler (true, FUNC_NAME, errmsg);
        return (ERROR);
    }

    /* Write the new XML file containing the GeoTIFF band names */
    if (write_metadata (&xml_metadata, xml_file) != SUCCESS)
    {
        sprintf (errmsg, "Error writing updated XML for the GeoTIFF product: "
            "%s", xml_file);
        error_handler (true, FUNC_NAME, errmsg);
        return (ERROR);
    }

    /* Free the metadata structure */
    free_metadata (&xml_metadata);

    /* Successful conversion */
    return (SUCCESS);
}
示例#4
0
/**
 * Transaction 5 - T5
 * 
 * Delete session
 *
 * Input:
 *   SubscriberNumber
 *   ServerId
 *   ServerBit
 *   DoRollback
 * Output:
 *   ChangedBy
 *   ChangedTime
 *   Location
 *   BranchExecuted
 */
int
T5(void * obj,
   const SubscriberNumber   inNumber,
   const SubscriberSuffix   inSuffix,
   const ServerId           inServerId,
   const ServerBit          inServerBit,
   ChangedBy          outChangedBy,
   ChangedTime        outChangedTime,
   Location         * outLocation,
   DoRollback         inDoRollback,
   BranchExecuted   * outBranchExecuted,
   BenchmarkTime    * outTransactionTime){
  
  Ndb           * pNDB = (Ndb *) obj;  
  NdbConnection * MyTransaction = 0;
  NdbOperation  * MyOperation = 0;

  GroupId        groupId;
  ActiveSessions sessions;
  Permission     permission;

  BenchmarkTime start;
  get_time(&start);

  int check;
  NdbRecAttr * check2;

  MyTransaction = pNDB->startTransaction();
  if (MyTransaction == NULL)	  
    error_handler("T5-1: startTranscation", pNDB->getNdbErrorString(), 0);

  MyOperation= MyTransaction->getNdbOperation(SUBSCRIBER_TABLE);
  CHECK_NULL(MyOperation, "T5-1: getNdbOperation", 
	     MyTransaction);
  
  
  check = MyOperation->readTupleExclusive();
  CHECK_MINUS_ONE(check, "T5-1: readTuple", 
		  MyTransaction);
  
  check = MyOperation->equal(IND_SUBSCRIBER_NUMBER, 
			     inNumber);
  CHECK_MINUS_ONE(check, "T5-1: equal subscriber",
		  MyTransaction);

  check2 = MyOperation->getValue(IND_SUBSCRIBER_LOCATION, 
				 (char *)outLocation);
  CHECK_NULL(check2, "T5-1: getValue location", 
	     MyTransaction);

  check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY, 
				 outChangedBy);
  CHECK_NULL(check2, "T5-1: getValue changed_by", 
	     MyTransaction);

  check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME, 
                                 outChangedTime);
  CHECK_NULL(check2, "T5-1: getValue changed_time",
	     MyTransaction);

  check2 = MyOperation->getValue(IND_SUBSCRIBER_GROUP,
				 (char *)&groupId);
  CHECK_NULL(check2, "T5-1: getValue group", 
	     MyTransaction);

  check2 = MyOperation->getValue(IND_SUBSCRIBER_SESSIONS,
				 (char *)&sessions);
  CHECK_NULL(check2, "T5-1: getValue sessions", 
	     MyTransaction);
  
  check = MyTransaction->execute( NoCommit ); 
  CHECK_MINUS_ONE(check, "T5-1: NoCommit", 
		  MyTransaction);
  
    /* Operation 2 */

  MyOperation = MyTransaction->getNdbOperation(GROUP_TABLE);
  CHECK_NULL(MyOperation, "T5-2: getNdbOperation", 
	     MyTransaction);
  
  
  check = MyOperation->readTuple();
  CHECK_MINUS_ONE(check, "T5-2: readTuple", 
		  MyTransaction);
  
  check = MyOperation->equal(IND_GROUP_ID,
		     (char*)&groupId);
  CHECK_MINUS_ONE(check, "T5-2: equal group",
		  MyTransaction);
  
  check2 = MyOperation->getValue(IND_GROUP_ALLOW_DELETE, 
				 (char *)&permission);
  CHECK_NULL(check2, "T5-2: getValue allow_delete", 
	     MyTransaction);
  
  check = MyTransaction->execute( NoCommit ); 
  CHECK_MINUS_ONE(check, "T5-2: NoCommit", 
		  MyTransaction);
  
  DEBUG3("T5(%.*s, %.2d): ", SUBSCRIBER_NUMBER_LENGTH, inNumber, inServerId);

  if(((permission & inServerBit) == inServerBit) &&
     ((sessions   & inServerBit) == inServerBit)){
  
    DEBUG("deleting - ");
  
    /* Operation 3 */
    MyOperation = MyTransaction->getNdbOperation(SESSION_TABLE);
    CHECK_NULL(MyOperation, "T5-3: getNdbOperation", 
	       MyTransaction);
    
    check = MyOperation->deleteTuple();
    CHECK_MINUS_ONE(check, "T5-3: deleteTuple", 
		    MyTransaction);
    
    check = MyOperation->equal(IND_SESSION_SUBSCRIBER,
			       (char*)inNumber);
    CHECK_MINUS_ONE(check, "T5-3: equal number",
		    MyTransaction);

    check = MyOperation->equal(IND_SESSION_SERVER,
			       (char*)&inServerId);
    CHECK_MINUS_ONE(check, "T5-3: equal server id",
		    MyTransaction);
    
    check = MyTransaction->execute( NoCommit ); 
    CHECK_MINUS_ONE(check, "T5-3: NoCommit", 
		    MyTransaction);

    /* Operation 4 */
    MyOperation = MyTransaction->getNdbOperation(SUBSCRIBER_TABLE);
    CHECK_NULL(MyOperation, "T5-4: getNdbOperation", 
	       MyTransaction);
    
    check = MyOperation->interpretedUpdateTuple();
    CHECK_MINUS_ONE(check, "T5-4: interpretedUpdateTuple", 
		    MyTransaction);
    
    check = MyOperation->equal(IND_SUBSCRIBER_NUMBER,
			       (char*)inNumber);
    CHECK_MINUS_ONE(check, "T5-4: equal number",
		    MyTransaction);

    check = MyOperation->subValue(IND_SUBSCRIBER_SESSIONS, 
				  (uint32)inServerBit);
    CHECK_MINUS_ONE(check, "T5-4: dec value",
		    MyTransaction);
        
    check = MyTransaction->execute( NoCommit ); 
    CHECK_MINUS_ONE(check, "T5-4: NoCommit", 
		    MyTransaction);

    /* Operation 5 */
    MyOperation = MyTransaction->getNdbOperation(SERVER_TABLE);
    CHECK_NULL(MyOperation, "T5-5: getNdbOperation", 
	       MyTransaction);
    
    
    check = MyOperation->interpretedUpdateTuple();
    CHECK_MINUS_ONE(check, "T5-5: interpretedUpdateTuple", 
		    MyTransaction);
    
    check = MyOperation->equal(IND_SERVER_ID,
			       (char*)&inServerId);
    CHECK_MINUS_ONE(check, "T5-5: equal serverId",
		    MyTransaction);

    check = MyOperation->equal(IND_SERVER_SUBSCRIBER_SUFFIX,
			       (char*)inSuffix);
    CHECK_MINUS_ONE(check, "T5-5: equal suffix",
		    MyTransaction);

    check = MyOperation->incValue(IND_SERVER_DELETES, (uint32)1);
    CHECK_MINUS_ONE(check, "T5-5: inc value",
		    MyTransaction);

    check = MyTransaction->execute( NoCommit ); 
    CHECK_MINUS_ONE(check, "T5-5: NoCommit", 
		    MyTransaction);

    (* outBranchExecuted) = 1;
  } else {
    DEBUG1("%s", ((permission & inServerBit) ? "permission - " : "no permission - "));
    DEBUG1("%s", ((sessions   & inServerBit) ? "in session - " : "no in session - "));
    (* outBranchExecuted) = 0;
  }

  if(!inDoRollback){
    DEBUG("commit\n");
    check = MyTransaction->execute( Commit ); 
    CHECK_MINUS_ONE(check, "T5: Commit", 
		    MyTransaction);
  } else {
    DEBUG("rollback\n");
    check = MyTransaction->execute(Rollback);
    CHECK_MINUS_ONE(check, "T5:Rollback", 
		    MyTransaction);
    
  }
  
  pNDB->closeTransaction(MyTransaction);
  
  get_time(outTransactionTime);
  time_diff(outTransactionTime, &start);
  return 0;
}
示例#5
0
/* pdf_createfilter
 * ----------------
 * Call this to create a new filter (of a certain type), on top of an
 * underlying file.
 *
 * Pass the underlying file object in "file".
 *
 * Pass the name of the desired filter-type in "name".
 *
 * Pass filter-creation arguments in the "args" dictionary.
 * This dictionary gets saved in theIParamDict of the returned flptr.
 *
 * Pass whether the close source/target flag should be set (for
 * non-StreamDecode filters) in the "cst" flag.
 *
 * Returns:
 * The return value is a boolean indicating success/failure. "file" is updated
 * with the new filter id and filelist.
 *
 * The filter created is in the pdf world, attached to the pdf context
 * with a corresponding lifetime -- it is not affected by save/restore.
 *
 * **** Note: Used for PDF Out as well as PDF input ***
 */
Bool pdf_createfilter( PDFCONTEXT *pdfc , OBJECT *file ,
                       OBJECT *name , OBJECT *args , int32 cst )
{
  int32 name_length ;
  int32 find_error ;
  uint8 *filter_name ;
  NAMECACHE *nptr ;
  FILELIST *flptr ;
  FILELIST *nflptr ;
  PDFXCONTEXT *pdfxc ;
  PDF_IXC_PARAMS *ixc ;
  OBJECT params_dict = OBJECT_NOTVM_NOTHING ;
  SFRAME myframe ;
  STACK mystack = { EMPTY_STACK, NULL, FRAMESIZE, STACK_TYPE_OPERAND } ;

  mystack.fptr = &myframe ;

  PDF_CHECK_MC( pdfc ) ;
  PDF_GET_XC( pdfxc ) ;
  PDF_GET_IXC( ixc ) ;

  HQASSERT(file, "no file object") ;
  HQASSERT( name , "name NULL in pdf_createfilter" ) ;
  HQASSERT( args , "args NULL in pdf_createfilter" ) ;

  HQASSERT( oType(*name) == ONAME , "bad OBJECT type in pdf_createfilter" ) ;
  nptr = oName(*name) ;

  /* handle possible abbreviations */
  switch ( theINameNumber(nptr) ) {
  case NAME_A85:
    nptr = system_names + NAME_ASCII85Decode;
    break;
  case NAME_AHx:
    nptr = system_names + NAME_ASCIIHexDecode;
    break;
  case NAME_CCF:
    nptr = system_names + NAME_CCITTFaxDecode;
    break;
  case NAME_DCT:
    nptr = system_names + NAME_DCTDecode;
    break;
  case NAME_Fl:
    nptr = system_names + NAME_FlateDecode;
    break;
  case NAME_LZW:
    nptr = system_names + NAME_LZWDecode;
    break;
  case NAME_RL:
    nptr = system_names + NAME_RunLengthDecode;
    break;
  }

  name_length = theINLen( nptr ) ;
  filter_name = theICList( nptr ) ;

  /* find the filter name in the external or standard filter table */
  nflptr = filter_external_find( filter_name, name_length,
                                  & find_error, TRUE ) ;
  if ( nflptr == NULL ) {
    if ( find_error != NOT_AN_ERROR)
      return error_handler( find_error );

    if ( NULL == ( nflptr = filter_standard_find( filter_name , name_length )))
      return error_handler( UNDEFINED ) ;
  }

  /* Sanity check. */
  HQASSERT(isIFilter(nflptr), "Not a filter") ;

  if ( isIInputFile( nflptr )) {
    if ( theINameNumber(nptr) == NAME_JPXDecode ) {
      /* JPXDecode can automatically layer an RSD underneath itself, but that
         RSD would be allocated from PostScript memory. To make sure that the
         RSD is allocated from PDF memory, we allocate it here. We force the
         cst flag TRUE on the JPXDecode, because the caller may not be
         expecting the RSD in the chain (this will make JPXDecode close the
         RSD, the RSD will close the underlying file if necessary). */
      OBJECT rsdname = OBJECT_NOTVM_NAME(NAME_ReusableStreamDecode, LITERAL) ;
      OBJECT rsdargs = OBJECT_NOTVM_NULL ;
      if ( !pdf_createfilter(pdfc, file, &rsdname, &rsdargs, cst) )
        return FALSE ;

      cst = TRUE ;
    } else if ( theINameNumber( nptr ) == NAME_FlateDecode ) {
      /* If we're creating a FlateDecode filter, add the
       * ErrorOnFlateChecksumFailure flag to the params.
       */
      OBJECT paramName = OBJECT_NOTVM_NAME(NAME_ErrorOnChecksumFailure, LITERAL) ;

      if ( oType(*args) != ODICTIONARY ) {
        /* The args object wasn't a dictionary - must be an ONULL
         * otherwise it doesn't make sense. Make a new dict - a length
         * of 4 should be enough to make sure it never needs to grow.
         */

        HQASSERT(oType(*args) == ONULL , "Expecting null args." ) ;

        if ( ! pdf_create_dictionary( pdfc , 4 , & params_dict ))
          return FALSE ;

        args = & params_dict ;
      }

      if ( ! pdf_fast_insert_hash( pdfc , args , & paramName ,
                                   pdfxc->ErrorOnFlateChecksumFailure ?
                                   & tnewobj : & fnewobj  ))
        return FALSE ;
    }
  }

  /* If we have an underlying file, put it on the stack for the init routine,
     and set the new filter id and file pointer for the return object. */
  if ( !push(file, &mystack) )
    return FALSE ;

  /* Provide an empty list to prevent the function scanning for a closed file -
   * for jobs with a very large number of pages the linear search can become
   * significant.
   */
  flptr = NULL;
  if ( !filter_create_with_alloc(nflptr, &flptr,
                                 args, &mystack, pdfxc->id,
                                 pdf_createfilter_alloc,
                                 pdfxc->mm_structure_pool) )
    return FALSE ;

  /* Add new filter to head of chain */
  flptr->next = pdfxc->streams;
  pdfxc->streams = flptr;

  /* promote streams to save level of pdf context */
  flptr->sid = CAST_UNSIGNED_TO_UINT8(pdfxc->savelevel) ;

  /* Only PDF Input filters are (initially at least) marked as rewindable */
  if ( isIInputFile( nflptr ))
    SetIRewindableFlag( flptr ) ;

  /* If cst is true set the "close source/target" flag. */
  if ( cst ) {
    HQASSERT( theINameNumber(nptr) != NAME_StreamDecode ,
              "Setting CST on a stream would mean the real file gets closed." ) ;
    SetICSTFlag( flptr ) ;
  }

  /* Prepare the return file object. The input file object's executability is
     retained. */
  file_store_object(file, flptr, CAST_UNSIGNED_TO_UINT8(oExec(*file))) ;

  /* We should be setting this on file close, but we don't have easy access to
     that, so use this file creation as a proxy. */
  pdfxc->lowmemRedoStreams = TRUE;

  return TRUE ;
}
示例#6
0
void index_matrix (char * mat_id, char * ind1_id, int ind1_val, MEMTYPE m1, char * ind2_id, int ind2_val, MEMTYPE m2, int is_assignment) {
	node * matsymb;
	node * refsymb;
	// make sure matrix exists in symbol table
	if ( (matsymb = lookup (sts, mat_id)) == NULL )
		error_handler (UNDECLARED_ID_ERROR, mat_id);
	// make sure we are indexing a matrix
	if ( matsymb->k != MATRIX )
		error_handler (NON_ARRAY_INDEX, NULL);
	// check for two result indices and switch stack order if so
	if (m1 == RESULT && m2 == RESULT) {
		fprintf (fp, "\tpopl\t%%ecx\n");
		fprintf (fp, "\tpopl\t%%ebx\n");
		fprintf (fp, "\tpushl\t%%ecx\n");
		fprintf (fp, "\tpushl\t%%ebx\n");
	}
	// handle two constant indices
	if (m1 == IMMEDIATE && m2 == IMMEDIATE) {
		if (is_assignment) {
			fprintf (fp, "\tmovl\t%d, %%eax\n", (matsymb->offset / 4) - (ind1_val * matsymb->plist->head->offset + ind2_val));
		} else {
			fprintf (fp, "\tpushl\t%d(%%ebp)\n", matsymb->offset - 4*(ind1_val * matsymb->plist->head->offset + ind2_val));
		}
		return;
	}
	// handle first index (multiply)
	fprintf (fp, "\tmovl\t$%d, %%ebx\n", matsymb->plist->head->offset);
	switch (m1) {
		case REFERENCE:
			// check for global or local ref
			refsymb = lookup (sts, ind1_id);
			if (refsymb->offset == 0) {
				fprintf (fp, "\timull\t%s, %%ebx\n", ind1_id);
			} else {
				fprintf (fp, "\timull\t%d(%%ebp), %%ebx\n", refsymb->offset);
			}
			break;
		case RESULT:
			fprintf (fp, "\tpopl\t%%ecx\n");
			fprintf (fp, "\timull\t%%ecx, %%ebx\n", ind1_id);
			break;
	}
	// handle second index (add)
	//   move array starting offset into register
	fprintf (fp, "\tmovl\t$%d, %%eax\n", matsymb->offset / 4);
	switch (m2) {
		case REFERENCE:
			// check for global or local ref
			refsymb = lookup (sts, ind2_id);
			if (refsymb->offset == 0) {
				fprintf (fp, "\taddl\t%s, %%ebx\n", ind2_id);
			} else {
				fprintf (fp, "\taddl\t%d(%%ebp), %%ebx\n", refsymb->offset);
			}
			break;
		case RESULT:
			fprintf (fp, "\tpopl\t%%ecx\n");
			fprintf (fp, "\taddl\t%%ecx, %%ebx\n");
			break;
	}
	// subtract total offset from start offset
	fprintf (fp, "\tsubl\t%%ebx, %%eax\n");
	// now push the correct index value
	if (!is_assignment)
		fprintf (fp, "\tpushl\t(%%ebp, %%eax, 4)\n");
}
示例#7
0
/**
 * Transaction 2 - T2
 *
 * Read from Subscriber:
 *
 * Input: 
 *   SubscriberNumber
 *
 * Output:
 *   Location
 *   Changed by
 *   Changed Timestamp
 *   Name
 */
int
T2(void * obj,
   const SubscriberNumber number, 
   Location * readLocation, 
   ChangedBy changed_by, 
   ChangedTime changed_time,
   SubscriberName subscriberName,
   BenchmarkTime * transaction_time){

  Ndb * pNDB = (Ndb *) obj;

  BenchmarkTime start;
  get_time(&start);

  int check;
  NdbRecAttr * check2;

  NdbConnection * MyTransaction = pNDB->startTransaction();
  if (MyTransaction == NULL)	  
    error_handler("T2: startTranscation", pNDB->getNdbErrorString(), 0);
  
  NdbOperation *MyOperation= MyTransaction->getNdbOperation(SUBSCRIBER_TABLE);
  CHECK_NULL(MyOperation, "T2: getNdbOperation", 
	     MyTransaction);
  
  
  check = MyOperation->readTuple();
  CHECK_MINUS_ONE(check, "T2: readTuple", 
		  MyTransaction);
  
  check = MyOperation->equal(IND_SUBSCRIBER_NUMBER, 
			     number);
  CHECK_MINUS_ONE(check, "T2: equal subscriber",
		  MyTransaction);

  check2 = MyOperation->getValue(IND_SUBSCRIBER_LOCATION, 
				(char *)readLocation);
  CHECK_NULL(check2, "T2: getValue location", 
	     MyTransaction);

  check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY, 
				 changed_by);
  CHECK_NULL(check2, "T2: getValue changed_by", 
	     MyTransaction);

  check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME, 
                                 changed_time);
  CHECK_NULL(check2, "T2: getValue changed_time",
	     MyTransaction);

  check2 = MyOperation->getValue(IND_SUBSCRIBER_NAME, 
				subscriberName);
  CHECK_NULL(check2, "T2: getValue name", 
	     MyTransaction);

  check = MyTransaction->execute( Commit ); 
  CHECK_MINUS_ONE(check, "T2: Commit", 
		  MyTransaction);
  
  pNDB->closeTransaction(MyTransaction);
  
  get_time(transaction_time);
  time_diff(transaction_time, &start);
  return 0;
}
示例#8
0
int decodeAACfile(char *sndfile, int def_srate, aac_dec_opt *opt)
{
    int tagsize;
    unsigned long samplerate;
    unsigned char channels;
    void *sample_buffer;

    FILE *infile;

    audio_file *aufile;

    NeAACDecHandle hDecoder;
    NeAACDecFrameInfo frameInfo;
    NeAACDecConfigurationPtr config;

    int first_time = 1;


    /* declare variables for buffering */
    DEC_BUFF_VARS

    infile = fopen(opt->filename, "rb");
    if (infile == NULL)
    {
        /* unable to open file */
        error_handler("Error opening file: %s\n", opt->filename);
        return 1;
    }
    INIT_BUFF(infile)

    tagsize = id3v2_tag(buffer);
    if (tagsize)
    {
        UPDATE_BUFF_SKIP(tagsize)
    }

    hDecoder = NeAACDecOpen();

    /* Set the default object type and samplerate */
    /* This is useful for RAW AAC files */
    config = NeAACDecGetCurrentConfiguration(hDecoder);
    if (def_srate)
        config->defSampleRate = def_srate;
    config->defObjectType = opt->object_type;
    config->outputFormat = opt->output_format;

    NeAACDecSetConfiguration(hDecoder, config);

    if ((bytesconsumed = NeAACDecInit(hDecoder, buffer, bytes_in_buffer,
        &samplerate, &channels)) < 0)
    {
        /* If some error initializing occured, skip the file */
        error_handler("Error initializing decoder library.\n");
        END_BUFF
        NeAACDecClose(hDecoder);
        fclose(infile);
        return 1;
    }
    buffer_index += bytesconsumed;

    do
    {
        /* update buffer */
        UPDATE_BUFF_READ

        sample_buffer = NeAACDecDecode(hDecoder, &frameInfo, buffer, bytes_in_buffer);

        /* update buffer indices */
        UPDATE_BUFF_IDX(frameInfo)

        if (frameInfo.error > 0)
        {
            error_handler("Error: %s\n",
            NeAACDecGetErrorMessage(frameInfo.error));
        }

        opt->progress_update((long)fileread, buffer_index);

        /* open the sound file now that the number of channels are known */
        if (first_time && !frameInfo.error)
        {
            if(opt->decode_mode == 0)
            {
                if (Set_WIN_Params (INVALID_FILEDESC, samplerate, SAMPLE_SIZE,
                                frameInfo.channels) < 0)
                {
                    error_handler("\nCan't access %s\n", "WAVE OUT");
                    END_BUFF
                    NeAACDecClose(hDecoder);
                    fclose(infile);
                    return (0);
                }
            }
            else
            {
                aufile = open_audio_file(sndfile, samplerate, frameInfo.channels,
                    opt->output_format, opt->file_type, aacChannelConfig2wavexChannelMask(&frameInfo));

                if (aufile == NULL)
                {
                    END_BUFF
                    NeAACDecClose(hDecoder);
                    fclose(infile);
                    return 0;
                }
            }
            first_time = 0;
        }

        if ((frameInfo.error == 0) && (frameInfo.samples > 0))
        {
            if(opt->decode_mode == 0)
                WIN_Play_Samples((short*)sample_buffer, frameInfo.channels*frameInfo.samples);
            else
                write_audio_file(aufile, sample_buffer, frameInfo.samples, 0);
        }

        if (buffer_index >= fileread)
            sample_buffer = NULL; /* to make sure it stops now */

        if(stop_decoding)
            break;

    } while (sample_buffer != NULL);

    NeAACDecClose(hDecoder);

    fclose(infile);

    if(opt->decode_mode == 0)
        WIN_Audio_close();
    else
    {
        if (!first_time)
            close_audio_file(aufile);
    }

    END_BUFF

    return frameInfo.error;
}
示例#9
0
int decodeMP4file(char *sndfile, aac_dec_opt *opt)
{
    int track;
    unsigned long samplerate;
    unsigned char channels;
    void *sample_buffer;

    mp4ff_t *infile;
    FILE *mp4File;
    int sampleId, numSamples;

    audio_file *aufile;

    NeAACDecHandle hDecoder;
    NeAACDecFrameInfo frameInfo;

    unsigned char *buffer;
    int buffer_size;

    int first_time = 1;

    /* initialise the callback structure */
    mp4ff_callback_t *mp4cb = malloc(sizeof(mp4ff_callback_t));

    mp4File = fopen(opt->filename, "rb");
    mp4cb->read = read_callback;
    mp4cb->seek = seek_callback;
    mp4cb->user_data = mp4File;

    infile = mp4ff_open_read(mp4cb);
    if (!infile)
    {
        /* unable to open file */
        error_handler("Error opening file: %s\n", opt->filename);
        return 1;
    }

    if ((track = GetAACTrack(infile)) < 0)
    {
        error_handler("Unable to find correct AAC sound track in the MP4 file.\n");
        mp4ff_close(infile);
        free(mp4cb);
        fclose(mp4File);
        return 1;
    }

    buffer = NULL;
    buffer_size = 0;
    mp4ff_get_decoder_config(infile, track, &buffer, &buffer_size);

    hDecoder = NeAACDecOpen();

    if(NeAACDecInit2(hDecoder, buffer, buffer_size, &samplerate, &channels) < 0)
    {
        /* If some error initializing occured, skip the file */
        error_handler("Error initializing decoder library.\n");
        NeAACDecClose(hDecoder);
        mp4ff_close(infile);
        free(mp4cb);
        fclose(mp4File);
        return 1;
    }
    if (buffer)
        free(buffer);

    numSamples = mp4ff_num_samples(infile, track);

    for (sampleId = 0; sampleId < numSamples; sampleId++)
    {
        int rc;

        /* get access unit from MP4 file */
        buffer = NULL;
        buffer_size = 0;

        rc = mp4ff_read_sample(infile, track, sampleId, &buffer, &buffer_size);
        if (rc == 0)
        {
            error_handler("Reading from MP4 file failed.\n");
            NeAACDecClose(hDecoder);
            mp4ff_close(infile);
            free(mp4cb);
            fclose(mp4File);
            return 1;
        }

        sample_buffer = NeAACDecDecode(hDecoder, &frameInfo, buffer, buffer_size);

        if (buffer)
            free(buffer);

        opt->progress_update((long)numSamples, sampleId);

        /* open the sound file now that the number of channels are known */
        if (first_time && !frameInfo.error)
        {
            if(opt->decode_mode == 0)
            {
                if (Set_WIN_Params (INVALID_FILEDESC, samplerate, SAMPLE_SIZE,
                                frameInfo.channels) < 0)
                {
                    error_handler("\nCan't access %s\n", "WAVE OUT");
                    NeAACDecClose(hDecoder);
                    mp4ff_close(infile);
                    free(mp4cb);
                    fclose(mp4File);
                    return (0);
                }
            }
            else
            {
                aufile = open_audio_file(sndfile, samplerate, frameInfo.channels,
                     opt->output_format, opt->file_type, aacChannelConfig2wavexChannelMask(&frameInfo));

                if (aufile == NULL)
                {
                    NeAACDecClose(hDecoder);
                    mp4ff_close(infile);
                    free(mp4cb);
                    fclose(mp4File);
                    return 0;
                }
            }
            first_time = 0;
        }

        if ((frameInfo.error == 0) && (frameInfo.samples > 0))
        {
            if(opt->decode_mode == 0)
                WIN_Play_Samples((short*)sample_buffer, frameInfo.channels*frameInfo.samples);
            else
                write_audio_file(aufile, sample_buffer, frameInfo.samples, 0);
        }

        if (frameInfo.error > 0)
        {
            error_handler("Error: %s\n",
            NeAACDecGetErrorMessage(frameInfo.error));
            break;
        }
        if(stop_decoding)
            break;
    }


    NeAACDecClose(hDecoder);


    mp4ff_close(infile);
    free(mp4cb);
    fclose(mp4File);

    if(opt->decode_mode == 0)
        WIN_Audio_close();
    else
    {
        if (!first_time)
            close_audio_file(aufile);
    }

    return frameInfo.error;
}
示例#10
0
int decodeMP4file(char *sndfile, aac_dec_opt *opt)
{
    int track;
    unsigned long samplerate;
    unsigned char channels;
    void *sample_buffer;

    MP4FileHandle infile;
    MP4SampleId sampleId, numSamples;

    audio_file *aufile;

    faacDecHandle hDecoder;
    faacDecFrameInfo frameInfo;

    unsigned char *buffer;
    int buffer_size;

    int first_time = 1;

    hDecoder = faacDecOpen();

    infile = MP4Read(opt->filename, 0);
    if (!infile)
    {
        /* unable to open file */
        error_handler("Error opening file: %s\n", opt->filename);
        return 1;
    }

    if ((track = GetAACTrack(infile)) < 0)
    {
        error_handler("Unable to find correct AAC sound track in the MP4 file.\n");
        MP4Close(infile);
        return 1;
    }

    buffer = NULL;
    buffer_size = 0;
    MP4GetTrackESConfiguration(infile, track, &buffer, &buffer_size);

    if(faacDecInit2(hDecoder, buffer, buffer_size, &samplerate, &channels) < 0)
    {
        /* If some error initializing occured, skip the file */
        error_handler("Error initializing decoder library.\n");
        faacDecClose(hDecoder);
        MP4Close(infile);
        return 1;
    }
    if (buffer)
        free(buffer);

    numSamples = MP4GetTrackNumberOfSamples(infile, track);

    for (sampleId = 1; sampleId <= numSamples; sampleId++)
    {
        int rc;

        /* get access unit from MP4 file */
        buffer = NULL;
        buffer_size = 0;

        rc = MP4ReadSample(infile, track, sampleId, &buffer, &buffer_size, NULL, NULL, NULL, NULL);
        if (rc == 0)
        {
            error_handler("Reading from MP4 file failed.\n");
            faacDecClose(hDecoder);
            MP4Close(infile);
            return 1;
        }

        sample_buffer = faacDecDecode(hDecoder, &frameInfo, buffer, buffer_size);

        if (buffer)
            free(buffer);

        opt->progress_update((long)numSamples, sampleId);

        /* open the sound file now that the number of channels are known */
        if (first_time && !frameInfo.error)
        {
            if(opt->decode_mode == 0)
            {
                if (Set_WIN_Params (INVALID_FILEDESC, samplerate, SAMPLE_SIZE,
                                frameInfo.channels) < 0)
                {
                    error_handler("\nCan't access %s\n", "WAVE OUT");
                    faacDecClose(hDecoder);
                    MP4Close(infile);
                    return (0);
                }
            }
            else
            {
                aufile = open_audio_file(sndfile, samplerate, frameInfo.channels,
                     opt->output_format, opt->file_type, aacChannelConfig2wavexChannelMask(&frameInfo));

                if (aufile == NULL)
                {
                    faacDecClose(hDecoder);
                    MP4Close(infile);
                    return 0;
                }
            }
            first_time = 0;
        }

        if ((frameInfo.error == 0) && (frameInfo.samples > 0))
        {
            if(opt->decode_mode == 0)
                WIN_Play_Samples((short*)sample_buffer, frameInfo.channels*frameInfo.samples);
            else
                write_audio_file(aufile, sample_buffer, frameInfo.samples, 0);
        }

        if (frameInfo.error > 0)
        {
            error_handler("Error: %s\n",
            faacDecGetErrorMessage(frameInfo.error));
            break;
        }
        if(stop_decoding)
            break;
    }


    faacDecClose(hDecoder);


    MP4Close(infile);

    if(opt->decode_mode == 0)
        WIN_Audio_close();
    else
    {
        if (!first_time)
            close_audio_file(aufile);
    }

    return frameInfo.error;
}
示例#11
0
/******************************************************************************
MODULE:  write_envi_hdr

PURPOSE:  Writes the ENVI header to the specified file using the input info
provided.

RETURN VALUE:
Type = int
Value           Description
-----           -----------
-1              An error occurred generating the header file
0               Header file was successful

PROJECT:  Land Satellites Data System Science Research and Development (LSRD)
at the USGS EROS

HISTORY:
Date        Programmer       Reason
--------    ---------------  -------------------------------------
2/8/2013    Gail Schmidt     Original Development
5/14/2013   Song Guo         Modified to support CFmask
7/15/2013   Song Guo         Added to support HDF hdr file which
                             includes map info

NOTES:
  1. It's assumed the header file will be for unsigned byte products and
     therefore an ENVI data type of 1.
******************************************************************************/
int write_envi_hdr
(
    char *hdr_file,        /* I: name of header file to be generated */
    File_type ftype,       /* I: HDF or Binary header is needed */
    Input_t *input,        /* I: input structure for cfmask products */
    Space_def_t *space_def /* I: spatial definition information */
)
{
    char FUNC_NAME[] = "write_envi_hdr";   /* function name */
    char errmsg[STR_SIZE];   /* error message */
    char *bin_file=NULL;     /* name of raw binary file */
    FILE *hdr_fptr=NULL;     /* file pointer to the ENVI header file */

    /* Open the header file */
    hdr_fptr = fopen (hdr_file, "w");
    if (hdr_fptr == NULL)
    {
        sprintf (errmsg, "Error opening %s for write access.", hdr_file);
        error_handler (true, FUNC_NAME, errmsg);
        return (-1);
    }

    /* Verify the projection is UTM or PS and sphere is WGS-84 */
    if (space_def->proj_num != GCTP_UTM_PROJ &&
        space_def->proj_num != GCTP_PS_PROJ)
    {
        sprintf (errmsg, "Error UTM projection code (%d) or PS projection "
            "code (%d) expected.", GCTP_UTM_PROJ, GCTP_PS_PROJ);
        error_handler (true, FUNC_NAME, errmsg);
        return (-1);
    }

    if (space_def->sphere != 12)
    {
        sprintf (errmsg, "Error WGS-84 sphere code (12) expected.");
        error_handler (true, FUNC_NAME, errmsg);
        return (-1);
    }

    /* Create the name of the associated raw binary file by replacing the
       .hdr of the header filename with .bin for the output binary file */
    bin_file = strdup (hdr_file);
    strncpy (&bin_file[strlen(hdr_file)-3], "bin", 3);

    /* Write the header to the file */
    if (ftype == HDF_FILE)
    {
        fprintf (hdr_fptr,
            "ENVI\n"
            "description = {%s}\n"
            "samples = %d\n"
            "lines   = %d\n"
            "bands   = 1\n"
            "header offset = 0\n"
            "file type = HDF Scientific Data\n"
            "data type = 1\n"
            "interleave = bsq\n"
            "byte order = 0\n", hdr_file, input->size.s, input->size.l);
    }
    else 
    {
        fprintf (hdr_fptr,
            "ENVI\n"
            "description = {%s}\n"
            "samples = %d\n"
            "lines   = %d\n"
            "bands   = 1\n"
            "header offset = 0\n"
            "file type = ENVI Standard\n"
            "data type = 1\n"
            "interleave = bsq\n"
            "byte order = 0\n", bin_file, input->size.s, input->size.l);
    }
   
    if (space_def->proj_num == GCTP_UTM_PROJ)
    {
        if (space_def->zone > 0)
            fprintf (hdr_fptr,
                "map info = {UTM, 1.000, 1.000, %f, %f, %f, %f, %d, North, "
                "WGS-84, units=Meters}\n", space_def->ul_corner.x,
                space_def->ul_corner.y, space_def->pixel_size,
                space_def->pixel_size, space_def->zone);
        else
            fprintf (hdr_fptr,
                "map info = {UTM, 1.000, 1.000, %f, %f, %f, %f, %d, South, "
                "WGS-84, units=Meters}\n", space_def->ul_corner.x,
                space_def->ul_corner.y, space_def->pixel_size,
                space_def->pixel_size, -(space_def->zone));
    }
    else if (space_def->proj_num == GCTP_PS_PROJ)
    {
        fprintf (hdr_fptr,
            "map info = {Polar Stereographic, 1.000, 1.000, %f, %f, %f, %f, "
            "WGS-84, units=Meters}\n", space_def->ul_corner.x,
            space_def->ul_corner.y, space_def->pixel_size,
            space_def->pixel_size);
        fprintf (hdr_fptr,
            "projection info = {%d, 6378137.0, 6356752.314245179, %lf, "
            "%lf, %lf, %lf, WGS-84, Polar Stereographic, units=Meters}\n",
            ENVI_PS_PROJ, space_def->proj_param[5], space_def->proj_param[4],
            space_def->proj_param[6], space_def->proj_param[7]);
    }

    /* Close the header file and free pointers */
    fclose (hdr_fptr);
    if (bin_file)
        free (bin_file);

    /* Successful completion */
    return SUCCESS;
}
示例#12
0
/* -----------------------------------------------------------------------------
   InitChannel
   Reads stream and road files and builds the networks.
   -------------------------------------------------------------------------- */
void
InitChannel(LISTPTR Input, MAPSIZE *Map, int deltat, CHANNEL *channel,
	    SOILPIX ** SoilMap, int *MaxStreamID, int *MaxRoadID, OPTIONSTRUCT *Options)
{
  int i;
  STRINIENTRY StrEnv[] = {
    {"ROUTING", "STREAM NETWORK FILE", "", ""},
    {"ROUTING", "STREAM MAP FILE", "", ""},
    {"ROUTING", "STREAM CLASS FILE", "", ""},
	{"ROUTING", "RIPARIAN VEG FILE", "", ""},
    {"ROUTING", "ROAD NETWORK FILE", "", "none"},
    {"ROUTING", "ROAD MAP FILE", "", "none"},
    {"ROUTING", "ROAD CLASS FILE", "", "none"},
    {NULL, NULL, "", NULL}
  };

  printf("\nInitializing Road/Stream Networks\n");

  /* Read the key-entry pairs from the ROUTING section in the input file */
  for (i = 0; StrEnv[i].SectionName; i++) {
    GetInitString(StrEnv[i].SectionName, StrEnv[i].KeyName, StrEnv[i].Default,
		  StrEnv[i].VarStr, (unsigned long) BUFSIZE, Input);
    if (IsEmptyStr(StrEnv[i].VarStr))
      ReportError(StrEnv[i].KeyName, 51);
  }

  channel->stream_class = NULL;
  channel->road_class = NULL;
  channel->streams = NULL;
  channel->roads = NULL;
  channel->stream_map = NULL;
  channel->road_map = NULL;

  channel_init();
  channel_grid_init(Map->NX, Map->NY);

  if (strncmp(StrEnv[stream_class].VarStr, "none", 4)) {

    printf("\tReading Stream data\n");

    if ((channel->stream_class =
	 channel_read_classes(StrEnv[stream_class].VarStr, stream_class,
	 FALSE)) == NULL) {
      ReportError(StrEnv[stream_class].VarStr, 5);
    }
    if ((channel->streams =
	 channel_read_network(StrEnv[stream_network].VarStr,
			      channel->stream_class, MaxStreamID)) == NULL) {
      ReportError(StrEnv[stream_network].VarStr, 5);
    }
    if ((channel->stream_map =
	 channel_grid_read_map(channel->streams,
			       StrEnv[stream_map].VarStr, SoilMap)) == NULL) {
      ReportError(StrEnv[stream_map].VarStr, 5);
    }
    error_handler(ERRHDL_STATUS,
		  "InitChannel: computing stream network routing coefficients");
    channel_routing_parameters(channel->streams, (double) deltat);
  }

  if (Options->StreamTemp) {
	if (strncmp(StrEnv[riparian_veg].VarStr, "none", 4)) {
	  printf("\tReading channel riparian vegetation params\n");
	  channel_read_rveg_param(channel->streams, StrEnv[riparian_veg].VarStr, MaxStreamID);
	}
  }

  if (strncmp(StrEnv[road_class].VarStr, "none", 4)) {

    printf("\tReading Road data\n");

    if ((channel->road_class =
	 channel_read_classes(StrEnv[road_class].VarStr, road_class,
	 Options->Sediment)) == NULL) {
      ReportError(StrEnv[road_class].VarStr, 5);
    }
    if ((channel->roads =
	 channel_read_network(StrEnv[road_network].VarStr,
			      channel->road_class, MaxRoadID)) == NULL) {
      ReportError(StrEnv[road_network].VarStr, 5);
    }
    if ((channel->road_map =
	 channel_grid_read_map(channel->roads,
			       StrEnv[road_map].VarStr, SoilMap)) == NULL) {
      ReportError(StrEnv[road_map].VarStr, 5);
    }
    error_handler(ERRHDL_STATUS,
		  "InitChannel: computing road network routing coefficients");
    channel_routing_parameters(channel->roads, (double) deltat);
  }
}
示例#13
0
/*---------------------------------------------------------------------------*
 *                                                                           *
 *---------------------------------------------------------------------------*/
void
read_raw_layout(disk *currdisk,char *rlfilename) {
#define LINELEN      100
    char line[LINELEN];
    int rot, numsurfaces;
    int lbn, cyl, head, sect, seqcnt;
    int linenum,retval,currcyl,currhead,valid_idx,i,spt;
    int range = 0;
    FILE *fp;
    int maxlbn,blocksize,numcyls;

    int *sf_cyls;
    sfreq_t *sectfreq;
#ifndef DISKSIM
    int cnt;
#endif
    unsigned int numtracks;

    if (!(fp = fopen (rlfilename, "r"))) {
        error_handler("Error opening raw layout file %s!\n",rlfilename);
    }
read_again:
    numtracks = 0;
    min_cyl_distance = cyl_distances[cyldist_index];

    if (!(sectfreq = (sfreq_t *) malloc(MAXSECTORS*sizeof(sfreq_t))))
        internal_error("Could not allocate sectfreq structure!\n");
    memset(sectfreq,0,sizeof(sectfreq));
    for(i=1; i<MAXSECTORS; i++)
        sectfreq[i].mincyl = NOVAL;

    if (!(sf_cyls = (int *) malloc(MAXSECTORS*sizeof(int))))
        internal_error("Could not allocate sf_cyls structure!\n");

    for(i=0; i<MAXSECTORS; i++)
        sf_cyls[i] = NOVAL;

    fgets(line,LINELEN,fp);
    retval = fscanf(fp,"maxlbn %d, blocksize %d\n",&maxlbn,&blocksize);
    retval = fscanf (fp, "%d cylinders, %d rot, %d heads\n", &numcyls,&rot,
                     &numsurfaces);

    if (retval != 3) {
        error_handler("Cannot read .layout.mappings file!\n");
    }

    linenum = 4;

    /*  currdisk->sectsize = blocksize; */
    currdisk->numsurfaces = numsurfaces;
    currdisk->numblocks = maxlbn+1;
    currdisk->numcyls = numcyls;
    currdisk->mapping = LAYOUT_RAWFILE;
    currdisk->sparescheme = NO_SPARING;

    if (!(currdisk->lbnrange = (lbn_rawlayout_t *) malloc(currdisk->numcyls *
                               currdisk->numsurfaces * sizeof(lbn_rawlayout_t))))
        internal_error("Could not allocate lbn_rawlayout_t structure!\n");

    if (!(currdisk->rlcyls = (cyl_rawlayout_t *)
                             malloc(currdisk->numcyls * sizeof(cyl_rawlayout_t))))
        internal_error("Could not allocate cyl_rawlayout_t structure!\n");

    memset(currdisk->rlcyls,0,currdisk->numcyls * sizeof(cyl_rawlayout_t));

    for(i=0; i<currdisk->numcyls; i++)
        currdisk->rlcyls[i].firstlbn = NOVAL;

    currcyl = NOVAL;
    currhead = NOVAL;
    numtracks++;
    /*  printf("Reading layout for %s %s\n", manufacturer, product); */

    fscanf (fp, "lbn %d --> cyl %d, head %d, sect %d, seqcnt %d\n",
            &lbn, &cyl, &head, &sect, &seqcnt);
    do {
        /* while (5 == fscanf (fp, "lbn %d --> cyl %d, head %d, sect %d, seqcnt %d\n",
           &lbn, &cyl, &head, &sect, &seqcnt)) { */
        if (currdisk->numcyls <= cyl) {
            error_handler("Cyl %d on line %d is bigger than the max value of %d!\n",
                          cyl,linenum,currdisk->numcyls-1);
        }
        if (currdisk->numsurfaces <= head) {
            error_handler("Head %d on line %d is bigger than the max value of %d!\n",
                          head,linenum,currdisk->numsurfaces-1);
        }

        if ((currhead != head) || (currcyl != cyl)) {
            numtracks++;
            if (currhead != NOVAL) {
                /* record the last lbn for the the surface */
                currdisk->rlcyls[currcyl].surface[currhead].lastlbn = lbn - 1;

                /* increment the count of tracks with # of sectors */
                spt = currdisk->rlcyls[currcyl].surface[currhead].lastlbn -
                      currdisk->rlcyls[currcyl].surface[currhead].firstlbn + 1;

                if (spt >= MAXSECTORS) {
                    internal_error("Sector count exceeds %d (MAXSECTORS).\n",MAXSECTORS);
                }

                sectfreq[spt].count++;
                sectfreq[spt].cyls += /*  currcyl */ cyl;
                if (sf_cyls[spt] != NOVAL) {
                    if (abs(/*  currcyl */ cyl - sf_cyls[spt]) > min_cyl_distance) {
                        sectfreq[spt].mincyl = /*  currcyl */ cyl;
                        sectfreq[spt].count = 1;
                        sectfreq[spt].cyls = /*  currcyl */ cyl;
                    }
                }
                sf_cyls[spt] = /*  currcyl */ cyl;

                /* record min and max cylinder for the given number of blocks */
                if ((sectfreq[spt].mincyl>/*  currcyl */ cyl) ||
                        (sectfreq[spt].mincyl==NOVAL)) {
                    sectfreq[spt].mincyl = /*  currcyl */ cyl;
                }
                if (sectfreq[spt].maxcyl < /*  currcyl */ cyl)
                    sectfreq[spt].maxcyl = /*  currcyl */ cyl;
            }
            currhead = head;
        }
        if (currcyl != cyl) {
            if (currcyl != NOVAL) {
                currdisk->rlcyls[currcyl].lastlbn = lbn-1;
                currdisk->lbnrange[range-1].lastlbn = lbn-1;
            }
            currcyl = cyl;
            currdisk->rlcyls[currcyl].validcyl = 1;

            currdisk->lbnrange[range].firstlbn = lbn;
            currdisk->lbnrange[range].cyl = cyl;
            range++;

            if ((currdisk->rlcyls[currcyl].firstlbn > lbn) ||
                    (currdisk->rlcyls[currcyl].firstlbn == NOVAL)) {
                currdisk->rlcyls[currcyl].firstlbn = lbn;
            }
        }
        /* !!! coalesce sequences if sect == 0 */
        valid_idx = currdisk->rlcyls[currcyl].surface[head].valid++;

        if (!valid_idx) {
            currdisk->rlcyls[currcyl].surface[head].firstlbn = lbn;
        }
#ifdef DETAILED_RAW_LAYOUT
        /* put in the sector and seqcnt values to the appropriate values */
        currdisk->rlcyls[currcyl].surface[head].sect[valid_idx] = sect;
        currdisk->rlcyls[currcyl].surface[head].seqcnt[valid_idx] = seqcnt;
#endif
        linenum++;
    } while (5 == fscanf (fp, "lbn %d --> cyl %d, head %d, sect %d, seqcnt %d\n",
                          &lbn, &cyl, &head, &sect, &seqcnt));

    currdisk->rlcyls[currcyl].lastlbn = lbn+seqcnt;;
    currdisk->rlcyls[currcyl].surface[head].lastlbn = lbn+seqcnt;

    /* put in the values for range */
    currdisk->lbnrange[range-1].lastlbn = lbn+seqcnt;
    currdisk->numlbnranges=range;
#ifndef DISKSIM
    currdisk->defect_lists = (defect_t *) malloc (0x80000);
    memset((void *)currdisk->defect_lists,0,0x80000);
    cnt = 1;
    do {
        retval = fscanf (fp, "Defect at cyl %d, head %d, sect %d\n",
                         &currdisk->defect_lists[cnt].cyl,
                         &currdisk->defect_lists[cnt].head,
                         &currdisk->defect_lists[cnt].sect);
        if (retval == 3) {
            /*  printf ("Defect at cyl %d, head %d, sect %d\n", currdisk->defect_lists[cnt].cyl, currdisk->defect_lists[cnt].head, currdisk->defect_lists[cnt].sect); */
            cnt++;
        }
        /* prune duplicated list entries if they are in mappings file */
        if ((cnt > 2) && (currdisk->defect_lists[cnt-1].cyl == currdisk->defect_lists[cnt-2].cyl) &&
                (currdisk->defect_lists[cnt-1].head == currdisk->defect_lists[cnt-2].head) &&
                (currdisk->defect_lists[cnt-1].sect == currdisk->defect_lists[cnt-2].sect)) {
            cnt--;
        }
    } while (retval == 3);
    currdisk->defect_lists[0].cyl = cnt-1;
#endif
    {
        int rc;
        rc = determine_zones(currdisk,sectfreq,
                             (int) (((double) currdisk->numblocks) *
                                    ((double) blocksize) /1024 /1024 /1024),
                             numtracks);
        free(sectfreq);
        free(sf_cyls);

        if ((rc == 0) && cyldist_index < MAX_DISTANCES) {
            cyldist_index++;
            rewind(fp);
            goto read_again;
        }
    }
    fclose(fp);
}
示例#14
0
文件: error.c 项目: skypjack/univ
void
fatal (const char *message)
{
  error_handler(EXIT_FAILURE, "FATAL", message);
}
示例#15
0
TYPE type_check_array_index (TYPE ind) {
	// only integer indices allowed
	if (ind != INT)
		error_handler (ARRAY_IND_TYPE_ERROR, NULL);
	return ind;
}
示例#16
0
/**
 * This routine gets characters from the filter's underlying file, and
 * decodes them according to the runlength scheme. It returns the number
 * of bytes placed into the filter's buffer through the ret_bytes arguments.
 * This number is negative if the EOD is found.
 * It returns FALSE if anything goes wrong. The caller is responsible for
 * setting the IOERROR condition.
 *
 * \param[in,out]  filter       Input and output streams for the filter
 * \param[out]     ret_bytes    Number of bytes placed in output buffer
 *                              (negative if EOD found)
 * \return                      Success status
 */
static Bool runlengthDecodeBuffer(FILELIST *filter, int32 *ret_bytes)
{
  int32    count, length;
  FILELIST *uflptr;
  uint8    *ptr;

  HQASSERT(filter, "NULL /RunLengthDecode filter");

  uflptr = filter->underlying_file;
  ptr = filter->buffer;

  HQASSERT(uflptr, "NULL /RunLengthDecode input buffer");
  HQASSERT(ptr, "NULL /RunLengthDecode output buffer");

  count = 0;
  for (;;)
  {
    register int32 ch = Getc(uflptr);

    if ( ch == EOF || ch == EOD )
    {
      /* found the EOD marker, or EOF on underlying file */
      count = -count;
      break;
    }
    if ( ch < 128 ) /* ch + 1 bytes to follow */
    {
      length = ch + 1;
      if ( ( count + length ) <= filter->buffersize )
      {
        count += length;
        /* If buffer is full enough avoid Getc() loop overhead */
        if ( length < uflptr->count )
        {
          HqMemCpy(ptr, uflptr->ptr, length);
          uflptr->count -= length;
          uflptr->ptr   += length;
          ptr += length;
        }
        else
        {
          while ( length-- )
          {
            if ( (ch = Getc(uflptr)) == EOF )
              return error_handler(IOERROR);
            *ptr++ = (uint8)ch;
          }
        }
      }
      else /* current run will not fit in */
      {
        UnGetc(ch, uflptr);
        break;
      }
    }
    else /* ch > 128, replicate single byte */
    {
      length = 257 - ch;
      if ( ( count + length ) <= filter->buffersize )
      {
        if (( ch = Getc( uflptr )) == EOF )
          return error_handler(IOERROR);
        count += length;
        HqMemSet8(ptr, (uint8)ch, length);
        ptr += length;
      }
      else /* current replciation will not fit into buffer */
      {
        UnGetc(ch , uflptr);
        break;
      }
    }
  }
  *ret_bytes = count;
  return TRUE;
}
示例#17
0
TYPE type_check_matrix_index (TYPE d1, TYPE d2) {
	// only integer
	if ( (d1 != INT) || (d2 != INT) )
		error_handler (MATRIX_IND_TYPE_ERROR, NULL);
	return d1;
}
示例#18
0
static Bool runlengthEncodeBuffer( FILELIST *filter )
{
  register FILELIST *uflptr ;
  register int32    count , c , length ;
  register int32    record_size , record_count ;
  register uint8    *ptr ;
  register uint8    *next , *prev , *lastptr ;

  HQASSERT( filter , "filter NULL in runlengthEncodeBuffer." ) ;

  ptr = theIBuffer( filter ) ;
  record_size = DEVICE_FILEDESCRIPTOR_TO_INT32(theIDescriptor( filter )) ;
  uflptr = theIUnderFile( filter ) ;
  count = theICount( filter ) ;

  if ( ! count && ! isIClosing( filter ))
    return TRUE ;

  HQASSERT( uflptr , "uflptr NULL in runlengthEncodeBuffer." ) ;

  if ( ! isIOpenFileFilterById( theIUnderFilterId( filter ) , uflptr ))
    return error_handler( IOERROR ) ;

  HQASSERT( ptr , "ptr NULL in runlengthEncodeBuffer." ) ;

  if ( record_size == 0 )
    record_size = count ;

  while (( count >= record_size ) && count ) { /* do all the records in the buffer */
    record_count = record_size ;
    lastptr = ptr + record_size ;
    while ( record_count > 1 ) { /* calculate spans within the record */
      prev = ptr ;
      next = prev + 1 ;
      if (( int32 )( *next ) == ( int32 )( *prev )) {
        /* span of the same byte */
        length = 1 ;
        do {
          length++ ;
          next++ ;
          if (( length == 128 ) || ( next == lastptr ))
            break ;
        } while (( int32 )( *next ) == ( int32 )( *prev )) ;
        /* output span */
        c = 257 - length ;
        if (( Putc( c , uflptr ) == EOF ) ||
            ( Putc( *ptr , uflptr ) == EOF ))
          return error_handler( IOERROR ) ;
        ptr += length ;
        record_count -= length ;
      } else {
        /* get a non-repeating span */
        length = 0 ;
        do {
          if ( ++length == 128 )
            break ;
          next++ ; prev++ ;
          if ( next == lastptr ) {
            length++ ;
            break ;
          }
        } while (( int32 )( *next ) != ( int32 )( *prev )) ;
        c = length - 1 ;
        record_count -= length ;
        if ( Putc( c , uflptr ) == EOF )
          return error_handler( IOERROR ) ;
        while ( length-- ) {
          if ( Putc( *ptr , uflptr ) == EOF )
            return error_handler( IOERROR ) ;
          ptr++ ;
        }
      }
    }
    if ( record_count == 1 ) {
      /* output the last byte in the record */
      if (( Putc( 0 , uflptr ) == EOF ) ||
          ( Putc( *ptr , uflptr ) == EOF ))
        return error_handler( IOERROR ) ;
      ptr++ ;
    }
    count -= record_size ;
  }

  if ( isIClosing( filter )) {
    if ( count ) {
      /* force the last partial record out */
      theIDescriptor( filter ) = count ;
      if ( ! runlengthEncodeBuffer( filter ))
        return error_handler( IOERROR ) ;
    }
    else {
      if ( Putc( 128 , uflptr ) == EOF )
        return error_handler( IOERROR ) ;
    }
  }
  else {
    if ( count ) {
      /* an incomplete record is left in the buffer */
      HqMemMove( theIBuffer( filter ) , ptr , count ) ;
    }
  }

  theICount( filter ) = count ;
  theIPtr( filter ) = theIBuffer( filter ) + count ;

  return TRUE ;
}
示例#19
0
void cubic_spline(int size1, int size2, const double *grid1, const double *grid2, const double *data1,
		  double *data2, double yp1, double ypn  )
{
  double *y2=NULL, *u=NULL;
  double p, sig, qn, un, h, a, b;
  int i, k, n, klo, khi;
  
  for(i=1; i<size1; i++) {
    if( grid1[i] <= grid1[i-1] ) error_handler("cubic_spline: grid1 is not monotonic increasing");
  }

  for(i=0; i<size2; i++) {
    if( grid2[i] < grid1[0] || grid2[i] > grid1[size1-1]) error_handler("cubic_spline: grid2 lies outside grid1");
  }  

  if(size1 < 2) error_handler("cubic_spline: the size of input grid should be at least 2");
  if(size1 == 2) {  /* when size1 is 2, it just reduced to a linear interpolation */
    p = (data1[1]-data1[0])/(grid1[1]-grid1[0]);
    for(i=0; i< size2; i++) data2[i] = p*(grid2[i] - grid1[0]) + data1[0];
    return;
  }
  y2 = (double *)malloc(size1*sizeof(double));
  u = (double *)malloc(size1*sizeof(double));
  if (yp1 >.99e30) {
    y2[0]=0.;
    u[0]=0.;
  }
  else {
    y2[0]=-0.5;
    u[0]=(3./(grid1[1]-grid1[0]))*((data1[1]-data1[0])/(grid1[1]-grid1[0])-yp1);
  }

  for(i=1; i<size1-1; i++) {
    sig=(grid1[i]-grid1[i-1])/(grid1[i+1]-grid1[i-1]);
    p=sig*y2[i-1]+2.;
    y2[i]=(sig-1.)/p;
    u[i]=(6.*((data1[i+1]-data1[i])/(grid1[i+1]-grid1[i])-(data1[i]-data1[i-1])
	      /(grid1[i]-grid1[i-1]))/(grid1[i+1]-grid1[i-1])-sig*u[i-1])/p;

  }
  
  if (ypn > .99e30) {
    qn=0.;
    un=0.;
  }
  else {
    qn=0.5;
    un=(3./(grid1[size1-1]-grid1[size1-2]))*(ypn-(data1[size1-1]-data1[size1-2])/(grid1[size1-1]-grid1[size1-2]));
  }

  y2[size1-1]=(un-qn*u[size1-2])/(qn*y2[size1-2]+1.);

  for(k=size1-2; k>=0; k--) y2[k] = y2[k]*y2[k+1]+u[k];

  /* interpolate data onto grid2 */
  for(k=0; k<size2; k++) {
    n = nearest_index(grid2[k],grid1, size1);
    if (grid1[n] < grid2[k]) {
	 klo = n;
    }
    else {
      if(n==0) {
	klo = n;
      }
      else {
	klo = n -1;
      }
    }
    khi = klo+1;
    h   = grid1[khi]-grid1[klo];
    a   = (grid1[khi] - grid2[k])/h;
    b   = (grid2[k] - grid1[klo])/h;
    data2[k] = a*data1[klo] + b*data1[khi]+ ((pow(a,3.0)-a)*y2[klo] + (pow(b,3.0)-b)*y2[khi])*(pow(h,2.0))/6;
  }

  free(y2);
  free(u);
  
};/* cubic spline */
示例#20
0
static Bool runlengthFilterInit( FILELIST *filter,
                                 OBJECT *args ,
                                 STACK *stack )
{
  int32 buffsize = RUNLENGTHBUFFSIZE ;
  int32 pop_args = 0 ;

  HQASSERT(args != NULL || stack != NULL,
           "Arguments and stack should not both be empty") ;

  if ( isIOutputFile( filter )) { /* encoding filter */
    OBJECT *theo ;
    int32  record_size ;

    /* Can't pass args directly to RunLengthEncode, since it
     * has no dictionary only form (Adobe oversight?). We might have
     * to add our own if we ever want RLE for pdf out.
     */
    HQASSERT( ! args ,
              "Can't handle direct dictionary arguments in RunLengthEncode." ) ;

    if ( isEmpty(*stack) )
      return error_handler( STACKUNDERFLOW ) ;

    theo = theITop(stack) ;
    pop_args = 1 ;

    if ( oType(*theo) != OINTEGER )
      return error_handler( TYPECHECK ) ;
    record_size = oInteger(*theo) ;
    if ( record_size < 0 ||
         record_size > 65536 )
      return error_handler( RANGECHECK ) ;

    theIDescriptor( filter ) = record_size ;
    if ( buffsize < record_size )
      buffsize = record_size ;
  }

  if ( ! args && theIStackSize(stack) >= pop_args ) {
    args = stackindex(pop_args, stack) ;
    if ( oType(*args) == ODICTIONARY )
      ++pop_args ;
  }

  if ( args && oType(*args) == ODICTIONARY ) {
    if ( ! oCanRead(*oDict(*args)) &&
         ! object_access_override(args) )
      return error_handler( INVALIDACCESS ) ;
    if ( ! FilterCheckArgs( filter , args ))
      return FALSE ;
    OCopy( theIParamDict( filter ), *args ) ;
  } else
    args = NULL ;

  /* Get underlying source/target if we have a stack supplied. */
  if ( stack ) {
    if ( theIStackSize(stack) < pop_args )
      return error_handler(STACKUNDERFLOW) ;

    if ( ! filter_target_or_source(filter, stackindex(pop_args, stack)) )
      return FALSE ;

    ++pop_args ;
  }

  theIBuffer( filter ) = ( uint8 * )
                         mm_alloc_with_header( mm_pool_temp ,
                                               buffsize + 1 ,
                                               MM_ALLOC_CLASS_RUNLEN_BUFFER ) ;
  if ( theIBuffer( filter ) == NULL )
    return error_handler( VMERROR ) ;

  theIBuffer( filter )++ ;
  theIPtr( filter ) = theIBuffer( filter ) ;
  theICount( filter ) = 0 ;
  theIBufferSize( filter ) = buffsize ;
  theIFilterState( filter ) = FILTER_INIT_STATE ;

  HQASSERT(pop_args == 0 || stack != NULL, "Popping args but no stack") ;
  if ( pop_args > 0 )
    npop(pop_args, stack) ;

  return TRUE ;
}
示例#21
0
/**
 * Transaction 3 - T3
 *
 * Read session details
 *
 * Input:
 *   SubscriberNumber
 *   ServerId
 *   ServerBit
 *
 * Output:
 *   BranchExecuted
 *   SessionDetails
 *   ChangedBy
 *   ChangedTime
 *   Location
 */
int
T3(void * obj,
   const SubscriberNumber   inNumber,
   const SubscriberSuffix   inSuffix,
   const ServerId           inServerId,
   const ServerBit          inServerBit,
   SessionDetails     outSessionDetails,
   ChangedBy          outChangedBy,
   ChangedTime        outChangedTime,
   Location         * outLocation,
   BranchExecuted   * outBranchExecuted,
   BenchmarkTime    * outTransactionTime){
  
  Ndb * pNDB = (Ndb *) obj;

  GroupId        groupId;
  ActiveSessions sessions;
  Permission     permission;

  BenchmarkTime start;
  get_time(&start);

  int check;
  NdbRecAttr * check2;

  NdbConnection * MyTransaction = pNDB->startTransaction();
  if (MyTransaction == NULL)	  
    error_handler("T3-1: startTranscation", pNDB->getNdbErrorString(), 0);
  
  NdbOperation *MyOperation= MyTransaction->getNdbOperation(SUBSCRIBER_TABLE);
  CHECK_NULL(MyOperation, "T3-1: getNdbOperation", 
	     MyTransaction);
  
  
  check = MyOperation->readTuple();
  CHECK_MINUS_ONE(check, "T3-1: readTuple", 
		  MyTransaction);
  
  check = MyOperation->equal(IND_SUBSCRIBER_NUMBER, 
			     inNumber);
  CHECK_MINUS_ONE(check, "T3-1: equal subscriber",
		  MyTransaction);

  check2 = MyOperation->getValue(IND_SUBSCRIBER_LOCATION, 
				 (char *)outLocation);
  CHECK_NULL(check2, "T3-1: getValue location", 
	     MyTransaction);

  check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY, 
				 outChangedBy);
  CHECK_NULL(check2, "T3-1: getValue changed_by", 
	     MyTransaction);

  check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME, 
                                 outChangedTime);
  CHECK_NULL(check2, "T3-1: getValue changed_time",
	     MyTransaction);

  check2 = MyOperation->getValue(IND_SUBSCRIBER_GROUP,
				 (char *)&groupId);
  CHECK_NULL(check2, "T3-1: getValue group", 
	     MyTransaction);

  check2 = MyOperation->getValue(IND_SUBSCRIBER_SESSIONS,
				 (char *)&sessions);
  CHECK_NULL(check2, "T3-1: getValue sessions", 
	     MyTransaction);
  
  check = MyTransaction->execute( NoCommit ); 
  CHECK_MINUS_ONE(check, "T3-1: NoCommit", 
		  MyTransaction);
  
    /* Operation 2 */

  MyOperation = MyTransaction->getNdbOperation(GROUP_TABLE);
  CHECK_NULL(MyOperation, "T3-2: getNdbOperation", 
	     MyTransaction);
  
  
  check = MyOperation->readTuple();
  CHECK_MINUS_ONE(check, "T3-2: readTuple", 
		  MyTransaction);
  
  check = MyOperation->equal(IND_GROUP_ID,
		     (char*)&groupId);
  CHECK_MINUS_ONE(check, "T3-2: equal group",
		  MyTransaction);
  
  check2 = MyOperation->getValue(IND_GROUP_ALLOW_READ, 
				 (char *)&permission);
  CHECK_NULL(check2, "T3-2: getValue allow_read", 
	     MyTransaction);

  check = MyTransaction->execute( NoCommit ); 
  CHECK_MINUS_ONE(check, "T3-2: NoCommit", 
		  MyTransaction);
  
  DEBUG3("T3(%.*s, %.2d): ", SUBSCRIBER_NUMBER_LENGTH, inNumber, inServerId);

  if(((permission & inServerBit) == inServerBit) &&
     ((sessions   & inServerBit) == inServerBit)){
    
    DEBUG("reading - ");

    /* Operation 3 */

    MyOperation = MyTransaction->getNdbOperation(SESSION_TABLE);
    CHECK_NULL(MyOperation, "T3-3: getNdbOperation", 
	       MyTransaction);
    
    check = MyOperation->readTuple();
    CHECK_MINUS_ONE(check, "T3-3: readTuple", 
		    MyTransaction);
    
    check = MyOperation->equal(IND_SESSION_SUBSCRIBER,
			       (char*)inNumber);
    CHECK_MINUS_ONE(check, "T3-3: equal number",
		    MyTransaction);

    check = MyOperation->equal(IND_SESSION_SERVER,
			       (char*)&inServerId);
    CHECK_MINUS_ONE(check, "T3-3: equal server id",
		    MyTransaction);
    
    check2 = MyOperation->getValue(IND_SESSION_DATA, 
				   (char *)outSessionDetails);
    CHECK_NULL(check2, "T3-3: getValue session details", 
	       MyTransaction);
    
    check = MyTransaction->execute( NoCommit ); 
    CHECK_MINUS_ONE(check, "T3-3: NoCommit", 
		    MyTransaction);

    /* Operation 4 */

    MyOperation = MyTransaction->getNdbOperation(SERVER_TABLE);
    CHECK_NULL(MyOperation, "T3-4: getNdbOperation", 
	       MyTransaction);
    
    check = MyOperation->interpretedUpdateTuple();
    CHECK_MINUS_ONE(check, "T3-4: interpretedUpdateTuple", 
		    MyTransaction);
    
    check = MyOperation->equal(IND_SERVER_ID,
			       (char*)&inServerId);
    CHECK_MINUS_ONE(check, "T3-4: equal serverId",
		    MyTransaction);

    check = MyOperation->equal(IND_SERVER_SUBSCRIBER_SUFFIX,
			       (char*)inSuffix);
    CHECK_MINUS_ONE(check, "T3-4: equal suffix",
		    MyTransaction);

    check = MyOperation->incValue(IND_SERVER_READS, (uint32)1);
    CHECK_MINUS_ONE(check, "T3-4: inc value",
		    MyTransaction);
    
    check = MyTransaction->execute( NoCommit ); 
    CHECK_MINUS_ONE(check, "T3-4: NoCommit", 
		    MyTransaction);

    (* outBranchExecuted) = 1;
  } else {
    (* outBranchExecuted) = 0;
  }
  DEBUG("commit\n");
  check = MyTransaction->execute( Commit ); 
  CHECK_MINUS_ONE(check, "T3: Commit", 
		  MyTransaction);
  
  pNDB->closeTransaction(MyTransaction);
  
  get_time(outTransactionTime);
  time_diff(outTransactionTime, &start);
  return 0;
}
/******************************************************************************
MODULE:  setup_mapping

PURPOSE:  Sets up the geolocation data structure and initializes the forward
and inverse mapping functions via GCTP.

RETURN VALUE:
Type = Geoloc_t *
Value      Description
-----      -----------
NULL       Error occurred in the setup
not-NULL   Successful completion

PROJECT:  Land Satellites Data System Science Research and Development (LSRD)
at the USGS EROS

HISTORY:
Date          Programmer       Reason
----------    ---------------  -------------------------------------
1/23/2014     Gail Schmidt     Original Development (based on input routines
                               from the LEDAPS lndsr application)
4/25/2014     Gail Schmidt     Updated to support additional projections

NOTES:
1. Memory is allocated for the Geoloc_t pointer.  It is up to the calling
   routine to free the memory for this pointer.
2. Make sure the corners Space_def_t are reported as the upper left of the
   the since that's what the other routines are expecting.
******************************************************************************/
Geoloc_t *setup_mapping
(
    Space_def_t *space_def     /* I: space definition structure */
)
{
    char FUNC_NAME[] = "setup_mapping"; /* function name */
    char errmsg[STR_SIZE];              /* error message */
    char file27[] = "FILE27";           /* file for NAD27 (only for State Plane)
                                           so just use something fake for now */
    char file83[] = "FILE83";           /* file for NAD83 (only for State Plane)
                                           so just use something fake for now */
    Geoloc_t *this = NULL;              /* pointer to the space structure */
    double temp1, temp2;                /* temp variables for PS projection */
    int i;                              /* looping variable */
    int iflag;                          /* return status from GCTP */
    int (*for_trans[MAX_PROJ + 1])();   /* forward transformation function */
    int (*inv_trans[MAX_PROJ + 1])();   /* inverse transformation function */
  
    /* Verify some of the space definition parameters */
    if (space_def->img_size.l < 1) 
    {
        sprintf (errmsg, "Invalid number of lines: %d", space_def->img_size.l);
        error_handler (true, FUNC_NAME, errmsg);
        return (NULL);
    }
    if (space_def->img_size.s < 1) 
    {
        sprintf (errmsg, "Invalid number of samples per line: %d",
            space_def->img_size.s);
        error_handler (true, FUNC_NAME, errmsg);
        return (NULL);
    }

    if (space_def->pixel_size[0] <= 0.0 || space_def->pixel_size[1] <= 0.0)
    {
        sprintf (errmsg, "Invalid pixel size: %lf %lf",
            space_def->pixel_size[0], space_def->pixel_size[1]);
        error_handler (true, FUNC_NAME, errmsg);
        return (NULL);
    }

    if (space_def->proj_num < 0  ||  space_def->proj_num > MAX_PROJ)
    {
        sprintf (errmsg, "Invalid projection number: %d", space_def->proj_num);
        error_handler (true, FUNC_NAME, errmsg);
        return (NULL);
    }
  
    /* Create the geolocation data structure */
    this = malloc (sizeof (Geoloc_t));
    if (this == NULL) 
    {
        sprintf (errmsg, "Allocating geolocation data structure");
        error_handler (true, FUNC_NAME, errmsg);
        return (NULL);
    }
  
    /* Copy the space definition fields */
    this->def.pixel_size[0] = space_def->pixel_size[0];
    this->def.pixel_size[1] = space_def->pixel_size[1];
    this->def.ul_corner.x = space_def->ul_corner.x;
    this->def.ul_corner.y = space_def->ul_corner.y;
    this->def.img_size.l = space_def->img_size.l;
    this->def.img_size.s = space_def->img_size.s;
    this->def.proj_num = space_def->proj_num;
    this->def.zone = space_def->zone;
    this->def.spheroid = space_def->spheroid;
    this->def.orientation_angle = space_def->orientation_angle;
    for (i = 0; i < NPROJ_PARAM; i++) 
        this->def.proj_param[i] = space_def->proj_param[i];
  
    /* Calculate the orientation cosine/sine */
    this->sin_orien = sin (space_def->orientation_angle);
    this->cos_orien = cos (space_def->orientation_angle);
  
    /* Convert angular projection parameters to DMS the necessary projections */
    if (this->def.proj_num == GCTP_PS_PROJ ||
        this->def.proj_num == GCTP_ALBERS_PROJ)
    {
        if (!degdms (&this->def.proj_param[4], &temp1, "DEG", "LON" ) ||
            !degdms (&this->def.proj_param[5], &temp2, "DEG", "LAT" ))
        {
            free (this);
            sprintf (errmsg, "Converting PS or ALBERS angular parameters from "
                "degrees to DMS");
            error_handler (true, FUNC_NAME, errmsg);
            return (NULL);
        }
        this->def.proj_param[4] = temp1;
        this->def.proj_param[5] = temp2;
    }
    else if (this->def.proj_num == GCTP_SIN_PROJ)
    {
        if (!degdms (&this->def.proj_param[4], &temp1, "DEG", "LON" ))
        {
            free (this);
            sprintf (errmsg, "Converting SIN angular parameters from degrees "
                "to DMS");
            error_handler (true, FUNC_NAME, errmsg);
            return (NULL);
        }
        this->def.proj_param[4] = temp1;
    }
     
    /* Setup the forward transform */
    for_init (this->def.proj_num, this->def.zone, this->def.proj_param, 
        this->def.spheroid, file27, file83, &iflag, for_trans);
    if (iflag)
    {
        free (this);
        sprintf (errmsg, "Error returned from for_init");
        error_handler (true, FUNC_NAME, errmsg);
        return (NULL);
    }
    this->for_trans = for_trans[this->def.proj_num];
  
    /* Setup the inverse transform */
    inv_init (this->def.proj_num, this->def.zone, this->def.proj_param, 
        this->def.spheroid, file27, file83, &iflag, inv_trans);
    if (iflag)
    {
        free (this);
        sprintf (errmsg, "Error returned from for_init");
        error_handler (true, FUNC_NAME, errmsg);
        return (NULL);
    }
    this->inv_trans = inv_trans[this->def.proj_num];
  
    /* Successful completion */
    return (this);
}
示例#23
0
SYNCED_COMMAND_HANDLER_FUNCTION(recruit, child, use_undo, show, error_handler)
{
	int current_team_num = resources::controller->current_side();
	team &current_team = resources::gameboard->teams()[current_team_num - 1];

	map_location loc(child, resources::gamedata);
	map_location from(child.child_or_empty("from"), resources::gamedata);
	// Validate "from".
	if ( !from.valid() ) {
		// This will be the case for AI recruits in replays saved
		// before 1.11.2, so it is not more severe than a warning.
		// EDIT:  we borke compability with 1.11.2 anyway so we should give an error.
		error_handler("Missing leader location for recruitment.\n", false);
	}
	else if ( resources::gameboard->units().find(from) == resources::gameboard->units().end() ) {
		// Sync problem?
		std::stringstream errbuf;
		errbuf << "Recruiting leader not found at " << from << ".\n";
		error_handler(errbuf.str(), false);
	}

	// Get the unit_type ID.
	std::string type_id = child["type"];
	if ( type_id.empty() ) {
		error_handler("Recruitment is missing a unit type.", true);
		return false;
	}

	const unit_type *u_type = unit_types.find(type_id);
	if (!u_type) {
		std::stringstream errbuf;
		errbuf << "Recruiting illegal unit: '" << type_id << "'.\n";
		error_handler(errbuf.str(), true);
		return false;
	}

	const std::string res = actions::find_recruit_location(current_team_num, loc, from, type_id);
	if(!res.empty())
	{
		std::stringstream errbuf;
		errbuf << "cannot recruit unit: " << res << "\n";
		error_handler(errbuf.str(), true);
		return false;
		//we are already oos because the unit wasn't created, no need to keep the bookkeeping right...
	}
	const int beginning_gold = current_team.gold();



	if ( u_type->cost() > beginning_gold ) {
		std::stringstream errbuf;
		errbuf << "unit '" << type_id << "' is too expensive to recruit: "
			<< u_type->cost() << "/" << beginning_gold << "\n";
		error_handler(errbuf.str(), false);
	}

	actions::recruit_unit(*u_type, current_team_num, loc, from, show, use_undo);

	LOG_REPLAY << "recruit: team=" << current_team_num << " '" << type_id << "' at (" << loc
		<< ") cost=" << u_type->cost() << " from gold=" << beginning_gold << ' '
		<< "-> " << current_team.gold() << "\n";
	return true;
}
示例#24
0
TYPE type_check_assignment ( TYPE left, TYPE right ) {
	// right operand must match left's type
	if ( right != left )
		error_handler (TYPE_ERROR_ASSIGNMENT, NULL);
	return right;
}	
示例#25
0
/** pdf_createfilterlist
 *
 * Call this to layer filters on top of an existing file or filter.
 *
 * Pass the existing file or filter in "file".
 * (This gets changed to be the topmost newly-added filter).
 *
 * Pass the name or array of names of the desired filter-types in "theo".
 *
 * Pass the filter-parameters or array of filter-parameters in "parms".
 *
 * Pass flag indicating if each filter-parameter dictionary needs
 * a deep copy to a new object before creating the filter in.
 * "copyparms".
 *
 * Pass whether the close source/target flag should be set (for
 * non-StreamDecode filters) in the "cst" flag.
 *
 * Returns:
 * The "*file" object is overwritten with the topmost newly-added filter.
 *
 * **** Note: Used for PDF Out as well as PDF input ***
 */
Bool pdf_createfilterlist( PDFCONTEXT *pdfc , OBJECT *file , OBJECT *theo ,
                           OBJECT *parms, Bool copyparms, int32 cst )
{
  HQASSERT( pdfc , "pdfc NULL in pdf_createfilterlist" ) ;
  HQASSERT( file , "file NULL in pdf_createfilterlist" ) ;
  HQASSERT( oType(*file) == OFILE ,
            "file not a file in pdf_createfilterlist" ) ;

  if ( theo != NULL ) {
    OBJECT null = OBJECT_NOTVM_NULL ;
    OBJECT dict = OBJECT_NOTVM_NOTHING ;

    if ( oType(*theo) == ONAME ) {
      if ( ! parms )
        parms = ( & null ) ;
      else {
        if ( oType(*parms) == OARRAY || oType(*parms) == OPACKEDARRAY ) {
          if ( theLen(*parms) != 1 )
            return error_handler( TYPECHECK ) ;
          parms = oArray(*parms) ;
        }
      }

      Copy( & dict, parms ) ;
      if ( copyparms ) {
        if ( ! pdf_copyobject( pdfc, parms, & dict ) )
          return FALSE ;
        if ( ! pdf_resolvexrefs( pdfc , &dict) )
          return FALSE ;
      }

      if ( !pdf_createfilter( pdfc , file , theo , & dict , cst ) )
        return FALSE ;
    }
    else {
      int32 i ;
      int32 len ;
      int32 isarray ;
      OBJECT *olistn , *olista ;

      HQASSERT(oType(*theo) == OARRAY || oType(*theo) == OPACKEDARRAY,
               "only know about names & arrays" ) ;
      if ( ! parms )
        parms = ( & null ) ;
      else {
        if ( oType(*parms) == ODICTIONARY )
          return error_handler( TYPECHECK ) ;
        if ( (oType(*parms) == OARRAY || oType(*parms) == OPACKEDARRAY)
             && theLen(*theo) != theLen(*parms) )
          return error_handler( RANGECHECK ) ;
      }
      olistn = oArray(*theo) ;
      isarray = FALSE ;
      olista = parms ;
      if ( oType(*parms) == OARRAY || oType(*parms) == OPACKEDARRAY ) {
        isarray = TRUE ;
        olista = oArray(*parms) ;
      }
      len = theLen(*theo) ;
      for ( i = 0 ; i < len ; ++i ) {
        theo = olistn ;
        if ( oType(*theo) == OINDIRECT ) {
          if ( ! pdf_lookupxref(pdfc, &theo, oXRefID(*theo),
                                theGen(*theo), FALSE) )
            return FALSE ;
          if ( theo == NULL )
            return error_handler( UNDEFINEDRESOURCE ) ;
        }
        if ( oType(*theo) != ONAME )
          return error_handler( TYPECHECK ) ;

        parms = olista ;
        if ( oType(*parms) == OINDIRECT ) {
          if ( ! pdf_lookupxref(pdfc, &parms, oXRefID(*parms),
                                theGen(*parms), FALSE) )
            return FALSE ;
          if ( parms == NULL )
            return error_handler( UNDEFINEDRESOURCE ) ;
        }
        if ( oType(*parms) != ONULL && oType(*parms) != ODICTIONARY )
          return error_handler( TYPECHECK ) ;

        Copy( & dict, parms ) ;
        if ( copyparms ) {
          if ( ! pdf_copyobject( pdfc, parms, & dict ) )
            return FALSE ;
          if ( ! pdf_resolvexrefs( pdfc , &dict) )
            return FALSE ;
        }

        if ( !pdf_createfilter( pdfc , file , theo , & dict , cst ) )
          return FALSE ;

        ++olistn ;
        if ( isarray )
          ++olista ;
      }
    }
  }

  return TRUE;
}
示例#26
0
TYPE type_check_bitwise ( TYPE left, TYPE right ) {
	// both must be of integral type
	if ( left != INT || right != INT )
		error_handler (TYPE_ERROR_BITWISE, NULL);
	return left;
}
/*---------------------------------------------------------------------------
 * Returns -1 on error, otherwise returns the ID of the command.
 *--------------------------------------------------------------------------*/
int 
recv_scsi_command(char *buffer)
{
#ifdef DIXTRAC_LINUX_SG
  int status = 0;

#ifdef LINUX_SG_IO
  sg_io_hdr_t sgio_hdr;
  int i;
#else
  char *buf_pointer;
  struct sg_header *sg_hd;
#endif

#ifndef SG_TIMER  
  struct timeval stop;
  struct timezone tz;
#endif
  
#ifdef SG_NONBLOCKING
#ifdef STATE_THREADS
#else
/* timeout in miliseconds */
#define TIMEOUT         5000  
  struct pollfd ufd;
  int rc;

  ufd.fd = scsidev_fd;
  ufd.events = POLLPRI | POLLIN;
  if ( 1 > (rc = poll(&ufd,1,TIMEOUT))) {
    if (rc == 0) {
      fprintf(stderr,"Disk timed out\n");
      return(-1);
    }
    else {
      error_handler("Error with poll syscall %s\n","");
    }
  }
#endif
#endif
#ifdef LINUX_SG_IO
  sgio_hdr.flags = SG_FLAG_DIRECT_IO; 
#ifdef STATE_THREADS
  status = st_read(scsidev_fd, &sgio_hdr, sizeof(sg_io_hdr_t),ST_TIMEOUT);
#else
  status = read(scsidev_fd, &sgio_hdr, sizeof(sg_io_hdr_t));
#endif
#else
  buf_pointer = buffer - SG_HDR_OFFSET; 
  sg_hd = (struct sg_header *) buf_pointer;
  /*  sg_hd->pack_id = cmd_id; */

  /* retrieve result */
  status = read(scsidev_fd, buf_pointer, SG_BIG_BUFF);
#endif

#ifndef SG_TIMER
  gettimeofday(&stop,&tz);
  ustop_sec = stop.tv_sec;
  /* ustop = (ustop_sec - ustart_sec)*1000000 + stop.tv_usec; */
  ustop = stop.tv_usec;
#else
#ifdef LINUX_SG_IO
  //  printf("%s() (%d,%d)\n", __func__, sgio_hdr.duration.tv_sec,
  // sgio_hdr.duration.tv_usec);


  ustop = sgio_hdr.duration.tv_usec;
  ustop_sec = sgio_hdr.duration.tv_sec;
#else
  ustop = sg_hd->time.tv_usec;
  ustop_sec = sg_hd->time.tv_sec;
#endif
#endif  

#ifdef LINUX_SG_IO  
  /*  printf("Time returned from sgio driver: %d ms\n",sgio_hdr.duration); */
  if ( status < 0 || (status < sizeof(sg_io_hdr_t))) {
    /* some error happened */
    fprintf( stderr, "read(sg_io) status = 0x%x\n", status);
    fprintf( stderr, "Sense buffer: ");
    for(i=0 ; i<sgio_hdr.sb_len_wr ; i++) 
      fprintf( stderr,"%x ",sense_buffer[i]);
    fprintf( stderr,"\n");
  }
  return(sgio_hdr.pack_id);
#else
  if ( status < 0 || sg_hd->result ) {
    /* some error happened */
    fprintf( stderr, "read(generic) status = 0x%x, result = 0x%x\n",
	     status, sg_hd->result);
    fprintf( stderr, "read(generic) sense "
	     "%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n",
	     sg_hd->sense_buffer[0],         sg_hd->sense_buffer[1],
	     sg_hd->sense_buffer[2],         sg_hd->sense_buffer[3],
	     sg_hd->sense_buffer[4],         sg_hd->sense_buffer[5],
	     sg_hd->sense_buffer[6],         sg_hd->sense_buffer[7],
	     sg_hd->sense_buffer[8],         sg_hd->sense_buffer[9],
	     sg_hd->sense_buffer[10],        sg_hd->sense_buffer[11],
	     sg_hd->sense_buffer[12],        sg_hd->sense_buffer[13],
	     sg_hd->sense_buffer[14],        sg_hd->sense_buffer[15]);
    if (status < 0)
      error_handler("recv_scsi_command: Read error (%s)\n",strerror(errno));
  }
  else 
    /* buffer should already have all the necessarry data */
    /* just adjust the number of bytes returned */
    status -= SG_HDR_OFFSET;
  return (sg_hd->pack_id);
#endif

/* DIXTRAC_LINUX_SG */
#endif

#ifdef DIXTRAC_FREEBSD_CAM
  return(0);
#endif

}
示例#28
0
TYPE type_check_modulo (TYPE left, TYPE right) {
	// modulo only takes integral types
	if ( left != INT || right != INT )
		error_handler (TYPE_ERROR_MODULO, NULL);
	return left;
}
示例#29
0
void check_arg_type(char *func, char* loc, cellpoint arg, int type)
{
	switch (type){
	case BOOLEAN_T:
		if (is_false(is_boolean(arg))){
			printf("Error: procedure \"%s\" expects the %s argument is a boolean, but given: ", func, loc);
			write(arg);
			newline();
			error_handler();
		}
		break;
	case CHARACTER_T:
		if (is_false(is_char(arg))){
			printf("Errror: procedure \"%s\" expects the %s argument is a character, but given: ", func, loc);
			write(arg);
			newline();
			error_handler();
		}
		break;
	case INTEGER_T:
		if (is_false(is_integer(arg))){
			printf("Error: procedure \"%s\" expects the %s argument is a integer, but given: ", func, loc);
			write(arg);
			newline();
			error_handler();
		}
		break;
	case NUMBER_T:
		if (is_false(is_number(arg))){
			printf("Error: procedure \"%s\" expects the %s argument is a number, but given: ", func, loc);
			write(arg);
			newline();
			error_handler();
		}
		break;
	case SYMBOL_T:
		if (is_false(is_symbol(arg))){
			printf("Error: procedure \"%s\" expects the %s argument is a symbol, but given: ", func, loc);
			write(arg);
			newline();
			error_handler();
		}
		break;
	case STRING_T:
		if (is_false(is_string(arg))){
			printf("Error: procedure \"%s\" expects the %s argument is a string, but given: ", func, loc);
			write(arg);
			newline();
			error_handler();
		}
		break;
	case VECTOR_T:
		if (is_false(is_vector(arg))){
			printf("Error: procedure \"%s\" expects the %s argument is a vector, but given: ", func, loc);
			write(arg);
			newline();
			error_handler();
		}
		break;
	case PAIR_T:
		if (is_false(is_pair(arg))){
			printf("Error: procedure \"%s\" expects the %s argument is a pair, but given: ", func, loc);
			write(arg);
			newline();
			error_handler();
		}
		break;
	case LIST_T:
		if (is_false(is_list(arg))){
			printf("Error: procedure \"%s\" expects the %s argument is a list, but given: ", func, loc);
			write(arg);
			newline();
			error_handler();
		}
		break;
	case PROCEDURE_T:
		if (is_false(is_procedure(arg))){
			printf("Error: procedure \"%s\" expects the %s argument is a procedure, but given: ", func, loc);
			write(arg);
			newline();
			error_handler();
		}
		break;
	default:
		printf("Error: unknown check arg type. -- CHECK_ARG_TYPE.\n");
		error_handler();
	}
}
示例#30
0
文件: error.c 项目: skypjack/univ
void
warning (const char *message)
{
  error_handler(-1, "Warning", message);
}