Example #1
0
void MythUIVirtualKeyboard::parseKey(const QDomElement &element)
{
    QString left, right, up, down;
    QString normal, shift, alt, altshift;

    QString name = element.attribute("name");
    QString type = element.attribute("type");

    QDomNode n = element.firstChild();
    while(!n.isNull())
    {
        QDomElement e = n.toElement();
        if(!e.isNull())
        {
            if (e.tagName() == "move")
            {
                left = e.attribute("left");
                right = e.attribute("right");
                up = e.attribute("up");
                down = e.attribute("down");
            }
            else if (e.tagName() == "char")
            {
                normal = e.attribute("normal");
                shift = e.attribute("shift");
                alt = e.attribute("alt");
                altshift = e.attribute("altshift");
            }
            else
                LOG(VB_GENERAL, LOG_ERR, "Unknown element in key definition");
        }
        n = n.nextSibling();
    }

    KeyDefinition key;
    key.name = name;
    key.type = type;
    key.left = left;
    key.right = right;
    key.up = up;
    key.down = down;
    key.normal = decodeChar(normal);
    key.alt = decodeChar(alt);
    key.shift = decodeChar(shift);
    key.altshift = decodeChar(altshift);

    m_keyMap[name] = key;
}
Example #2
0
/**
 * Takes a FILE handle in as input (corresponding to a
 * "binary" decoded file) and reads the file, 6 chars at a
 * time. Each 6 chars (all ASCII 0's and 1's) should be read into a
 * char array and decoded into its corresponding char (by calling
 * decodeChar). The resulting chars would be output to the FILE handle
 * pointed to by out.
 *
 * @param in the input file, encoded as ASCII '1's and '0's
 * @Param out the decoded output file (ASCII)
 */
