本文整理汇总了C++中display_error函数的典型用法代码示例。如果您正苦于以下问题:C++ display_error函数的具体用法?C++ display_error怎么用?C++ display_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了display_error函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
}
开发者ID:thewon86,项目名称:qt4-camera,代码行数:27,代码来源:processImage.cpp
示例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);
}
开发者ID:patcon,项目名称:eVACS,代码行数:33,代码来源:get_rotation.c
示例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!");
}
}
开发者ID:frostblooded,项目名称:ReadingCalculator,代码行数:29,代码来源:mainwindow.cpp
示例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;
}
开发者ID:whenjonny,项目名称:Recording,代码行数:28,代码来源:processImage.cpp
示例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;
}
开发者ID:0w,项目名称:moai-dev,代码行数:29,代码来源:nss.c
示例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);
}
开发者ID:dennisieur,项目名称:MBA,代码行数:40,代码来源:win_agent.c
示例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;
}
开发者ID:whenjonny,项目名称:Recording,代码行数:31,代码来源:videodevice.cpp
示例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;
}
开发者ID:Doxlon,项目名称:buildroot-uboot,代码行数:60,代码来源:lowlevel_init.c
示例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;
}
开发者ID:dennisieur,项目名称:MBA,代码行数:64,代码来源:win_agent.c
示例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);
}
开发者ID:zcw159357,项目名称:citadel,代码行数:58,代码来源:setup.c
示例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;
}
开发者ID:401968875,项目名称:armphone,代码行数:52,代码来源:audiodevice.cpp
示例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;
}
}
开发者ID:skbaek,项目名称:lean,代码行数:13,代码来源:error_handling.cpp
示例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;
}
开发者ID:dennisieur,项目名称:MBA,代码行数:37,代码来源:win_agent.c
示例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);
}
开发者ID:kinmax,项目名称:tictactoe,代码行数:36,代码来源:main.c
示例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);
}
}
开发者ID:dennisieur,项目名称:MBA,代码行数:32,代码来源:win_agent.c
示例16: check_xinetd_entry
/*
* On systems which use xinetd, see if we can offer to install Citadel as
* the default telnet target.
*/
void check_xinetd_entry(void)
{
char *filename = "/etc/xinetd.d/telnet";
FILE *fp;
char buf[SIZ];
int already_citadel = 0;
int rv;
fp = fopen(filename, "r+");
if (fp == NULL) return; /* Not there. Oh well... */
while (fgets(buf, sizeof buf, fp) != NULL) {
if (strstr(buf, "/citadel") != NULL) {
already_citadel = 1;
}
}
fclose(fp);
if (already_citadel) return; /* Already set up this way. */
/* Otherwise, prompt the user to create an entry. */
if (getenv("CREATE_XINETD_ENTRY") != NULL) {
if (strcasecmp(getenv("CREATE_XINETD_ENTRY"), "yes")) {
return;
}
}
else {
snprintf(buf, sizeof buf,
_("Setup can configure the \"xinetd\" service to automatically\n"
"connect incoming telnet sessions to Citadel, bypassing the\n"
"host system login: prompt. Would you like to do this?\n"
)
);
if (yesno(buf, 1) == 0) {
return;
}
}
fp = fopen(filename, "w");
fprintf(fp,
"# description: telnet service for Citadel users\n"
"service telnet\n"
"{\n"
" disable = no\n"
" flags = REUSE\n"
" socket_type = stream\n"
" wait = no\n"
" user = root\n"
" server = /usr/sbin/in.telnetd\n"
" server_args = -h -L %s/citadel\n"
" log_on_failure += USERID\n"
"}\n",
ctdl_bin_dir);
fclose(fp);
/* Now try to restart the service */
rv = system("/etc/init.d/xinetd restart >/dev/null 2>&1");
if (rv != 0) {
display_error(_("failed to restart xinetd.\n"));
}
}
开发者ID:zcw159357,项目名称:citadel,代码行数:64,代码来源:setup.c
示例17: main
int main(int ac, char **av)
{
t_args option;
if (ac < 5)
return (usage(av[0]));
signal(SIGINT, &signal_handler);
signal(SIGPIPE, SIG_IGN);
srand(time(NULL) + getpid());
init_args(&option);
if (check_args(ac, av, &option) == false
|| check_all_args(&option) == false)
return (usage(av[0]));
display_init(&option);
g_s.global_time = 0;
g_s.id_egg = 1;
g_s.other_size = 0;
if ((g_s.sock = init_server(option.port)) == -1)
return (display_error("Error : Could not init the server.\n"));
printf("**** Initialization done\n");
init_map(&g_s, option.width, option.height);
init_team(&g_s, option.nb_client, option.team_name);
init_stone(&g_s, option.width * option.height);
g_s.option = &option;
server_loop(&g_s);
xclose(g_s.sock);
return (0);
}
开发者ID:jonquach,项目名称:zappy,代码行数:28,代码来源:main.c
示例18: get_initial_cursor
int get_initial_cursor(const struct electorate *elec)
{
struct http_vars *reply;
int initial_cursor;
/* SIPL 2011-09-26 Added one to length of array. There was
no chance of a buffer overflow, but do this to make it consistent
with all other uses of INT_CHARS. */
char ecodestr[INT_CHARS+1];
struct http_vars request[]
= { { (char*)"ecode", ecodestr }, { NULL, NULL } };
sprintf(ecodestr, "%u", elec->code);
reply = http_exchange(SERVER_ADDRESS, SERVER_PORT, CURSOR_CGI,request);
if (!reply)
display_error(ERR_SERVER_UNREACHABLE);
initial_cursor = atoi(http_string(reply, "cursor"));
http_free(reply);
cursor = initial_cursor;
return initial_cursor;
}
开发者ID:darg0001,项目名称:evoting-systems,代码行数:25,代码来源:get_cursor.c
示例19: extract_json
client_t * extract_json(char *text) {
json_t *root, *rtinfo, *node;
json_error_t error;
unsigned int i;
client_t *clients;
if(!(root = json_loads(text, 0, &error))) {
display_error("json errors\n");
return NULL;
}
json_check_object(root);
rtinfo = json_object_get(root, "rtinfo");
json_check_array(rtinfo);
clients = client_create(json_array_size(rtinfo));
for(i = 0; i < json_array_size(rtinfo); i++) {
node = json_array_get(rtinfo, i);
json_check_object(node);
extract_json_head(node, &clients->clients[i]);
extract_json_summary(node, &clients->clients[i]);
extract_json_network(node, &clients->clients[i]);
extract_json_disk(node, &clients->clients[i]);
}
json_decref(root);
return clients;
}
开发者ID:maxux,项目名称:rtinfo,代码行数:33,代码来源:rtinfo_extract_json.c
示例20: return
/* needed to shut the compilor up */
return(0);
}
//admin only command: lists registered bot users
static int msg_listusers(const char *replyto, struct userlist *user, const char * UNUSED(data))
{
info_log("Requested listusers by %s\n", user->userinfo->nick);
int i=0;
struct userdata *userdata_curr;
userdata_curr=conf_userdata;
while(userdata_curr != NULL){
msgreply(user, replyto, " %s",userdata_curr->usernick);
userdata_curr=userdata_curr->next;
i++;
}
msgreply(user, replyto, "--- %i users total ---",i);
return(0);
}
static int msg_version(const char *replyto, struct userlist *user, const char * UNUSED(data))
{
msgreply(user, replyto, "Version: %s", botinfo->ver);
return(0);
}
static int msg_time(const char *replyto, struct userlist *user, const char * UNUSED(data))
{
char timestr[50];
time(&currtime);
strftime(timestr, sizeof(timestr), "%a %b %d %H:%M:%Y",
localtime(&currtime));
msgreply(user, replyto, "The current time is: %s", timestr);
return(0);
}
static int msg_reload(const char *replyto, struct userlist *user, const char * UNUSED(data))
{
info_log("Reload by %s\n", user->userinfo->nick);
acid_reload("reloading\n");
//msgreply(user, replyto, "Reload complete.");
msgreply(user, replyto, "Professore ho ricaricato Utenti e Log sulla navetta siamo pronti a consegnarli.");
return(0);
}
#if 0 /* too ugly to live */
static int msg_help(const char *replyto, struct userlist *user, const char *data)
{
char *line;
FILE *fp_help;
/* This is not ideal.. spending this much time inside a routine will
make it hard for the bot to handle outside events in a timely manor */
if ((line = malloc(100)) == NULL) {
display_error("execute: Malloc error!\n");
return (-1);
}
if ((fp_help = fopen("../docs/help", "r")) == NULL) {
info_log("Cant open help file! \n");
free(line);
msgreply(user, replyto, "Cant open help file! ");
return(0);
}
while (fgets(line, 100, fp_help) != NULL) {
if (msgreply(user, replyto, "%s", line) == -1) {
free(line);
return (-1);
}
/* give the server time to accept the input */
sleep(1);
}
free(line);
return (0);
}
开发者ID:ranauei,项目名称:melabot,代码行数:80,代码来源:usrcommands.c
注:本文中的display_error函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论