本文整理汇总了C++中display_error函数的典型用法代码示例。如果您正苦于以下问题:C++ display_error函数的具体用法?C++ display_error怎么用?C++ display_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了display_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: VideoDevice
void ProcessImage::initCamera()
{
vd = new VideoDevice(QString("/dev/video0"));
connect(vd, SIGNAL(display_error(QString)), this,SLOT(display_error(QString)));
rs = vd->open_device();
if(-1==rs)
{
return;
}
rs = vd->init_device();
if(-1==rs)
{
vd->close_device();
return;
}
rs = vd->start_capturing();
if(-1==rs)
{
vd->close_device();
return;
}
}
示例2: get_rotation
/* DDS3.2.6: Get Rotation */
void get_rotation(const struct electorate *elec)
{
struct http_vars *reply;
unsigned int i;
char ecodestr[INT_CHARS];
struct http_vars request[]
= { { (char*)"ecode", ecodestr }, { NULL, NULL } };
sprintf(ecodestr, "%u", elec->code);
reply = http_exchange(SERVER_ADDRESS, SERVER_PORT, ROBSON_CGI,request);
if (!reply)
display_error(ERR_SERVER_UNREACHABLE);
/* Some error occurred? */
if (http_error(reply))
display_error(http_error(reply));
for (i = 0; i < elec->num_seats; i++) {
char varname[strlen("rotation")
+ sizeof(STRINGIZE(MAX_ELECTORATE_SEATS))];
const char *val;
sprintf(varname, "rotation%u", i);
val = http_string(reply, varname);
current_rotation.rotations[i] = atoi(val);
assert(current_rotation.rotations[i] < elec->num_seats);
}
/* DDS3.2.6: Save Rotation */
current_rotation.size = elec->num_seats;
http_free(reply);
}
示例3: get_days_difference
void MainWindow::submit()
{
if(check_pages_input()){
int read_pages = read_pages_text_edit->text().toInt();
int all_pages = all_pages_text_edit->text().toInt();
int pages_to_read = all_pages - read_pages;
int days_to_read = get_days_difference();
int pages_per_day;
if(days_to_read > 0){
pages_per_day = ceil(pages_to_read / days_to_read); //round upwards so that it is accurate
//sometimes when there are too many days, pages_per_day becomes zero, so this if fixes that
if(pages_per_day == 0)
result_label->setText("You should read less than 1 page per day");
else
result_label->setText("You should read " + QString::number(pages_per_day) + " pages per day");
}
else{
result_label->setText("Try again!");
display_error("Please select a valid date!");
}
}
else{
display_error("The given input is invalid!");
}
}
示例4: printf
ProcessImage::ProcessImage(QWidget *parent):QWidget(parent)
{
printf("create ProcessImage\n");
canCapture = false;
canDisplay = false;
pp = (unsigned char *)malloc(LCDWIDTH * LCDHEIGHT* 3 * sizeof(char));
painter = new QPainter(this);
frame = new QImage(pp,LCDWIDTH,LCDHEIGHT,QImage::Format_RGB888);
label = new QLabel();
vd = new VideoDevice(tr("/dev/video0"));
connect(vd, SIGNAL(display_error(QString)), this,SLOT(display_error(QString)));
connect(&client, SIGNAL(newMessage(QString,QString)),
this, SLOT(updatePP(QString,QString)));
connect(&client,SIGNAL(newMessage(QString,QString)),
this,SLOT(update()));
// timer->start(30);
QHBoxLayout *mainLayout = new QHBoxLayout();
mainLayout->addWidget(label);
setLayout(mainLayout);
counter = 0;
}
示例5: cert_stuff
static int cert_stuff(struct connectdata *conn,
int sockindex, char *cert_file, char *key_file)
{
struct SessionHandle *data = conn->data;
int rv = 0;
if(cert_file) {
rv = nss_load_cert(&conn->ssl[sockindex], cert_file, PR_FALSE);
if(!rv) {
if(!display_error(conn, PR_GetError(), cert_file))
failf(data, "Unable to load client cert %d.", PR_GetError());
return 0;
}
}
if(key_file || (is_file(cert_file))) {
if(key_file)
rv = nss_load_key(conn, sockindex, key_file);
else
/* In case the cert file also has the key */
rv = nss_load_key(conn, sockindex, cert_file);
if(!rv) {
if(!display_error(conn, PR_GetError(), key_file))
failf(data, "Unable to load client key %d.", PR_GetError());
return 0;
}
}
return 1;
}
示例6: prep_and_launch_redirected_child
/// Sets up STARTUPINFO structure, and launches redirected child. Start command.
///
/// \param sCommand_line fully command line, after modify
/// \param hChildStdOut child std out pipe
/// \param hChildStdIn child std in pipe
/// \param hChildStdErr child std error pipe
///
/// no return value
static void prep_and_launch_redirected_child(char *sCommand_line, HANDLE hChildStdOut, HANDLE hChildStdIn, HANDLE hChildStdErr)
{
PROCESS_INFORMATION pi;
STARTUPINFO si;
// Set up the start up info struct.
ZeroMemory(&si, sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFO);
si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
si.hStdOutput = hChildStdOut;
si.hStdInput = hChildStdIn;
si.hStdError = hChildStdErr;
si.wShowWindow = SW_HIDE;
// Launch the process that you want to redirect.
if (!CreateProcess(
NULL, // command line
sCommand_line, // command line, with argument
NULL, // process security attributes
NULL, // primary thread security attributes
TRUE, // handles are inherited
CREATE_NO_WINDOW, // creation flags, CREATE_NO_WINDOW to prevent console window
NULL, // use parent's environment
NULL, // use parent's current direct
&si, // STARTUPINFO pointer
&pi)) // receives PROCESS_INFORMATION
display_error("prep_and_launch_redirected_child - CreateProcess", TRUE);
// Close any unnecessary handles.
if ( !CloseHandle(pi.hProcess) && !CloseHandle(pi.hThread))
display_error("prep_and_launch_redirected_child - CloseHandle - after redirect", TRUE);
}
示例7: printf
int VideoDevice::start_capturing()
{
printf("start capturing\n");
unsigned int i;
for(i = 0; i < n_buffers; ++i)
{
v4l2_buffer buf;
CLEAR(buf);
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory =V4L2_MEMORY_MMAP;
buf.index = i;
// fprintf(stderr, "n_buffers: %d\n", i);
if(-1 == ioctl(fd, VIDIOC_QBUF, &buf))
{
emit display_error(tr("VIDIOC_QBUF: %1").arg(QString(strerror(errno))));
return -1;
}
}
v4l2_buf_type type;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if(-1 == ioctl(fd, VIDIOC_STREAMON, &type))
{
emit display_error(tr("VIDIOC_STREAMON: %1").arg(QString(strerror(errno))));
return -1;
}
return 0;
}
示例8: lowlevel_init
int lowlevel_init(void)
{
unsigned por_cfg = READ_CBUS_REG(ASSIST_POR_CONFIG);
if (((por_cfg & POR_ROM_BOOT_ENABLE) == 0)) {
// take me as a spi rom boot mode
romboot_info->por_cfg = POR_ROM_BOOT_ENABLE | POR_INTL_SPI;
romboot_info->boot_id = 0;
}
WRITE_CBUS_REG(PAD_PULL_UP_REG0,-1);
WRITE_CBUS_REG(PAD_PULL_UP_REG1,-1);
WRITE_CBUS_REG(PAD_PULL_UP_REG2,-1);
WRITE_CBUS_REG(PAD_PULL_UP_REG3,-1);
//changed by Elvis, add uart rx pull up
//pull up LINUX_RX(B15--->GPIOE_19) reg (7422y v1.pdf)
//GPIOE_19(M1-Apps v25- 2010-07-19-BGA372_297-6.xls serach B15)
WRITE_CBUS_REG( PAD_PULL_UP_REG3, READ_CBUS_REG(PAD_PULL_UP_REG3) & ~(1<<2) ); // Meson-pull-up-down_table.xlsx ( GPIOE_19 is PAD_PULL_UP_REG3---0x203e 2bits)
//Adjust 1us timer base
WRITE_CBUS_REG_BITS(PREG_CTLREG0_ADDR,CONFIG_CRYSTAL_MHZ,4,5);
pll_initial(); //running under default freq now . Before we fixed the PLL stable problem
unsigned clk;
if ((readl(P_HHI_MPEG_CLK_CNTL) & (1 << 8)) == 0) {
clk = CONFIG_CRYSTAL_MHZ * 1000000;
} else {
clk = romboot_info->clk81;
}
unsigned memory_size;
memory_size = PHYS_MEMORY_SIZE;
serial_init_with_clk(clk);
writel((1<<22)|1000000,P_WATCHDOG_TC);
do {
unsigned ret1, ret2, ret3, ret4;
ret1 = ret2 = ret3 = ret4 = 0;
por_cfg = 0;
ret1 = initial_ddr(&__hw_setting.ddr, __hw_setting.ddr.lane);
display_error(ret1, "DDr Init");
#ifdef CONFIG_MEM_TEST
ret2=memTestDevice((volatile datum *)PHYS_MEMORY_START,memory_size);
display_error(ret2,"TestDevice");
por_cfg=ret2;
#endif
ret3 = memTestDataBus((volatile datum *) PHYS_MEMORY_START);
display_error(ret3, "TestDataBus");
ret4 = memTestAddressBus((volatile datum *) PHYS_MEMORY_START,
memory_size);
display_error(ret4, "TestAddressBus");
por_cfg = ret1 | ret2 | ret3 | ret4;
} while (por_cfg != 0);
writel(0,P_WATCHDOG_RESET);
return 0;
}
示例9: socket_setup
/// Set up socket for listen on 'DEFAULT_PORT' port.
///
/// No parameter
///
/// Return a socket number which is for listen socket(sListenSocket)
/// Return -1 for socket error, program should be terminate
static SOCKET socket_setup()
{
int iResult; // system information with error message
char host_name[128]; // host name
SOCKET sListenSocket;
struct addrinfo hints;
struct addrinfo *result = NULL;
// Initial socket information
ZeroMemory(&hints, sizeof(hints));
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
hints.ai_flags = AI_PASSIVE;
// Resolve the server address and port
gethostname(host_name, sizeof(host_name));
sprintf_s(g_sLogMessage, SZ_MAX_LOG, "Calling gethostname with %s\r\n", host_name);
write_log();
iResult = getaddrinfo(host_name, DEFAULT_PORT, &hints, &result);
if (iResult != 0) {
WSACleanup();
display_error("main - getaddrinfo", FALSE);
return -1;
}
// Create a SOCKET for connecting to server
sListenSocket = socket(result->ai_family, result->ai_socktype, result->ai_protocol);
if (sListenSocket == INVALID_SOCKET) {
freeaddrinfo(result);
WSACleanup();
display_error("main - socket", FALSE);
return -1;
}
// Setup the TCP listening socket
iResult = bind(sListenSocket, result->ai_addr, (int)result->ai_addrlen);
if (iResult == SOCKET_ERROR) {
freeaddrinfo(result);
closesocket(sListenSocket);
WSACleanup();
display_error("main - bind", FALSE);
return -1;
}
freeaddrinfo(result);
iResult = listen(sListenSocket, SOMAXCONN);
if (iResult == SOCKET_ERROR) {
closesocket(sListenSocket);
WSACleanup();
display_error("main - listen", FALSE);
return -1;
}
return sListenSocket;
}
示例10: disable_other_mta
/*
* Offer to disable other MTA's
*/
void disable_other_mta(const char *mta) {
char buf[SIZ];
FILE *fp;
int lines = 0;
int rv;
snprintf(buf, sizeof buf,
"/bin/ls -l /etc/rc*.d/S*%s 2>/dev/null; "
"/bin/ls -l /etc/rc.d/rc*.d/S*%s 2>/dev/null",
mta, mta
);
fp = popen(buf, "r");
if (fp == NULL) return;
while (fgets(buf, sizeof buf, fp) != NULL) {
++lines;
}
fclose(fp);
if (lines == 0) return; /* Nothing to do. */
/* Offer to replace other MTA with the vastly superior Citadel :) */
snprintf(buf, sizeof buf,
"%s \"%s\" %s%s%s%s%s%s%s",
_("You appear to have the "),
mta,
_(" email program\n"
"running on your system. If you want Citadel mail\n"
"connected with "),
mta,
_(" you will have to manually integrate\n"
"them. It is preferable to disable "),
mta,
_(", and use Citadel's\n"
"SMTP, POP3, and IMAP services.\n\n"
"May we disable "),
mta,
_("so that Citadel has access to ports\n"
"25, 110, and 143?\n")
);
if (yesno(buf, 1) == 0) {
return;
}
snprintf(buf, sizeof buf, "for x in /etc/rc*.d/S*%s; do mv $x `echo $x |sed s/S/K/g`; done >/dev/null 2>&1", mta);
rv = system(buf);
if (rv != 0)
display_error("%s %s.\n", _("failed to disable other mta"), mta);
snprintf(buf, sizeof buf, "/etc/init.d/%s stop >/dev/null 2>&1", mta);
rv = system(buf);
if (rv != 0)
display_error(" %s.\n", _("failed to disable other mta"), mta);
}
示例11: FRAG
int AudioDevice::init_device(void)
{
int buffarg;
int frag = 0;
fragnum &= 0xFFFF;
for(buffarg = 0; fragsize > 1; buffarg++, fragsize >>= 1)
;
frag = FRAG(fragnum, buffarg);
if(-1 == ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &frag))
{
emit display_error(tr("SNDCTL_DSP_SETFRAGMENT: %1").arg(QString(strerror(errno))));
// perror("setting fragments");
return -1;
}
fprintf(stderr,"set frag\n");
if(-1 == ioctl(fd, SNDCTL_DSP_SETFMT, &sample_size))
{
emit display_error(tr("SNDCTL_DSP_SETFMT: %1").arg(QString(strerror(errno))));
// perror("setting sample size");
return -1;
}
fprintf(stderr,"set sample\n");
if(-1 == ioctl(fd, SNDCTL_DSP_CHANNELS, &channels))
{
emit display_error(tr("SNDCTL_DSP_CHANNELS: %1").arg(QString(strerror(errno))));
// perror("setting channels");
return -1;
}
fprintf(stderr, "set channels\n");
if(-1 == ioctl(fd, SNDCTL_DSP_SPEED, &sample_rate))
{
emit display_error(tr("SNDCTRL_DSP_SPEED: %1").arg(QString(strerror(errno))));
// perror("setting sample rate");
return -1;
}
fprintf(stderr, "set rate\n");
audio_buf_info bi;
if(-1 == ioctl(fd, SNDCTL_DSP_GETOSPACE, &bi))
{
emit display_error(tr("SNDCTL_DSP_GETOSPACE: %1").arg(QString(strerror(errno))));
// perror("getospace");
return -1;
}
fprintf(stderr,"bytes %d,fragments %d,fragsize %d, fragstotal %d\n",
bi.bytes, bi.fragments, bi.fragsize, bi.fragstotal);
return 0;
}
示例12: display_error
void display_error(io_state_stream const & ios, pos_info_provider const * p, throwable const & ex) {
flycheck_error err(ios);
if (auto k_ex = dynamic_cast<ext_exception const *>(&ex)) {
display_error(ios, p, *k_ex);
} else if (auto e_ex = dynamic_cast<unifier_exception const *>(&ex)) {
display_error(ios, p, *e_ex);
} else if (p) {
display_error_pos(ios, p->get_file_name(), p->get_some_pos().first, p->get_some_pos().second);
ios << " " << ex.what() << endl;
} else {
ios << "error: " << ex.what() << endl;
}
}
示例13: get_and_send_input_thread
/// Receive command from MBA and send to child through pipe 'lpvThreadParam'.
///
/// \param lpvThreadParam child input pipe
///
/// Return DWORD WINAPI
static DWORD WINAPI get_and_send_input_thread(LPVOID lpvThreadParam)
{
CHAR cInBuf[SZ_MAX_CMD]; // input buffer, write to child
CHAR errorbuf[sizeof(MSG_REC_SUCCESS)];
DWORD nBytesRead,
nBytesWrote;
HANDLE hPipeWrite = (HANDLE)lpvThreadParam;
/// Get input from our console and send it to child through the pipe.
/// Two conditions to break the inifinite loop
/// 1. The child process is terminated, causing broken pipe
/// 2. The main thread detects child process termination and close the DUPLICATED socket,
/// causing the recv failed with return <= 0
while( TRUE ) {
nBytesRead = recv(g_sClientDupSocket, cInBuf, SZ_MAX_CMD, MSG_WAITALL);
if( nBytesRead > 0 ) {
if( !WriteFile(hPipeWrite, cInBuf, strlen(cInBuf), &nBytesWrote, NULL) ) {
if (GetLastError() == ERROR_NO_DATA)
break; // Pipe was closed (normal exit path).
else
display_error("get_and_send_input_thread - WriteFile", TRUE);
}
}
else
break;
}
return 0;
}
示例14: game_loop
/* Boucle principale du jeu */
int game_loop(char board[3][3])
{
int win;
int turn;
int error;
int player;
char input[64];
int insert_nb;
win = -1;
turn = 0;
error = -42;
while (win == -1)
{
player = turn % 2;
system("clear");
display_board(board);
display_error(error);
printf("Player %d enter the case number where to put an %c : ", player + 1, player == 0 ? 'X' : 'O');
scanf("%s", input);
error = check_input(board, input);
if (error == -42)
{
insert_nb = input[0] - '1';
board[insert_nb / 3][insert_nb % 3] = player;
win = check_winner(board, player);
if (win >= 0)
return (player);
else if (turn >= 8)
return (2);
turn++;
}
}
return (0);
}
示例15: read_and_handle_output
/// Monitors handle for input. Exits when child exits or pipe breaks.
///
/// \param hPipeRead child output pipe
///
/// No return value
static void read_and_handle_output(HANDLE hPipeRead)
{
CHAR cOutBuf[4096]; // output buffer, read from child
CHAR cInBuf[sizeof(MSG_REC_SUCCESS)];
DWORD nBytesRead;
// send ready message for agent 'execute' action
send( g_sClientSocket, MSG_EXEC_READY, sizeof(MSG_EXEC_READY), 0 );
while (TRUE) {
ZeroMemory(cOutBuf, sizeof(cOutBuf));
// Get the stdout from child process
if (!ReadFile(hPipeRead, cOutBuf, sizeof(cOutBuf), &nBytesRead, NULL) || !nBytesRead)
{
if (GetLastError() == ERROR_BROKEN_PIPE)
break; // pipe done - normal exit path.
else
display_error("read_and_handle_output - ReadFile", TRUE);
}
send(g_sClientSocket, (const char*)&nBytesRead, sizeof(nBytesRead), 0);
send(g_sClientSocket, cOutBuf, nBytesRead, 0);
}
}