Пример #1
0
static const char* get_gzip_eof( FILE* file, long* eof )
{
	unsigned char buf [4];
	if ( !fread( buf, 2, 1, file ) )
		RAISE_ERROR( "Couldn't read from file" );
	
	if ( buf [0] == 0x1F && buf [1] == 0x8B )
	{
		if ( fseek( file, -4, SEEK_END ) )
			RAISE_ERROR( "Couldn't seek in file" );
		
		if ( !fread( buf, 4, 1, file ) )
			RAISE_ERROR( "Couldn't read from file" );
		
		*eof = buf [3] * 0x1000000L + buf [2] * 0x10000L + buf [1] * 0x100L + buf [0];
	}
	else
	{
		if ( fseek( file, 0, SEEK_END ) )
			RAISE_ERROR( "Couldn't seek in file" );
		
		*eof = ftell( file );
	}
	
	return 0;
}
Пример #2
0
error_t Mem_Writer::write( const void* p, long s )
{
	long remain = allocated - size_;
	if ( s > remain )
	{
		if ( mode == fixed )
			RAISE_ERROR( "Tried to write more data than expected" );
		
		if ( mode == ignore_excess )
		{
			s = remain;
		}
		else // expanding
		{
			long new_allocated = size_ + s;
			new_allocated += (new_allocated >> 1) + 2048;
			void* p = realloc( data_, new_allocated );
			if ( !p )
				RAISE_ERROR( "Out of memory" );
			data_ = (char*) p;
			allocated = new_allocated;
		}
	}
	
	assert( size_ + s <= allocated );
	memcpy( data_ + size_, p, s );
	size_ += s;
	
	return 0;
}
Пример #3
0
lib7_val_t   _lib7_runtime_export_heap   (   lib7_state_t*   lib7_state,
                                               lib7_val_t arg
                                           )
{
    /* _lib7_runtime_export_heap : String -> Bool
     *
     * Export the world to the given file and return false (the exported version
     * returns true).
     */

    char	fname[1024];
    FILE	*file;

    strcpy(fname, STR_LIB7toC(arg)); /* XXX BUGGO FIXME no buffer overflow check! */

    fprintf(stderr,"\n");
    fprintf(stderr,"------------------------------------------------------------------------------------------------------\n");
    fprintf(stderr," export-heap.c:_lib7_runtime_export_heap:   Writing file '%s'\n",fname);
    fprintf(stderr,"------------------------------------------------------------------------------------------------------\n");

    if (!(file = fopen(fname, "wb"))) {
      return RAISE_ERROR(lib7_state, "unable to open file for writing");
    }

    lib7_state->lib7_argument = LIB7_true;

    {   int status = ExportHeapImage (lib7_state, file);
        fclose (file);

	if (status == SUCCESS)   return LIB7_false;
	else                     return RAISE_ERROR( lib7_state, "export failed");
    }
}
Пример #4
0
AnnotationList::RuleBitSet AnnotationList::checkDuplicateDeclarations(
    DeclarationKind declKind,
    const QueryLoc& loc) const
{
  RuleBitSet lCurrAnn;

  // mark and detect duplicates
  for (Annotations::const_iterator ite = theAnnotationList.begin();
       ite != theAnnotationList.end();
       ++ite)
  {
    const store::Item* qname = (*ite)->getQName();
    AnnotationId id = (*ite)->getId();

    // detect duplicate annotations (if we "know" them)
    if (id != AnnotationInternal::zann_end && lCurrAnn.test(id))
    {
      if (declKind == var_decl)
      {
        RAISE_ERROR(err::XQST0116, loc,
        ERROR_PARAMS(ZED(XQST0116_Duplicate), qname->getStringValue()));
      }
      else
      {
        RAISE_ERROR(err::XQST0106, loc,
        ERROR_PARAMS(ZED(XQST0106_Duplicate), qname->getStringValue()));
      }
    }
    lCurrAnn.set(id);
  }
  return lCurrAnn;
}
Пример #5
0
/* given an host int hte form of C string (e.g. "192.168.1.2" or "localhost"), returns the address */
BOOL get_dst_sockaddr_storage(char *host, SOCKADDR_STORAGE *addrPtr) 
{
	struct addrinfo hints, *res = NULL, *ressave = NULL;
	char serviceName[8] = {0};
	sock_t sock = 0;
	
	if((host == NULL) || (addrPtr == NULL)) 
		return RAISE_ERROR(ERROR_WRONG_ARG, NULL);
	
	bzero(&hints, sizeof(struct addrinfo));
	
	if(NetWorkFamily == IPV6) 
	{
		hints.ai_family = AF_INET6;
		hints.ai_flags = AI_V4MAPPED;
	} 
	else 
	{
		hints.ai_family = AF_INET;
	}
	hints.ai_socktype = SOCK_DGRAM;
	snprintf(serviceName, sizeof(serviceName), "%d", SERVER_PORT); // endianness will be handled by getaddrinfo
	if (getaddrinfo(host, serviceName, &hints, &res) !=0 ) 
	{
		return RAISE_ERROR(ERROR_GENERAL, "Can't resolve hostname");
	}
	
	ressave = res;
	do 
	{
		if((sock = socket(res->ai_family, res->ai_socktype, res->ai_protocol)) < 0) 
		{
			continue;                                  /* try next address */
		}
		
		break;
	} while ((res = res->ai_next) != NULL);
	
	close(sock);
	
	if(res == NULL)   /* error on last iteration */
	{ 
		RAISE_SYS_ERR(ERROR_CREATING);
	}
	
	sock_cpy_addr_port((SOCKADDR *)addrPtr, (res->ai_addr));
	
	freeaddrinfo(ressave);
	
	return TRUE;
}
Пример #6
0
/* _lib7_Ncurses_addch : Void -> Bool
 *
 */
