static int cmd_number(globalstate *gstate) { int newval; char tmpbuf[20]; message_prompt("Number of processes to show: "); newval = readline(tmpbuf, 8, Yes); if (newval > -1) { if (newval > gstate->max_topn) { message_error(" This terminal can only display %d processes", gstate->max_topn); } if (newval == 0) { /* inhibit the header */ display_header(No); } else if (gstate->topn == 0) { display_header(Yes); } gstate->topn = newval; } return CMD_REFRESH; }
void option_f(t_data_64 *data) { printf("\n"); file_format(data); display_header(data); printf("\n"); }
void display(char *gifbuffer) { gifhdr_t *gifheader; gifheader = (gifhdr_t *)malloc(HEADER_LENGTH); memcpy(gifheader,gifbuffer,HEADER_LENGTH); display_header(gifheader); fprintf(stderr,"%s\n",(gifbuffer+HEADER_LENGTH)); }
int init_hash_table()//初始化hash表; { char mysql_server_ip[] = "172.16.20.50"; char mysqlDB_name[] = "Telephone"; char mysql_name[] = "root"; char mysql_password[] = "IceFlow2012"; hash_table_init();//初始化哈希表大小和哈希数组; mysql_init(&my_connection);//初始化MYSQL结构; //数据库的连接; if(mysql_real_connect(&my_connection, mysql_server_ip, mysql_name, mysql_password, mysqlDB_name, 0, NULL, 0)) { printf("Database connection success\n"); res = mysql_query(&my_connection, "select * from staffs");//查询数据库信息; if(res) { printf("database select error:%s\n", mysql_error(&my_connection)); return -1; } else { res_ptr = mysql_store_result(&my_connection);//将检索到的数据储存到本地; if(res_ptr) { printf("Retrieved %lu rows\n", (unsigned long)mysql_num_rows(res_ptr));//打印取回多少行; display_header();//建立哈希表功能函数; if(mysql_errno(&my_connection)) { fprintf(stderr, "Retrive error:%s\n", mysql_error(&my_connection)); return -1; } } mysql_free_result(res_ptr);//释放资源; } mysql_close(&my_connection); printf("Database connection closed.\n"); } else { fprintf(stderr, "Connection failed\n"); if(mysql_errno(&my_connection)) { fprintf(stderr,"Connection error %d:%s\n", mysql_errno(&my_connection), //错误消息编号; mysql_error(&my_connection));//返回包含错误消息的、由NULL终结的字符串; return -1; } } return 0; }
int main(int argc, char *argv[]) { int res; int first_row = 1; mysql_init(&my_connection); if (mysql_real_connect(&my_connection, "localhost", "rick", "secret", "foo", 0, NULL, 0)) { printf("Connection success\n"); res = mysql_query(&my_connection, "SELECT childno, fname, age FROM children WHERE age > 5"); if (res) { fprintf(stderr, "SELECT error: %s\n", mysql_error(&my_connection)); } else { res_ptr = mysql_use_result(&my_connection); if (res_ptr) { display_header(); while ((sqlrow = mysql_fetch_row(res_ptr))) { if (first_row) { display_header(); first_row = 0; } display_row(); } if (mysql_errno(&my_connection)) { fprintf(stderr, "Retrive error: %s\n", mysql_error(&my_connection)); } } mysql_free_result(res_ptr); } mysql_close(&my_connection); } else { fprintf(stderr, "Connection failed\n"); if (mysql_errno(&my_connection)) { fprintf(stderr, "Connection error %d: %s\n", mysql_errno(&my_connection), mysql_error(&my_connection)); } } return EXIT_SUCCESS; }
int main(int argc, char *argv[]) { int c; int longindex; while (EOF != (c = getopt_long(argc, argv, "dhs:", longopts, &longindex))) switch (c) { case 'd': debuglevel = LOG_DEBUG; debugthreads = 1; debugtimeprecision = 3; break; case 'h': usage(argv[0]); return EXIT_SUCCESS; case 's': scale = atof(optarg); if (scale <= 0) { throw std::runtime_error("scale must be positive"); } break; default: throw std::runtime_error("unknown option"); } // next argument must be the device name if (argc <= optind) { throw std::runtime_error("no device specified"); } DeviceName devicename(argv[optind++]); // retrieve the guider port astro::module::Repository repository; astro::module::Devices devices(repository); astro::camera::GuidePortPtr guideport = devices.getGuidePort(devicename); // get the program number int prognumber = 0; if (argc > optind) { prognumber = std::stoi(argv[optind++]) - 1; } debug(LOG_DEBUG, DEBUG_LOG, 0, "run program %d on %s", prognumber, devicename.toString().c_str()); // run the different programs if ((prognumber > 4) || (prognumber < 0)) { throw std::runtime_error("unknown program number"); } globaltimer.start(); display_header(); programtable[prognumber](guideport); return EXIT_SUCCESS; }
/* Challenges Menu */ void display_challenges_menu(Menu* challenges) { int win_width, win_height; render_update(challenges->window); SDL_GetWindowSize(challenges->window.win, &win_width, &win_height); display_challenges_background(win_width, win_height, challenges); display_header(win_width, win_height, challenges); display_beginner_button(win_width, win_height, challenges); display_intermediate_button(win_width, win_height, challenges); display_expert_button(win_width, win_height, challenges); display_main_menu_button(win_width, win_height, challenges); }
int isnt_dir(char *av, int *arg_nb) { int fd; int ret; ret = 1; fd = open(av, O_DIRECTORY); if (fd == -1) return (0); if (fd != -1) { display_header(av, arg_nb); close(fd); } return (ret); }
int main(int argc,char *argv[]) { int res; /* Used to ensure we display the row header exactly once when * data is successfully retrieved */ int first_row = 1; mysql_init(&my_connection); if(mysql_real_connect(&my_connection,"localhost","rick","secret","foo",0,NULL,0)){ printf("Connection success\n"); res = mysql_query(&my_connection,"SELECT childno,fname,age FROM children WHERE age > 5"); if(res) printf("SELECT error: %s\n",mysql_error(&my_connection)); else{ res_ptr = mysql_use_result(&my_connection); if(res_ptr){ printf("Retrieved %lu rows\n",(unsigned long)mysql_num_rows(res_ptr)); while((sqlrow = mysql_fetch_row(res_ptr))){ if(first_row){ display_header(); first_row = 0; } display_row(); } if(mysql_errno(&my_connection)){ fprintf(stderr,"Retrive error:%s\n",mysql_error(&my_connection)); } mysql_free_result(res_ptr); } } mysql_close(&my_connection); }else{ fprintf(stderr,"Connection failed\n"); if(mysql_errno(&my_connection)){ fprintf(stderr,"Connection error %d:%s\n",mysql_errno(&my_connection),mysql_error(&my_connection)); } } return EXIT_SUCCESS; }
int main(int argc, const char *argv[]) { int res; int first_row = 1; mysql_init(&my_connection); if (mysql_real_connect(&my_connection, "localhost", "linq", "linq", "rick", 0, NULL, 0)) { printf("Connection success\n"); res = mysql_query(&my_connection, "select childno, fname , age from children where age > 5"); if (res) { printf("select error: %s\n", mysql_error(&my_connection)); } else { res_ptr = mysql_use_result(&my_connection); if (res_ptr) { while ((sqlrow = mysql_fetch_row(res_ptr))) { if (first_row) { display_header(); first_row = 0; } display_row(); } if (mysql_errno(&my_connection)) { fprintf(stderr, "Retrived error: %s\n", mysql_error(&my_connection)); } mysql_free_result(res_ptr); } } mysql_close(&my_connection); } else { fprintf(stderr, "Connection failed\n"); if (mysql_errno(&my_connection)) { fprintf(stderr, "Connection error %d: %s\n", mysql_errno(&my_connection), mysql_error(&my_connection)); } } return 0; }
void stdout_update(int nb_results, int line_by_line) { struct display_data display_data; display_data.duration = logtop_timespan(gl_env.logtop); display_data.qte_of_elements = logtop_qte_of_elements(gl_env.logtop); if (display_data.duration == 0) display_data.duration = 1; if (line_by_line) { avl_traverse(gl_env.logtop, nb_results, display_result, &display_data); printf("\n"); } else { display_header(&display_data); avl_traverse(gl_env.logtop, nb_results, display_line, &display_data); } }
wxString mmReportSummaryStocks::getHTMLText() { mmHTMLBuilder hb; hb.init(); hb.addHeader(2, _("Summary of Stocks")); hb.addDateNow(); hb.addLineBreak(); hb.startTable(); for (const auto& acct : stocks_) { const Model_Account::Data* account = Model_Account::instance().get(acct.id); const Model_Currency::Data* currency = Model_Account::currency(account); hb.startTotalTableRow(); hb.addTableCell(acct.name); hb.addTableCell(""); hb.addTableCell(""); hb.addTableCell(""); hb.addTableCell(""); hb.addTableCell(""); hb.addTableCell(""); hb.addTableCell(""); hb.addTableCell(""); hb.endTableRow(); display_header(hb); hb.startTbody(); for (const auto& entry : acct.data) { hb.startTableRow(); hb.addTableCell(entry.name); hb.addTableCell(entry.symbol); hb.addTableCell(entry.date); hb.addTableCell(Model_Account::toString(entry.qty, account, 4), true); hb.addCurrencyCell(entry.purchase, currency, 4); hb.addCurrencyCell(entry.current, currency, 4); hb.addCurrencyCell(entry.commission, currency, 4); hb.addCurrencyCell(entry.gainloss, currency); hb.addCurrencyCell(entry.value, currency); hb.endTableRow(); } hb.endTbody(); hb.startTotalTableRow(); hb.addTableCell(_("Total:")); hb.addTableCell(""); hb.addTableCell(""); hb.addTableCell(""); hb.addTableCell(""); hb.addTableCell(""); hb.addTableCell(""); hb.addCurrencyCell(acct.gainloss); hb.addCurrencyCell(acct.total); hb.endTableRow(); hb.startTbody(); hb.startTableRow(); hb.addTableCell(" "); hb.endTableRow(); hb.endTbody(); } hb.startTfoot(); hb.startTotalTableRow(); hb.addTableCell(_("Grand Total:")); hb.addTableCell(""); hb.addTableCell(""); hb.addTableCell(""); hb.addTableCell(""); hb.addTableCell(""); hb.addTableCell(""); hb.addCurrencyCell(gain_loss_sum_total_); hb.addCurrencyCell(stockBalance_); hb.endTableRow(); hb.endTfoot(); hb.endTable(); //hb.endCenter(); hb.end(); return hb.getHTMLText(); }
wxString mmReportSummaryStocks::getHTMLText() { RefreshData(); mmHTMLBuilder hb; hb.init(); hb.addDivContainer(); hb.addHeader(2, m_title); hb.addDateNow(); hb.addLineBreak(); hb.addDivRow(); hb.addDivCol17_67(); for (const auto& acct : m_stocks) { const Model_Account::Data* account = Model_Account::instance().get(acct.id); const Model_Currency::Data* currency = Model_Account::currency(account); hb.addHeader(3, acct.name); hb.startTable(); display_header(hb); hb.startTbody(); for (const auto& entry : acct.data) { hb.startTableRow(); hb.addTableCell(entry.name); hb.addTableCell(entry.symbol); hb.addTableCellDate(entry.date); hb.addTableCell(Model_Account::toString(entry.qty, account, floor(entry.qty) ? 0 : 4), true); hb.addCurrencyCell(entry.purchase, currency, 4); hb.addCurrencyCell(entry.current, currency, 4); hb.addCurrencyCell(entry.commission, currency, 4); hb.addCurrencyCell(entry.gainloss, currency); hb.addCurrencyCell(entry.value, currency); hb.endTableRow(); } hb.endTbody(); hb.startTfoot(); hb.startTotalTableRow(); hb.addTableCell(_("Total:")); hb.addEmptyTableCell(6); hb.addCurrencyCell(acct.gainloss, currency); hb.addCurrencyCell(acct.total, currency); hb.endTableRow(); hb.endTfoot(); hb.endTable(); } hb.addDivCol17_67(); hb.addHeader(3, _("Grand Total:")); hb.startTable(); hb.startThead(); hb.startTableRow(); hb.addTableHeaderCell(_("Gain/Loss"), true); hb.addTableHeaderCell(_("Current Value"), true); hb.endTableRow(); hb.endThead(); hb.startTfoot(); hb.startTotalTableRow(); hb.addCurrencyCell(m_gain_loss_sum_total); hb.addCurrencyCell(m_stock_balance); hb.endTableRow(); hb.endTfoot(); hb.endTable(); hb.endDiv(); hb.endDiv(); hb.endDiv(); hb.endDiv(); hb.end(); Model_Report::outputReportFile(hb.getHTMLText()); return ""; }