示例#1
0
// -------------------------------------------------------------------------------- //
void guGoogleCoverFetcher::ExtractImageInfo( const wxString &content )
{
    //guLogMessage( wxT( "ExtractImageInfo: '%s'" ), content.c_str() );
    wxArrayString CurImageInfo;
    CurImageInfo.Add( ExtractString( content, wxT( "\"url\":\"" ), wxT( "\",\"" ) ) );
    wxString ImgInfo = ExtractString( content, wxT( "\"width\":\"" ), wxT( "\",\"" ) );
    if( !ImgInfo.IsEmpty() )
        ImgInfo += wxT( " x " ) + ExtractString( content, wxT( "\"height\":\"" ), wxT( "\",\"" ) );
    CurImageInfo.Add( ImgInfo );
    m_CoverLinks->Add( CurImageInfo );
}
示例#2
0
Bool HandleMail(char *ptr, long len)
{
   long index;
   WORD num_recipients, i;
   char message[MAXMESSAGE + MAX_SUBJECT + 200];
   char* msg = message;
   char sender[MAXUSERNAME + 1];
   char recipients[MAX_RECIPIENTS][MAXUSERNAME + 1];
   ID resource_id;
   long msg_time;
   char *start = ptr;

   Extract(&ptr, &index, 4);
   len -= 4;
   len = ExtractString(&ptr, len, sender, MAXUSERNAME);
   if (len == -1)
      return False;
   Extract(&ptr, &msg_time, SIZE_TIME);
   Extract(&ptr, &num_recipients, SIZE_NUM_RECIPIENTS);
   len -= SIZE_TIME + SIZE_NUM_RECIPIENTS;

   // If somehow mail message is screwed up, delete it
   if (num_recipients > MAX_RECIPIENTS)
   {
      RequestDeleteMail(index);
      return False;
   }

   /* If no recipients, then there is no more mail */
   if (num_recipients == 0)
   {
      MailNewMessage(0, sender, 0, NULL, NULL, 0);
      return True;
   }

   for (i=0; i < num_recipients; i++)
   {
      len = ExtractString(&ptr, len, recipients[i], MAXUSERNAME);
      if (len == -1)
         return False;
   }
   
   Extract(&ptr, &resource_id, SIZE_ID);
   len -= SIZE_ID;
   
   /* Remove format string id # & other ids from length */
   if (!CheckServerMessage(&msg, &ptr, len, resource_id))
      return False;

   MailNewMessage(index, sender, num_recipients, recipients, msg, msg_time);

   return True;
}
示例#3
0
Bool HandleArticles(char *ptr, long len)
{
   WORD newsgroup;
   WORD num_articles;
   BYTE part, max_part;
   NewsArticle *article;
   list_type list = NULL;
   int i;

   if (len < SIZE_NEWSGROUP_ID + 2 * SIZE_PART + 2)
      return False;

   Extract(&ptr, &newsgroup, SIZE_NEWSGROUP_ID);
   Extract(&ptr, &part, SIZE_PART);
   Extract(&ptr, &max_part, SIZE_PART);
   Extract(&ptr, &num_articles, 2);
   len -= SIZE_NEWSGROUP_ID + 2 * SIZE_PART + 2;

   for (i=0; i < num_articles; i++)
   {
      if (len < 4 + SIZE_TIME)
      {
	 list_destroy(list);
	 return False;
      }
      len -= 4 + SIZE_TIME;

      article = (NewsArticle *) SafeMalloc(sizeof(NewsArticle));
      Extract(&ptr, &article->num, 4);
      Extract(&ptr, &article->time, SIZE_TIME);
      len = ExtractString(&ptr, len, article->poster, MAXUSERNAME);
      if (len == -1)
      {
	 list_destroy(list);
	 return False;
      }

      len = ExtractString(&ptr, len, article->title, MAX_SUBJECT);
      if (len == -1)
      {
	 list_destroy(list);
	 return False;
      }
      list = list_add_item(list, article);     
   }

   if (len != 0)
      return False;

   ReceiveArticles(newsgroup, part, max_part, list);
   return True;
}
示例#4
0
static const char *ParseObject(ParseArgs& args, const char *data)
{
    data = SkipWS(data + 1);
    if ('}' == *data)
        return data + 1;

    size_t pathIdx = args.path.Size();
    for (;;) {
        data = SkipWS(data);
        if ('"' != *data)
            return NULL;
        args.path.Append('/');
        data = ExtractString(args.path, data);
        if (!data)
            return NULL;
        data = SkipWS(data);
        if (':' != *data)
            return NULL;

        data = ParseValue(args, data + 1);
        if (args.canceled || !data)
            return data;
        args.path.RemoveAt(pathIdx, args.path.Size() - pathIdx);

        data = SkipWS(data);
        if ('}' == *data)
            return data + 1;
        if (',' != *data)
            return NULL;
        data++;
    }
}
示例#5
0
static const char *ParseString(ParseArgs& args, const char *data)
{
    str::Str<char> string;
    data = ExtractString(string, data);
    if (data)
        args.canceled = !args.visitor->Visit(args.path.Get(), string.Get(), Type_String);
    return data;
}
示例#6
0
Bool HandleArticle(char *ptr, long len)
{
   char article[MAXMESSAGE + 1];

   len = ExtractString(&ptr, len, article, MAXMESSAGE);
   if (len != 0)
      return False;

   UserReadArticle(article);
   return True;
}
示例#7
0
Entity *Message::ExtractEntity() {
  if (message_type_ == kEntityDataMessage ||
      message_type_ == kViewUpdateMessage) {
    boost::uuids::uuid source = ExtractUuid();
    std::string name = ExtractString();
    int health_value = ExtractInt();
    int health_bound = ExtractInt();
    BoundedAttribute health(health_value, health_bound);

    Entity *entity = new Entity(name, health);
    entity->AssignId(source);

    std::string weapon_name = ExtractString();
    int value = ExtractInt();
    int min_damage = ExtractInt();
    int max_damage = ExtractInt();
    Weapon *weapon = new Weapon(weapon_name, value, min_damage, max_damage);
    weapon->Equip(*entity);

    return entity;
  }

  return NULL;
}
示例#8
0
Bool HandleGamePlayer(char *ptr, long len)
{
   char name[MAXUSERNAME + 1];
   BYTE player_num;

   // If we've haven't received our game object number, skip
   if (game_obj == 0)
      return False;

   Extract(&ptr, &player_num, 1);
   len -= 1;
   len = ExtractString(&ptr, len, name, MAXUSERNAME);

   if (len != 0)
      return False;
   
   ChessGotPlayerName(player_num, name);
   return True;
}
示例#9
0
Bool HandleGameState(char *ptr, long len)
{
   ID game;
   unsigned char state[BOARD_STATE_LEN + 1];

   Extract(&ptr, &game, SIZE_ID);

   if (game != game_obj)
   {
      debug(("Chess got game state for game %d, expecting game %d\n", game, game_obj));
      return False;
   }
   len -= SIZE_ID;
   len = ExtractString(&ptr, len, (char *) state, BOARD_STATE_LEN);

   if (len != 0)
      return False;

   ChessGotState(state);
      
   return True;
}
示例#10
0
文件: router.c 项目: MartinNuc/netmon
void	RouterType::Parse(char* tagName, const char *s, int len, Configuration *conf)
{
	XMLTag *tag = tagList;
	char	szPos[200];
	char	szType[200], szType1[200], *szBuf;
	while(tag)
	{
		if(!strcmp(tagName, tag->name))
		{
			switch(tag->type)
			{
				case TT_INT:			
				case TT_STRING:
				case TT_BOOL:
					XMLObject::Parse(tagName, s, len, conf);
					return;
				case TT_USER:
					if(!strcmp(tagName, XML_RT_DIM))
					{
						strncpy(szPos, s, len);
						szPos[len] = 0;
						/* use temporarly szType variable */
						ExtractString(0, szPos, szType, ' ');
						if(!strcmp(szType, ""))
						{
							printf("  Warning: Router type has invalid dimension format.\n           Should be for example <dimension>100 60</dimension>. Line: %d\n", XML_GetCurrentLineNumber(conf->np.theParser));
							conf->np.iWarnings++;
							return;
						}
						sx = atoi(szType);
						ExtractString(1, szPos, szType, ' ');
						if(!strcmp(szType, ""))
						{
							printf("  Warning: Router type has invalid dimension format.\n           Should be for example <dimension>100 60</dimension>. Line: %d\n", XML_GetCurrentLineNumber(conf->np.theParser));
							conf->np.iWarnings++;
							return;
						}
						sy = atoi(szType);	
						return;
					}
					if(!strcmp(conf->np.chNextTag, XML_RT_COLOR))
					{
						strncpy(szPos, s, len);
						szPos[len] = 0;
						/* use temporarly szType variable */
						ExtractString(0, szPos, szType, ' ');
						if(!strcmp(szType, ""))
						{
							printf("  Warning: Router type has invalid color format.\n           Should be RGB format (i.e. <color>100 100 125</color>). Line: %d\n", XML_GetCurrentLineNumber(conf->np.theParser));
							conf->np.iWarnings++;
							return;
						}
						r = (unsigned char)atoi(szType);
						ExtractString(1, szPos, szType, ' ');
						if(!strcmp(szType, ""))
						{
							printf("  Warning: Router type has invalid color format.\n           Should be RGB format (i.e. <color>100 100 125</color>). Line: %d\n", XML_GetCurrentLineNumber(conf->np.theParser));
							conf->np.iWarnings++;
							return;
						}
						g = (unsigned char)atoi(szType);
						ExtractString(2, szPos, szType, ' ');
						if(!strcmp(szType, ""))
						{
							printf("  Warning: Router type has invalid color format.\n           Should be RGB format (i.e. <color>100 100 125</color>). Line: %d\n", XML_GetCurrentLineNumber(conf->np.theParser));
							conf->np.iWarnings++;
							return;
						}
						b = (unsigned char)atoi(szType);	
						return;
					}	
					if(!strcmp(conf->np.chNextTag, XML_RT_INFO))
					{	
						int i = 0;
						info = 0;
						strncpy(szPos, s, len);
						szPos[len] = 0;
						/* use temporarly szType variable */
						ExtractString(0, szPos, szType, ' ');
						while(strcmp(szType, ""))
						{
							ExtractString(i++, szPos, szType, ' ');
							/* extract values from the info string */			

							/*
							*	Color and size of the IP adr.
							*
							*/
							if(!strncmp(szType, RTI_IP, 2))
							{
								info |= RI_IP;
								labels[labIndex++] = RI_IP;
								/* jump over ip( */
								szBuf = szType;
								szBuf += 2;				
								/* detect color */
								if(!strncmp(szBuf, "(", 1))
								{				
									/* jump over the bracket */
									szBuf++;
									/* get color */
									ExtractString(0, szBuf, szType1, ',');					
									if(strcmp(szType1, ""))
									{
										/* red */
										ipr = (unsigned char)atoi(szType1);
										ExtractString(1, szBuf, szType1, ',');						
										if(strcmp(szType1, ""))
										{
											/* green */
											ipg = (unsigned char)atoi(szType1);
											ExtractString(2, szBuf, szType1, ',');							
											if(strcmp(szType1, ""))
											{
												/* blue */
												ipb = (unsigned char)atoi(szType1);
												ExtractString(3, szBuf, szType1, ',');	
												if(strcmp(szType1, ""))
												{
													/* size */
													ip_size = (unsigned char)atoi(szType1);
													/*if(ip_size >= UF_FONT_COUNT)
													{
														printf("  Warning: Font ID is invalid.\n           Should be in range from 0 to %d. Line: %d\n", UF_FONT_COUNT-1, XML_GetCurrentLineNumber(conf->np.theParser));
														conf->np.iWarnings++;										
													}*/
												}
												/* is not obligatory */
												continue;
											}
											else
											{
												printf("  Warning: Color of the IP has invalid format.\n           Should be RGB format (i.e. ip(100,100,125)). Line: %d\n", XML_GetCurrentLineNumber(conf->np.theParser));
												conf->np.iWarnings++;
												continue;
											}
										}
										else
										{
											printf("  Warning: Color of the IP has invalid format.\n           Should be RGB format (i.e. ip(100,100,125)). Line: %d\n", XML_GetCurrentLineNumber(conf->np.theParser));
											conf->np.iWarnings++;
											continue;				
										}
									}	
								}
							}

							if(!strncmp(szType, RTI_NAME, 4))
							{
								info |= RI_NAME;
								labels[labIndex++] = RI_NAME;
								/* jump over name( */
								szBuf = szType;
								szBuf += 4;
								/* detect color */
								if(!strncmp(szBuf, "(", 1))
								{				
									/* jump over the bracket */
									szBuf++;
									/* get color */
									ExtractString(0, szBuf, szType1, ',');					
									if(strcmp(szType1, ""))
									{
										/* red */
										namr = (unsigned char)atoi(szType1);
										ExtractString(1, szBuf, szType1, ',');						
										if(strcmp(szType1, ""))
										{
											/* green */
											namg = (unsigned char)atoi(szType1);
											ExtractString(2, szBuf, szType1, ',');							
											if(strcmp(szType1, ""))
											{
												/* blue */
												namb = (unsigned char)atoi(szType1);
												ExtractString(3, szBuf, szType1, ',');	
												if(strcmp(szType1, ""))
												{
													/* size */
													name_size = (unsigned char)atoi(szType1);
													/*if(name_size <= -UF_FONT_COUNT)
													{
														printf("  Warning: Font ID is invalid.\n           Should be in range from 0 to %d. Line: %d\n", UF_FONT_COUNT-1, XML_GetCurrentLineNumber(conf->np.theParser));
														conf->np.iWarnings++;										
													}*/
												}
												/* is not obligatory */
											}
											else
											{
												printf("  Warning: Color of the NAME has invalid format.\n           Should be RGB format (i.e. name(100,100,125)). Line: %d\n", XML_GetCurrentLineNumber(conf->np.theParser));
												conf->np.iWarnings++;
												continue;
											}
										}
										else
										{
											printf("  Warning: Color of the NAME has invalid format.\n           Should be RGB format (i.e. name(100,100,125)). Line: %d\n", XML_GetCurrentLineNumber(conf->np.theParser));
											conf->np.iWarnings++;
											continue;				
										}
									}	
								}
							}

							if(!strncmp(szType, RTI_LOC, strlen(RTI_LOC)))
							{
								info |= RI_COM;
								labels[labIndex++] = RI_COM;
								/* jump over location( */
								szBuf = szType;
								szBuf += strlen(RTI_LOC);
								/* detect color */
								if(!strncmp(szBuf, "(", 1))
								{				
									/* jump over the bracket */
									szBuf++;
									/* get color */
									ExtractString(0, szBuf, szType1, ',');					
									if(strcmp(szType1, ""))
									{
										/* red */
										locr = (unsigned char)atoi(szType1);
										ExtractString(1, szBuf, szType1, ',');						
										if(strcmp(szType1, ""))
										{
											/* green */
											locg = (unsigned char)atoi(szType1);
											ExtractString(2, szBuf, szType1, ',');							
											if(strcmp(szType1, ""))
											{
												/* blue */
												locb = (unsigned char)atoi(szType1);
												ExtractString(3, szBuf, szType1, ',');	
												if(strcmp(szType1, ""))
												{
													/* size */
													loc_size = (unsigned char)atoi(szType1);
													/*if(loc_size >= UF_FONT_COUNT)
													{
														printf("  Warning: Font ID is invalid.\n           Should be in range from 0 to %d. Line: %d\n", UF_FONT_COUNT-1, XML_GetCurrentLineNumber(conf->np.theParser));
														conf->np.iWarnings++;										
													}*/
												}
												/* is not obligatory */
											}
											else
											{
												printf("  Warning: Color of the COMMENT has invalid format.\n           Should be RGB format (i.e. comment(100,100,125)). Line: %d\n", XML_GetCurrentLineNumber(conf->np.theParser));
												conf->np.iWarnings++;
												continue;
											}
										}
										else
										{
											printf("  Warning: Color of the COMMENT has invalid format.\n           Should be RGB format (i.e. comment(100,100,125)). Line: %d\n", XML_GetCurrentLineNumber(conf->np.theParser));
											conf->np.iWarnings++;
											continue;				
										}
									}	
								}
							}

							if(!strncmp(szType, RTI_BORDER, 6))
							{
								info |= RI_BORDER;				
								/* jump over border( */
								szBuf = szType;
								szBuf += 6;
								/* detect color */
								if(!strncmp(szBuf, "(", 1))
								{				
									/* jump over the bracket */
									szBuf++;
									/* get width */
									ExtractString(0, szBuf, szType1, ',');
									if(strcmp(szType1, ""))
									{
										iBorderWidth = atoi(szType1);
										/* get color */
										ExtractString(1, szBuf, szType1, ',');
										if(strcmp(szType1, ""))
										{
											br = (unsigned char)atoi(szType1);
											ExtractString(2, szBuf, szType1, ',');
											if(strcmp(szType1, ""))
											{
												bg = (unsigned char)atoi(szType1);
												ExtractString(3, szBuf, szType1, ',');
												if(strcmp(szType1, ""))
												{
													bb = (unsigned char)atoi(szType1);
												}
												else
												{
													printf("  Warning: Params of the BORDER has invalid format.\n           Should be RGB format (i.e. border(1, 100,100,125)). Line: %d\n", XML_GetCurrentLineNumber(conf->np.theParser));
													conf->np.iWarnings++;
													continue;				
												}
											}
											else
											{
												printf("  Warning: Params of the BORDER has invalid format.\n           Should be RGB format (i.e. border(1, 100,100,125)). Line: %d\n", XML_GetCurrentLineNumber(conf->np.theParser));
												conf->np.iWarnings++;
												continue;				
											}
										}
										else
										{
											printf("  Warning: Params of the BORDER has invalid format.\n           Should be RGB format (i.e. border(1, 100,100,125)). Line: %d\n", XML_GetCurrentLineNumber(conf->np.theParser));
											conf->np.iWarnings++;
											continue;				
										}
									}
								}
							}			
						}
					}
					return;
			}
		}
		tag = tag->pNext;
	}
}
示例#11
0
文件: router.c 项目: MartinNuc/netmon
void	Interface::Parse(char* tagName, const char *s, int len, Configuration *conf)
{
	XMLTag *tag = tagList;
	int		ip_invalid;
	char	szPos[200];
	char	szType[200];
	while(tag)
	{
		if(!strcmp(tagName, tag->name))
		{
			switch(tag->type)
			{
				case TT_INT:			
				case TT_STRING:
				case TT_BOOL:
					XMLObject::Parse(tagName, s, len, conf);
					return;
				case TT_USER:
					if(!strcmp(tagName, XML_IP))
					{
						ip_invalid = 0;
						/* IP adr is too long */
						if(len > MAX_IP)
						{
							ip_invalid = 1;
						}
						else
						{
							strncpy(szPos, s, len);		
							szPos[len] = 0;
							/* IP adr is totally corrupted */
							for(int i = 0; i < 4; i++)
							{
								ExtractString(i, szPos, szType, '.');
								if(!strcmp(szType, ""))
								{
									ip_invalid = 1;
								}
								int ip = atoi(szType);
								if(ip > 0xff || ip < 0)
								{
									ip_invalid = 1;
								}
							}			
						}
						if(!ip_invalid)
						{
							strncpy(szIP, s, len);	
							szIP[len] = 0;
						}
						else
						{
							printf("  Warning: IP address format is invalid. Line: %d\n", XML_GetCurrentLineNumber(conf->np.theParser));
							conf->np.iWarnings++;
						}	
					}
					return;
			}
		}
		tag = tag->pNext;		
	}
}
示例#12
0
static int PALSARRecipeFCN( CeosSARVolume_t *volume, void *token )
{
    struct CeosSARImageDesc *ImageDesc = &(volume->ImageDesc);
    CeosTypeCode_t TypeCode;
    CeosRecord_t *record;
    char szSARDataFormat[29], szProduct[32];

    memset( ImageDesc, 0, sizeof( struct CeosSARImageDesc ) );

    /* -------------------------------------------------------------------- */
    /*      First, we need to check if the "SAR Data Format Type            */
    /*      identifier" is set to "COMPRESSED CROSS-PRODUCTS" which is      */
    /*      pretty idiosyncratic to SIRC products.  It might also appear    */
    /*      for some other similarly encoded Polarimetric data I suppose.    */
    /* -------------------------------------------------------------------- */
    /* IMAGE_OPT */
    TypeCode.UCharCode.Subtype1 = 63;
    TypeCode.UCharCode.Type     = 192;
    TypeCode.UCharCode.Subtype2 = 18;
    TypeCode.UCharCode.Subtype3 = 18;

    record = FindCeosRecord( volume->RecordList, TypeCode,
                             __CEOS_IMAGRY_OPT_FILE, -1, -1 );
    if( record == NULL )
        return 0;

    ExtractString( record, 401, 28, szSARDataFormat );
    if( !EQUALN( szSARDataFormat, "INTEGER*18                 ", 25) )
        return 0;

    ExtractString( record, 49, 16, szProduct );
    if( !EQUALN( szProduct, "ALOS-", 5 ) )
        return 0;

    /* -------------------------------------------------------------------- */
    /*      Apply normal handling...                                        */
    /* -------------------------------------------------------------------- */
    CeosDefaultRecipe( volume, token );

    /* -------------------------------------------------------------------- */
    /*      Make sure this looks like the SIRC product we are expecting.    */
    /* -------------------------------------------------------------------- */
    if( ImageDesc->BytesPerPixel != 18 )
        return 0;

    /* -------------------------------------------------------------------- */
    /*      Then fix up a few values.                                       */
    /* -------------------------------------------------------------------- */
    ImageDesc->DataType = __CEOS_TYP_PALSAR_COMPLEX_SHORT;
    ImageDesc->NumChannels = 6;

    /* -------------------------------------------------------------------- */
    /*      Sanity checking                                                 */
    /* -------------------------------------------------------------------- */
    if( ImageDesc->PixelsPerLine == 0 || ImageDesc->Lines == 0 ||
            ImageDesc->RecordsPerLine == 0 || ImageDesc->ImageDataStart == 0 ||
            ImageDesc->FileDescriptorLength == 0 || ImageDesc->DataType == 0 ||
            ImageDesc->NumChannels == 0 || ImageDesc->BytesPerPixel == 0 ||
            ImageDesc->ChannelInterleaving == 0 || ImageDesc->BytesPerRecord == 0)
    {
        return 0;
    } else {

        ImageDesc->ImageDescValid = TRUE;
        return 1;
    }
}
示例#13
0
int CeosDefaultRecipe( CeosSARVolume_t *volume, void *token )
{
    CeosRecipeType_t *recipe;
    CeosRecord_t *record;
    CeosTypeCode_t TypeCode;
    struct CeosSARImageDesc *ImageDesc = &(volume->ImageDesc);
    char temp_str[1024];
    int i /*, temp_int */;

#define DoExtractInt(a) ExtractInt( record, recipe[i].Type, recipe[i].Offset, recipe[i].Length, &a)

    if(token == NULL)
    {
        return 0;
    }

    memset(ImageDesc, 0, sizeof( struct CeosSARImageDesc ) );

    /*    temp_imagerecipe = (CeosSARImageDescRecipe_t *) token;
        recipe = temp_imagerecipe->Recipe; */

    recipe = token;

    for(i = 0; recipe[i].ImageDescValue != 0; i++ )
    {
        if(recipe[i].Override)
        {
            TypeCode.UCharCode.Subtype1 = recipe[i].TypeCode.Subtype1;
            TypeCode.UCharCode.Type = recipe[i].TypeCode.Type;
            TypeCode.UCharCode.Subtype2 = recipe[i].TypeCode.Subtype2;
            TypeCode.UCharCode.Subtype3 = recipe[i].TypeCode.Subtype3;

            record = FindCeosRecord( volume->RecordList, TypeCode, recipe[i].FileId, -1, -1 );

            if(record == NULL)
            {
                /* temp_int = 0; */
            } else {

                switch( recipe[i].ImageDescValue )
                {
                case __CEOS_REC_NUMCHANS:
                    DoExtractInt( ImageDesc->NumChannels );
                    break;
                case __CEOS_REC_LINES:
                    DoExtractInt( ImageDesc->Lines );
                    break;
                case __CEOS_REC_BPP:
                    DoExtractInt( ImageDesc->BytesPerPixel );
                    break;
                case __CEOS_REC_RPL:
                    DoExtractInt( ImageDesc->RecordsPerLine );
                    break;
                case __CEOS_REC_PDBPR:
                    DoExtractInt( ImageDesc->PixelDataBytesPerRecord );
                    break;
                case __CEOS_REC_FDL:
                    DoExtractInt( ImageDesc->FileDescriptorLength );
                    break;
                case __CEOS_REC_IDS:
                    DoExtractInt( ImageDesc->ImageDataStart );
                    /*
                    ** This is really reading the quantity of prefix data
                    ** per data record.  We want the offset from the very
                    ** beginning of the record to the data, so we add another
                    ** 12 to that.  I think some products incorrectly indicate
                    ** 192 (prefix+12) instead of 180 so if we see 192 assume
                    ** the 12 bytes of record start data has already been
                    ** added.  Frank Warmerdam.
                    */
                    if( ImageDesc->ImageDataStart != 192 )
                        ImageDesc->ImageDataStart += 12;
                    break;
                case __CEOS_REC_SUFFIX_SIZE:
                    DoExtractInt( ImageDesc->ImageSuffixData );
                    break;
                case __CEOS_REC_RECORDSIZE:
                    DoExtractInt( ImageDesc->BytesPerRecord );
                    break;
                case __CEOS_REC_PPL:
                    DoExtractInt( ImageDesc->PixelsPerLine );
                    break;
                case __CEOS_REC_TBP:
                    DoExtractInt( ImageDesc->TopBorderPixels );
                    break;
                case __CEOS_REC_BBP:
                    DoExtractInt( ImageDesc->BottomBorderPixels );
                    break;
                case __CEOS_REC_LBP:
                    DoExtractInt( ImageDesc->LeftBorderPixels );
                    break;
                case __CEOS_REC_RBP:
                    DoExtractInt( ImageDesc->RightBorderPixels );
                    break;
                case __CEOS_REC_INTERLEAVE:
                    ExtractString( record, recipe[i].Offset, recipe[i].Length, temp_str );

                    ImageDesc->ChannelInterleaving = GetCeosStringType( CeosInterleaveType, temp_str );
                    break;
                case __CEOS_REC_DATATYPE:
                    ExtractString( record, recipe[i].Offset, recipe[i].Length, temp_str );

                    ImageDesc->DataType = GetCeosStringType( CeosDataType, temp_str );
                    break;
                }

            }
        }
    }

    /* Some files (Telaviv) don't record the number of pixel groups per line.
     * Try to derive it from the size of a data group, and the number of
     * bytes of pixel data if necessary.
     */

    if( ImageDesc->PixelsPerLine == 0
            && ImageDesc->PixelDataBytesPerRecord != 0
            && ImageDesc->BytesPerPixel != 0 )
    {
        ImageDesc->PixelsPerLine =
            ImageDesc->PixelDataBytesPerRecord / ImageDesc->BytesPerPixel;
        CPLDebug( "SAR_CEOS", "Guessing PixelPerLine to be %d\n",
                  ImageDesc->PixelsPerLine );
    }

    /* Some files don't have the BytesPerRecord stuff, so we calculate it if possible */

    if( ImageDesc->BytesPerRecord == 0 && ImageDesc->RecordsPerLine == 1 &&
            ImageDesc->PixelsPerLine > 0 && ImageDesc->BytesPerPixel > 0 )
    {
        CeosRecord_t *img_rec;

        ImageDesc->BytesPerRecord = ImageDesc->PixelsPerLine *
                                    ImageDesc->BytesPerPixel + ImageDesc->ImageDataStart +
                                    ImageDesc->ImageSuffixData ;

        TypeCode.UCharCode.Subtype1 = 0xed;
        TypeCode.UCharCode.Type = 0xed;
        TypeCode.UCharCode.Subtype2 = 0x12;
        TypeCode.UCharCode.Subtype3 = 0x12;

        img_rec = FindCeosRecord( volume->RecordList, TypeCode,
                                  __CEOS_IMAGRY_OPT_FILE, -1, -1 );
        if( img_rec == NULL )
        {
            CPLDebug( "SAR_CEOS",
                      "Unable to find imagery rec to check record length." );
            return 0;
        }

        if( img_rec->Length != ImageDesc->BytesPerRecord )
        {
            CPLDebug( "SAR_CEOS",
                      "Guessed record length (%d) did not match\n"
                      "actual imagery record length (%d), recipe fails.",
                      ImageDesc->BytesPerRecord, img_rec->Length );
            return 0;
        }
    }

    if( ImageDesc->PixelsPerRecord == 0 &&
            ImageDesc->BytesPerRecord != 0 && ImageDesc->BytesPerPixel != 0 )
    {
        ImageDesc->PixelsPerRecord = ( ( ImageDesc->BytesPerRecord -
                                         (ImageDesc->ImageSuffixData +
                                          ImageDesc->ImageDataStart )) /
                                       ImageDesc->BytesPerPixel );

        if(ImageDesc->PixelsPerRecord > ImageDesc->PixelsPerLine)
            ImageDesc->PixelsPerRecord = ImageDesc->PixelsPerLine;
    }

    /* If we didn't get a data type, try guessing. */
    if( ImageDesc->DataType == 0
            && ImageDesc->BytesPerPixel != 0
            && ImageDesc->NumChannels != 0 )
    {
        int  nDataTypeSize = ImageDesc->BytesPerPixel / ImageDesc->NumChannels;

        if( nDataTypeSize == 1 )
            ImageDesc->DataType = __CEOS_TYP_UCHAR;
        else if( nDataTypeSize == 2 )
            ImageDesc->DataType = __CEOS_TYP_USHORT;
    }

    /* Sanity checking */

    if( ImageDesc->PixelsPerLine == 0 || ImageDesc->Lines == 0 ||
            ImageDesc->RecordsPerLine == 0 || ImageDesc->ImageDataStart == 0 ||
            ImageDesc->FileDescriptorLength == 0 || ImageDesc->DataType == 0 ||
            ImageDesc->NumChannels == 0 || ImageDesc->BytesPerPixel == 0 ||
            ImageDesc->ChannelInterleaving == 0 || ImageDesc->BytesPerRecord == 0)
    {
        return 0;
    } else {

        ImageDesc->ImageDescValid = TRUE;
        return 1;
    }
}
示例#14
0
// ---
STDMETHODIMP CCodeGen::GetDescription( BYTE** description ) {
	return ExtractString( IDS_IFACE_DESCRIPTION, description );
}
示例#15
0
const char *on_geo_server_config (/* IN  */const char* data,
/* IN  */void* context,
/* OUT */BOOL* more_data_needed,
/* OUT */roadmap_result* rc) {

   int size;
   // Default error for early exit:
   (*rc) = err_parser_unexpected_data;

   init_context ();

   // Expected data:
   //   <id> <name> <RTServerID> <lang> <num_parameters><version>

   // ID
   data = ReadIntFromString (data, //   [in]      Source string
            ",", //   [in,opt]  Value termination
            NULL, //   [in,opt]  Allowed padding
            &GeoConfigContext.id, //   [out]     Output value
            1); //   [in]      TRIM_ALL_CHARS, DO_NOT_TRIM, or 'n'

   if (!data) {
      roadmap_log (ROADMAP_ERROR,"on_geo_server_config() - Failed to read 'ID'" );
      return NULL;
   }

   // Name
   size = sizeof (GeoConfigContext.name);
   data = ExtractString (data, GeoConfigContext.name, &size, ",", 1);
   if (!data) {
       roadmap_log (ROADMAP_ERROR, "on_geo_server_config() - Failed to read 'name'");
       return NULL;
   }


   // lang
   size = sizeof (GeoConfigContext.lang);
   data = ExtractString (data, GeoConfigContext.lang, &size, ",", 1);
   if (!data) {
       roadmap_log (ROADMAP_ERROR, "on_geo_server_config() - Failed to read 'lang'");
       return NULL;
   }



   // num_paramerets
   data = ReadIntFromString(  data,                            //   [in]      Source string
                               ",",                        //   [in,opt]  Value termination
                               NULL,                           //   [in,opt]  Allowed padding
                               &GeoConfigContext.num_results,  //   [out]     Output value
                               1);                //   [in]      TRIM_ALL_CHARS, DO_NOT_TRIM, or 'n'

   if (!data) {
       roadmap_log (ROADMAP_ERROR, "on_geo_server_config() - Failed to read 'num_parameters'");
       return NULL;
   }


   // version
   data = ReadIntFromString(  data,                            //   [in]      Source string
                               ",\r\n",                        //   [in,opt]  Value termination
                               NULL,                           //   [in,opt]  Allowed padding
                               &GeoConfigContext.version,  //   [out]     Output value
                               TRIM_ALL_CHARS);                //   [in]      TRIM_ALL_CHARS, DO_NOT_TRIM, or 'n'

   if (!data) {
       roadmap_log (ROADMAP_ERROR, "on_geo_server_config() - Failed to read 'version'");
       return NULL;
   }

   roadmap_log (ROADMAP_DEBUG, "got GeoServerConfig message - Id=%d, name=%s lang=%s, num_parameters=%d version=%d",GeoConfigContext.id, GeoConfigContext.name, GeoConfigContext.lang, GeoConfigContext.num_results, GeoConfigContext.version );
   if (GeoConfigContext.num_results == 0){
      roadmap_log (ROADMAP_DEBUG, "GeoServerConfig, No Parameters passed. Completing... " );
      on_recieved_completed();
   }

   (*rc) = succeeded;
   return data;
}
示例#16
0
bool CRealTextParser::ExtractTextTag(wstring& p_rszLine, Tag& p_rTag)
{
    p_rTag.m_bText = true;
    return ExtractString(p_rszLine, p_rTag.m_szName);
}
示例#17
0
static int SIRCRecipeFCN( CeosSARVolume_t *volume, const void *token )
{
    struct CeosSARImageDesc *ImageDesc = &(volume->ImageDesc);
    CeosTypeCode_t TypeCode = { 0 };
    CeosRecord_t *record;
    char szSARDataFormat[29];

    memset( ImageDesc, 0, sizeof( struct CeosSARImageDesc ) );

/* -------------------------------------------------------------------- */
/*      First, we need to check if the "SAR Data Format Type            */
/*      identifier" is set to "COMPRESSED CROSS-PRODUCTS" which is      */
/*      pretty idiosyncratic to SIRC products.  It might also appear    */
/*      for some other similarly encoded Polarimetric data I suppose.    */
/* -------------------------------------------------------------------- */
    /* IMAGE_OPT */
    TypeCode.UCharCode.Subtype1 = 63;
    TypeCode.UCharCode.Type     = 192;
    TypeCode.UCharCode.Subtype2 = 18;
    TypeCode.UCharCode.Subtype3 = 18;

    record = FindCeosRecord( volume->RecordList, TypeCode,
                             CEOS_IMAGRY_OPT_FILE, -1, -1 );
    if( record == NULL )
        return 0;

    ExtractString( record, 401, 28, szSARDataFormat );
    if( !STARTS_WITH_CI(szSARDataFormat, "COMPRESSED CROSS-PRODUCTS") )
        return 0;

/* -------------------------------------------------------------------- */
/*      Apply normal handling...                                        */
/* -------------------------------------------------------------------- */
    CeosDefaultRecipe( volume, token );

/* -------------------------------------------------------------------- */
/*      Make sure this looks like the SIRC product we are expecting.    */
/* -------------------------------------------------------------------- */
    if( ImageDesc->BytesPerPixel != 10 )
        return 0;

/* -------------------------------------------------------------------- */
/*      Then fix up a few values.                                       */
/* -------------------------------------------------------------------- */
    /* It seems the bytes of pixel data per record is just wrong.  Fix. */
    ImageDesc->PixelDataBytesPerRecord =
        ImageDesc->BytesPerPixel * ImageDesc->PixelsPerLine;

    ImageDesc->DataType = CEOS_TYP_CCP_COMPLEX_FLOAT;

/* -------------------------------------------------------------------- */
/*      Sanity checking                                                 */
/* -------------------------------------------------------------------- */
    if( ImageDesc->PixelsPerLine == 0 || ImageDesc->Lines == 0 ||
	ImageDesc->RecordsPerLine == 0 || ImageDesc->ImageDataStart == 0 ||
	ImageDesc->FileDescriptorLength == 0 || ImageDesc->DataType == 0 ||
	ImageDesc->NumChannels == 0 || ImageDesc->BytesPerPixel == 0 ||
	ImageDesc->ChannelInterleaving == 0 || ImageDesc->BytesPerRecord == 0)
    {
	return 0;
    } else {

	ImageDesc->ImageDescValid = TRUE;
	return 1;
    }
}
示例#18
0
std::string Message::ExtractError() {
  return ExtractString();
}
示例#19
0
// ---
STDMETHODIMP CCodeGen::GetVersion( BYTE** version ) {
	return ExtractString( IDS_IFACE_VERSION, version );
}
示例#20
0
// ---
STDMETHODIMP CCodeGen::GetVendor( BYTE** vendor ) {
	return ExtractString( IDS_IFACE_VENDOR, vendor );
}
示例#21
0
文件: router.c 项目: MartinNuc/netmon
void	Router::Parse(char* tagName, const char *s, int len, Configuration *conf)
{
	XMLTag *tag = tagList;
	int		ip_invalid;
	char	szPos[200];
	char	szType[200];
	while(tag)
	{
		if(!strcmp(tagName, tag->name))
		{
			switch(tag->type)
			{
				case TT_INT:			
				case TT_STRING:
				case TT_BOOL:
					XMLObject::Parse(tagName, s, len, conf);
					if(!strcmp(tagName, XML_ETH) && iEth)
					{
						conf->np.iLANsCount++;
					}
					if(!strcmp(tagName, XML_APTYPE))
					{
						conf->np.iAPsCount += iAP;
					}
					return;
				case TT_USER:
					if(!strcmp(tagName, XML_IP))
					{
						ip_invalid = 0;
						/* IP adr is too long */
						if(len > MAX_IP)
						{
							ip_invalid = 1;
						}
						else
						{
							strncpy(szPos, s, len);		
							szPos[len] = 0;
							/* IP adr is totally corrupted */
							for(int i = 0; i < 4; i++)
							{
								ExtractString(i, szPos, szType, '.');
								if(!strcmp(szType, ""))
								{
									ip_invalid = 1;
								}
								int ip = atoi(szType);
								if(ip > 0xff || ip < 0)
								{
									ip_invalid = 1;
								}
							}			
						}
						if(!ip_invalid)
						{
							/* pokud se najde platna IP mimo sekci interfaces, vytvori se default interface */
							if(!pInterfaces)
							{
								pInterfaces = new Interface();
								pInterfaces->pNext = NULL;
								pInterfaces->szName = NULL; // default
								strncpy(pInterfaces->szIP, s, len);
								pInterfaces->szIP[len] = 0;
								pLastInt = pInterfaces;
							}
							else
							{
								pLastInt->pNext = new Interface();
								pLastInt->pNext->pNext = NULL;
								pLastInt->pNext->szName = NULL; // default
								strncpy(pLastInt->pNext->szIP, s, len);
								pLastInt->pNext->szIP[len] = 0;
								pLastInt = pLastInt->pNext;
							}		
							iHasDefault = 1;							
							//printf("  Warning: Tag <ip> is obsolete and will be removed in the next\n\t   netmon version, use rather <interfaces> structure. Line: %d\n", XML_GetCurrentLineNumber(conf->np.theParser));							
							//conf->np.iWarnings++;
						}
						else
						{
							printf("  Warning: IP address format is invalid. Line: %d\n", XML_GetCurrentLineNumber(conf->np.theParser));
							conf->np.iWarnings++;
						}	
					}
					if(!strcmp(tagName, XML_POSITION))
					{
						strncpy(szPos, s, len);
						szPos[len] = 0;
						/* use temporarly szType variable */
						ExtractString(0, szPos, szType, ' ');
						if(!strcmp(szType, ""))
						{
							printf("  Warning: Router has invalid position format.\n           Should be for example <position>1 6</position>. Line: %d\n", XML_GetCurrentLineNumber(conf->np.theParser));
							conf->np.iWarnings++;
							return;
						}
						iX = atoi(szType)-1;
						iRealX = (atoi(szType)-1)*conf->gd.iCellWidth+conf->gd.iCellWidth/2;
						ExtractString(1, szPos, szType, ' ');
						if(!strcmp(szType, ""))
						{
							printf("  Warning: Router has invalid position format.\n           Should be for example <position>1 6</position>. Line: %d\n", XML_GetCurrentLineNumber(conf->np.theParser));
							conf->np.iWarnings++;
							return;
						}
						iY = atoi(szType)-1;
						iRealY = (atoi(szType)-1)*conf->gd.iCellHeight+conf->gd.iCellHeight/2+10;	
						tag->set = 1;
					}
					return;
			}
		}
		tag = tag->pNext;		
	}
}
int main(int argc, char *argv[])
{
    XCBConnection *c;
    int scrn;
    char *display_name = NULL;
    char *name = NULL;
    XCBWINDOW root_window = {0};
    XCBSCREEN *screen;
    XCBXvQueryExtensionRep *query_ext;
    XCBXvQueryAdaptorsRep *adaptors_rep;
    XCBXvAdaptorInfoIter adaptors_iter;
    XCBXvAdaptorInfo *ainfo;
    XCBXvFormat *format;
    XCBXvQueryPortAttributesRep *attr_rep;
    XCBXvAttributeInfoIter attr_iter;
    XCBXvAttributeInfo *attribute;

    int nscreens, nattr, i, j, k;

    if ((argc != 1) && (argc != 3))
        PrintUsage();

    if (argc != 1) {
        if (strcmp(argv[1], "-display"))
            PrintUsage();
        display_name = argv[2];
    }

    if (!display_name) display_name = getenv("DISPLAY");
    if (!(c = XCBConnect(display_name, &scrn)))
    {
        fprintf(stderr, "xcbxvinfo: Unable to open display %s\n", display_name);
        exit(1);
    }

    if (!(query_ext = XCBXvQueryExtensionReply(c, XCBXvQueryExtension(c), NULL)))
    {
        fprintf(stderr, "xvinfo: No X-Video extension on %s\n", display_name);
        exit(0);
    }
    else
    {
        fprintf(stdout, "X-Video Extension version %i.%i\n", query_ext->major, query_ext->minor);
    }

    free(query_ext);

    nscreens = XCBConnSetupSuccessRepRootsIter(XCBGetSetup(c)).rem;

    for (i = 0; i < nscreens; i++)
    {
        fprintf(stdout, "screen #%i\n", i);

        screen = ScreenOfDisplay(c, scrn);
        if (screen) root_window = screen->root;

        adaptors_rep = XCBXvQueryAdaptorsReply(c, XCBXvQueryAdaptors(c, root_window), NULL);
        if (!adaptors_rep->num_adaptors) {
            fprintf(stdout, " no adaptors present.\n");
            continue;
        }

        adaptors_iter = XCBXvQueryAdaptorsInfoIter(adaptors_rep);

        for (j = 0; j < adaptors_rep->num_adaptors; j++)
        {
            ainfo = adaptors_iter.data;
            name = ExtractString(XCBXvAdaptorInfoName(ainfo), XCBXvAdaptorInfoNameLength(ainfo));
            fprintf(stdout, "  Adaptor #%i: \"%s\"\n", j, name);
            fprintf(stdout, "    number of ports: %i\n", ainfo->num_ports);
            fprintf(stdout, "    port base: %li\n", ainfo->base_id.xid);
            fprintf(stdout, "    operations supported: ");
            free(name);

            switch(ainfo->type & (XCBXvTypeInputMask | XCBXvTypeOutputMask)) {
                case XCBXvTypeInputMask:
                    if (ainfo->type & XCBXvTypeVideoMask)
                        fprintf(stdout, "PutVideo ");
                    if (ainfo->type & XCBXvTypeStillMask)
                        fprintf(stdout, "PutStill ");
                    if (ainfo->type & XCBXvTypeImageMask)
                        fprintf(stdout, "PutImage ");
                    break;
                case XCBXvTypeOutputMask:
                    if (ainfo->type & XCBXvTypeVideoMask)
                        fprintf(stdout, "GetVideo ");
                    if (ainfo->type & XCBXvTypeStillMask)
                        fprintf(stdout, "GetStill ");
                    break;
                default:
                    fprintf(stdout, "none ");
                    break;
            }
            fprintf(stdout, "\n");

            format = XCBXvAdaptorInfoFormats(ainfo);

            fprintf(stdout, "    supported visuals:\n");
            for (k=0; k < ainfo->num_formats; k++, format++)
                fprintf(stdout, "      depth %i, visualID 0x%2lx\n",
                        format->depth, format->visual.id);

            attr_rep = XCBXvQueryPortAttributesReply(c,
                    XCBXvQueryPortAttributes(c, ainfo->base_id), NULL);
            nattr = attr_rep->num_attributes;
            attr_iter = XCBXvQueryPortAttributesAttributesIter(attr_rep);

            if (nattr) {            
                fprintf(stdout, "    number of attributes: %i\n", nattr);

                for (k = 0; k < nattr; k++) {
                    attribute = attr_iter.data;
                    fprintf(stdout, "      \"%s\" (range %li to %li)\n",
                            XCBXvAttributeInfoName(attribute),
                            attribute->min,
                            attribute->max);

                    if (attribute->flags & XCBXvAttributeFlagSettable)
                        fprintf(stdout, "              client settable attribute\n");

                    if (attribute->flags & XCBXvAttributeFlagGettable) {
                        XCBATOM the_atom;
                        XCBInternAtomRep *atom_rep;

                        fprintf(stdout, "              client gettable attribute");

                        atom_rep = XCBInternAtomReply(c,
                                XCBInternAtom(c,
                                    1, 
                                    /*XCBXvAttributeInfoNameLength(attribute),*/
                                    strlen(XCBXvAttributeInfoName(attribute)),
                                    XCBXvAttributeInfoName(attribute)),
                                NULL);
                        the_atom = atom_rep->atom;

                        if (the_atom.xid != 0) {
                            XCBXvGetPortAttributeRep *pattr_rep =
                                XCBXvGetPortAttributeReply(c,
                                        XCBXvGetPortAttribute(c, ainfo->base_id, the_atom),
                                        NULL);
                            if (pattr_rep) fprintf(stdout, " (current value is %li)", pattr_rep->value);
                            free(pattr_rep);
                        }
                        fprintf(stdout, "\n");
                        free(atom_rep);
                    }
                    XCBXvAttributeInfoNext(&attr_iter);
                }
            }
            else {
                fprintf(stdout, "    no port attributes defined\n");
            }

            XCBXvQueryEncodingsRep *qencodings_rep;
            qencodings_rep = XCBXvQueryEncodingsReply(c, XCBXvQueryEncodings(c, ainfo->base_id), NULL);
            int nencode = qencodings_rep->num_encodings;
            XCBXvEncodingInfoIter encoding_iter = XCBXvQueryEncodingsInfoIter(qencodings_rep);
            XCBXvEncodingInfo *encoding;

            int ImageEncodings = 0;
            if (nencode) {
                int n;
                for (n = 0; n < nencode; n++) {
                    encoding = encoding_iter.data;
                    name = ExtractString(XCBXvEncodingInfoName(encoding), XCBXvEncodingInfoNameLength(encoding));
                    if (!nstrcmp(name, strlen(name), "XV_IMAGE"))
                        ImageEncodings++;
                    XCBXvEncodingInfoNext(&encoding_iter);
                    free(name);
                }

                if(nencode - ImageEncodings) {
                    fprintf(stdout, "    number of encodings: %i\n", nencode - ImageEncodings);

                    /* Reset the iter. */
                    encoding_iter = XCBXvQueryEncodingsInfoIter(qencodings_rep);
                    for(n = 0; n < nencode; n++) {
                        encoding = encoding_iter.data;
                        name = ExtractString(XCBXvEncodingInfoName(encoding), XCBXvEncodingInfoNameLength(encoding));
                        if(nstrcmp(name, strlen(name), "XV_IMAGE")) {
                            fprintf(stdout,
                                    "      encoding ID #%li: \"%*s\"\n",
                                    encoding->encoding.xid,
                                    strlen(name),
                                    name);
                            fprintf(stdout, "        size: %i x %i\n",
                                    encoding->width,
                                    encoding->height);
                            fprintf(stdout, "        rate: %f\n",
                                    (float)encoding->rate.numerator/
                                    (float)encoding->rate.denominator);
                            free(name);
                        }
                        XCBXvEncodingInfoNext(&encoding_iter);
                    }
                }

                if(ImageEncodings && (ainfo->type & XCBXvTypeImageMask)) {
                    char imageName[5] = {0, 0, 0, 0, 0};
                    encoding_iter = XCBXvQueryEncodingsInfoIter(qencodings_rep);
                    for(n = 0; n < nencode; n++) {
                        encoding = encoding_iter.data;
                        name = ExtractString(XCBXvEncodingInfoName(encoding), XCBXvEncodingInfoNameLength(encoding));
                        if(!nstrcmp(name, strlen(name), "XV_IMAGE")) {
                            fprintf(stdout, 
                                    "    maximum XvImage size: %i x %i\n",	
                                    encoding->width, encoding->height);
                            break;
                        }
                        free(name);
                    }
                    XCBXvListImageFormatsRep *formats_rep;
                    formats_rep = XCBXvListImageFormatsReply(c,
                            XCBXvListImageFormats(c, ainfo->base_id),
                            NULL);

                    int numImages = formats_rep->num_formats;
                    XCBXvImageFormatInfo *format;
                    XCBXvImageFormatInfoIter formats_iter = XCBXvListImageFormatsFormatIter(formats_rep);
                    fprintf(stdout, "    Number of image formats: %i\n",
                            numImages);

                    for(n = 0; n < numImages; n++) {
                        format = formats_iter.data;
                        memcpy(imageName, &(format->id), 4);
                        fprintf(stdout, "      id: 0x%lx", format->id);
                        if(isprint(imageName[0]) && isprint(imageName[1]) &&
                                isprint(imageName[2]) && isprint(imageName[3])) 
                        {
                            fprintf(stdout, " (%s)\n", imageName);
                        } else {
                            fprintf(stdout, "\n");
                        }
                        fprintf(stdout, "        guid: ");
                        fprintf(stdout, "%02x", (unsigned char) 
                                format->guid[0]);
                        fprintf(stdout, "%02x", (unsigned char) 
                                format->guid[1]);
                        fprintf(stdout, "%02x", (unsigned char) 
                                format->guid[2]);
                        fprintf(stdout, "%02x-", (unsigned char) 
                                format->guid[3]);
                        fprintf(stdout, "%02x", (unsigned char) 
                                format->guid[4]);
                        fprintf(stdout, "%02x-", (unsigned char) 
                                format->guid[5]);
                        fprintf(stdout, "%02x", (unsigned char) 
                                format->guid[6]);
                        fprintf(stdout, "%02x-", (unsigned char) 
                                format->guid[7]);
                        fprintf(stdout, "%02x", (unsigned char) 
                                format->guid[8]);
                        fprintf(stdout, "%02x-", (unsigned char) 
                                format->guid[9]);
                        fprintf(stdout, "%02x", (unsigned char) 
                                format->guid[10]);
                        fprintf(stdout, "%02x", (unsigned char) 
                                format->guid[11]);
                        fprintf(stdout, "%02x", (unsigned char) 
                                format->guid[12]);
                        fprintf(stdout, "%02x", (unsigned char) 
                                format->guid[13]);
                        fprintf(stdout, "%02x", (unsigned char) 
                                format->guid[14]);
                        fprintf(stdout, "%02x\n", (unsigned char) 
                                format->guid[15]);

                        fprintf(stdout, "        bits per pixel: %i\n",
                                format->bpp);
                        fprintf(stdout, "        number of planes: %i\n",
                                format->num_planes);
                        fprintf(stdout, "        type: %s (%s)\n", 
                                (format->type == XCBXvImageFormatInfoTypeRGB) ? "RGB" : "YUV",
                                (format->format == XCBXvImageFormatInfoFormatPacked) ? "packed" : "planar");

                        if(format->type == XCBXvImageFormatInfoTypeRGB) {
                            fprintf(stdout, "        depth: %i\n", 
                                    format->depth);

                            fprintf(stdout, "        red, green, blue masks: " 
                                    "0x%lx, 0x%lx, 0x%lx\n", 
                                    format->red_mask,
                                    format->green_mask,
                                    format->blue_mask);
                        } else {

                        }
                        XCBXvImageFormatInfoNext(&formats_iter);
                    }
                    free(formats_rep);
                }
            }
            free(qencodings_rep);
            XCBXvAdaptorInfoNext(&adaptors_iter);
        }
    }

    free(adaptors_rep);
    adaptors_rep = NULL;

    return 1;
}
示例#23
0
const char *on_update_config (/* IN  */const char* data,
								/* IN  */void* context,
								/* OUT */BOOL* more_data_needed,
								/* OUT */roadmap_result* rc) {

   int size;
   char file[256];
   char category[256];
   char key[256];
   char value[512];
   // Default error for early exit:
   (*rc) = err_parser_unexpected_data;

   // Expected data:
   // <file>, <category>, <key>, <value>

   // File
   size = sizeof ( file );
   data = ExtractString( data, file, &size, ",", 1 );
   if (!data)
   {
      roadmap_log (ROADMAP_ERROR, "on_update_config() - Failed to read 'file'" );
      return NULL;
   }

   // Category
   size = sizeof ( category );
   data = ExtractString( data, category, &size, ",", 1 );
   if ( !data ) {
      roadmap_log (ROADMAP_ERROR, "on_update_config() - Failed to read 'category'");
      return NULL;
   }

   // Key
   size = sizeof ( key );
   data = ExtractString ( data, key, &size, ",", 1 );
   if (!data) {
      roadmap_log (ROADMAP_ERROR, "on_update_config() - Failed to read 'key' " );
      return NULL;
   }

   // Value
   size = sizeof (value);
   data = ExtractString ( data, value, &size, ",\r\n", TRIM_ALL_CHARS );
   if (!data)
   {
      roadmap_log (ROADMAP_ERROR, "on_update_config() - Failed to read 'value' " );
      return NULL;
   }

   (*rc) = succeeded;
   roadmap_log (ROADMAP_INFO, "Successfully got UpdateConfig message - file %s, category=%s, key=%s, value=%s", file, category, key, value );

   /* Set the configuration value */
   {
	   RoadMapConfigDescriptor cfgDesc ;
	   cfgDesc.category = strdup( category);
	   cfgDesc.name  = strdup( key );
	   roadmap_config_declare( file, &cfgDesc, "", NULL );
	   parse_string( value );
	   roadmap_config_set( &cfgDesc, value );
   }
   return data;
}
示例#24
0
const char *on_server_config (/* IN  */const char* data,
/* IN  */void* context,
/* OUT */BOOL* more_data_needed,
/* OUT */roadmap_result* rc) {

   int serial;
   int size;
   char category[256];
   char key[256];
   char value[256];
   RoadMapConfigDescriptor param;

   // Default error for early exit:
   (*rc) = err_parser_unexpected_data;
   // Expected data:
   // <serial> <category> <key> <value>

   // Serial
   data = ReadIntFromString (data, //   [in]      Source string
            ",", //   [in,opt]  Value termination
            NULL, //   [in,opt]  Allowed padding
            &serial, //   [out]     Output value
            1); //   [in]      TRIM_ALL_CHARS, DO_NOT_TRIM, or 'n'

   if (!data) {
      roadmap_log (ROADMAP_ERROR,"on_serve_config() - Failed to read 'serial'" );
      return NULL;
   }

   // Category
   size = sizeof (category);
   data = ExtractString (data, category, &size, ",", 1);
   if (!data) {
      roadmap_log (ROADMAP_ERROR, "on_geo_server_config() - Failed to read 'category' serial = %d", serial);
      return NULL;
   }

   // Key
   size = sizeof (key);
   data = ExtractString (data, key, &size, ",", 1);
   if (!data) {
      roadmap_log (ROADMAP_ERROR, "on_geo_server_config() - Failed to read 'key' serial = %d", serial);
      return NULL;
   }

   // Value
   size = sizeof (value);
   data = ExtractString (data, value, &size, ",\r\n", TRIM_ALL_CHARS);
   if (!data) {
      roadmap_log (ROADMAP_ERROR, "on_geo_server_config() - Failed to read 'value' serial = %d", serial);
      return NULL;
   }

   (*rc) = succeeded;
   roadmap_log (ROADMAP_INFO, "got ServerConfig message - serial=%d out of %d, category=%s, key=%s, value=%s",serial+1, GeoConfigContext.num_results, category, key, value );

   GeoConfigContext.num_received++;

   param.category = strdup(category);
   param.name = strdup(key);
   roadmap_config_declare("preferences",&param, "", NULL);
   parse_string( value );
   roadmap_config_set(&param,value);

   if (GeoConfigContext.num_received == GeoConfigContext.num_results) {
      roadmap_log (ROADMAP_INFO, "GeoServerConfig, Got all results... " );
      on_recieved_completed();
   }

   (*rc) = succeeded;
   return data;
}
示例#25
0
//-----------------------------------------------------------------------------
                             //correo de rebote /correo destino / dir de buzon destino /acceso
