/*********************************************************************** * * Procedure: * list_new_page - displays packet contents to stderr * ***********************************************************************/ void list_new_page(unsigned long *body) { Scr.Vx = body[0]; Scr.Vy = body[1]; if (Scr.CurrentDesk != body[2]) { /* first handle the new desk */ body[0] = body[2]; list_new_desk(body); } if((Scr.VxMax != body[3])||(Scr.VyMax != body[4])) { Scr.VxMax = body[3]; Scr.VyMax = body[4]; Scr.VxPages = Scr.VxMax / Scr.MyDisplayWidth; Scr.VyPages = Scr.VyMax / Scr.MyDisplayHeight; Scr.VWidth = Scr.VxMax + Scr.MyDisplayWidth; Scr.VHeight = Scr.VyMax + Scr.MyDisplayHeight; ReConfigure(); } MovePage(False); MoveStickyWindows(); Hilight(FocusWin,True); }
int main(int argc, char **argv) { vector<string> cfg; size_t cfg_num = 0; if(argc==2) { cfg.push_back(argv[1]); } else if(argc==3) { cfg.push_back(argv[1]); cfg.push_back(argv[2]); } else { cfg.push_back(CONFIG_FILE); } time_t mtime; struct stat s; if (stat(cfg[cfg_num].c_str(), &s) == 0) { mtime = s.st_mtime; } else { mtime = 0; } cout << "BBC MDI Generator Rev " << svn_version() << ", using libsdixml Rev " << libsdixml::svn_version() << endl << "Implementing SDI Schema version " << libsdixml::SDI_Schema_version() << endl << "Reading config from " << cfg[cfg_num] << endl; cout.flush(); Mdigen mdigen; /* DcpIn dcpin; dcpin.ReConfigure("dcp.udp://:9998"); tagpacketlist t; dcpin.getFrame(t); for(tagpacketlist::iterator i=t.begin(); i!=t.end(); i++) cout << i->first << " " << i->second.size() << endl; */ #ifdef WIN32 int iResult; WSADATA wsaData; // Initialize Winsock iResult = WSAStartup(MAKEWORD(2,2), &wsaData); if (iResult != 0) { printf("WSAStartup failed: %d\n", iResult); exit(1); } #else struct sigaction sa; sa.sa_flags = SA_SIGINFO; sigemptyset(&sa.sa_mask); sa.sa_sigaction = signal_handler; if (sigaction(SIGHUP, &sa, NULL) == -1) { cerr << "error assigning signal handler" << endl; exit(1); } FAMConnection fc; if(FAMOpen(&fc)==0) { FAMRequest fr; if(cfg[0][0]!='/') { string path = getenv("PWD"); cerr << path << endl; cfg[0] = path + "/" + cfg[0]; } if(FAMMonitorFile(&fc, cfg[0].c_str(), &fr, NULL)) cerr << "can't monitor " << cfg[0] << endl; else cout << "FAM Monitoring " << cfg[0] << endl; } else { cerr << "can't connect to file alteration monitor " << endl; } #endif bool ok = true; int max_frames = -1; int reconf_interval = 32; int reconf = reconf_interval; ReConfigure(mdigen, cfg[cfg_num], ok, max_frames); while(ok) { try { mdigen.eachframe(); //cout << "Frame: " << mdigen.transmitted_frames << endl; #ifndef WIN32 while(FAMPending(&fc)) { FAMEvent fe; FAMNextEvent(&fc, &fe); switch(fe.code) { case FAMDeleted: break; case FAMChanged: cout << "file alteration monitor detected config change" << endl; reconfiguration_requested = true; break; case FAMCreated: case FAMExists: break; case FAMEndExist: cout << "FAM initialised " << fe.filename << endl; break; case FAMAcknowledge: cout << "FAM cancel acknowledged " << fe.filename << endl; break; case FAMStartExecuting: case FAMStopExecuting: case FAMMoved: cout << "unexpected fam event " << fe.code << " '" << fe.filename << "'" << endl; break; default: cout << "unknown fam event " << fe.code << " '" << fe.filename << "'" << endl; } } #endif } catch(char const* e) { cerr << e << endl; cerr.flush(); } if(reconfiguration_requested) { ReConfigure(mdigen, cfg[cfg_num], ok, max_frames); } if(cfg.size()>1) { reconf--; if(reconf==0) { cfg_num = 1 - cfg_num; ReConfigure(mdigen, cfg[cfg_num], ok, max_frames); reconf = reconf_interval; } } if(max_frames!=-1 && mdigen.transmitted_frames > max_frames) break; } }