Example #1
0
void ErrorMessage(const TCHAR *str)  //display detailed error info
{
  LPVOID msg;
  FormatMessage(
    FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
    NULL,
    GetLastError(),
    MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
    (LPTSTR) &msg,
    0,
    NULL
    );
  wnd_printf(str);
  wnd_printf(_T(": "));
  wnd_printf((TCHAR*)msg);
  LocalFree(msg);
}
Example #2
0
/* 'display' message handler */
wnd_msg_retcode_t radio_on_display( wnd_t *wnd )
{
	radio_t *r = RADIO_OBJ(wnd);

	wnd_move(wnd, 0, 0, 0);
	wnd_apply_default_style(wnd);
	wnd_printf(wnd, 0, 0, "(%c)", r->m_checked ? 'X' : ' ');
	wnd_apply_style(wnd, WND_FOCUS(wnd) == wnd ? "focus-label-style" :
			"label-style");
	wnd_putchar(wnd, 0, ' ');
	label_text_display(wnd, &RADIO_OBJ(wnd)->m_text);
	wnd_move(wnd, 0, 1, 0);
    return WND_MSG_RETCODE_OK;
} /* End of 'radio_on_display' function */
Example #3
0
DWORD WINAPI ThreadProc(LPVOID p) // thread that will start & monitor makensis
{
  TCHAR buf[1024];
  char iobuf[1024];           //i/o buffer
  STARTUPINFO si={sizeof(si),};
  SECURITY_ATTRIBUTES sa={sizeof(sa),};
  SECURITY_DESCRIPTOR sd={0,};               //security information for pipes
  PROCESS_INFORMATION pi={0,};
  HANDLE newstdout=0,read_stdout=0;         //pipe handles

  OSVERSIONINFO osv={sizeof(osv)};
  GetVersionEx(&osv);
  if (osv.dwPlatformId == VER_PLATFORM_WIN32_NT)        //initialize security descriptor (Windows NT)
  {
    InitializeSecurityDescriptor(&sd,SECURITY_DESCRIPTOR_REVISION);
    SetSecurityDescriptorDacl(&sd, true, NULL, false);
    sa.lpSecurityDescriptor = &sd;
  }
  else sa.lpSecurityDescriptor = NULL;
  sa.bInheritHandle = true;         //allow inheritable handles

  if (!CreatePipe(&read_stdout,&newstdout,&sa,0))  //create stdout pipe
  {
    ErrorMessage(_T("CreatePipe"));
    PostMessage(g_hwnd,WM_NOTIFYENDCOMPILE,0,1);
    return 1;
  }

  GetStartupInfo(&si);      //set startupinfo for the spawned process
  /*
    The dwFlags member tells CreateProcess how to make the process.
    STARTF_USESTDHANDLES validates the hStd* members. STARTF_USESHOWWINDOW
    validates the wShowWindow member.
  */
  si.dwFlags = STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW;
  si.wShowWindow = SW_HIDE;
  si.hStdOutput = newstdout;
  si.hStdError = newstdout;     //set the new handles for the child process

  // *******************************************************************
  // If there is a command line in the config file, use it for create process

  //spawn the child process
  if (!CreateProcess(NULL,g_cmdline,NULL,NULL,TRUE,CREATE_NEW_CONSOLE,
      NULL,tempzip_path,&si,&pi))
  {
    ErrorMessage(_T("CreateProcess"));
    wnd_printf(_T("\r\nPlease make sure the path to makensis.exe is correct."));
    CloseHandle(newstdout);
    CloseHandle(read_stdout);
    PostMessage(g_hwnd,WM_NOTIFYENDCOMPILE,0,1);
    return 1;
  }
  CloseHandle(newstdout); // close this handle (duplicated in subprocess) now so we get ERROR_BROKEN_PIPE
  DWORD dwLeft = 0, dwRead = 0;
  while (ReadFile(read_stdout, iobuf+dwLeft, sizeof(iobuf)-dwLeft-1, &dwRead, NULL)) //wait for buffer, or fails with ERROR_BROKEN_PIPE when subprocess exits
  {
    dwRead += dwLeft;
    iobuf[dwRead] = '\0';
#ifdef _UNICODE
    // this tweak is to prevent LogMessage from cutting in the middle of an UTF-8 sequence
    // we print only up to the latest \n of the buffer, and keep the remaining for the next loop
    char* lastLF = strrchr(iobuf,'\n');
    if (lastLF == NULL) lastLF = iobuf+dwRead-1;
    char ch = *++lastLF;
    *lastLF = '\0';
    MultiByteToWideChar(CP_UTF8,0,iobuf,lastLF+1-iobuf,buf,COUNTOF(buf));
    wnd_printf(buf);
    *lastLF = ch;
    dwLeft = iobuf+dwRead-lastLF;
    memmove(iobuf, lastLF, dwLeft);
#else
    wnd_printf(iobuf);
#endif
  }
#ifdef _UNICODE
  // because of UTF-8 tweak, in rare case there can be some data remaining
  dwRead += dwLeft;
  iobuf[dwRead] = 0;
  MultiByteToWideChar(CP_UTF8,0,iobuf,dwRead+1,buf,COUNTOF(buf));
  wnd_printf(buf);
#endif
  CloseHandle(pi.hThread);
  CloseHandle(pi.hProcess);
  CloseHandle(read_stdout);


  wsprintf(buf,_T("(source ZIP size was %d bytes)\r\n"),g_zipfile_size);
  wnd_printf(buf);

  PostMessage(g_hwnd,WM_NOTIFYENDCOMPILE,0,0);
  return 0;
}
Example #4
0
/* Display play list */
void plist_display( plist_t *pl, wnd_t *wnd )
{
	int i, j, start, end;
	char time_text[80];

	assert(pl);
	PLIST_GET_SEL(pl, start, end);

	plist_lock(pl);

	/* Display each song */
	for ( i = 0, j = pl->m_scrolled; i < PLIST_HEIGHT; i ++, j ++ )
	{
		int attrib;
		
		/* Set respective print attributes */
		if (j >= start && j <= end)
		{
			if (j == pl->m_cur_song)
				wnd_apply_style(wnd, "plist-sel-and-play-style");
			else
				wnd_apply_style(wnd, "plist-selected-style");
		}
		else
		{
			if (j == pl->m_cur_song)
				wnd_apply_style(wnd, "plist-playing-style");
			else
				wnd_apply_style(wnd, "plist-style");
		}
		
		/* Print song title */
		if (j < pl->m_len)
		{
			song_t *s = pl->m_list[j];
			char len[10];
			int x;
			int queueList;
			
			wnd_move(wnd, 0, 0, pl->m_start_pos + i);
			wnd_printf(wnd, WND_PRINT_ELLIPSES, WND_WIDTH(wnd) - 8, 
					"%i. %s", j + 1, STR_TO_CPTR(s->m_title));
			for(queueList=0;queueList<num_queued_songs;queueList++)
			{
				if(queued_songs[queueList] == j)
					wnd_printf(wnd, 0, 0, "    #%i in queue...", queueList+1);
			}
			int l = TIME_TO_SECONDS(s->m_len);
			sprintf(len, "%i:%02i", l / 60, l % 60);
			wnd_move(wnd, WND_MOVE_ADVANCE, WND_WIDTH(wnd) - strlen(len) - 1, 
					pl->m_start_pos + i);
			wnd_printf(wnd, 0, 0, "%s", len);
		}
	}

	/* Display play list time */
	song_time_t l_time = 0, s_time = 0;
	if (pl->m_len)
	{
		for ( i = 0; i < pl->m_len; i ++ )
			l_time += pl->m_list[i]->m_len;
		for ( i = start; i <= end; i ++ )
			s_time += pl->m_list[i]->m_len;
	}
	int l_seconds = TIME_TO_SECONDS(l_time);
	int s_seconds = TIME_TO_SECONDS(s_time);
	wnd_apply_style(wnd, "plist-time-style");
	sprintf(time_text, ngettext("%i/%i song; %i:%02i:%02i/%i:%02i:%02i",
				"%i/%i songs; %i:%02i:%02i/%i:%02i:%02i", pl->m_len),
			(end >= 0 && pl->m_len > 0) ? end - start + 1 : 0, pl->m_len,
			s_seconds / 3600, (s_seconds % 3600) / 60, s_seconds % 60,
			l_seconds / 3600, (l_seconds % 3600) / 60, l_seconds % 60);
	wnd_move(wnd, 0, WND_WIDTH(wnd) - utf8_width(time_text) - 1, 
			pl->m_start_pos + PLIST_HEIGHT);
	wnd_printf(wnd, 0, 0, "%s", time_text);

	plist_unlock(pl);
} /* End of 'plist_display' function */