lib7_val_t

_lib7_Ncurses_addch (lib7_state_t *lib7_state, lib7_val_t arg)
{
#if HAVE_CURSES_H && HAVE_LIBNCURSES
    int ch     = INT32_LIB7toC(arg);    
    int result = addch( ch );
    if (result == ERR)     return RAISE_ERROR(lib7_state, "addch");
    return LIB7_void;
#else
    extern char* no_ncurses_support_in_runtime;
    return RAISE_ERROR(lib7_state, no_ncurses_support_in_runtime);
#endif
}
Пример #7
0
void dynamic_context::get_variable(
    ulong varid,
    const store::Item_t& varname,
    const QueryLoc& loc,
    store::Item_t& itemValue,
    store::TempSeq_t& seqValue) const
{
  itemValue = NULL;
  seqValue = NULL;

  if (varid >= theVarValues.size() ||
      theVarValues[varid].theState == VarValue::undeclared)
  {
    zstring varName = static_context::var_name(varname.getp());

    if (varid >= theVarValues.size() ||
        theVarValues[varid].theIsExternalOrLocal ||
        (varid > 0 && varid < MAX_IDVARS_RESERVED))
    {
      RAISE_ERROR(err::XPDY0002, loc,
      ERROR_PARAMS(ZED(XPDY0002_VariableUndeclared_2), varName));
    }
    else
    {
      RAISE_ERROR(err::XQDY0054, loc, ERROR_PARAMS(varName));
    }
  }

  const VarValue& var = theVarValues[varid];

  if (var.theState == VarValue::declared)
  {
    zstring varName = static_context::var_name(varname.getp());

    if (var.theIsExternalOrLocal)
    {
      RAISE_ERROR(err::XPDY0002, loc,
      ERROR_PARAMS(ZED(XPDY0002_VariableHasNoValue_2), varName));
    }
    else
    {
      RAISE_ERROR(err::XQDY0054, loc, ERROR_PARAMS(varName));
    }
  }

  if (var.theState == VarValue::item)
    itemValue = var.theValue.item;
  else
    seqValue = var.theValue.temp_seq;
}
Пример #8
0
/*******************************************************************************
  declare updating function
  put($uri as xs:string, $doc as xs:document-node()) as empty-sequence()
********************************************************************************/
bool PutDocumentIterator::nextImpl(
    store::Item_t& result,
    PlanState& aPlanState) const
{
  zstring       lRetrievedUriString;
  zstring       lResolvedUriString;
  store::Item_t lUri;
  store::Item_t lDoc;
  store::Item_t lResolvedUriItem;
  std::unique_ptr<store::PUL> lPul;

  PlanIteratorState* state;
  DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState);

  consumeNext(lUri, theChildren[0].getp(), aPlanState);

  // absolutize retrieved uri
  try
  {
    lUri->getStringValue2(lRetrievedUriString);
    lResolvedUriString = theSctx->resolve_relative_uri(lRetrievedUriString, true);
  }
  catch (ZorbaException const&)
  {
    RAISE_ERROR(err::FODC0004, loc,
    ERROR_PARAMS(lResolvedUriString, ZED(NoResolveRelativeURI)));
  }

  // check if document already exists in the store
  if (GENV_STORE.getDocument(lResolvedUriString) != NULL)
  {
    RAISE_ERROR(zerr::ZAPI0020_DOCUMENT_ALREADY_EXISTS, loc,
    ERROR_PARAMS(lResolvedUriString));
  }

  // create the pul and add the primitive
  GENV_ITEMFACTORY->createAnyURI(lResolvedUriItem, lResolvedUriString);

  lPul.reset(GENV_ITEMFACTORY->createPendingUpdateList());

  consumeNext(lDoc, theChildren[1].getp(), aPlanState);
  lPul->addCreateDocument(&loc, lResolvedUriItem, lDoc);

  result = lPul.release();
  STACK_PUSH(result != NULL, state);

  STACK_END(state);
}
Пример #9
0
/* _lib7_Date_mktime : (Int, Int, Int, Int, Int, Int, Int, Int, Int)
 *	-> int32::Int
 *
 * This takes a 9-tuple with the fields: tm_sec, tm_min, tm_hour, tm_mday,
 * tm_mon, tm_year, tm_wday, tm_yday, tm_isdst, and returns the corresponding
 * localtime value (in seconds).
 */