void binaryToText(FILE *in, FILE *out){
    //if the in file or the out file is null, end the function
    if(in == NULL || out == NULL)
        return;
    char *arr = (char*)malloc(6*sizeof(char));
    //if malloc fails, end the function
    if(arr == NULL)
        return;
    while(1)
    {
        //read the file 1 byte at a time, iterate 6 times
        //we get a array with 6 bytes
        int check = fread(arr, 1, 6, in);
        //if check is less than 6, there is no enough information to be read
        if(check < 6)
        {
            break;
        }
        //decode the array, then get a char
        char test = decodeChar(arr);
        //if test is null, return
        if(test == 0)
            return;
        //write that char into the out file
        fprintf(out, "%c", test);
    }
    if(arr != NULL)
        free(arr);
}
Example #3
0
void MainWidget::next(){
	//printf("connected()\n");
	
	pProgressDialog = new ZProgressDlg("", "Пожалуйста, подождите...", 140, 100, this);
	ZSoftKey* zsoft = pProgressDialog->getSoftKey();

	zsoft->disableClickedSlot(ZSoftKey::LEFT);
	zsoft->disableClickedSlot(ZSoftKey::RIGHT);

	zsoft->setText(ZSoftKey::LEFT, "", ZSoftKey::ZERO);
	zsoft->setText(ZSoftKey::RIGHT, "", ZSoftKey::ZERO);
	
	getProgress = 0;
	pProgressDialog->setProgress(getProgress);
	pProgressDialog->raise();
	pProgressDialog->show();

	if (!timer->isActive()) timer->start(500, FALSE);
	
	QString text1 = LineEdit1->text();
	
	text1 = decodeChar(text1); // TODO: to do something about it

	QString text = QString::fromUtf8(toPercentEncoding(text1));
	printf("Text=%s\n",text.latin1());
#if ALT_TRANSLATE
	QString url2 = QString(	"GET "
							"/ajax/services/language/translate?v=2.0&;hl=ru&q="
							+ QString(text)
							+ "&langpair="
							+ QString(lang_src)
							+ "|"
							+ QString(lang_dst) +
							" HTTP/1.1\r\n"
							"User-Agent: " "Mozilla/5.0" "\r\n"
							"Host: " "ajax.googleapis.com" "\r\n"
							"Connection: Close\r\n\r\n"							
							);
#else
	QString url2 = QString(	"GET "
							"/translate_a/t?client=t&sl="
							+ QString(lang_src)
							+ 	"&tl="
							+ QString(lang_dst) +
							+ "&text="
							+ QString(text) +
							" HTTP/1.1\r\n"
							"User-Agent: " "Mozilla/5.0" "\r\n"
							"Host: " "www.google.com " "\r\n"
							"Connection: Close\r\n\r\n"
							);
#endif						
	socket.writeBlock(url2, url2.length());


}
int  Magnetostatics2D::decode(buffer* b)
{
	int i = LongRange2D::decode(b);
	char version = decodeChar(b);
	if(version == 0)
	{
	}
	else
	{
		fprintf(stderr, "(%s:%i) %s::decode, unknown version:%i\n", __FILE__, __LINE__, lineage(0), (int)version);
	}

	return i;
}
Example #5
0
/**
 * Takes a FILE handle in as input (corresponding to a
 * "binary" decoded file) and reads the file, 6 chars at a
 * time. Each 6 chars (all ASCII 0's and 1's) should be read into a
 * char array and decoded into its corresponding char (by calling
 * decodeChar). The resulting chars would be output to the FILE handle
 * pointed to by out.
 *
 * @param in the input file, encoded as ASCII '1's and '0's
 * @Param out the decoded output file (ASCII)
*/
void binaryToText(FILE *in, FILE *out){
	//int bit;
	char temp[6];
	while(1)
	{
		for(int i=0;i<6;i++)
		{
			temp[i]=fgetc(in);
			if(temp[i]==EOF)
				return;
		}
		fputc(decodeChar(temp),out);	
	}
    
}
int  Thermal::decode(buffer* b)
{
	SpinOperation::decode(b);
	char version = decodeChar(b);
	if(version == 0)
	{
		temperature = decodeDouble(b);
		
		luaT_dec<dArray>(scale);
		scale = luaT_inc<dArray>(new dArray(nx,ny,nz));
		scale->decode(b);
	}
	else
	{
		fprintf(stderr, "(%s:%i) %s::decode, unknown version:%i\n", __FILE__, __LINE__, lineage(0), (int)version);
	}
	return 0;
}
Example #7
0
void decode(char* str, int len) {
    int colon = findNextColon(str, 0, len);
    char* shifts = str;
    int slen = colon;
    char* code = str + colon + 1;
    int clen = len - colon - 1;
    for(int i=0,j=0;i<clen;++i,++j) {
        if(j == slen) {
            j = 0;
        }
        char t = decodeChar(code[i], shifts[j]);
        if(t == '\n') {
            printf("\\n");
        }
        else {
            printf("%c", t);
        }
    }
    printf("\n");
}
int  ShortRange::decode(buffer* b)
{
    deinit();

    SpinOperation::decode(b);
    char version = decodeChar(b);
    if(version == 0)
    {
	pbc[0] = decodeInteger(b);
	pbc[1] = decodeInteger(b);
	pbc[2] = decodeInteger(b);
		
	nxyz = nx * ny * nz;
		
	size = decodeInteger(b);
	num = size;
	size++; //so we can double if size == 0
	pathways = (sss*)malloc(sizeof(sss) * size);
	for(int i=0; i<num; i++)
	{
	    pathways[i].fromsite = decodeInteger(b);
	    pathways[i].tosite = decodeInteger(b);
	    pathways[i].strength = decodeDouble(b);
	    for(int j=0; j<9; j++)
	    {
		pathways[i].matrix[j] = decodeDouble(b);
	    }
	    pathways[i].sig_dot_sig_pow = decodeDouble(b);
	}
    }
    else
    {
	fprintf(stderr, "(%s:%i) %s::decode, unknown version:%i\n", __FILE__, __LINE__, lineage(0), (int)version);
    }

    return 0;
}
Example #9
0
int main(int argc, char *argv[]){
  decodeChar(NULL);
  printf("Segfault check passed: 1.0\n");
  return 0;
}
uint32_t MamaRecordedMessageCodec::decodeField(char*& buffer, MamaMsg* mm)
{
	// These modifications will be applied regardless of data type
	mamaFieldType mft = (mamaFieldType)0;
	mama_fid_t mff = 0;
	// Extract the fid
	memcpy(&mff, buffer, 2);
	buffer += 2;
	// Extract the field type
	memcpy(&mft, buffer, 4);
	buffer += 4;
	// 6 bytes already decoded...
	uint32_t r = 6;

	switch(mft)
	{
	case MAMA_FIELD_TYPE_BOOL:
		r += decodeBool(buffer, mm, mff);
		break;
	case MAMA_FIELD_TYPE_CHAR:
		r += decodeChar(buffer, mm, mff);
		break;
	case MAMA_FIELD_TYPE_I8:
		r += decodeI8(buffer, mm, mff);
		break;
	case MAMA_FIELD_TYPE_U8:
		r += decodeU8(buffer, mm, mff);
		break;
	case MAMA_FIELD_TYPE_I16:
		r += decodeI16(buffer, mm, mff);
		break;
	case MAMA_FIELD_TYPE_U16:
		r += decodeU16(buffer, mm, mff);
		break;
	case MAMA_FIELD_TYPE_I32:
		r += decodeI32(buffer, mm, mff);
		break;
	case MAMA_FIELD_TYPE_U32:
		r += decodeU32(buffer, mm, mff);
		break;
	case MAMA_FIELD_TYPE_I64:
		r += decodeI64(buffer, mm, mff);
		break;
	case MAMA_FIELD_TYPE_U64:
		r += decodeU64(buffer, mm, mff);
		break;
	case MAMA_FIELD_TYPE_F32:
		r += decodeF32(buffer, mm, mff);
		break;
	case MAMA_FIELD_TYPE_F64:
		r += decodeF64(buffer, mm, mff);
		break;
	case MAMA_FIELD_TYPE_TIME:
		r += decodeTime(buffer, mm, mff);
		break;
	case MAMA_FIELD_TYPE_PRICE:
		r += decodePrice(buffer, mm, mff);
		break;
	case MAMA_FIELD_TYPE_STRING:
		r += decodeString(buffer, mm, mff);
		break;
	case MAMA_FIELD_TYPE_VECTOR_STRING:
		r += decodeVectorString(buffer, mm, mff);
		break;
	case MAMA_FIELD_TYPE_VECTOR_I32:
		r += decodeVectorI32(buffer, mm, mff);
		break;
	case MAMA_FIELD_TYPE_VECTOR_F64:
		r += decodeVectorF64(buffer, mm, mff);
		break;
	case MAMA_FIELD_TYPE_MSG:
		r += decodeMsgField(buffer, mm, mff);
		break;
	case MAMA_FIELD_TYPE_VECTOR_MSG:
		r += decodeVectorMsg(buffer, mm, mff);
		break;
	default:
		break;
	}

	return r;
}