示例#1
0
int WINAPI _export GetArcItem(struct PluginPanelItem *Item,struct ArcItemInfo *Info)
{
  if (setjmp(jumper) != 0)
    {cleanup(); return GETARC_BROKEN;}  // Сюда мы попадём при возникновении ошибки в одной из вызываемых процедур

  // Считаем следующий блок каталога архива, если все файлы из текущего уже перечислены
  if( current_block < 0 || ++current_file_in_block >= dirblock->total_files)
  {
    FreeAndNil (dirblock);
    for(;;)
    {
      if( ++current_block == arcinfo->control_blocks_descriptors.size )
      {
        return GETARC_EOF;
      }

      // Если это блок каталога - прочитаем его и выйдем из цикла
      BLOCK& descriptor = arcinfo->control_blocks_descriptors [current_block];
      if (descriptor.type == DIR_BLOCK)
      {
         dirblock = new DIRECTORY_BLOCK (*arcinfo, descriptor);
         current_file_in_block = current_data_block = 0;
         if (dirblock->total_files>0)  break;
         FreeAndNil (dirblock);
      }
    }
    //printf("%d files\n", dirblock->total_files);
  }

  // Заполним описание файла
  int i = current_file_in_block;
  Item->FindData.dwFileAttributes = dirblock->isdir[i]? FILE_ATTRIBUTE_DIRECTORY : 0;
  UnixTimeToFileTime (dirblock->time[i], &Item->FindData.ftLastWriteTime);
  Item->FindData.nFileSizeHigh = ((uint64) dirblock->size[i]) >> 32;
  Item->FindData.nFileSizeLow  = dirblock->size[i];
  char utf8name[MY_FILENAME_MAX*4]; WCHAR utf16name[MY_FILENAME_MAX*2];
  dirblock->fullname (i, utf8name);
  utf8_to_utf16 (utf8name, utf16name);
  CharToOemW (utf16name, Item->FindData.cFileName);
  Item->CRC32  = dirblock->crc[i];
  Info->UnpVer = UnpVer;

  // Теперь извлечём информацию из описания солид-блока
  int &b = current_data_block;
  // Увеличим номер солид-блока если мы вышли за последний принадлежащий ему файл
  if (current_file_in_block >= dirblock->block_end(b))
    b++;
  // Если это первый файл в солид-блоке - соберём block-related информацию
  if (current_file_in_block == dirblock->block_start(b))
  { // Запишем на первый файл в блоке весь его упакованный размер
    uint64 packed = dirblock->data_block[b].compsize;
    Item->PackSizeHigh = packed >> 32;
    Item->PackSize     = packed;
    // Запомним информацию о солид-блоке для использования её со всеми файлами из этого солид-блока
    char *c = dirblock->data_block[b].compressor;
    Solid     = dirblock->block_start(b)+1 != dirblock->block_end(b);
    Encrypted = strstr (c, "+aes-")!=NULL || strstr (c, "+serpent-")!=NULL || strstr (c, "+blowfish-")!=NULL || strstr (c, "+twofish-")!=NULL;
    DictSize  = compressorGetDecompressionMem (dirblock->data_block[b].compressor);
  }
示例#2
0
/* Show usage */
void
usage (void)
{
  WCHAR wszUsage[4096];
  char oemUsage[4096];

  LoadStringW (GetModuleHandleW (NULL), IDS_USAGE, wszUsage, sizeof(wszUsage) / sizeof(wszUsage[0]));
  CharToOemW (wszUsage, oemUsage);
  fputs (oemUsage, stdout);
}
示例#3
0
文件: format.c 项目: GYGit/reactos
VOID PrintStringV(LPWSTR szStr, va_list args)
{
    WCHAR bufFormatted[RC_STRING_MAX_SIZE];
    CHAR bufFormattedOem[RC_STRING_MAX_SIZE];

    _vsnwprintf(bufFormatted, ARRAYSIZE(bufFormatted), szStr, args);

    CharToOemW(bufFormatted, bufFormattedOem);
    puts(bufFormattedOem);
}
示例#4
0
文件: tree.c 项目: GYGit/reactos
/*
 * This takes strings from a resource string table
 * and outputs it to the console.
 */
VOID PrintResourceString(INT resID, ...)
{
    WCHAR tmpBuffer[STR_MAX];
    CHAR tmpBufferA[STR_MAX];
    va_list arg_ptr;

    va_start(arg_ptr, resID);
    LoadStringW(GetModuleHandle(NULL), resID, tmpBuffer, STR_MAX);
    CharToOemW(tmpBuffer, tmpBufferA);
    vfprintf(stdout, tmpBufferA, arg_ptr);
    va_end(arg_ptr);
}
// Преобразование строки Windows в строку в кодировке OEM.
LPCSTR CConvOem::toOemW(LPCWSTR const lpszSrc)
{
	if (m_blInvalidBuff || !lpszSrc)
	{
		SetLastError(ERROR_INVALID_ADDRESS);
		return 0;
	}
	size_t len(wcslen(lpszSrc)); len++;
	if (len > m_BuffSize)
	{
		SetLastError(ERROR_INVALID_ADDRESS);
		return 0;
	}
	CharToOemW(lpszSrc, m_szBuff);
	return m_szBuff;
}
示例#6
0
char* RusW(const wchar_t* text) {
	CharToOemW(text, bufRus);
	return bufRus;
}
示例#7
0
/* Main program */
int
main (int argc, char **argv)
{
  char *opt, *needle = NULL;
  int ret = 0;
  WCHAR wszMessage[4096];
  char oemMessage[4096];

  int invert_search = 0;		/* flag to invert the search */
  int count_lines = 0;			/* flag to whether/not count lines */
  int number_output = 0;		/* flag to print line numbers */
  int ignore_case = 0;			/* flag to be case insensitive */

  FILE *pfile;				/* file pointer */
  int hfind;				/* search handle */
  struct _finddata_t finddata;		/* _findfirst, filenext block */

  /* Scan the command line */
  while ((--argc) && (needle == NULL))
    {
      if (*(opt = *++argv) == '/')
        {
          switch (opt[1])
	    {
	      case 'c':
	      case 'C':		/* Count */
	        count_lines = 1;
	        break;

	      case 'i':
	      case 'I':		/* Ignore */
	        ignore_case = 1;
	        break;

	      case 'n':
	      case 'N':		/* Number */
	        number_output = 1;
	        break;

	      case 'v':
	      case 'V':		/* Not with */
	        invert_search = 1;
	        break;

	      default:
	        usage ();
	        exit (2);		/* syntax error .. return error 2 */
	        break;
	    }
        }
      else
        {
          /* Get the string */
	  if (needle == NULL)
	    {
              /* Assign the string to find */
              needle = *argv;
	    }
	}
    }

  /* Check for search string */
  if (needle == NULL)
    {
      /* No string? */
      usage ();
      exit (1);
    }

  /* Scan the files for the string */
  if (argc == 0)
    {
      ret = find_str (needle, stdin, invert_search, count_lines,
                      number_output, ignore_case);
    }

  while (--argc >= 0)
    {
      hfind = _findfirst (*++argv, &finddata);
      if (hfind < 0)
	{
	  /* We were not able to find a file. Display a message and
	     set the exit status. */
	  LoadStringW (GetModuleHandleW (NULL), IDS_NO_SUCH_FILE, wszMessage, sizeof(wszMessage) / sizeof(wszMessage[0]));
	  CharToOemW (wszMessage, oemMessage);
	  fprintf (stderr, oemMessage, *argv);
	}
      else
        {
          /* repeat find next file to match the filemask */
	  do
            {
              /* We have found a file, so try to open it */
	      if ((pfile = fopen (finddata.name, "r")) != NULL)
	        {
	          printf ("---------------- %s\n", finddata.name);
	          ret = find_str (needle, pfile, invert_search, count_lines,
	                          number_output, ignore_case);
	          fclose (pfile);
	        }
 	      else
	        {
	          LoadStringW (GetModuleHandleW (NULL), IDS_CANNOT_OPEN, wszMessage, sizeof(wszMessage) / sizeof(wszMessage[0]));
	          CharToOemW (wszMessage, oemMessage);
	          fprintf (stderr, oemMessage,
		           finddata.name);
                }
	    }
          while (_findnext(hfind, &finddata) > 0);
        }
      _findclose(hfind);
    } /* for each argv */

 /* RETURN: If the string was found at least once, returns 0.
  * If the string was not found at all, returns 1.
  * (Note that find_str.c returns the exact opposite values.)
  */
  exit ( (ret ? 0 : 1) );
}