lib7_val_t _lib7_Date_mktime (lib7_state_t *lib7_state, lib7_val_t arg)
{
    struct tm	tm;
    time_t	t;

    tm.tm_sec	= REC_SELINT(arg, 0);
    tm.tm_min	= REC_SELINT(arg, 1);
    tm.tm_hour	= REC_SELINT(arg, 2);
    tm.tm_mday	= REC_SELINT(arg, 3);
    tm.tm_mon	= REC_SELINT(arg, 4);
    tm.tm_year	= REC_SELINT(arg, 5);
    /* tm.tm_wday = REC_SELINT(arg, 6); */  /* ignored by mktime */
    /* tm.tm_yday = REC_SELINT(arg, 7); */  /* ignored by mktime */
    tm.tm_isdst	= REC_SELINT(arg, 8);

    t = mktime (&tm);

    if (t < 0) {
        return RAISE_ERROR(lib7_state, "Invalid date");
    }
    else {
	lib7_val_t result;

	INT32_ALLOC(lib7_state, result, t);

	return result;
    }
}
Пример #10
0
Val   _lib7_Ncurses_move   (Task* task,  Val arg)   {    // : (Int, Int) -> Void
    //==================
    //
    #if HAVE_CURSES_H && HAVE_LIBNCURSES
	int y = INT1_LIB7toC( GET_TUPLE_SLOT_AS_INT(arg, 0) );
	int x = INT1_LIB7toC( GET_TUPLE_SLOT_AS_INT(arg, 1) );

	int result = move( y, x );

	if (result == ERR)     return RAISE_ERROR(task, "move");
	return HEAP_VOID;
    #else
	extern char* no_ncurses_support_in_runtime;
	return RAISE_ERROR(task, no_ncurses_support_in_runtime);
    #endif
}
Пример #11
0
char *popen_fgets(char *cmd, char *str, int len)
{
	FILE *fp=NULL; 
	if((cmd == NULL) || (str == NULL))
	{
		RAISE_ERROR(ERROR_WRONG_ARG, NULL);
	   return NULL;
	}
	printf_d("CMD: %s\t", cmd);
	memset(str, 0, len);
	fp = popen(cmd, "r");
	if(fp == NULL)
	{
		printf_d("cmd:%s error!%s\n", cmd, strerror(errno));	   
		APVLog("cmd:%s error!%s\n", cmd, strerror(errno)); 	   
		return NULL;   
	}
	   
	fgets(str, len, fp);	   
	if(str[strlen(str)-1] == '\n')	   
	{		   
	   str[strlen(str)-1] = '\0';	   
	}	   
	pclose(fp);
	printf_d("result:%s\n", str);	   
	return str;
}
Пример #12
0
/* _ml_P_Process_waitpid : int * word -> int * int * int
 *
 * Wait for child processes to stop or terminate
 */
