static void autobuild_callback(mtk_event *e, void *arg) { char key[8]; char filename[384]; char *c; int i, index; mtk_req(appid, key, sizeof(key), "e_key.text"); mtk_req(appid, filename, sizeof(filename), "e_filename.text"); index = strtol(key, &c, 0); if((*c != 0x00) || (index < 0) || (index > 63)) { messagebox("Auto build failed", "Invalid key code.\nUse a decimal or hexadecimal (0x...) number between 0 and 63."); return; } if(filename[0] == 0x00) strcpy(filename, SIMPLE_PATCHES_FOLDER); i = strlen(filename); if(filename[i-1] == '/') filename[i-1] = 0x00; autobuild(index, filename); update_list(); }
static INT_PTR CALLBACK dialog_proc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) { switch( uMsg ) { case WM_INITDIALOG: dialog_init( hwndDlg ); update_list( hwndDlg, ( GSList * ) lParam ); return FALSE; case WM_COMMAND: switch( LOWORD( wParam ) ) { case IDOK: EndDialog( hwndDlg, SendDlgItemMessage( hwndDlg, IDC_ROLLBACK_LV, LVM_GETSELECTIONMARK, 0, 0 ) ); return 0; case IDCANCEL: EndDialog( hwndDlg, -1 ); return 0; } break; case WM_CLOSE: EndDialog( hwndDlg, -1 ); return 0; } return FALSE; }
void *monitor_list(void *path) { char* listpath = (char*) path; signal(SIGQUIT, quit_pthread); int inotifyFd = -1; char str[512]; while(1) { if (inotifyFd == -1 || read(inotifyFd, str, sizeof(str)) == -1) { close(inotifyFd); inotifyFd = inotify_init(); if (inotifyFd == -1) { fprintf(logfile, "MagiskHide: Unable to watch %s\n", listpath); exit(1); } if (inotify_add_watch(inotifyFd, listpath, IN_MODIFY) == -1) { fprintf(logfile, "MagiskHide: Unable to watch %s\n", listpath); exit(1); } } update_list(listpath); } return NULL; }
void ChannelEditWindow::delete_channel(int number) { delete thread->new_channels->get(number); channel_list.remove_number(number); thread->new_channels->remove_number(number); update_list(); }
void accept_file_dialog(GtkWidget *widget, gpointer data) { add_file(gtk_file_selection_get_filename(GTK_FILE_SELECTION(filew))); update_list(); gtk_widget_destroy(filew); }
/* * Updates all the neighborlists during subsequent iterations * * arguments: * particles: The spatially decomposed particle information * neighbors: The array of all neighbor lists * moved_lists:The list of particles that have moved between iterations * counts: The number of particles in each moved list * my_rank: The rank of the node */ void update_neighbor_lists(Particle* particles[XDiv][YDiv][ZDiv], Neighbor** neighbors, Particle** moved_list[XDiv][YDiv][ZDiv], int counts[XDiv][YDiv][ZDiv], int my_rank){ //Iterate through all the particles in all the blocks //If a particles has moved, then do a full rebuild of its neighbor list //Otherwise, look at the particles that have moved, and update the list int x, y, z, i; int rank = my_rank - 1; int tag = 0; Particle p; for (x = node_boundries[rank][0]; x <= node_boundries[rank][1]; ++x) { for (y = node_boundries[rank][2]; y <= node_boundries[rank][3]; ++y) { for (z = node_boundries[rank][4]; z <= node_boundries[rank][5]; ++z) { #pragma omp for private(p) for (i = 0; i < block_size; ++i){ p = particles[x][y][z][i]; if (p.index != -1) { if (p.moved){ clear_list(neighbors[tag+i]); build_list_full(particles, neighbors[tag+i], x, y, z, i); } else { remove_moved_particles(neighbors[tag+i]); update_list(particles, neighbors[tag+i], x, y, z, i, moved_list, counts); } } } tag = tag + block_size; } } } }
int main(int argc,char **argv) { int i; for(i=0;i<24;i++) hourly[i]=0; for(i=0;i<7;i++) weekly[i]=0; for(i=0;i<256;i++) nsrc[i]=i; time_cons[0]=0; time_cons[1]=0; useridx=ispidx=0; gtk_init(&argc,&argv); gdk_rgb_init(); load_log(); create_loglist(); update_list(); make_resume(); gtk_main(); g_list_free(users); g_list_free(isps); for(i=0;i<3;i++) gdk_pixmap_unref(iconmap[i]); free_log(); return 0; }
void ChannelEditWindow::scan() { thread->new_channels->clear(); update_list(); if(!thread->scan_thread) thread->scan_thread = new ScanThread(thread); thread->scan_thread->start(); }
int main(void) { entry* entries = main_create_entries(); list* menu = create_list(0,24,25,entries,MAINMENU_SIZE); nio_scrbuf_init(); do { int selection = update_list(menu); if(selection != -1) { wait_no_key_pressed(); switch(selection) { case 0: display_tasks_screen(); break; case 1: display_pools_screen(); break; case 2: display_events_screen(); break; case 3: display_queues_screen(); break; case 4: display_semaphores_screen(); break; case 5: display_mailboxes_screen(); break; default: display_settings_screen(); break; } } nio_scrbuf_clear(); nio_grid_printf(0,0,0,0,NIO_COLOR_WHITE,NIO_COLOR_BLACK,"TI-Nspire Task Manager (built %s %s)",__DATE__,__TIME__); int i; for(i = 0; i < 53; i++) { nio_grid_putc(0,0,i,2,'-',NIO_COLOR_WHITE,NIO_COLOR_BLACK); nio_grid_putc(0,0,i,28,'-',NIO_COLOR_WHITE,NIO_COLOR_BLACK); } draw_list(menu); nio_grid_puts(0,0,0,29,"Use UP/DOWN keys to navigate, ENTER to select",NIO_COLOR_WHITE,NIO_COLOR_BLACK); nio_scrbuf_flip(); wait_key_pressed(); } while(!isKeyPressed(KEY_NSPIRE_ESC)); nio_scrbuf_free(); free(entries); free(menu); return 0; }
void CMFCAppDlg::OnTimer(UINT_PTR nIDEvent) { // TODO: 在此添加消息处理程序代码和/或调用默认值 MYSQL_RES *res; //查询结果集 // MYSQL_ROW column; //数据行的列 switch (nIDEvent) { case 1: if (serverinfo.runstate) { for (int i = 0; i<sumgarage; i++) garage[i].accspendtime(); for (int i = 0; i < sumioClient; i++) ioClient_list[i].spendtime++; //update_list(); } break; case 2: if (serverinfo.runstate) { m_Osc.AppendPoint(serverinfo.activeThreadtime/10.0); //printf("[%ld]", serverinfo.activeThread); serverinfo.activeThreadtime = 0; } break; case 3: mysql_query(&serverinfo.mysql, "SET NAMES 'GB2312'"); if (mysql_query(&serverinfo.mysql, "delete from t_reservation where now()>endtime") != NULL) { AfxMessageBox(_T("time:32数据库连接失败")); exit(1); } //else AfxMessageBox(_T("delete successful")); if (mysql_query(&serverinfo.mysql, "select plate from t_reservation") == NULL) { res = mysql_store_result(&serverinfo.mysql);//保存查询到的数据到result serverinfo.reservation = (int)mysql_num_rows(res); //printf("[reservation=%d]", serverinfo.reservation); } else { AfxMessageBox(_T("time:31数据库连接失败")); exit(1); } break; case 4: update_list(); break; default: break; } CDialogEx::OnTimer(nIDEvent); }
void open_ir_window(void) { if(w_open) return; w_open = 1; load_config(); update_list(); mtk_cmd(appid, "w.open()"); input_add_callback(ir_event); }
void dlgAirspaceWarningsShowModal(SingleWindow &parent, bool auto_close) { if (dlgAirspaceWarningVisible()) return; assert(airspace_warnings != NULL); wf = LoadDialog(CallBackTable, parent, _T("IDR_XML_AIRSPACEWARNINGS")); assert(wf != NULL); wbAck1 = (WndButton *)wf->FindByName(_T("frmAck1")); wbAck2 = (WndButton *)wf->FindByName(_T("frmAck2")); wbAck = (WndButton *)wf->FindByName(_T("frmAck")); wbEnable = (WndButton *)wf->FindByName(_T("frmEnable")); assert(wbAck1 != NULL); assert(wbAck2 != NULL); assert(wbAck != NULL); assert(wbEnable != NULL); wf->SetKeyDownNotify(OnKeyDown); hBrushInsideBk.set(Color(254,50,50)); hBrushNearBk.set(Color(254,254,50)); hBrushInsideAckBk.set(Color(254,100,100)); hBrushNearAckBk.set(Color(254,254,100)); wAirspaceList = (WndListFrame*)wf->FindByName(_T("frmAirspaceWarningList")); assert(wAirspaceList != NULL); wAirspaceList->SetPaintItemCallback(OnAirspaceListItemPaint); wAirspaceList->SetCursorCallback(AirspaceWarningCursorCallback); wAirspaceList->SetActivateCallback(OnAirspaceListEnter); AutoClose = auto_close; update_list(); // JMW need to deselect everything on new reopening of dialog CursorAirspace = NULL; FocusAirspace = NULL; wf->SetTimerNotify(OnTimer); wAirspaceList->SetCursorIndex(0); wf->ShowModal(); wf->SetTimerNotify(NULL); delete wf; // Needed for dlgAirspaceWarningVisible() wf = NULL; hBrushInsideBk.reset(); hBrushNearBk.reset(); hBrushInsideAckBk.reset(); hBrushNearAckBk.reset(); }
error context::get_device_list(std::vector<std::shared_ptr<device>>& list) { std::unique_lock<std::recursive_mutex> lock(m_mutex); error err = update_list(); if(err != error::SUCCESS) return err; list.resize(m_devlist.size()); for(size_t i = 0; i < m_devlist.size(); i++) list[i] = m_devlist[i]; return error::SUCCESS; }
void CVRP::constructGreedyRandomizedSolution(){ int n = 0; double waitTime = 0.0; int nVehi = deduce_nVehicles(0); vector<Route*> solution(nVehi, new Route); vector<int> route_capacity(nVehi, 0); vector<double> routes_times(nVehi, 0.0); vector<vector<Costumer*> > sol_candidates(solution.size(), vector<Costumer*> ()); dep.nVehicles = nVehi; for(int i = 0; i < solution.size(); i++){ solution[i] = new Route; } //Initialize the solution with nearby close clients init_solution(solution, routes_times, route_capacity, n); while(n != clients.size()){ //Update the list of candidates sol_candidates = update_list(solution, routes_times, n); for(int c = 0; c < sol_candidates.size(); c++){ sort(sol_candidates[c].begin(), sol_candidates[c].end(), saving_heuristic); } //shrink_routes(solution); select_candidate(solution, sol_candidates, routes_times, route_capacity, n); } double sum = 0.0; cout << "Solution size: " << solution.size() << endl; for(Route *r : solution){ for(Costumer *c : r->clients){ sum += c->cost; cout << c->id << " "; } cout << endl; } cout << sum << endl; cout << endl; /*for(int i = 0; i < solution.size(); i++){ solution[i]->clients.push_front(new Costumer(0, dep.coord,0,0,0,0)); solution[i]->clients.push_back(new Costumer(0, dep.coord,0,0,0,0)); }*/ sol = solution; for(Route *r : solution){ for(int i = 0; i < r->clients.size()-1; i++){ cout << r->clients[i]->id << ":" << r->clients[i]->arrTime + r->clients[i]->servTime << " " << r->clients[i+1]->id << ":" << r->clients[i+1]->dTime << endl; } cout << endl; } save(); }
void ChannelEditWindow::update_list(Channel *channel) { int i; for(i = 0; i < thread->new_channels->size(); i++) if(thread->new_channels->get(i) == channel) break; if(i < thread->new_channels->size()) { channel_list.values[i]->set_text(channel->title); } update_list(); }
static void library_switch_cb (GtkWidget *combo_box, Browser *br) { GtkTreePath *path; GList *libs = oregano.libraries; br->library = (Library *) g_list_nth_data (libs, gtk_combo_box_get_active (GTK_COMBO_BOX (combo_box))); update_list (br); path = gtk_tree_path_new_first (); gtk_tree_view_set_cursor (GTK_TREE_VIEW (br->list), path, NULL, FALSE); gtk_tree_path_free (path); }
void dlgAirspaceWarningShowDlg() { assert(wf != NULL); assert(wAirspaceList != NULL); update_list(); if (wf->is_visible()) { return; } else { // JMW need to deselect everything on new reopening of dialog CursorAirspace = NULL; FocusAirspace = NULL; wf->ShowModal(); } }
void start_text_dump(void) { struct timeval now; struct tm *tm; signal(SIGINT, signal_func); signal(SIGTERM, signal_func); while (!done) { gettimeofday(&now, NULL); printf("=============== %s", asctime(localtime(&now.tv_sec))); update_list(); print_global_list(); print_procs(); if (done) break; sleep(10); } }
static void addupdate_callback(mtk_event *e, void *arg) { char key[8]; int index; char *c; char filename[384]; mtk_req(appid, key, sizeof(key), "e_key.text"); mtk_req(appid, filename, sizeof(filename), "e_filename.text"); index = strtol(key, &c, 0); if((*c != 0x00) || (index < 0) || (index > 63)) { messagebox("Error", "Invalid key code.\nUse a decimal or hexadecimal (0x...) number between 0 and 63."); return; } strcpy(key_bindings[index], filename); update_list(); mtk_cmd(appid, "e_key.set(-text \"\")"); mtk_cmd(appid, "e_filename.set(-text \"\")"); }
int extract_areas(void) { double nullVal; row = col = top = 0; /* get started for read of first */ bottom = 1; /* line from raster map */ area_num = 0; tl_area = 0; G_set_d_null_value(&nullVal, 1); /* represents the "outside", the external null values */ assign_area(nullVal, 0); G_message(_("Extracting areas...")); scan_length = read_next(); while (read_next()) { /* read rest of file, one row at *//* a time */ G_percent(row, n_rows, 2); for (col = 0; col < scan_length - 1; col++) { tl = get_raster_value(buffer[top], col); /* top left in window */ tr = get_raster_value(buffer[top], col + 1); /* top right */ bl = get_raster_value(buffer[bottom], col); /* bottom left */ br = get_raster_value(buffer[bottom], col + 1); /* bottom right */ update_list(nabors()); } if (h_ptr != NULPTR) /* if we have a loose end, */ end_hline(); /* tie it down */ row++; } G_percent(row, n_rows, 2); write_area(a_list, e_list, area_num, n_equiv); G_free(a_list); G_free(e_list); return 0; } /* extract_areas */
void ChannelEditWindow::sort() { int done = 0; while(!done) { done = 1; for(int i = 0; i < thread->new_channels->size() - 1; i++) { Channel *channel1 = thread->new_channels->get(i); Channel *channel2 = thread->new_channels->get(i + 1); int ch1, st1; get_chan_num(channel1, ch1, st1); int ch2, st2; get_chan_num(channel2, ch2, st2); if( (ch1 > 0 && ch2 > 0) ? (ch1 > ch2 || (ch1 == ch2 && (st1 > st2 || (st1 == st2 && strcasecmp(channel2->title, channel1->title) < 0)))) : strcasecmp(channel2->title, channel1->title) < 0) { thread->new_channels->set(i, channel2); thread->new_channels->set(i + 1, channel1); done = 0; } } } update_list(); }
static int add_known_elems(const char *buf, int index) { int list_name_len; char list_name[MAXATOMLEN]; struct exmpp_hashtable *kl; /* Get the list name from the given Erlang term. */ if (get_known_list_name(buf, &index, list_name, &list_name_len) != 0) return (RET_ERROR); /* We can lookup the list (it will be created if it doesn't * already exist. */ kl = lookup_known_elems(list_name, list_name_len); if (kl == NULL) return (RET_ERROR); /* Update the list. */ if (update_list(kl, buf, &index) != 0) return (RET_ERROR); return (RET_OK); }
int ChannelEditWindow::add_channel() { Channel *new_channel; Channel *prev_channel = 0; // Create new channel new_channel = new Channel; // Reuse parameters from previous channel if(thread->new_channels->size()) { prev_channel = thread->new_channels->get( thread->new_channels->size() - 1); new_channel->copy_settings(prev_channel); } else // Use default channel parameters if(channel_picker->get_master_channel()) { new_channel->copy_settings(channel_picker->get_master_channel()); } // Copy device usage. Need the same thing for playback. if(channel_picker->get_master_channel()) { new_channel->copy_usage(channel_picker->get_master_channel()); } // Add to channel table channel_list.append(new BC_ListBoxItem(new_channel->title)); thread->new_channels->append(new_channel); update_list(); // Start common routing edit_thread->edit_channel(new_channel, 0); return 0; }
void fireworks::update() { update_list(from_player); update_list(from_enemies); }
//------------------------------------------------------------------------------ // Name: on_filter_textChanged(const QString &text) // Desc: //------------------------------------------------------------------------------ void DialogAttach::on_filter_textChanged(const QString &text) { update_list(text); }
void CoreCloseBipartitePairContainer::do_before_evaluate() { IMP_OBJECT_LOG; if (covers_[0]==base::get_invalid_index<ParticleIndexTag>() || algebra::get_distance(get_model()->get_sphere(covers_[0]), get_model()->get_sphere(covers_[1])) < distance_ || reset_) { if (!reset_ && were_close_ && !internal::get_if_moved(get_model(), slack_, xyzrs_[0], rbs_[0], constituents_, rbs_backup_[0], xyzrs_backup_[0]) && !internal::get_if_moved(get_model(), slack_, xyzrs_[1], rbs_[1], constituents_, rbs_backup_[1], xyzrs_backup_[1])){ // all ok } else { // rebuild IMP_LOG(TERSE, "Recomputing bipartite close pairs list." << std::endl); internal::reset_moved(get_model(), xyzrs_[0], rbs_[0], constituents_, rbs_backup_[0], xyzrs_backup_[0]); internal::reset_moved(get_model(), xyzrs_[1], rbs_[1], constituents_, rbs_backup_[1], xyzrs_backup_[1]); ParticleIndexPairs pips; internal::fill_list(get_model(), access_pair_filters(), key_, 2*slack_+distance_, xyzrs_, rbs_, constituents_, pips); reset_=false; update_list(pips); } were_close_=true; } else { ParticleIndexPairs none; update_list(none); } IMP_IF_CHECK(base::USAGE_AND_INTERNAL) { for (unsigned int i=0; i< sc_[0]->get_number_of_particles(); ++i) { XYZR d0(sc_[0]->get_particle(i)); for (unsigned int j=0; j< sc_[1]->get_number_of_particles(); ++j) { XYZR d1(sc_[1]->get_particle(j)); double dist = get_distance(d0, d1); if (dist < .9*distance_) { ParticleIndexPair pip(d0.get_particle_index(), d1.get_particle_index()); bool filtered=false; for (unsigned int i=0; i< get_number_of_pair_filters(); ++i) { if (get_pair_filter(i)->get_value_index(get_model(), pip)) { filtered=true; break; } } IMP_INTERNAL_CHECK(filtered|| std::find(get_access().begin(), get_access().end(), pip) != get_access().end(), "Pair " << pip << " not found in list with coordinates " << d0 << " and " << d1 << " list is " << get_access()); } } } } }
// part_browser_create // // Creates a new part browser. This is only called once per schematic window. GtkWidget * part_browser_create (SchematicView *schematic_view) { Browser *br; GtkBuilder *gui; GError *perror = NULL; char *msg; GtkWidget *w, *view; GtkCellRenderer *cell_text; GtkTreeViewColumn *cell_column; static GtkTargetEntry dnd_types[] = { { "x-application/oregano-part", 0, DRAG_PART_INFO } }; static int dnd_num_types = sizeof (dnd_types) / sizeof (dnd_types[0]); GtkTreePath *path; if ((gui = gtk_builder_new ()) == NULL) { oregano_error (_("Could not create part browser")); return NULL; } else gtk_builder_set_translation_domain (gui, NULL); br = g_new0 (Browser, 1); br->preview = NULL; br->schematic_view = schematic_view; br->hidden = FALSE; schematic_view_set_browser (schematic_view, br); if (gtk_builder_add_from_file (gui, OREGANO_UIDIR "/part-browser.ui", &perror) <= 0) { msg = perror->message; oregano_error_with_title (_("Could not create part browser"), msg); g_error_free (perror); return NULL; } view = GTK_WIDGET (gtk_builder_get_object (gui, "viewport1")); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (view), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (view), 115); w = goo_canvas_new (); gtk_container_add (GTK_CONTAINER (view), GTK_WIDGET (w)); br->canvas = w; g_signal_connect (w, "realize", (GCallback) preview_realized, br); //gtk_widget_set_size_request (w, PREVIEW_WIDTH, // PREVIEW_HEIGHT + PREVIEW_TEXT_HEIGHT); goo_canvas_set_bounds (GOO_CANVAS (w), 0, 0, PREVIEW_WIDTH, (PREVIEW_HEIGHT + PREVIEW_TEXT_HEIGHT)); br->description = GOO_CANVAS_TEXT (goo_canvas_text_new ( goo_canvas_get_root_item (GOO_CANVAS (br->canvas)), "", 0.0, PREVIEW_HEIGHT - 9.0, 100.0, GOO_CANVAS_ANCHOR_NORTH_WEST, "font", "sans 9", NULL)); // Set up dnd. g_signal_connect (G_OBJECT (br->canvas), "drag_data_get", G_CALLBACK (drag_data_get), br); gtk_drag_source_set (br->canvas, GDK_BUTTON1_MASK | GDK_BUTTON3_MASK, dnd_types, dnd_num_types, GDK_ACTION_MOVE); br->filter_entry = GTK_ENTRY (gtk_builder_get_object (gui, "part_search")); g_signal_connect (G_OBJECT (br->filter_entry), "changed", G_CALLBACK (part_search_change), br); g_signal_connect (G_OBJECT (br->filter_entry), "activate", G_CALLBACK (part_search_activate), br); // Buttons. w = GTK_WIDGET (gtk_builder_get_object (gui, "place_button")); g_signal_connect (G_OBJECT (w), "clicked", G_CALLBACK (place_cmd), br); // Update the libraries option menu br->library = g_list_nth_data (oregano.libraries, 0); part_browser_setup_libs (br, gui); // Parts list. w = GTK_WIDGET (gtk_builder_get_object (gui, "parts_list")); br->list = w; // Create the List Model for TreeView, this is a Real model br->real_model = GTK_TREE_MODEL (gtk_list_store_new (1, G_TYPE_STRING)); cell_text = gtk_cell_renderer_text_new (); cell_column = gtk_tree_view_column_new_with_attributes ( "", cell_text, "text", 0, NULL); // Create the sort model for the items, this sort the real model br->sort_model = gtk_tree_model_sort_new_with_model ( GTK_TREE_MODEL (br->real_model)); gtk_tree_sortable_set_sort_column_id ( GTK_TREE_SORTABLE (br->sort_model), 0, GTK_SORT_ASCENDING); // Create the filter sorted model. This filter items based on user // request for fast item search br->filter_model = gtk_tree_model_filter_new (br->sort_model, NULL); gtk_tree_model_filter_set_visible_func ( GTK_TREE_MODEL_FILTER (br->filter_model), part_list_filter_func, br, NULL); // If we have TreeFilter use it, if not, just use sorting model only if (br->filter_model) gtk_tree_view_set_model (GTK_TREE_VIEW (w), br->filter_model); else gtk_tree_view_set_model (GTK_TREE_VIEW (w), br->sort_model); gtk_tree_view_append_column (GTK_TREE_VIEW (w), cell_column); update_list (br); // Set up TreeView dnd. g_signal_connect (G_OBJECT (w), "drag_data_get", G_CALLBACK (drag_data_get), br); gtk_drag_source_set (w, GDK_BUTTON1_MASK | GDK_BUTTON3_MASK, dnd_types, dnd_num_types, GDK_ACTION_MOVE); g_signal_connect (G_OBJECT (w), "cursor_changed", G_CALLBACK (select_row), br); g_signal_connect (G_OBJECT (w), "row_activated", G_CALLBACK (part_selected), br); br->viewport = GTK_WIDGET (gtk_builder_get_object (gui, "part_browser_vbox")); path = gtk_tree_path_new_first (); gtk_tree_view_set_cursor (GTK_TREE_VIEW (w), path, NULL, FALSE); gtk_tree_path_free (path); gtk_widget_unparent (br->viewport); return br->viewport; }
int main (int argc, char **argv) { int i; char *host = NULL; char *infile = NULL; char *port = NULL; int tls = 0; int raw = 1; int flags = 0; mu_stream_t stream; mu_smtp_t smtp; mu_stream_t instr; char *from = NULL; mu_list_t rcpt_list = NULL; mu_list_t meth_list = NULL; mu_list_t skiphdr_list = NULL; struct mu_sockaddr *sa; struct mu_sockaddr_hints hints; mu_set_program_name (argv[0]); mu_stdstream_setup (MU_STDSTREAM_RESET_NONE); if (argc < 2) usage (); memset (&hints, 0, sizeof (hints)); hints.flags = MU_AH_DETECT_FAMILY; hints.port = 25; hints.protocol = IPPROTO_TCP; hints.socktype = SOCK_STREAM; MU_ASSERT (mu_smtp_create (&smtp)); for (i = 1; i < argc; i++) { if (strncmp (argv[i], "port=", 5) == 0) port = argv[i] + 5; else if (strncmp (argv[i], "family=", 7) == 0) { hints.flags &= ~MU_AH_DETECT_FAMILY; switch (argv[i][7]) { case '4': hints.family = AF_INET; break; case '6': hints.family = AF_INET6; break; default: mu_error ("invalid family name: %s", argv[i]+7); exit (1); } } else if (strncmp (argv[i], "trace=", 6) == 0) { char *arg = argv[i] + 6; if (mu_isdigit (arg[0])) mu_smtp_trace (smtp, atoi (argv[i] + 6) ? MU_SMTP_TRACE_SET : MU_SMTP_TRACE_CLR); else { mu_smtp_trace (smtp, MU_SMTP_TRACE_SET); if (strcmp (arg, "secure") == 0) mu_smtp_trace_mask (smtp, MU_SMTP_TRACE_SET, MU_XSCRIPT_SECURE); else if (strcmp (arg, "payload") == 0) mu_smtp_trace_mask (smtp, MU_SMTP_TRACE_SET, MU_XSCRIPT_PAYLOAD); } } else if (strncmp (argv[i], "tls=", 4) == 0) tls = atoi (argv[i] + 4); else if (strncmp (argv[i], "domain=", 7) == 0) MU_ASSERT (mu_smtp_set_param (smtp, MU_SMTP_PARAM_DOMAIN, argv[i] + 7)); else if (strncmp (argv[i], "user="******"pass="******"service=", 8) == 0) MU_ASSERT (mu_smtp_set_param (smtp, MU_SMTP_PARAM_SERVICE, argv[i] + 8)); else if (strncmp (argv[i], "realm=", 6) == 0) MU_ASSERT (mu_smtp_set_param (smtp, MU_SMTP_PARAM_REALM, argv[i] + 6)); else if (strncmp (argv[i], "host=", 5) == 0) MU_ASSERT (mu_smtp_set_param (smtp, MU_SMTP_PARAM_HOST, argv[i] + 5)); else if (strncmp (argv[i], "url=", 4) == 0) MU_ASSERT (mu_smtp_set_param (smtp, MU_SMTP_PARAM_URL, argv[i] + 4)); else if (strncmp (argv[i], "input=", 6) == 0) infile = argv[i] + 6; else if (strncmp (argv[i], "raw=", 4) == 0) raw = atoi (argv[i] + 4); else if (strncmp (argv[i], "rcpt=", 5) == 0) { if (!rcpt_list) MU_ASSERT (mu_list_create (&rcpt_list)); MU_ASSERT (mu_list_append (rcpt_list, argv[i] + 5)); } else if (strncmp (argv[i], "from=", 5) == 0) from = argv[i] + 5; else if (strncmp (argv[i], "auth=", 5) == 0) update_list (&meth_list, argv[i] + 5); else if (strncmp (argv[i], "skiphdr=", 8) == 0) { update_list (&skiphdr_list, argv[i] + 8); raw = 0; } else if (host) { mu_error ("server name already given: %s, new name %s?", host, argv[i]); exit (1); } else host = argv[i]; } if (!host) usage (); if (!raw) flags = MU_STREAM_SEEK; if (infile) MU_ASSERT (mu_file_stream_create (&instr, infile, MU_STREAM_READ|flags)); else MU_ASSERT (mu_stdio_stream_create (&instr, MU_STDIN_FD, flags)); host = argv[1]; MU_ASSERT (mu_sockaddr_from_node (&sa, host, port, &hints)); MU_ASSERT (mu_tcp_stream_create_from_sa (&stream, sa, NULL, MU_STREAM_RDWR)); mu_smtp_set_carrier (smtp, stream); mu_stream_unref (stream); if (!from) { from = getenv ("USER"); if (!from) { mu_error ("cannot determine sender name"); exit (1); } } if (raw && !rcpt_list) { mu_error ("no recipients"); exit (1); } MU_ASSERT (mu_smtp_open (smtp)); MU_ASSERT (mu_smtp_ehlo (smtp)); if (tls && mu_smtp_capa_test (smtp, "STARTTLS", NULL) == 0) { MU_ASSERT (mu_smtp_starttls (smtp)); MU_ASSERT (mu_smtp_ehlo (smtp)); } if (meth_list) { int status; MU_ASSERT (mu_smtp_add_auth_mech_list (smtp, meth_list)); status = mu_smtp_auth (smtp); switch (status) { case 0: MU_ASSERT (mu_smtp_ehlo (smtp)); break; case ENOSYS: case MU_ERR_NOENT: /* Ok, skip it */ break; default: mu_error ("authentication failed: %s", mu_strerror (status)); exit (1); } } MU_ASSERT (mu_smtp_mail_basic (smtp, from, NULL)); mu_list_foreach (rcpt_list, send_rcpt_command, smtp); if (raw) { /* Raw sending mode: send from the stream directly */ MU_ASSERT (mu_smtp_send_stream (smtp, instr)); } else { /* Message (standard) sending mode: send a MU message. */ mu_message_t msg; mu_stream_t ostr, bstr; mu_header_t hdr; mu_iterator_t itr; mu_body_t body; if (skiphdr_list) mu_list_set_comparator (skiphdr_list, headercmp); MU_ASSERT (mu_stream_to_message (instr, &msg)); mu_stream_unref (instr); MU_ASSERT (mu_smtp_data (smtp, &ostr)); MU_ASSERT (mu_message_get_header (msg, &hdr)); MU_ASSERT (mu_header_get_iterator (hdr, &itr)); for (mu_iterator_first (itr); !mu_iterator_is_done (itr); mu_iterator_next (itr)) { const char *name; void *value; mu_iterator_current_kv (itr, (void*) &name, &value); if (mu_list_locate (skiphdr_list, (void*) name, NULL) == 0) continue; mu_stream_printf (ostr, "%s: %s\n", name, (char*)value); } mu_iterator_destroy (&itr); MU_ASSERT (mu_stream_write (ostr, "\n", 1, NULL)); MU_ASSERT (mu_message_get_body (msg, &body)); MU_ASSERT (mu_body_get_streamref (body, &bstr)); MU_ASSERT (mu_stream_copy (ostr, bstr, 0, NULL)); mu_stream_destroy (&bstr); mu_stream_close (ostr); mu_stream_destroy (&ostr); } MU_ASSERT (mu_smtp_dot (smtp)); MU_ASSERT (mu_smtp_quit (smtp)); mu_smtp_destroy (&smtp); mu_stream_close (instr); mu_stream_destroy (&instr); return 0; }
void search_modify(GtkEditable *editable, gpointer data) { DEBUG_MSG("search_modify"); update_list(); }
static void OnTimer(gcc_unused WndForm &Sender) { update_list(); }