bool TAdministradora :: SendEmail(TMail* pRebote,TMail* pMail,AnsiString pDestiny, bool IntAccess)//Modoficarlo
{
  AnsiString Problema = " No se pudo mandar el correo a "+ pDestiny +" por la razon siguiente: ";
  AnsiString VerAdministrador = " Por si tiene alguna duda puede contactar con su administrador ";
  void* TempPtr;
  int tam = pDestiny.Length()-1;
  AnsiString RootName = ExtractString(pDestiny,tam);
  //servidor nacional
  if( ((TDomain*)aTree->Root()->Info())->NameDomain() == RootName )         // si coincide con la raiz
  {
    TGBinTreeNode* node = (TGBinTreeNode*)aTree->Root();
    AnsiString NameDomain;
    bool found = true;
    while( !node->IsLeaf() && (found)) //ciclo que recorre el camino buscando el camino de subdominios hasta el servidor donde esta la
    {                                 //cuenta de esa direccion
      NameDomain = ExtractString(pDestiny,tam);
      node = (TGBinTreeNode*)aTree->GetSons(node)->FirstThat(Daemon::FindDomainNameList,&NameDomain);
      if(!node)
      {
        pRebote->Parrafo(Problema + "No hay servidores en ese dominio" + VerAdministrador + pMail->Parrafo());
        found = false;
      }
    }    //en este instante, la direccion solo es el nombre del usuario
         //estas en el server
    if(!found)
      return false;
    if( ((TServidor*)node->Info())->Max() < pMail->Size() )  // si el correo es mayor que lo que admite el servidor destino
    {
      pRebote->Parrafo(Problema + " El tamaño del correo es mayor que el asignado por el servidor de correo a la direccion donde escribio " + VerAdministrador + pMail->Parrafo());
      return false;
    }
    //se busca la cuenta en el server con el ultimo nombre
    TCuenta* cuentadestino = (TCuenta*)((TServidor*)node->Info())->Cuentas()->FirstThat(Daemon::FindCuenta,&NameDomain);
    if(!cuentadestino)
    {
      pRebote->Parrafo(Problema + " La direccion donde escribio el correo es incorrecta o no existe " + VerAdministrador + pMail->Parrafo());
      return false;
    }
    else
    {
      int tamRemit = pRebote->Remitente().Length()-1;   //si es distinto a la raiz nacional es que es internacional
      AnsiString Remit = pRebote->Remitente();
      AnsiString NameDominio = ExtractString(Remit,tamRemit);
      //si del correo que tu le estas escribiendo no es nacional y la cuenta de el no tiene salida internacional entonces
      //no puedes mandar el correo
      if( ((TDomain*)aTree->Root()->Info())->NameDomain() != NameDominio && !cuentadestino->Salida())
      {
        pRebote->Parrafo(Problema + " La cuenta a la que le estas escribiendo no tiene permiso de salida internacional  y no puede responder a usurios externos al cu" + VerAdministrador + pMail->Parrafo());
        return false;
      }
      if(!cuentadestino->InsertMail(pMail))     // dice si el buzon estaba lleno o no
      {
        pRebote->Parrafo(Problema + " El buzon del destinatario esta lleno o desabilitado " + VerAdministrador + pMail->Parrafo());
        return false;
      }
      else
       return true;
    }
  }
   //sino /////////////////
  else
  {
  // servidor internacional/////////////////////////////////////////////////////// david@ yahoo.com
    AnsiString InterName = ExtractString(pDestiny, tam);  //yahoo
    InterName = InterName + '.' + RootName;                      // me da un servidor internacional   yahoo.com
    AnsiString account = ExtractString(pDestiny, tam);
    TServidor* server = (TServidor*)aInternacionales->FirstThat(Daemon::FindNameList,&InterName);
    if(!server)
    {
      pRebote->Parrafo(Problema + " No existe el servidor " + InterName + "para ese Dominio Internacional en esa direccion " + VerAdministrador + pMail->Parrafo());
      return false;
    }
    else
    {
      if(!IntAccess)
      {
        pRebote->Parrafo(Problema + "Esta cuenta no tiene esta autorizada con permiso para Salida Internacional" + VerAdministrador + pMail->Parrafo());
        return false;
      }

      if( server->Max() < pMail->Size() )
      {
        pRebote->Parrafo(Problema + " El tamaño del correo es mayor al asignado por el servidor a su cuenta " + VerAdministrador + VerAdministrador + pMail->Parrafo());
        return false;
      }
    }
    TCuenta* cuenta = (TCuenta*)server->Cuentas()->FirstThat(Daemon::FindCuenta,&account);
    if(!cuenta)
    {
      pRebote->Parrafo(Problema + " El nombre de Usuario "+ account + " no existe en la direccion a donde escribio el correo " + VerAdministrador + pMail->Parrafo());
      return false;
    }
    else
    {
      if(!cuenta->InsertMail(pMail))
     {
      pRebote->Parrafo(Problema + " El buzon del destinatario esta lleno o desabilitado " + VerAdministrador + pMail->Parrafo());
      return false;
     }
     else
      return true;
    }
  }
}