ml_val_t _ml_P_Process_waitpid (ml_state_t *msp, ml_val_t arg)
{
    int       pid;
    int       status, how, val;
    ml_val_t  r;

    pid = waitpid(REC_SELINT(arg, 0), &status, REC_SELWORD(arg, 1));
    if (pid < 0)
	return RAISE_SYSERR(msp, pid);

    if (WIFEXITED(status)) {
	how = 0;
	val = WEXITSTATUS(status);
    }
    else if (WIFSIGNALED(status)) {
	how = 1;
	val = WTERMSIG(status);
    }
    else if (WIFSTOPPED(status)) {
	how = 2;
	val = WSTOPSIG(status);
    }
    else
	return RAISE_ERROR(msp, "unknown child status");

    REC_ALLOC3(msp, r, INT_CtoML(pid), INT_CtoML(how), INT_CtoML(val));

    return r;

} /* end of _ml_P_Process_waitpid */
Пример #13
0
void kill_node(node n){
	if(n != NULL){
		free(n);
		n= NULL;
	}
	RAISE_ERROR("Could not delete node ");
}
Пример #14
0
char *in_id(node n){
	if(n != NULL){
		return n->id;
	}
	RAISE_ERROR("NODE EMPTY -- could not find id");
	return n->id;
}
Пример #15
0
/* _lib7_P_Process_osval : String -> int
 *
 * Return the OS-dependent, compile-time constant specified by the string.
 */
