KJS::Value Point::call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args ) {
    if( !JSProxy::checkType(self, JSProxy::ValueProxy, "QPoint") ) return KJS::Value();
    JSValueProxy *vp = JSProxy::toValueProxy( self.imp() );
    KJS::Value retValue = KJS::Value();
    QPoint val = vp->toVariant().toPoint();

    switch ( mid ) { 
      case Methodx:
	retValue = KJS::Number(val.x());
       break;
      case MethodsetX:
	val.setX(extractInt(exec,args,0));
	break;
      case  Methody:
	retValue = KJS::Number(val.y());
	break;
      case  MethodsetY:
	val.setY(extractInt(exec,args,0));
	break;
      case  MethodmanhattanLength:
	retValue = KJS::Number(val.manhattanLength());
	break;
      default:
	QString msg = i18n( "Point has no method %1" ).arg(mid);
  return throwError(exec, msg);
	break;
    }

    vp->setValue(val);
    return retValue;
  }
示例#2
0
static int doExtensionMcp23s17 (char *progName, int pinBase, char *params)
{
  int spi, port ;

  if ((params = extractInt (progName, params, &spi)) == NULL)
    return FALSE ;

  if ((spi < 0) || (spi > 1))
  {
    verbError ("%s: SPI address (%d) out of range", progName, spi) ;
    return FALSE ;
  }

  if ((params = extractInt (progName, params, &port)) == NULL)
    return FALSE ;

  if ((port < 0) || (port > 7))
  {
    verbError ("%s: port address (%d) out of range", progName, port) ;
    return FALSE ;
  }

  mcp23s17Setup (pinBase, spi, port) ;

  return TRUE ;
}
示例#3
0
static int doExtensionMcp3422 (char *progName, int pinBase, char *params)
{
  int i2c, sampleRate, gain ;

  if ((params = extractInt (progName, params, &i2c)) == NULL)
    return FALSE ;

  if ((i2c < 0x03) || (i2c > 0x77))
  {
    verbError ("%s: i2c address (0x%X) out of range", progName, i2c) ;
    return FALSE ;
  }

  if ((params = extractInt (progName, params, &sampleRate)) == NULL)
    return FALSE ;

  if ((sampleRate < 0) || (sampleRate > 3))
  {
    verbError ("%s: sample rate (%d) out of range", progName, sampleRate) ;
    return FALSE ;
  }

  if ((params = extractInt (progName, params, &gain)) == NULL)
    return FALSE ;

  if ((gain < 0) || (gain > 3))
  {
    verbError ("%s: gain (%d) out of range", progName, gain) ;
    return FALSE ;
  }

  mcp3422Setup (pinBase, i2c, sampleRate, gain) ;

  return TRUE ;
}
示例#4
0
static int doExtensionSr595 (char *progName, int pinBase, char *params)
{
  int pins, data, clock, latch ;

// Extract pins

  if ((params = extractInt (progName, params, &pins)) == NULL)
    return FALSE ;

  if ((pins < 8) || (pins > 32))
  {
    verbError ("%s: pin count (%d) out of range - 8-32 expected.", progName, pins) ;
    return FALSE ;
  }

  if ((params = extractInt (progName, params, &data)) == NULL)
    return FALSE ;

  if ((params = extractInt (progName, params, &clock)) == NULL)
    return FALSE ;

  if ((params = extractInt (progName, params, &latch)) == NULL)
    return FALSE ;

  sr595Setup (pinBase, pins, data, clock, latch) ;

  return TRUE ;
}
JNIEXPORT void JNICALL Java_ondrej_platek_bind_NativeRenderer_changeWH(JNIEnv *env, jobject mythis) {
    AppCtx * c =  reinterpret_cast<AppCtx*>(extractInt(env, mythis, "pAppCtx"));
    if(c == NULL) {
      LOGE("NativeRender_changeWH context is NULL");
    }
    else {
        c->height = extractInt(env, mythis, "height");
        c->width = extractInt(env, mythis, "width");
        viewValuesSetUp(c);
    }
}
static bool chooseKernel (Kernel *kernel, Description *desc, int &unrollFactor) 
{
	if (kernel == NULL)
	{
		return true;	
	}

	std::string str = "";

	unsigned int nbr = kernel->getNbrStatements ();

	for (unsigned int i = 0; i < nbr; i++)
	{
		//Get statement
		Statement *stmt = kernel->getModifiableStatement (i);

		//Paranoid
		assert (stmt != NULL);

		//We only care about comment
		Comment *comment = dynamic_cast<Comment *> (stmt);	 

		if (comment != NULL)   
		{
			stmt->getString (str, desc, 0);

			//We care about '#Unroll factor'
			if (str.find ("#Unrolled factor") != str.npos)
			{
				//The first unroll comment update the factor of unrolling
				if (unrollFactor == -1)  
				{
					//Update the unroll factor
					unrollFactor = extractInt (str);
				}
				else
				{
					if (extractInt (str) != unrollFactor)
					{	
						return false;
					}
				}			
			}
		}
	}

	return true;
}
/////////// JNICALL .._releaseCpp resources ////////////
JNIEXPORT void JNICALL Java_ondrej_platek_bind_NativeRenderer_releaseCppResources(JNIEnv * env, jobject mythis) {
    AppCtx * c =  reinterpret_cast<AppCtx*>(extractInt(env, mythis, "pAppCtx"));
    if(c == NULL) {
      LOGE("NativeRender_releaseCppResources context is NULL");
    }
    releaseVertexRes(c);
}
/////////// JNICALL .._Zoom ////////////
JNIEXPORT void JNICALL Java_ondrej_platek_bind_NativeRenderer_Zoom(JNIEnv * env, jobject mythis, float z) {
    AppCtx * c =  reinterpret_cast<AppCtx*>(extractInt(env, mythis, "pAppCtx"));
    if(c == NULL) {
        LOGE("NativeRender_Zoom context is NULL");
    }
    else {
        zoom(c,z);
    }
}
/////////// JNICALL .._step ////////////
JNIEXPORT void JNICALL Java_ondrej_platek_bind_NativeRenderer_step(JNIEnv * env, jobject mythis) {
    AppCtx * c =  reinterpret_cast<AppCtx*>(extractInt(env, mythis, "pAppCtx"));
    if(c == NULL) {
      LOGE("NativeRender_step context is NULL");
    }
    else {
        renderFrame(c);
    }
}
示例#10
0
static int doExtensionRht03 (char *progName, int pinBase, char *params)
{
  int piPin ;

  if ((params = extractInt (progName, params, &piPin)) == NULL)
    return FALSE ;

  return rht03Setup (pinBase, piPin) ;
}
示例#11
0
/////////// JNICALL .._RotateAnchor ////////////
JNIEXPORT void JNICALL Java_ondrej_platek_bind_NativeRenderer_RotateAnchor(JNIEnv * env, jobject mythis, float dx, float dy) {
    // LOGI("rotating with dx, dy by %f %f", dx,dy);
    AppCtx * c =  reinterpret_cast<AppCtx*>(extractInt(env, mythis, "pAppCtx"));
    if(c == NULL) {
        LOGE("NativeRender_RotateAnchor context is NULL");
    } 
    else {
        rotateAnchor(c, dx, dy);
    }
}
bool extractOneColumnMeta(std::istream & sourceFile, ColumnMetadata & oneColumn) {
	std::wstring dummyWstring;
	extractWstring(sourceFile, dummyWstring);
	oneColumn.setColumnName(dummyWstring);
	unsigned char oneChar = extractIntegralBytes<unsigned char>(sourceFile, 1);
	//sourceFile.read((char*)&oneChar, 1);
	oneColumn.setColumnType((ColumnTypeEnum)oneChar);
	oneColumn.setColumnTypeSize(extractInt(sourceFile));
	return true;
}
bool extractNameTypeValueTrips(std::istream & sourceFile, std::vector<DataHeaderParameter> & vectorToStoreParameters) {
	int paramCount = extractInt(sourceFile);

	vectorToStoreParameters.reserve(paramCount);
	for (int i = 0; i < paramCount; i++) {
		DataHeaderParameter newDHP;
		extractOneHeaderTriple(sourceFile, newDHP);
		vectorToStoreParameters.push_back(newDHP);
	}

	return true;
}
bool extractString(std::istream & sourceFile, std::string & result) {
	int stringLengthPrefix = extractInt(sourceFile);
	char * buff = new char[stringLengthPrefix];

	sourceFile.read(buff, stringLengthPrefix);
	result.clear();
	result.reserve(stringLengthPrefix+1);
	result.assign(buff, stringLengthPrefix);
	delete [] buff;

	return true;
}
示例#15
0
static int doExtensionDrcS (char *progName, int pinBase, char *params)
{
  char *port ;
  int pins, baud ;

  if ((params = extractInt (progName, params, &pins)) == NULL)
    return FALSE ;

  if ((pins < 1) || (pins > 1000))
  {
    verbError ("%s: pins (%d) out of range (2-1000)", progName, pins) ;
    return FALSE ;
  }
  
  if ((params = extractStr (progName, params, &port)) == NULL)
    return FALSE ;

  if (strlen (port) == 0)
  {
    verbError ("%s: serial port device name required", progName) ;
    return FALSE ;
  }

  if ((params = extractInt (progName, params, &baud)) == NULL)
    return FALSE ;

  if ((baud < 1) || (baud > 4000000))
  {
    verbError ("%s: baud rate (%d) out of range", progName, baud) ;
    return FALSE ;
  }

  drcSetupSerial (pinBase, pins, port, baud) ;

  return TRUE ;
}
bool extractFileHeader(std::istream & sourceFile, int & groupCount, unsigned int & startPos) {
	int magicNum = extractIntegralBytes<int>(sourceFile, 1);
	if ( magicNum != 59 ) {
		return false;
	}

	int versionNum = extractIntegralBytes<int>(sourceFile, 1);
	if ( versionNum != 1 ) {
		return false;
	}

	groupCount = extractInt(sourceFile);
	startPos = extractUint(sourceFile);

	return true;
}
KJS::Value MyCustomObjectImp::call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args ) {

    kdDebug() << "MyCustomObjectImp::call() " << mid << endl;
    JSOpaqueProxy *op = JSProxy::toOpaqueProxy( self.imp() );
    if ( !op ) {
        kdWarning() << "MyCustomObjectImp::call() failed, not a JSOpaqueProxy" << endl;
        return KJS::Value();
    }

    if ( op->typeName() != "MyCustomObject" ) {
	kdWarning() << "MyCustomObjectImp::call() failed, type is " << op->typeName() << endl;
	return KJS::Value();
    }

    MyCustomObject *obj = op->toNative<MyCustomObject>();

    KJS::Value retValue = KJS::Value();
    switch ( mid ) {
    case Methodthing:
    {
	retValue = KJS::String(obj->thing);
	break;
    }
    case MethodsetThing:
    {
	obj->thing = extractString(exec, args, 0);
	break;
    }
    case Methodmode:
    {
	retValue = KJS::Number( (int)obj->mode );
	break;
    }
    case MethodsetMode:
    {
	obj->mode = (MyCustomObject::Mode) extractInt(exec, args, 0);
	break;
    }
    default:
        kdWarning() << "MyCustomObject has no method " << mid << endl;
        break;
    }

    op->setValue((void*) obj, "MyCustomObject");
    return retValue;
}
示例#18
0
static int doExtensionMcp4802 (char *progName, int pinBase, char *params)
{
  int spi ;

  if ((params = extractInt (progName, params, &spi)) == NULL)
    return FALSE ;

  if ((spi < 0) || (spi > 1))
  {
    verbError ("%s: SPI channel (%d) out of range", progName, spi) ;
    return FALSE ;
  }

  mcp4802Setup (pinBase, spi) ;

  return TRUE ;
}
static int doExtensionPcf8574 (char *progName, int pinBase, char *params)
{
  int i2c ;

  if ((params = extractInt (progName, params, &i2c)) == NULL)
    return FALSE ;

  if ((i2c < 0x03) || (i2c > 0x77))
  {
    fprintf (stderr, "%s: i2c address (0x%X) out of range\n", progName, i2c) ;
    return FALSE ;
  }

  pcf8574Setup (pinBase, i2c) ;

  return TRUE ;
}
示例#20
0
static int doExtensionPcf8591 (char *progName, int pinBase, char *params)
{
  int i2c ;

  if ((params = extractInt (progName, params, &i2c)) == NULL)
    return FALSE ;

  if ((i2c < 0x03) || (i2c > 0x77))
  {
    verbError ("%s: i2c address (0x%X) out of range", progName, i2c) ;
    return FALSE ;
  }

  pcf8591Setup (pinBase, i2c) ;

  return TRUE ;
}
示例#21
0
static int doExtensionDrcNet (char *progName, int pinBase, char *params)
{
  int pins ;
  char *ipAddress, *port, *password ;
  char pPort [1024] ;

  if ((params = extractInt (progName, params, &pins)) == NULL)
    return FALSE ;

  if ((pins < 1) || (pins > 1000))
  {
    verbError ("%s: pins (%d) out of range (2-1000)", progName, pins) ;
    return FALSE ;
  }
  
  if ((params = extractStr (progName, params, &ipAddress)) == NULL)
    return FALSE ;

  if (strlen (ipAddress) == 0)
  {
    verbError ("%s: ipAddress required", progName) ;
    return FALSE ;
  }

  if ((params = extractStr (progName, params, &port)) == NULL)
    return FALSE ;

  if (strlen (port) == 0)
  {
    sprintf (pPort, "%d", DEFAULT_SERVER_PORT) ;
    port = pPort ;
  }

  if ((params = extractStr (progName, params, &password)) == NULL)
    return FALSE ;

  if (strlen (password) == 0)
  {
    verbError ("%s: password required", progName) ;
    return FALSE ;
  }

  return drcSetupNet (pinBase, pins, ipAddress, port, password) ;
}
bool extractWstring(std::istream & sourceFile, std::wstring & result) {
	int stringLengthPrefix = extractInt(sourceFile);
	unsigned char * buff = new unsigned char[2*stringLengthPrefix];
	char16_t oneWchar;

	sourceFile.read((char*)buff, 2*stringLengthPrefix);
	result.clear();
	result.reserve(stringLengthPrefix+1);

	// .CEL files' "Unicode" wide-strings do not actually conform to
	// the Unicode standard. Each wide-byte is big-endian instead
	// of the required little-endian.
	for (int i = 0; i < stringLengthPrefix; i++) {
		oneWchar = buff[i*2] << 8;
		oneWchar += buff[(i+1)*2-1];
		result.append(1, oneWchar);
	}
	delete [] buff;

	return true;
}
KJS::Value BrushImp::call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args ) {
 
    if( !JSProxy::checkType(self, JSProxy::ValueProxy, "QBrush") ) return KJS::Value();
    JSValueProxy *op = JSProxy::toValueProxy( self.imp() );
    QBrush brush = op->toVariant().toBrush();

    KJS::Value retValue = KJS::Value();
    switch ( mid ) {
    case Methodstyle:
    {
    	return KJS::Number((int) brush.style() );
	break;
    }
    case MethodsetStyle:
    {
    	int style = extractInt(exec, args, 0);
	brush.setStyle((Qt::BrushStyle)style);
	break;
    }
    case MethodColor:
    {
    	return convertToValue(exec, brush.color());
	break;
    }
    case MethodsetColor:
    {
    	QColor color = extractQColor(exec, args, 0);
	brush.setColor(color);
	break;
    }
    default:
        kdWarning() << "Brush has no method " << mid << endl;
        break;
    }

    op->setValue(brush);
    return retValue;
}
bool extractGenericDataHeader(std::istream & sourceFile, std::vector<DataHeaderParameter> & vectorToStoreParameters) {
	std::string dataTypeID;
	std::string fileGUID;
	std::wstring timeOfCreation;
	std::wstring fileLocale;
	int parentHeaderCount;

	extractString(sourceFile, dataTypeID);
	extractString(sourceFile, fileGUID);
	extractWstring(sourceFile, timeOfCreation);
	extractWstring(sourceFile, fileLocale);
	extractNameTypeValueTrips(sourceFile, vectorToStoreParameters);

	// Extract and ignore parent Generic Data Headers
	bool parentRecordsExtracted = true;
	std::vector<DataHeaderParameter> parentParamVector;
	parentHeaderCount = extractInt(sourceFile);
	parentParamVector.reserve(parentHeaderCount);
	for (int i = 0; i < parentHeaderCount; i++) {
		parentRecordsExtracted &= extractGenericDataHeader(sourceFile, parentParamVector);
	}

	return parentRecordsExtracted;
}
示例#25
0
文件: Time.cpp 项目: evgs/bombus-ng
PackedTime strtime::PackIso8601(const std::string &time) {
    SYSTEMTIME st;
    memset(&st, 0, sizeof(SYSTEMTIME));
    PackedTime t={0,0};
    if (time.length()<17) return t;
    // 0123456789abcdef0
    // CCYYMMDDThh:mm:ss
    if (time[8]=='T') {
        st.wYear=extractInt(time, 0, 4);
        st.wMonth=extractInt(time, 4, 6);
        st.wDay=extractInt(time, 6, 8);
        st.wHour=extractInt(time, 9, 11);
        st.wMinute=extractInt(time, 12, 14);
        st.wSecond=extractInt(time, 15, 17);
    } 

    // 0123456789abcdef0
	// CCYY-MM-DDThh:mm:ss[.sss]TZD
    if (time[10]=='T') {
		if (time.length()<19) return t;
        st.wYear=extractInt(time, 0, 4);
        st.wMonth=extractInt(time, 5, 7);
        st.wDay=extractInt(time, 8, 10);
        st.wHour=extractInt(time, 11, 13);
        st.wMinute=extractInt(time, 14, 16);
        st.wSecond=extractInt(time, 17, 19);
    } //TODO CCYY-MM-DDThh:mm:ss[.sss]TZD

    SystemTimeToFileTime(&st, &t);
    return t;
}
KJS::Value Pixmap::call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args ) {

    if( !JSProxy::checkType( self, JSProxy::ValueProxy, "QPixmap") )
        return KJS::Value();

    JSValueProxy *op = JSProxy::toValueProxy( self.imp() );
    pix = op->toVariant().toPixmap();

    KJS::Value retValue = KJS::Value();
    switch ( mid ) {
    case Methodwidth:
        retValue = KJS::Number(width());
        break;
    case Methodheight:
        retValue = KJS::Number(height());
        break;
    case Methoddepth:
        retValue = KJS::Number(depth());
        break;
    case MethodisNull:
        retValue = KJS::Boolean(isNull());
        break;
    case Methodsize:
        retValue = convertToValue(exec, size());
        break;
    case Methodrect:
        retValue = convertToValue(exec, rect());
        break;
    case Methodresize:
    {
        if( args.size() == 2)
		resize(extractInt(exec, args, 0), extractInt(exec, args, 1));
	else if( args.size() == 1)
	    resize(extractQSize(exec, args, 0) );
	break;
    }
    case Methodfill:
        fill( extractQColor(exec, args, 0));
        break;
    case Methodmask:
    {
        retValue = convertToValue(exec, mask() );
        break;
    }
    case MethodsetMask:
    {
       setMask(extractQPixmap(exec, args, 0));
       break;
    }
    case MethodcreateHeuristicMask:
    {
       retValue = convertToValue(exec, createHeuristicMask(extractBool(exec, args, 0)));
       break;
    }
    case MethodgrabWindow:
    {
    	int winid = extractInt(exec, args,0);
	int x = extractInt(exec, args,1);
	int y = extractInt(exec, args,2);
	int w = extractInt(exec, args,3);
	int h = extractInt(exec, args,4);
    	grabWindow(winid,x,y,w,h);
	break;
    }
    default:
        kdWarning() << "Image has no method " << mid << endl;
        break;
    }

    op->setValue(pix);
    return retValue;
}
示例#27
0
/////////// JNICALL .._init ////////////
JNIEXPORT void JNICALL Java_ondrej_platek_bind_NativeRenderer_initV(JNIEnv * env, jobject mythis,jobjectArray npo, jobjectArray Faces)  {
    int ic = extractInt(env, mythis,"pAppCtx");
    LOGI("AppCtx pointer at beggining init: %d",ic);
    AppCtx * c =  reinterpret_cast<AppCtx*>(ic);
    if(c == NULL) { // create new AppCtx -> should be only 1
        c = new AppCtx();
        LOGI("AppCtx pointer initialize in init: %d",c);
    }
    else {
        releaseVertexRes(c);
    }

    int vert_raw_size = extractInt(env, mythis, "vertices_size");
    int norm_raw_size = extractInt(env, mythis, "normals_size");
    c->parts_number = extractInt(env, mythis, "parts_number");

    // jArrays -> I have to release them afterwards
    jobject mvdata = objForArray(env, mythis, "vertices", "[F");
    jfloatArray * arr = reinterpret_cast<jfloatArray*>(&mvdata);
    float * raw_vertices = env->GetFloatArrayElements(*arr, NULL);

    mvdata = objForArray(env, mythis, "normals", "[F");
    jfloatArray * arr1 = reinterpret_cast<jfloatArray*>(&mvdata);
    float * raw_normals = env->GetFloatArrayElements(*arr1, NULL);


    mvdata = objForArray(env, mythis, "parts_sizes", "[I");
    jintArray * arr2 = reinterpret_cast<jintArray*>(&mvdata);
    int * raw_parts_sizes = env->GetIntArrayElements(*arr2, NULL);

    c->parts_sizes = new int[c->parts_number];
    // TODO memcpy
    for(int i = 0; i < c->parts_number; i++) {
        c->parts_sizes[i] = raw_parts_sizes[i];
    }

    c->faces = new GLuint*[c->parts_number];
    GLuint ** np = new GLuint*[c->parts_number];
    for(int i = 0; i < c->parts_number; i++) {
         jshortArray oneDimFaces = (jshortArray) env->GetObjectArrayElement(Faces, i);
         jshortArray oneDimNormP = (jshortArray)env->GetObjectArrayElement(npo, i);
         jshort * arrface =env->GetShortArrayElements(oneDimFaces, 0);
         jshort * arrnorm =env->GetShortArrayElements(oneDimNormP, 0);
         c->faces[i] = new GLuint[c->parts_sizes[i]];
         np[i] = new GLuint[c->parts_sizes[i]];
         for(int j = 0; j < c->parts_sizes[i]; j++) { // each part could have different number of vertices
            c->faces[i][j] = arrface[j];
            np[i][j]= arrnorm[j];
         }
    }

    // delete np, fill vertices, change faces
    c->vertices = separateVertices(&c->numVertices, raw_vertices,
        raw_normals, c->faces, np, c->parts_sizes, c->parts_number);


    // Don't forget to release it
    env->ReleaseFloatArrayElements(*arr, raw_vertices, JNI_ABORT);
    env->ReleaseFloatArrayElements(*arr1, raw_normals, JNI_ABORT);
    env->ReleaseIntArrayElements(*arr2, raw_parts_sizes, JNI_ABORT);

    // return AppCtx c
    int retValue = reinterpret_cast<int>(c);
    LOGI("AppCtx pointer at the end of init: %d",retValue);
    returnInt(env, mythis,"pAppCtx", retValue);
}
示例#28
0
/*
 * Total Order Broadcast with good throughput.
 * Note that like every functions defined here, they have the type NodesFct.
 */
