char* pcap_lookupdev(char* errbuf) { int port = 0; struct rte_eth_dev_info info; if (globalInit(errbuf) != DPDKPCAP_OK) { return NULL; } int portsNumber = rte_eth_dev_count(); if (portsNumber < 1) { snprintf (errbuf, PCAP_ERRBUF_SIZE, "No devices found"); return NULL; } if (deviceInit(port, errbuf) == DPDKPCAP_FAILURE) { return NULL; } rte_eth_dev_info_get(port, &info); snprintf(ifName, DPDKPCAP_IF_NAMESIZE, "enp%us%u", info.pci_dev->addr.bus, info.pci_dev->addr.devid); deviceNames[port] = ifName; return ifName; }
Socket::Socket(unsigned long int _haddr, Port _port, int _handle, bool runInit) : closeOnDelete(true),handle(_handle),haddr(_haddr) { if (!globalInit()) JGACHINE_SERROR("globalInit"); if (runInit) init(); // todo "reverse" lookup addr iaddr.second=ntohs(_port); }
bool NetStreamBufServer::init(){ globalInit(); FD_ZERO(&active_fd_set); if (!serverSocket.init()) return false; FD_SET(serverSocket.getHandle(),&active_fd_set); return true; }
int main(int argc, char* argv[]){ globalInit(&argc, &argv); AppSolver < float > solver; string model_file = "G:/Dataset/cifar10/snapshot/quick_iter_10000.model"; string net_file = "G:/Dataset/cifar10/net_train_test.prototxt"; solver.initTestNet(model_file, net_file); while (1) {} }
Socket::Socket(const InternetAddress &_iaddr, bool runInit) : server(false), closeOnDelete(true), handle(-1), iaddr(_iaddr) { if (!globalInit()) JGACHINE_SERROR("globalInit"); if (runInit) init(); }
Socket::Socket(Port _port, bool runInit) : server(true), closeOnDelete(true), handle(-1), iaddr(HostAddress(),_port) { if (!globalInit()) JGACHINE_SERROR("globalInit"); if (runInit) init(); }
int main (int argc, char **argv) { Wrapper *w = globalInit(argc, argv); if (w) { printf("Wrapper successfully created\n"); globalCleanup(&w); } else printf("Couldn't create wrapper\n"); }
static int flashlight_open(struct inode *inode, struct file *file) { int i4RetValue = 0; static int bInited=0; if(bInited==0) { globalInit(); bInited=1; } logI("[flashlight_open] E ~"); return i4RetValue; }
int main(int argc, char **argv) { globalInit(); glutInit(&argc, argv); glutInitWindowSize(width, height); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutCreateWindow("Hello world!"); glutMouseFunc(mouseClick); glutDisplayFunc(display); glutReshapeFunc(reshape); glutTimerFunc(0, timer, 0); glClearColor(0.0, 0.0, 0.0, 1.0); //Infinite event loop glutMainLoop(); return 0; }
void wyDirector_android::attachContext(wyGLContext context) { if (m_context != context) { // get env JNIEnv* env = wyUtils::getJNIEnv(); // global init globalInit(env); // delete old reference if(m_context != NULL) { env->DeleteGlobalRef(m_context); m_context = NULL; } // save context reference if(context != NULL) m_context = env->NewGlobalRef(context); // setup sal setupAAL(); // get resources jobject res = env->CallObjectMethod(m_context, g_mid_Context_getResources); // get display metrics jobject dm = env->CallObjectMethod(res, g_mid_Resources_getDisplayMetrics); env->DeleteLocalRef(res); // set surface size wyDevice::realWidth = env->GetIntField(dm, g_fid_DisplayMetrics_widthPixels); wyDevice::realHeight = env->GetIntField(dm, g_fid_DisplayMetrics_heightPixels); if(SCALE_MODE_BY_DENSITY == wyDevice::scaleMode) { wyDevice::winWidth = wyDevice::realWidth; wyDevice::winHeight = wyDevice::realHeight; } // save other parameters wyDevice::density = env->GetFloatField(dm, g_fid_DisplayMetrics_density); wyDevice::scaledDensity = env->GetFloatField(dm, g_fid_DisplayMetrics_scaledDensity); // set density to aal if(gAAL.setDensity) gAAL.setDensity(wyDevice::density); // delete display metrics ref env->DeleteLocalRef(dm); } }
//----------------------------------------------------------------------------- // name: ChucK() // desc: constructor //----------------------------------------------------------------------------- ChucK::ChucK() { // instantiate the carrier! m_carrier = new Chuck_Carrier(); // set reference back to this m_carrier->chuck = this; // increment the numChucKs o_numVMs++; // initialize default params initDefaultParams(); // did user init? m_init = FALSE; // global init, if needed if( !o_isGlobalInit ) globalInit(); }
int main(int argc, char *argv[]) { initConfig(); if (!parseCmdLine(argc, argv)) goto exit; if (estgbconf.isSingleton) { switch (checkSingleton()) { case 0: break; // No another instance found, continue to work case 1: goto exit; // Found another instance of bot, exiting case 2: printf("Error open PID file for singleton check\n"); goto exit; // Something goes wrong, exiting } } if (!globalInit()) goto exit; if (estgbconf.isDaemonize) daemon(0, 0); if (estgbconf.needUnescape) { estgbconf.text = zc_unescape(estgbconf.text); estgbconf.comment = zc_unescape(estgbconf.comment); } if (estgbconf.isScan >= 0) { scan(); goto exit; } if (estgbconf.isWildcard) sendMultiple(); else sendSingle(); exit: freeConfig(); return 0; }
int main(int argc, char** argv) { bool d = (argc > 1 && strcmp(argv[1], "-d") == 0) ? true : false; QApplication *app = new QApplication(argc, argv); app->setOrganizationName("F-list.net"); app->setOrganizationDomain("www.f-list.net"); app->setApplicationName("F-list Messenger"); globalInit(); QFile stylefile("default.qss"); stylefile.open(QFile::ReadOnly); QString stylesheet = QLatin1String(stylefile.readAll()); app->setStyleSheet(stylesheet); flist_messenger::init(); flist_messenger *fmessenger = new flist_messenger(d); fmessenger->show(); return app->exec(); //todo: globalQuit(); }
QSEngineImp::QSEngineImp( QSEngine *s ) : scr(s), initialized(false), en( 0 ), glob( 0 ) #ifdef QSDEBUGGER ,dbg(0L) #endif { #if defined (QT_THREAD_SUPPORT) && QT_VERSION >= 0x030300 QMutexLocker locker(qt_global_mutexpool ? qt_global_mutexpool->get(qApp) : 0); #endif instances++; // are we the first interpreter instance ? Initialize some stuff if (instances == 1) globalInit(); }
int main(int argc, char *argv[]) { // 读取传参,顺序如下:线上环境、线下环境、词表 if (argc != 4) { printf("Usage: %s onlineEnv offlineEnv dictFilename\n", argv[0]); exit(-1); } else { g_pArgs = &gArgs; // strcpy(g_pArgs->pOnlineEnv, argv[1]); // strcpy(g_pArgs->pOfflineEnv, argv[2]); strcpy(g_pArgs->pOnlineEnv, "http://yf-map-mirror-wpng.vm.baidu.com:8000"); strcpy(g_pArgs->pOfflineEnv, "http://cp01-centos43-testing005.epc.baidu.com:8000"); strcpy(g_pArgs->pDictName, argv[3]); } // 读取配置文件初始化词表目录、数据结果目录 if (globalInit() != 0) { ul_writelog(UL_LOG_FATAL, "globalInit fail, exit!!!"); exit(-1); } // strcpy(g_pArgs->pStrTimestamp, "201508052127"); // filterFields(); time_t start, end; start = time(NULL); // 根据词表文件多线程发送http请求 sendReqs(); end = time(NULL); printf("Total cost is : %f\n", difftime(end, start)); // 生成diff结果后,开始对结果进行处理 // TODO dealResultFiles(); return 0; }
Socket::Socket() : server(true), closeOnDelete(false), handle(-1) { globalInit(); }
Socket::Socket(const Socket&o) : server(o.server), closeOnDelete(o.closeOnDelete), handle(o.handle), iaddr(o.iaddr), haddr(o.haddr) { globalInit(); }
#include "DeviceMatcher.hpp" #include "AllMatcher.hpp" #include <boost/property_tree/ptree.hpp> #include "GlobalInit.hpp" unordered_map<string,function<DeviceMatcher*(const ptree&)> > DeviceMatcher::s_createFunctions; const bool DeviceMatcher::GLOBAL_INIT=globalInit(); static const string CLASS_NAME_KEY("CLASS_NAME"); void DeviceMatcher::write(const DeviceMatcher &matcher,ptree& writeTo){ writeTo.put(CLASS_NAME_KEY,matcher.className()); matcher.writeSelf(writeTo); } DeviceMatcher *DeviceMatcher::read(const ptree& readFrom){ auto className=readFrom.get<string>(CLASS_NAME_KEY); auto functionIt=s_createFunctions.find(className); if(functionIt==s_createFunctions.end()){ return new AllMatcher(); }
int pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf) { int port = 0; pcap_if_t *pPcapIf = NULL; pcap_if_t *pPcapPrevious = NULL; struct rte_eth_dev_info info; if (globalInit(errbuf) != DPDKPCAP_OK) { return DPDKPCAP_FAILURE; } int portsNumber = rte_eth_dev_count(); if (portsNumber < 1) { snprintf (errbuf, PCAP_ERRBUF_SIZE, "No devices found"); return DPDKPCAP_FAILURE; } debug ("Discovered %d devices\n", portsNumber); for (port = 0; port < portsNumber; port++) { if (deviceInit(port, errbuf) == DPDKPCAP_FAILURE) { return DPDKPCAP_FAILURE; } pPcapIf = malloc(sizeof(pcap_if_t)); memset(pPcapIf, 0, sizeof(pcap_if_t)); if (pPcapPrevious) pPcapPrevious->next = pPcapIf; else *alldevsp = pPcapIf; pPcapPrevious = pPcapIf; rte_eth_dev_info_get(port, &info); pPcapIf->name = malloc(DPDKPCAP_IF_NAMESIZE); memset(pPcapIf->name, 0, DPDKPCAP_IF_NAMESIZE); snprintf(pPcapIf->name, DPDKPCAP_IF_NAMESIZE, "port%ubus%udev%u", port, info.pci_dev->addr.bus, info.pci_dev->addr.devid); deviceNames[port] = pPcapIf->name; pPcapIf->description = malloc(DPDKPCAP_IF_NAMESIZE); memset(pPcapIf->description, 0, DPDKPCAP_IF_NAMESIZE); snprintf(pPcapIf->description, DPDKPCAP_IF_NAMESIZE, "DPDK interface"); printf("Allocating memory for %s\n", pPcapIf->name); } pPcapPrevious->next = NULL; return DPDKPCAP_OK; }