lib7_val_t _lib7_P_Process_osval (lib7_state_t *lib7_state, lib7_val_t arg)
{
    name_val_t *result = _lib7_posix_nv_lookup (STR_LIB7toC(arg), values, NUMELMS);

    if (result)   return INT_CtoLib7(result->val);
    else          return RAISE_ERROR(lib7_state, "system constant not defined");
}
Пример #16
0
/*******************************************************************************
  declare function
  is-available-document($uri as xs:string) as xs:boolean
********************************************************************************/
bool IsAvailableDocumentIterator::nextImpl(
    store::Item_t& result,
    PlanState& aPlanState) const
{
  zstring       lRetrievedUriString;
  zstring       lResolvedUriString;
  store::Item_t lUri;

  PlanIteratorState* state;
  DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState);

  consumeNext(lUri, theChildren[0].getp(), aPlanState);

  // absolutize retrieved uri
  try
  {
    lUri->getStringValue2(lRetrievedUriString);
    lResolvedUriString = theSctx->resolve_relative_uri(lRetrievedUriString, true);
  }
  catch (ZorbaException const&)
  {
    RAISE_ERROR(err::FODC0004, loc,
    ERROR_PARAMS(lResolvedUriString, ZED(NoResolveRelativeURI)));
  }

  // check if document exists in the store
  GENV_ITEMFACTORY->
  createBoolean(result, GENV_STORE.getDocument(lResolvedUriString) != NULL);

  STACK_PUSH(true, state);

  STACK_END(state);
}
Пример #17
0
bool OpNumericUnaryIterator::nextImpl(store::Item_t& result, PlanState& planState) const
{
  store::Item_t item;
  store::SchemaTypeCode type;

  const TypeManager* tm = theSctx->get_typemanager();

  PlanIteratorState* state;
  DEFAULT_STACK_INIT(PlanIteratorState, state, planState);

  if (consumeNext(item, theChild.getp(), planState ))
  {
    assert(item->isAtomic());

    type = item->getTypeCode();

    if (type == store::XS_UNTYPED_ATOMIC)
    {
      GenericCast::castToBuiltinAtomic(item, item, store::XS_DOUBLE, NULL, loc);
      type = store::XS_DOUBLE;
    }
    
    // TODO Optimizations (e.g. if item has already the correct type and value,
    // it does not have to be created newly)
    if (TypeOps::is_subtype(type, store::XS_DOUBLE))
    {
      GENV_ITEMFACTORY->
      createDouble(result,
                   (thePlus ? item->getDoubleValue() : -item->getDoubleValue()));
    }
    else if (TypeOps::is_subtype(type, store::XS_FLOAT))
    {
      GENV_ITEMFACTORY->
      createFloat(result,
                  (thePlus ? item->getFloatValue() : -item->getFloatValue()));
    }
    else if (TypeOps::is_subtype(type, store::XS_INTEGER))
    {
      GENV_ITEMFACTORY->
      createInteger(result,
                    (thePlus ? item->getIntegerValue() : -item->getIntegerValue()));
    }
    else if (TypeOps::is_subtype(type, store::XS_DECIMAL))
    {
      GENV_ITEMFACTORY->
      createDecimal(result,
                   (thePlus ? item->getDecimalValue() : -item->getDecimalValue()));
    }
    else
    {
      xqtref_t type = tm->create_value_type(item);
      RAISE_ERROR(err::XPTY0004, loc,
      ERROR_PARAMS(ZED(BadTypeFor_23), type->toSchemaString(), ZED(UnaryArithOp)));
    }
    
    STACK_PUSH(true, state);
  }

  STACK_END(state);
}
Пример #18
0
error_t Std_File_Writer::write( const void* p, long s )
{
	long result = (long) fwrite( p, 1, s, file_ );
	if ( result != s )
		RAISE_ERROR( "Couldn't write to file" );
	return 0;
}
Пример #19
0
static void
Unpack_HLS(OBJ_PTR hls, double *hp, double *lp, double *sp, int *ierr)
{
   int len = Array_Len(hls, ierr);
   if (*ierr != 0) return;
   if (len != 3) {
      RAISE_ERROR("Sorry: invalid hls array: must have 3 entries", ierr);
      return;
   }
   OBJ_PTR entry = Array_Entry(hls, 0, ierr); if (*ierr != 0) return;
   double h = Number_to_double(entry, ierr); if (*ierr != 0) return;
   entry = Array_Entry(hls, 1, ierr); if (*ierr != 0) return;
   double l = Number_to_double(entry, ierr); if (*ierr != 0) return;
   entry = Array_Entry(hls, 2, ierr); if (*ierr != 0) return;
   double s = Number_to_double(entry, ierr); if (*ierr != 0) return;
   if (l < 0.0 || l > 1.0) {
      RAISE_ERROR_g("Sorry: invalid lightness (%g) for hls: must be between 0 "
                    "and 1", l, ierr);
      return;
   }
   if (s < 0.0 || s > 1.0) {
      RAISE_ERROR_g("Sorry: invalid saturation (%g) for hls: must be between "
                    "0 and 1", s, ierr);
      return;
   }
   *hp = h; *lp = l; *sp = s;
}
Пример #20
0
/* 
 * this creates an arbitrary mapping from positions to colors given as
 * (r,g,b) triples
 *
 * the colormap size is set to the length of the vectors 
 *
 * the Rs, Gs, and Bs are VALUEs from 0 to 1 representing the
 * intensity of the color component
 */