void TOBThroughputBroadcast(int id, Message m){

    PipelineAckData_t data;
    int argSize, ackOrigin;
    char *event, *eventArg, *msgTxt;
    Message mOut;
    NumberedMessage NumMsg, temp;

    if((data=(PipelineAckData_t)getData(id))==NULL){
        //Initialization

        if((data=malloc(sizeof(struct _PipleineAckData_t)))==NULL){
            fprintf(stderr,"malloc fail at TOBThroughputBroadcast\n");
            exit(EXIT_FAILURE);
        }

        data->clock=0;
        data->next=(id+1)%getNbNodes();
        //        data->pred=(id==0)?getNbNodes()-1:id-1;
        data->pending=newSortedList(NumberedMsgComp);
        setData(id,data);
    }

    if(m==NULL){
        // Event Rules
        if((event = getNextExternalEvent(id)) != NULL){
            printf("event received %i %s\n",id, event); 
            // Read the first event
            if(event==strstr(event, "broadcast")){
                //there is an event : increment the clock
                data->clock++;
                //event is someting like broadcast <string>
                if((eventArg=malloc(sizeof(char)*maxArgSize))==NULL){
                    fprintf(stderr,"malloc fail at TOBThroughputBroadcast\n");
                    exit(EXIT_FAILURE);
                }
                if(1>sscanf(event, "broadcast %s", eventArg)){
                    sscanf("hello","%s",eventArg);
                }
                //eventArg is either the string to broadcast, or "hello"
                argSize=strlen(eventArg);
                if((msgTxt=malloc((intToStringSize+1+argSize)*sizeof(char)))==NULL){
                    fprintf(stderr,"malloc fail at TOBThroughputBroadcast\n");
                    exit(EXIT_FAILURE);
                }
                sprintf(msgTxt, "%d ",data->clock);
                strncat(msgTxt, eventArg, argSize); 
                //Now the message text have the format: clk <arg>
                if((NumMsg=malloc(sizeof(struct _NumberedMessage)))==NULL){
                    fprintf(stderr,"malloc fail at TOBThroughputBroadcast\n");
                    exit(EXIT_FAILURE);
                }
                NumMsg->clk=data->clock;
                //waiting for 1 ack
                //creating the actual message
                NumMsg->m=initMessage(msgTxt,id,id,data->next);
                free(msgTxt);
                NumMsg->origin=id;
                if(data->next==id){
                    //we are the only process of the system
                    deliver(NumMsg->m,id);
                    free(NumMsg->m->msg);
                    free(NumMsg->m);
                    free(NumMsg);
                }else{
                    //and send it
                    Send(copyMessage(NumMsg->m));
                    //Finally store the numbered msg in the pending list
                    AddSorted(NumMsg,data->pending);
                }
            }
            free(event);
        }

    }else{
        // Message Rules
        if((NumMsg=malloc(sizeof(struct _NumberedMessage)))==NULL){
            fprintf(stderr,"malloc fail at TOBThroughputBroadcast\n");
            exit(EXIT_FAILURE);
        }

        //this is a new message at the format:
        //clock <text> where text is either ack or the text of the
        //message
        //We have to parse the clock of the broadcast
        extractInt(m->msg, &(NumMsg->clk));
        NumMsg->origin=m->origin;
        //don't forget to update the clock
        data->clock=MAX(NumMsg->clk,data->clock)+1;

        if(strstr(m->msg,"ack")==NULL){
            printf("%s received by %d from %d but not delivered yet\n", m->msg, id, m->sender);
            //m is an actual message
            NumMsg->m=m;
            if(m->origin!=data->next){
                //We need to forward the message
                mOut=initMessage(m->msg,m->origin,id,data->next);
                Send(mOut);
                AddSorted(NumMsg,data->pending);
            }else{
                AddSorted(NumMsg,data->pending);
                //we deliver all the older messages
                mOut=NULL;
                while((temp=getFirst(data->pending))!=NULL && NumMsg!=NULL && NumberedMsgComp(temp,NumMsg)<=0){
                    //we remove the message from the pending list
                    RemoveFirst(data->pending);
                    if(!NumberedMsgComp(temp,NumMsg)){
                        //to ensure we stop after that
                        NumMsg=NULL;
                    }
                    //prepare an ack
                    if(temp->origin!=id){
                        if(mOut!=NULL){
                            free(mOut);
                        }
                        mOut=Ack(temp->clk,temp->origin,id,data->next);
                    }
                    //deliver
                    deliver(temp->m,id);
                    //we can free the message
                    free(temp->m->msg);
                    free(temp->m);
                    free(temp);
                }
                //if we have managed to deliver a message
                //we acknowleged the older message delvered
                if(mOut){
                    Send(mOut);
                }
            }

        }else{
            //this is an ack
            printf("%s received by %d from %d origin %d\n", m->msg, id, m->sender, m->origin);
            //we deliver all the older messages
            mOut=NULL;
            while((temp=getFirst(data->pending))!=NULL && NumMsg!=NULL && NumberedMsgComp(temp,NumMsg)<=0){
                //we remove the message from the pending list
                RemoveFirst(data->pending);
                //prepare an ack
                ackOrigin=((temp->origin+getNbNodes()-1)%getNbNodes());
                if(ackOrigin!=data->next){
                    if(mOut!=NULL){
                        free(mOut);
                    }
                    mOut=Ack(temp->clk,temp->origin,id,data->next);
                }
                //deliver
                deliver(temp->m,id);
                //we can free the message
                free(temp->m->msg);
                free(temp->m);
                free(temp);
            }
            //if we have managed to deliver a message
            //we acknowleged the older message delvered
            ackOrigin=((NumMsg->origin+getNbNodes()-1)%getNbNodes());
            if(mOut){
                Send(mOut);
            }else if(Size(data->pending)==0 && ackOrigin!=data->next){
                //we haven't be able to deliver a message because our pending
                //list is empty, but the message may be blocked in someon else
                //queue so we forward the ack
                Send(Ack(NumMsg->clk,NumMsg->origin,id,data->next));
            }
            // Free the local message
            free(m->msg);
            free(m);
        }
    }

}
KJS::Value KJSEmbed::Bindings::KFileItemImp::call( KJS::ExecState * exec, KJS::Object & self, const KJS::List & args )
{
	kdDebug() << "KFileItemImp::call() " << mid << endl;
	JSOpaqueProxy *op = JSProxy::toOpaqueProxy( self.imp() );
	if ( !op ) {
		kdWarning() << "KFileItemImp::call() failed, not a JSOpaqueProxy" << endl;
		return KJS::Value();
	}
	
	if ( op->typeName() != "KFileItem" ) {
		kdWarning() << "KFileItemImp::call() failed, type is " << op->typeName() << endl;
		return KJS::Value();
	}
	
	KFileItem *obj = op->toNative<KFileItem >();
	
	KJS::Value retValue = KJS::Value();
	switch ( mid ) {
	case Methodrefresh:
		obj->refresh();
		break;
	case MethodrefreshMimeType:
		obj->refreshMimeType(); 
		break;
	case Methodurl:
	{
		QString url = obj->url().url();
		retValue = KJS::String(url);
		break;
	}
	case MethodsetUrl:
	{
		QString url = extractQString(exec, args, 0);
		obj->setURL(url);
		break;
	}
	case MethodsetName: 
	case MethodpermissionsString: 
	case Methoduser: 
	case Methodgroup: 
	case MethodisLink: 
	case MethodisDir: 
	case MethodisFile: 
	case MethodisReadable: 
	case MethodlinkDest: 
	case MethodtimeString: 
	case MethodisLocalFile: 
	case Methodtext:
	{
		retValue = convertToValue(exec, obj->text() );
		break;
	} 
	case Methodname:  
	case MethodmimeType: 
	case MethodisMimeTypeKnown: 
	case MethodmimeComment: 
	case MethodiconName: 
	{
		retValue = convertToValue( exec, obj->iconName() );
		break;
	}
	case Methodpixmap:
	{
		int size = extractInt(exec, args, 0);
		int state = extractInt(exec, args, 1);
		retValue = convertToValue(exec, obj->pixmap(size, state));
		break;
	}
	case Methodoverlays: 
	{
		retValue = convertToValue(exec, obj->overlays());
		break;
	}
	case MethodgetStatusBarInfo: 
	{
		retValue = KJS::String( obj->getStatusBarInfo() );
		break;
	}
	case MethodgetToolTipText:
	{
		int maxcount = extractInt(exec, args, 0);
		retValue = KJS::String(obj->getToolTipText(maxcount));
		break;
	}
	case Methodrun:
		obj->run();
		break;
	default:
		kdWarning() << "KFileItemImp has no method " << mid << endl;
		break;
	}
	
	op->setValue((void*) obj, "KFileItem");
	return retValue;

} 
int32_t LogisticsComponent::init(PSTR dataLine)
{
	PSTR line  = dataLine;
	PSTR pLine = line;
	char pBuffer[1025];
	ID = (extractInt(pLine));
	// the type
	extractString(pLine, pBuffer, 1024);
	int32_t i;
	for (i = 0; i < NUM_COMPONENT_FORMS; ++i)
	{
		if (0 == _stricmp(ComponentFormString[i], pBuffer))
		{
			Type = i;
			break;
		}
	}
	if (i == NUM_COMPONENT_FORMS)
		return -1;
	// name, probably aren't going to use this, they should be in the RC.
	extractString(pLine, pBuffer, 1024);
	// name, probably aren't going to use this, they should be in the RC.
	extractString(pLine, pBuffer, 1024); // ignore critical hits
	recycleTime = extractFloat(pLine);
	heat		= extractFloat(pLine);
	// weight
	weight = extractFloat(pLine);
	damage = extractFloat(pLine);
	// ignore battle rating
	extractString(pLine, pBuffer, 1024);
	// cost
	cost = extractInt(pLine);
	// range
	extractString(pLine, pBuffer, 1024);
	if (!isWeapon())
		rangeType = NO_RANGE;
	else if (!strcmp(pBuffer, "int32_t"))
		rangeType = int32_t;
	else if (!strcmp(pBuffer, "medium"))
		rangeType = MEDIUM;
	else
		rangeType = int16_t;
	// we need to figure out where things can go
	extractString(pLine, pBuffer, 1024);
	bHead = _stricmp(pBuffer, "Yes") ? false : true;
	extractString(pLine, pBuffer, 1024);
	bTorso = _stricmp(pBuffer, "Yes") ? false : true;
	// ignore the next 4 columns
	for (i = 0; i < 4; ++i)
		extractString(pLine, pBuffer, 1024);
	extractString(pLine, pBuffer, 1024);
	bLegs = _stricmp(pBuffer, "Yes") ? false : true;
	// ignore the next 4 columns
	for (i = 0; i < 4; ++i)
		extractString(pLine, pBuffer, 1024);
	Ammo = extractInt(pLine);
	// now read in icon info
	extractString(pLine, pBuffer, 1024);
	if (*pBuffer && (pBuffer[0] != '0'))
	{
		iconFileName = new char[strlen(pBuffer) + 1];
		strcpy(iconFileName, pBuffer);
	}
	else
		return -1; // fail if no picture
	extractString(pLine, pBuffer, 1024);
	if (*pBuffer)
	{
		pictureFileName =
			new char[strlen(pBuffer) + 1]; // Forgot the nullptr all over the place did we?
		strcpy(pictureFileName, pBuffer);
	}
	stringID	 = extractInt(pLine);
	helpStringID = extractInt(pLine);
	iconX		 = extractInt(pLine);
	iconY		 = extractInt(pLine);
	char nameBuffer[256];
	cLoadString(stringID, nameBuffer, 256);
	name = flavorText = new char[strlen(nameBuffer) + 1]; // Lets not forget the nullptr!!!
	strcpy(name, nameBuffer);
	return ID;
}