OBJ_PTR
c_convert_to_colormap(OBJ_PTR fmkr, FM* p, OBJ_PTR Rs, OBJ_PTR Gs, OBJ_PTR Bs,
                      int *ierr)
{

   long r_len, g_len, b_len;
   double *r_ptr = Vector_Data_for_Read(Rs, &r_len, ierr);
   if (*ierr != 0) RETURN_NIL;
   double *g_ptr = Vector_Data_for_Read(Gs, &g_len, ierr);
   if (*ierr != 0) RETURN_NIL;
   double *b_ptr = Vector_Data_for_Read(Bs, &b_len, ierr);
   if (*ierr != 0) RETURN_NIL;
   if (r_len <= 0 || r_len != g_len || b_len != g_len) {
      RAISE_ERROR("Sorry: vectors for convert_to_colormap must all be of "
                  "same length", ierr);
      RETURN_NIL;
   }
   int i, j, buff_len = r_len * 3;
   unsigned char *buff;
   buff = ALLOC_N_unsigned_char(buff_len);
   for (i = 0, j = 0; j < r_len; j++) {
      buff[i++] = ROUND(r_ptr[j]*255);
      buff[i++] = ROUND(g_ptr[j]*255);
      buff[i++] = ROUND(b_ptr[j]*255);
   }
   OBJ_PTR lookup = String_New((char *)buff, buff_len);
   free(buff);
   OBJ_PTR result = Array_New(2);
   Array_Store(result, 0, Integer_New(r_len-1), ierr);
   Array_Store(result, 1, lookup, ierr);
   if (*ierr != 0) RETURN_NIL;
   return result;
}
Пример #21
0
void
c_private_radial_shading(OBJ_PTR fmkr, FM *p,
                         double x0, double y0, double r0,
                         double x1, double y1, double r1, OBJ_PTR colormap,
                         double a, double b, double c, double d,
                         bool extend_start, bool extend_end, int *ierr)
{
   int len = Array_Len(colormap, ierr);
   if (*ierr != 0) return;
   if (len != 2) {
      RAISE_ERROR("Sorry: colormap must be array [hivalue, lookup]", ierr);
      return;
   }
   OBJ_PTR hival = Array_Entry(colormap, 0, ierr);
   OBJ_PTR lookup = Array_Entry(colormap, 1, ierr);
   int hi_value = Number_to_int(hival, ierr);
   int lookup_len = String_Len(lookup, ierr);
   unsigned char *lookup_ptr = (unsigned char *)(String_Ptr(lookup, ierr));
   if (*ierr != 0) return;
   c_radial_shading(p, x0, y0, r0, x1, y1, r1,
                    hi_value, lookup_len, lookup_ptr,
                    convert_figure_to_output_dx(p, a),
                    convert_figure_to_output_dy(p, b),
                    convert_figure_to_output_dx(p, c),
                    convert_figure_to_output_dy(p, d),
                    convert_figure_to_output_x(p, 0.0),
                    convert_figure_to_output_y(p, 0.0),
                    extend_start, extend_end);
}
Пример #22
0
void AnnotationList::checkLiterals(DeclarationKind k, const QueryLoc& loc) const
{
  for (Annotations::const_iterator ite = theAnnotationList.begin();
       ite != theAnnotationList.end();
       ++ite)
  {
    AnnotationInternal* lAnn = *ite;
    switch (lAnn->getId())
    {
      case AnnotationInternal::zann_exclude_from_cache_key:
      case AnnotationInternal::zann_compare_with_deep_equal:
        //One or more integers
        if (!lAnn->getNumLiterals())
        {
          RAISE_ERROR(zerr::ZXQP0062_INVALID_ANNOTATION_LITERALS_NUMBER, loc,
              ERROR_PARAMS(
                  AnnotationInternal::lookup(lAnn->getId())->getStringValue(),
                  ZED(ZXQP0062_ONE_OR_MORE_LITERALS)));
        }
        for (csize i=0; i<lAnn->getNumLiterals(); ++i)
          checkLiteralType(lAnn, lAnn->getLiteral(i), store::XS_INTEGER, loc);
        break;
      default:
        break;
    }
  }
}
Пример #23
0
/*******************************************************************************
  declare updating function
  remove($uri as xs:string) as empty-sequence()
********************************************************************************/
bool RemoveDocumentIterator::nextImpl(
    store::Item_t& result,
    PlanState& aPlanState) const
{
  zstring       lRetrievedUriString;
  zstring       lResolvedUriString;
  store::Item_t lUri;
  store::Item_t lResolvedUriItem;
  store::PUL_t lPul;

  PlanIteratorState* state;
  DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState);

  consumeNext(lUri, theChildren[0].getp(), aPlanState);

  // absolutize retrieved uri
  try
  {
    lUri->getStringValue2(lRetrievedUriString);
    lResolvedUriString = theSctx->resolve_relative_uri(lRetrievedUriString, true);
  }
  catch (ZorbaException const&)
  {
    RAISE_ERROR(err::FODC0004, loc,
    ERROR_PARAMS(lResolvedUriString, ZED(NoResolveRelativeURI)));
  }

  // check if document exists in the store
  if (GENV_STORE.getDocument(lResolvedUriString) == NULL)
  {
    RAISE_ERROR(zerr::ZXQD0002_DOCUMENT_NOT_VALID, loc,
    ERROR_PARAMS(lResolvedUriString, ZED(NoURIInStore)));
  }

  // create the pul and add the primitive
  GENV_ITEMFACTORY->createAnyURI(lResolvedUriItem, lResolvedUriString);

  lPul = GENV_ITEMFACTORY->createPendingUpdateList();

  lPul->addDeleteDocument(&loc, lResolvedUriItem);

  result.transfer(lPul);
  STACK_PUSH(result != NULL, state);

  STACK_END(state);
}
Пример #24
0
lib7_val_t   _lib7_runtime_itick   (   lib7_state_t*   lib7_state,
                                         lib7_val_t      arg
                                     )
{
    /* _lib7_runtime_itick : Void -> (int * int) */

  return RAISE_ERROR( lib7_state, "itick unimplemented");
}
Пример #25
0
void* loadPlugin(const char* path, uint16_t minVersion, 
                 const char* functionNames[], void** functionPtrs,
                 const char** description) {
  void*               handle;
  PredefinedFunctions preFuncs;
  int                 num, found;

  // Try to load the file
  handle = dlopen(path, RTLD_NOW | RTLD_LOCAL);
  if (handle == NULL) {
    RAISE_ERROR("Failed to load the plugin '%s' : %s", path, dlerror());
    return NULL;
  }

  // Resolve the predefined functions
  load(handle, PredefinedNames, STRUCT_FUNC_PTRS(preFuncs), &num, &found);
  if (found != num) {
    RAISE_ERROR("Invalid plugin");
    dlclose(handle);
    return NULL;
  }

  // Minimum version?
  if (preFuncs.getVersion() < minVersion) {
    RAISE_ERROR("Invalid plugin version (%u < %u)",
               preFuncs.getVersion(), minVersion);
    dlclose(handle);
    return NULL;
  }

  // Resolve the user-functions
  load(handle, functionNames, functionPtrs, &num, &found);
  if (found != num) {
    RAISE_ERROR("Plugin did not contain all functions (exp. = %d, found = %d)",
               num, found);
    dlclose(handle);
    return NULL;
  }

  // In case the user requested the description
  if (description != NULL) {
    *description = preFuncs.getDesc();
  }

  return handle;
}
Пример #26
0
void AnnotationList::checkRequiredDeclarations(
    RuleBitSet declaredAnn,
    DeclarationKind declKind,
    const QueryLoc& loc) const
{
  // check rules
  std::vector<AnnotationRequirement>::const_iterator ite = AnnotationInternal::theRequiredRuleSet.begin();
  std::vector<AnnotationRequirement>::const_iterator end = AnnotationInternal::theRequiredRuleSet.end();

  for (; ite != end; ++ite)
  {
    const AnnotationId& lCurrAnn = ite->first;
    const RuleBitSet& lCurrSet = ite->second;

    if (declaredAnn.test(lCurrAnn) && (declaredAnn & lCurrSet).count() == 0)
    {
      // build error string to return set of required annotations
      std::ostringstream lProblems;
      for (csize i = 0, j = 0; i < AnnotationInternal::zann_end; ++i)
      {
        if (lCurrSet.test(i))
        {
          AnnotationId id = static_cast<AnnotationId>(i);
          lProblems << AnnotationInternal::lookup(id)->getStringValue()
                    << ((j == lCurrSet.count() - 1) ? "" : ", ");
          ++j;
        }
      }

      if (declKind == var_decl)
      {
        RAISE_ERROR(err::XQST0116, loc,
        ERROR_PARAMS(ZED(XQST0116_Requirement),
            AnnotationInternal::lookup(lCurrAnn)->getStringValue(),
            lProblems.str()));
      }
      else
      {
        RAISE_ERROR(err::XQST0106, loc,
        ERROR_PARAMS(ZED(XQST0106_Requirement),
            AnnotationInternal::lookup(lCurrAnn)->getStringValue(),
            lProblems.str()));
      }
    }
  }
}
Пример #27
0
void
FC_SHPCLMOVE(void **addr, fortran_integer_t *length, fortran_integer_t *errcode, fortran_integer_t *want_abort)
{
    void *ret;

    SHMEM_ERR_CHECK_INITIALIZED();
    SHMEM_ERR_CHECK_SYMMETRIC_HEAP(*addr);

    if (*length <= 0) {
        if (0 == *want_abort) {
            fprintf(stderr, "[%03d] shpclmove failure (invalid length)\n",
                    shmem_internal_my_pe);
            RAISE_ERROR(-1);
        } else {
            *errcode = -1;
            return;
        }
    }

    shmem_internal_barrier_all();

    SHMEM_MUTEX_LOCK(shmem_internal_mutex_alloc);
    ret = dlrealloc(*addr, *length * 4); /* length is number of 32 bit words */
    SHMEM_MUTEX_UNLOCK(shmem_internal_mutex_alloc);

    if (*addr != NULL) {
        if (*addr == ret) {
            *errcode = 0;
        } else {
            *errcode = 1;
        }
        *addr = ret;
    } else {
        if (0 == *want_abort) {
            fprintf(stderr, "[%03d] shpclmove failure\n",
                    shmem_internal_my_pe);
            RAISE_ERROR(-2);
        } else {
            *errcode = -2;
            return;
        }
    }

    shmem_internal_barrier_all();
}
Пример #28
0
/* _lib7_P_ProcEnv_ttyname: int -> String
 *
 * Return terminal name associated with file descriptor, if any.
 */
lib7_val_t _lib7_P_ProcEnv_ttyname (lib7_state_t *lib7_state, lib7_val_t arg)
{
    char* name = ttyname(INT_LIB7toC(arg));

    if (name == NULL)
        return RAISE_ERROR(lib7_state, "not a terminal device");
  
    return LIB7_CString (lib7_state, name);
}
Пример #29
0
/* _lib7_NetDB_getnetbyname : String -> (String * String list * addr_family * sysword) option
 */
lib7_val_t _lib7_NetDB_getnetbyname (lib7_state_t *lib7_state, lib7_val_t arg)
{
#if defined(OPSYS_WIN32)
  /* FIXME:  getnetbyname() does not seem to exist under Windows.  What is
     the equivalent? */
  return RAISE_ERROR(lib7_state, "<getnetbyname not implemented>");
#else
    return _util_NetDB_mknetent (lib7_state, getnetbyname (STR_LIB7toC(arg)));
#endif
} /* end of _lib7_NetDB_getnetbyname */
Пример #30
0
void AnnotationList::checkConflictingDeclarations(
    RuleBitSet currAnn,
    DeclarationKind declKind,
    const QueryLoc& loc) const
{
  // check rules
  std::vector<RuleBitSet>::const_iterator ite = AnnotationInternal::theConflictRuleSet.begin();
  std::vector<RuleBitSet>::const_iterator end = AnnotationInternal::theConflictRuleSet.end();

  for (; ite != end; ++ite)
  {
    const RuleBitSet& lCurrSet = *ite;

    if ((currAnn & lCurrSet).count() > 1)
    {
      // build error string to return set of conflicting annotations
      std::ostringstream lProblems;
      for (csize i = 0, j = 0; i < AnnotationInternal::zann_end; ++i)
      {
        if (lCurrSet.test(i))
        {
          AnnotationId id = static_cast<AnnotationId>(i);

          lProblems << AnnotationInternal::lookup(id)->getStringValue()
                    << ((j == (currAnn & lCurrSet).count() - 1) ? "" : ", ");
          ++j;
        }
      }

      if (declKind == var_decl)
      {
        RAISE_ERROR(err::XQST0116, loc,
        ERROR_PARAMS(ZED(XQST0116_Conflicting), lProblems.str()));
      }
      else
      {
        RAISE_ERROR(err::XQST0106, loc,
        ERROR_PARAMS(ZED(XQST0106_Conflicting), lProblems.str()));
      }
    }
  }
}