示例#1
0
// ---------------------------------------------------------------------------
// 
// -----------
int bExtLibMgr::load(){
_bTrace_("bExtLibMgr::load()",true);
OSErr			pErr1=noErr,pErr2=noErr;
CFArrayRef		bundles;
CFBundleRef		bndl=CFBundleGetMainBundle();
CFURLRef		url;

	url=CFBundleCopyBuiltInPlugInsURL(bndl);
	if(url!=NULL){
		bundles=CFBundleCreateBundlesFromDirectory(kCFAllocatorSystemDefault,url,CFSTR("bundle"));
		CFRelease(url);
		if(bundles!=NULL){
_tm_((int)CFArrayGetCount(bundles)+" plugins");
			pErr2=load(bundles);
			CFRelease(bundles);
		}
		else{
			pErr2=coreFoundationUnknownErr;
		}
	}
	else{
_tm_("Plug-Ins directory not found");
		pErr2=coreFoundationUnknownErr;
	}

	if(pErr1&&pErr2){
_te_("Plug-Ins load ("+pErr1+"/"+pErr2+")");
		return(-1000);
	}

	return(noErr);
}
示例#2
0
/* -----------------------------------------------------------------------------
plugin entry point, called by vpnd
ref is the vpn bundle reference
pppref is the ppp bundle reference
bundles can be layout in two different ways
- As simple vpn bundles (bundle.vpn). the bundle contains the vpn bundle binary.
- As full ppp bundles (bundle.ppp). The bundle contains the ppp bundle binary, 
and also the vpn kext and the vpn bundle binary in its Plugins directory.
if a simple vpn bundle was used, pppref will be NULL.
if a ppp bundle was used, the vpn plugin will be able to get access to the 
Plugins directory and load the vpn kext.
----------------------------------------------------------------------------- */
int start(struct vpn_channel* the_vpn_channel, CFBundleRef ref, CFBundleRef pppref, int debug_mode)
{
    char 	name[MAXPATHLEN]; 
    CFURLRef	url;

    debug = debug_mode;
    
    /* first load the kext if we are loaded as part of a ppp bundle */
    if (pppref) {
        while ((listen_sockfd = socket(PF_PPP, SOCK_DGRAM, PPPPROTO_L2TP)) < 0)
            if (errno != EINTR)
                break;
        if (listen_sockfd < 0) {
            vpnlog(LOG_DEBUG, "first call to socket failed - attempting to load kext\n");
            if (url = CFBundleCopyBundleURL(pppref)) {
                name[0] = 0;
                CFURLGetFileSystemRepresentation(url, 0, name, MAXPATHLEN - 1);
                CFRelease(url);
                strcat(name, "/");
                if (url = CFBundleCopyBuiltInPlugInsURL(pppref)) {
                    CFURLGetFileSystemRepresentation(url, 0, name + strlen(name), 
                                MAXPATHLEN - strlen(name) - strlen(L2TP_NKE) - 1);
                    CFRelease(url);
                    strcat(name, "/");
                    strcat(name, L2TP_NKE);
                    if (!load_kext(name))
                        while ((listen_sockfd = socket(PF_PPP, SOCK_DGRAM, PPPPROTO_L2TP)) < 0)
                            if (errno != EINTR)
                                break;
                }	
            }
            if (listen_sockfd < 0) {
                vpnlog(LOG_ERR, "VPND L2TP plugin: Unable to load L2TP kernel extension\n");
                return -1;
            }
        }
    }
    

    /* retain reference */
    bundle = ref;
    CFRetain(bundle);
    
    pppbundle = pppref;
    CFRetain(pppbundle);
            
    // hookup our socket handlers
    bzero(the_vpn_channel, sizeof(struct vpn_channel));
    the_vpn_channel->get_pppd_args = l2tpvpn_get_pppd_args;
    the_vpn_channel->listen = l2tpvpn_listen;
    the_vpn_channel->accept = l2tpvpn_accept;
    the_vpn_channel->refuse = l2tpvpn_refuse;
    the_vpn_channel->close = l2tpvpn_close;

    return 0;
}
示例#3
0
文件: main.c 项目: Deanzou/ppp
/* -----------------------------------------------------------------------------
plugin entry point, called by pppd
----------------------------------------------------------------------------- */
int start(CFBundleRef ref)
{
    CFStringRef 	strref;
    CFURLRef 		urlref;
   
    bundle = ref;
    CFRetain(bundle);
    
    url = CFBundleCopyBundleURL(bundle);

    // hookup our handlers
    old_check_options = the_channel->check_options;
    the_channel->check_options = serial_check_options;
    
    old_connect = the_channel->connect;
    the_channel->connect = serial_connect;
    
    old_process_extra_options = the_channel->process_extra_options;
    the_channel->process_extra_options = serial_process_extra_options;

    add_notifier(&connect_fail_notify, serial_connect_notifier, 0);
    add_notifier(&lcp_lowerdown_notify, serial_lcpdown_notifier, 0);

    cancelstrref = CFBundleCopyLocalizedString(bundle, CFSTR("Cancel"), CFSTR("Cancel"), NULL);
    if (cancelstrref == 0) return 1;
    CFStringGetCString(cancelstrref, (char*)cancelstr, sizeof(cancelstr), kCFStringEncodingUTF8);
    
    icstrref = CFBundleCopyLocalizedString(bundle, CFSTR("Network Connection"), CFSTR("Network Connection"), NULL);
    if (icstrref == 0) return 1;
    CFStringGetCString(icstrref, (char*)icstr, sizeof(icstr), kCFStringEncodingUTF8);
    
    urlref = CFBundleCopyResourceURL(bundle, CFSTR("NetworkConnect.icns"), NULL, NULL);
    if (urlref == 0 || ((strref = CFURLGetString(urlref)) == 0)) {
		if (urlref)
            CFRelease(urlref);
        return 1;
    }
    CFStringGetCString(strref, (char*)iconstr, sizeof(iconstr), kCFStringEncodingUTF8);
	
	iconstrref = CFStringCreateCopy(NULL, strref);
    CFRelease(urlref);

	urlref = CFBundleCopyBuiltInPlugInsURL(bundle);
	if (urlref == 0 || ((CFURLGetFileSystemRepresentation(urlref, TRUE, pathccl, sizeof(pathccl))) == FALSE)) {
		if (urlref)
            CFRelease(urlref);
        return 1;
    }
    strlcat((char*)pathccl, SUFFIX_CCLENGINE, sizeof(pathccl));
    CFRelease(urlref);
    
    // add the socket specific options
    add_options(serial_options);

    return 0;
}
示例#4
0
    void set_message(wchar_t const* filename) {

#ifdef __APPLE__
      CFBundleRef mainBundle = CFBundleGetMainBundle();
      CFURLRef pluginURL = CFBundleCopyBuiltInPlugInsURL(mainBundle);
      CFStringRef fn = CFStringCreateWithWString(kCFAllocatorDefault, filename, kCFStringEncodingUTF8);
      CFURLRef path = CFURLCreateCopyAppendingPathComponent(NULL, pluginURL, fn, FALSE);
      
      CFBundleRef bundle = CFBundleCreate(kCFAllocatorSystemDefault, path);
      CFRelease(path);
      CFRelease(fn);
      CFRelease(pluginURL);
      
      if (bundle==NULL)
        throw filename;
      
      FuncLoadMessage func = (FuncLoadMessage)CFBundleGetFunctionPointerForName(bundle, CFSTR("load_message"));
      
      if (func==NULL) {
        CFRelease(bundle);
        throw filename;
      }
#elif _MSC_VER
      wstring path = wstring(L"dll\\")+filename;

      HMODULE handle = LoadLibrary(path.c_str());

      if (handle==0)
        throw path.c_str();

      FuncLoadMessage func = (FuncLoadMessage)GetProcAddress(handle, "load_message");

      if (func==0)
        throw path.c_str();
#else
#error Not implemented
#endif

      vector<wstring> message;
      message.resize(Message::NUMBER_OF_MESSAGES);

      func(message);

      message_object.reset(new Message);
      message_object->set(message);

#ifdef __APPLE__
      CFRelease(bundle);
#endif
    }
QStringList QMediaPluginLoader::availablePlugins() const
{
    QStringList paths;
    QStringList plugins;

#if defined(Q_OS_SYMBIAN)
    DirChecker dirChecker;
#endif

#if defined(Q_OS_MAC)
    QString imageSuffix(qgetenv("DYLD_IMAGE_SUFFIX"));

    // Bundle plugin directory
    CFBundleRef mainBundle = CFBundleGetMainBundle();
    if (mainBundle != 0) {
        CFURLRef baseUrl = CFBundleCopyBundleURL(mainBundle);
        CFURLRef pluginUrlPart = CFBundleCopyBuiltInPlugInsURL(mainBundle);
        CFStringRef pluginPathPart = CFURLCopyFileSystemPath(pluginUrlPart, kCFURLPOSIXPathStyle);
        CFURLRef pluginUrl = CFURLCreateCopyAppendingPathComponent(0, baseUrl, pluginPathPart, true);
        CFStringRef pluginPath = CFURLCopyFileSystemPath(pluginUrl, kCFURLPOSIXPathStyle);

        CFIndex length = CFStringGetLength(pluginPath);
        UniChar buffer[length];
        CFStringGetCharacters(pluginPath, CFRangeMake(0, length), buffer);

        paths << QString(reinterpret_cast<const QChar *>(buffer), length);

        CFRelease(pluginPath);
        CFRelease(pluginUrl);
        CFRelease(pluginPathPart);
        CFRelease(pluginUrlPart);
        CFRelease(baseUrl);
    }
#endif

#ifdef QTM_PLUGIN_PATH
    // Mobility's plugin directory
    paths << QLatin1String(QTM_PLUGIN_PATH);
#endif

    // Qt paths
    paths << QCoreApplication::libraryPaths();

    foreach (const QString &path, paths) {
        QDir typeDir(path + m_location);
#if defined(Q_OS_SYMBIAN)
        if (dirChecker.checkDir(typeDir))
#endif
        {
            foreach (const QString &file, typeDir.entryList(QDir::Files)) {
#if defined(Q_OS_MAC)
                if (!imageSuffix.isEmpty()) {   // Only add appropriate images
                    if (file.lastIndexOf(imageSuffix, -6) == -1)
                        continue;
                } else {  // Ignore any images with common suffixes
                    if (file.endsWith(QLatin1String("_debug.dylib")) ||
                        file.endsWith(QLatin1String("_profile.dylib")))
                        continue;
                }
#elif defined(Q_OS_UNIX)
                // Ignore separate debug files
                if (file.endsWith(QLatin1String(".debug")))
                    continue;
#elif defined(Q_OS_WIN)
                // Ignore non-dlls
                if (!file.endsWith(QLatin1String(".dll"), Qt::CaseInsensitive))
                    continue;
#endif
                plugins << typeDir.absoluteFilePath(file);
            }
        }
示例#6
0
    void set_menu(void* hwnd, wchar_t const* filename) {

      CFBundleRef mainBundle = CFBundleGetMainBundle();
      CFURLRef pluginURL = CFBundleCopyBuiltInPlugInsURL(mainBundle);
      CFStringRef fn = CFStringCreateWithWString(kCFAllocatorDefault, filename, kCFStringEncodingUTF8);
      CFURLRef path = CFURLCreateCopyAppendingPathComponent(NULL, pluginURL, fn, FALSE);
      
      CFBundleRef bundle = CFBundleCreate(kCFAllocatorSystemDefault, path);
      CFRelease(path);
      CFRelease(fn);
      CFRelease(pluginURL);
      
      if (bundle==NULL)
        throw filename;
      
      FuncLoadMenu func = reinterpret_cast<FuncLoadMenu>(CFBundleGetFunctionPointerForName(bundle, CFSTR("load_menu")));
      
      if (func==NULL) {
        CFRelease(bundle);
        throw filename;
      }
#elif _MSC_VER
    void set_menu(HWND hwnd, wchar_t const* filename) {

      wstring path = wstring(L"dll\\")+filename;

      HMODULE handle = LoadLibrary(path.c_str());

      FuncLoadMenu func = (FuncLoadMenu)GetProcAddress(handle, "load_menu");

      if (func==0)
        throw path.c_str();
#endif

      unordered_map<int, wstring> menu;

      func(menu);

#ifdef __APPLE__
      HMENU hmenu = get_main_menu();
      
      unsigned int main_menu_id = get_file_menu_pos(hmenu);
      
      int mii = NULL;
#elif _MSC_VER
      HMENU hmenu = CreateMenu();

      UINT main_menu_id = 0;

      MENUITEMINFO mii;
#else
#error Not implemented
#endif

      ////////////////////////////////////////////////////////////////////////////////
      // FILE

#ifdef __APPLE__
      HMENU hmenu_file = get_file_menu(hmenu);
      ++main_menu_id;
#else
      HMENU hmenu_file = create_submenu(mii, hmenu, main_menu_id, menu, IDM_FILE);
#endif

      {
#ifndef __APPLE__
        unsigned int pos = 0;

        create_menuitem(mii, hmenu_file, pos, menu, IDM_FILE_CANCEL);

        create_separator(mii, hmenu_file, pos);

        create_menuitem(mii, hmenu_file, pos, menu, IDM_FILE_QUIT);
#endif
      }


      ////////////////////////////////////////////////////////////////////////////////
      // EDIT

      HMENU hmenu_edit = create_submenu(mii, hmenu, main_menu_id, menu, IDM_EDIT);

      {
        unsigned int pos = 0;

        HMENU hmenu_edit_select_current = create_submenu(mii, hmenu_edit, pos, menu, IDM_EDIT_MARK_ON_CURRENT_LAYER);

        {
#ifdef __APPLE__
          unsigned int pos = 0;
#endif
          create_menuitem(mii, hmenu_edit_select_current, pos, menu, IDM_EDIT_MARK_ALL_NODES_ON_CURRENT_LAYER);

          create_menuitem(mii, hmenu_edit_select_current, pos, menu, IDM_EDIT_MARK_ALL_EDGES_ON_CURRENT_LAYER);

          create_separator(mii, hmenu_edit_select_current, pos);

          create_menuitem(mii, hmenu_edit_select_current, pos, menu, IDM_EDIT_MARK_NODES_INSIDE_COMMUNITY_ON_CURRENT_LAYER);

          create_menuitem(mii, hmenu_edit_select_current, pos, menu, IDM_EDIT_MARK_EDGES_INSIDE_COMMUNITY_ON_CURRENT_LAYER);

          create_menuitem(mii, hmenu_edit_select_current, pos, menu, IDM_EDIT_MARK_ELEMENTS_INSIDE_COMMUNITY_ON_CURRENT_LAYER);

          create_separator(mii, hmenu_edit_select_current, pos);

          create_menuitem(mii, hmenu_edit_select_current, pos, menu, IDM_EDIT_MARK_NODES_OUTSIDE_COMMUNITY_ON_CURRENT_LAYER);

          create_menuitem(mii, hmenu_edit_select_current, pos, menu, IDM_EDIT_MARK_EDGES_OUTSIDE_COMMUNITY_ON_CURRENT_LAYER);

          create_menuitem(mii, hmenu_edit_select_current, pos, menu, IDM_EDIT_MARK_ELEMENTS_OUTSIDE_COMMUNITY_ON_CURRENT_LAYER);

          create_separator(mii, hmenu_edit_select_current, pos);

          create_menuitem(mii, hmenu_edit_select_current, pos, menu, IDM_EDIT_MARK_NODES_IN_SELECTED_COMMUNITY_CONTINUUMS_ON_CURRENT_LAYER);

          create_menuitem(mii, hmenu_edit_select_current, pos, menu, IDM_EDIT_MARK_EDGES_IN_SELECTED_COMMUNITY_CONTINUUMS_ON_CURRENT_LAYER);

          create_menuitem(mii, hmenu_edit_select_current, pos, menu, IDM_EDIT_MARK_ELEMENTS_IN_SELECTED_COMMUNITY_CONTINUUMS_ON_CURRENT_LAYER);

          create_separator(mii, hmenu_edit_select_current, pos);

          create_menuitem(mii, hmenu_edit_select_current, pos, menu, IDM_EDIT_MARK_ALL_ELEMENTS_ON_CURRENT_LAYER);

          create_menuitem(mii, hmenu_edit_select_current, pos, menu, IDM_EDIT_INVERT_MARK_ON_CURRENT_LAYER);
        }

        HMENU hmenu_edit_select_all = create_submenu(mii, hmenu_edit, pos, menu, IDM_EDIT_MARK_ON_EACH_LAYER);

        {
#ifdef __APPLE__
          unsigned int pos = 0;
#endif
          create_menuitem(mii, hmenu_edit_select_all, pos, menu, IDM_EDIT_MARK_ALL_NODES_ON_EACH_LAYER);

          create_menuitem(mii, hmenu_edit_select_all, pos, menu, IDM_EDIT_MARK_ALL_EDGES_ON_EACH_LAYER);

          create_separator(mii, hmenu_edit_select_all, pos);

          create_menuitem(mii, hmenu_edit_select_all, pos, menu, IDM_EDIT_MARK_NODES_INSIDE_COMMUNITY_ON_EACH_LAYER);

          create_menuitem(mii, hmenu_edit_select_all, pos, menu, IDM_EDIT_MARK_EDGES_INSIDE_COMMUNITY_ON_EACH_LAYER);

          create_menuitem(mii, hmenu_edit_select_all, pos, menu, IDM_EDIT_MARK_ELEMENTS_INSIDE_COMMUNITY_ON_EACH_LAYER);

          create_separator(mii, hmenu_edit_select_all, pos);

          create_menuitem(mii, hmenu_edit_select_all, pos, menu, IDM_EDIT_MARK_NODES_OUTSIDE_COMMUNITY_ON_EACH_LAYER);

          create_menuitem(mii, hmenu_edit_select_all, pos, menu, IDM_EDIT_MARK_EDGES_OUTSIDE_COMMUNITY_ON_EACH_LAYER);

          create_menuitem(mii, hmenu_edit_select_all, pos, menu, IDM_EDIT_MARK_ELEMENTS_OUTSIDE_COMMUNITY_ON_EACH_LAYER);

          create_separator(mii, hmenu_edit_select_all, pos);

          create_menuitem(mii, hmenu_edit_select_all, pos, menu, IDM_EDIT_MARK_NODES_IN_SELECTED_COMMUNITY_CONTINUUMS_ON_EACH_LAYER);

          create_menuitem(mii, hmenu_edit_select_all, pos, menu, IDM_EDIT_MARK_EDGES_IN_SELECTED_COMMUNITY_CONTINUUMS_ON_EACH_LAYER);

          create_menuitem(mii, hmenu_edit_select_all, pos, menu, IDM_EDIT_MARK_ELEMENTS_IN_SELECTED_COMMUNITY_CONTINUUMS_ON_EACH_LAYER);

          create_separator(mii, hmenu_edit_select_all, pos);

          create_menuitem(mii, hmenu_edit_select_all, pos, menu, IDM_EDIT_MARK_ALL_ELEMENTS_ON_EACH_LAYER);

          create_menuitem(mii, hmenu_edit_select_all, pos, menu, IDM_EDIT_INVERT_MARK_ON_EACH_LAYER);
        }

        create_separator(mii, hmenu_edit, pos);

        HMENU hmenu_edit_hide = create_submenu(mii, hmenu_edit, pos, menu, IDM_EDIT_HIDE_MARKED_ELEMENTS);

        {
#ifdef __APPLE__
          unsigned int pos = 0;
#endif
          create_menuitem(mii, hmenu_edit_hide, pos, menu, IDM_EDIT_HIDE_MARKED_NODES_ON_CURRENT_LAYER);

          create_menuitem(mii, hmenu_edit_hide, pos, menu, IDM_EDIT_HIDE_MARKED_EDGES_ON_CURRENT_LAYER);

          create_menuitem(mii, hmenu_edit_hide, pos, menu, IDM_EDIT_HIDE_MARKED_ELEMENTS_ON_CURRENT_LAYER);

          create_separator(mii, hmenu_edit_hide, pos);

          create_menuitem(mii, hmenu_edit_hide, pos, menu, IDM_EDIT_HIDE_MARKED_NODES_ON_EACH_LAYER);

          create_menuitem(mii, hmenu_edit_hide, pos, menu, IDM_EDIT_HIDE_MARKED_EDGES_ON_EACH_LAYER);

          create_menuitem(mii, hmenu_edit_hide, pos, menu, IDM_EDIT_HIDE_MARKED_ELEMENTS_ON_EACH_LAYER);
        }

        HMENU hmenu_edit_hide_all = create_submenu(mii, hmenu_edit, pos, menu, IDM_EDIT_HIDE_MARKED_ELEMENTS_ALL);

        {
#ifdef __APPLE__
          unsigned int pos = 0;
#endif
          create_menuitem(mii, hmenu_edit_hide_all, pos, menu, IDM_EDIT_HIDE_MARKED_NODES_ON_CURRENT_LAYER_ALL);

          create_menuitem(mii, hmenu_edit_hide_all, pos, menu, IDM_EDIT_HIDE_MARKED_EDGES_ON_CURRENT_LAYER_ALL);

          create_menuitem(mii, hmenu_edit_hide_all, pos, menu, IDM_EDIT_HIDE_MARKED_ELEMENTS_ON_CURRENT_LAYER_ALL);

          create_separator(mii, hmenu_edit_hide_all, pos);

          create_menuitem(mii, hmenu_edit_hide_all, pos, menu, IDM_EDIT_HIDE_MARKED_NODES_ON_EACH_LAYER_ALL);

          create_menuitem(mii, hmenu_edit_hide_all, pos, menu, IDM_EDIT_HIDE_MARKED_EDGES_ON_EACH_LAYER_ALL);

          create_menuitem(mii, hmenu_edit_hide_all, pos, menu, IDM_EDIT_HIDE_MARKED_ELEMENTS_ON_EACH_LAYER_ALL);
        }

        HMENU hmenu_edit_show = create_submenu(mii, hmenu_edit, pos, menu, IDM_EDIT_SHOW_HIDDEN_ELEMENTS);

        {
#ifdef __APPLE__
          unsigned int pos = 0;
#endif
          create_menuitem(mii, hmenu_edit_show, pos, menu, IDM_EDIT_SHOW_HIDDEN_NODES_ON_CURRENT_LAYER);

          create_menuitem(mii, hmenu_edit_show, pos, menu, IDM_EDIT_SHOW_HIDDEN_EDGES_ON_CURRENT_LAYER);

          create_menuitem(mii, hmenu_edit_show, pos, menu, IDM_EDIT_SHOW_HIDDEN_ELEMENTS_ON_CURRENT_LAYER);

          create_separator(mii, hmenu_edit_show, pos);

          create_menuitem(mii, hmenu_edit_show, pos, menu, IDM_EDIT_SHOW_HIDDEN_NODES_ON_EACH_LAYER);

          create_menuitem(mii, hmenu_edit_show, pos, menu, IDM_EDIT_SHOW_HIDDEN_EDGES_ON_EACH_LAYER);

          create_menuitem(mii, hmenu_edit_show, pos, menu, IDM_EDIT_SHOW_HIDDEN_ELEMENTS_ON_EACH_LAYER);
        }

        create_separator(mii, hmenu_edit, pos);

        HMENU hmenu_edit_remove = create_submenu(mii, hmenu_edit, pos, menu, IDM_EDIT_REMOVE_MARKED_ELEMENTS);

        {
#ifdef __APPLE__
          unsigned int pos = 0;
#endif
          create_menuitem(mii, hmenu_edit_remove, pos, menu, IDM_EDIT_REMOVE_MARKED_NODES_ON_CURRENT_LAYER);

          create_menuitem(mii, hmenu_edit_remove, pos, menu, IDM_EDIT_REMOVE_MARKED_EDGES_ON_CURRENT_LAYER);

          create_menuitem(mii, hmenu_edit_remove, pos, menu, IDM_EDIT_REMOVE_MARKED_ELEMENTS_ON_CURRENT_LAYER);

          create_separator(mii, hmenu_edit_remove, pos);

          create_menuitem(mii, hmenu_edit_remove, pos, menu, IDM_EDIT_REMOVE_MARKED_NODES_ON_EACH_LAYER);

          create_menuitem(mii, hmenu_edit_remove, pos, menu, IDM_EDIT_REMOVE_MARKED_EDGES_ON_EACH_LAYER);

          create_menuitem(mii, hmenu_edit_remove, pos, menu, IDM_EDIT_REMOVE_MARKED_ELEMENTS_ON_EACH_LAYER);
        }

        HMENU hmenu_edit_remove_all = create_submenu(mii, hmenu_edit, pos, menu, IDM_EDIT_REMOVE_MARKED_ELEMENTS_ALL);

        {
#ifdef __APPLE__
          unsigned int pos = 0;
#endif
          create_menuitem(mii, hmenu_edit_remove_all, pos, menu, IDM_EDIT_REMOVE_MARKED_NODES_ON_CURRENT_LAYER_ALL);

          create_menuitem(mii, hmenu_edit_remove_all, pos, menu, IDM_EDIT_REMOVE_MARKED_EDGES_ON_CURRENT_LAYER_ALL);

          create_menuitem(mii, hmenu_edit_remove_all, pos, menu, IDM_EDIT_REMOVE_MARKED_ELEMENTS_ON_CURRENT_LAYER_ALL);

          create_separator(mii, hmenu_edit_remove_all, pos);

          create_menuitem(mii, hmenu_edit_remove_all, pos, menu, IDM_EDIT_REMOVE_MARKED_NODES_ON_EACH_LAYER_ALL);

          create_menuitem(mii, hmenu_edit_remove_all, pos, menu, IDM_EDIT_REMOVE_MARKED_EDGES_ON_EACH_LAYER_ALL);

          create_menuitem(mii, hmenu_edit_remove_all, pos, menu, IDM_EDIT_REMOVE_MARKED_ELEMENTS_ON_EACH_LAYER_ALL);
        }
      }


      ////////////////////////////////////////////////////////////////////////////////
      // VIEW

      HMENU hmenu_view = create_submenu(mii, hmenu, main_menu_id, menu, IDM_VIEW);

      {
        unsigned int pos = 0;

        create_menuitem(mii, hmenu_view, pos, menu, IDM_VIEW_SHOW_NODE);

        create_menuitem(mii, hmenu_view, pos, menu, IDM_VIEW_SHOW_EDGE);

        create_menuitem(mii, hmenu_view, pos, menu, IDM_VIEW_SHOW_COMMUNITY);

        create_menuitem(mii, hmenu_view, pos, menu, IDM_VIEW_SHOW_COMMUNITY_EDGE);

        create_separator(mii, hmenu_view, pos);

        HMENU hmenu_view_node_size = create_submenu(mii, hmenu_view, pos, menu, IDM_VIEW_NODE_SIZE);

        {
#ifdef __APPLE__
          unsigned int pos = 0;
#endif
          create_menuitem(mii, hmenu_view_node_size, pos, menu, IDM_VIEW_NODE_SIZE_UPDATE);

          create_menuitem(mii, hmenu_view_node_size, pos, menu, IDM_VIEW_NODE_SIZE_CANCEL);

          create_separator(mii, hmenu_view_node_size, pos);

          create_menuitem(mii, hmenu_view_node_size, pos, menu, IDM_VIEW_NODE_SIZE_UNIFORM);

          create_menuitem(mii, hmenu_view_node_size, pos, menu, IDM_VIEW_NODE_SIZE_WEIGHT);

          create_menuitem(mii, hmenu_view_node_size, pos, menu, IDM_VIEW_NODE_SIZE_DEGREE_CENTRALITY);

          create_menuitem(mii, hmenu_view_node_size, pos, menu, IDM_VIEW_NODE_SIZE_CLOSENESS_CENTRALITY);

          create_menuitem(mii, hmenu_view_node_size, pos, menu, IDM_VIEW_NODE_SIZE_BETWEENNESS_CENTRALITY);

          create_menuitem(mii, hmenu_view_node_size, pos, menu, IDM_VIEW_NODE_SIZE_PAGERANK);

          create_menuitem(mii, hmenu_view_node_size, pos, menu, IDM_VIEW_NODE_SIZE_POINT);
        }

        HMENU hmenu_view_edge_width = create_submenu(mii, hmenu_view, pos, menu, IDM_VIEW_EDGE_WIDTH);

        {
#ifdef __APPLE__
          unsigned int pos = 0;
#endif
          create_menuitem(mii, hmenu_view_edge_width, pos, menu, IDM_VIEW_EDGE_WIDTH_UPDATE);

          create_menuitem(mii, hmenu_view_edge_width, pos, menu, IDM_VIEW_EDGE_WIDTH_CANCEL);

          create_separator(mii, hmenu_view_edge_width, pos);

          create_menuitem(mii, hmenu_view_edge_width, pos, menu, IDM_VIEW_EDGE_WIDTH_UNIFORM);

          create_menuitem(mii, hmenu_view_edge_width, pos, menu, IDM_VIEW_EDGE_WIDTH_WEIGHT);

          create_menuitem(mii, hmenu_view_edge_width, pos, menu, IDM_VIEW_EDGE_WIDTH_BETWEENNESS_CENTRALITY);
        }

        create_separator(mii, hmenu_view, pos);
        
        HMENU hmenu_view_node_style = create_submenu(mii, hmenu_view, pos, menu, IDM_VIEW_NODE_STYLE);

        {
#ifdef __APPLE__
          unsigned int pos = 0;
#endif
          create_menuitem(mii, hmenu_view_node_style, pos, menu, IDM_VIEW_NODE_STYLE_POLYGON);

          create_menuitem(mii, hmenu_view_node_style, pos, menu, IDM_VIEW_NODE_STYLE_TEXTURE);
        }

        HMENU hmenu_view_edge_style = create_submenu(mii, hmenu_view, pos, menu, IDM_VIEW_EDGE_STYLE);

        {
#ifdef __APPLE__
          unsigned int pos = 0;
#endif
          create_menuitem(mii, hmenu_view_edge_style, pos, menu, IDM_VIEW_EDGE_STYLE_LINE);

          create_menuitem(mii, hmenu_view_edge_style, pos, menu, IDM_VIEW_EDGE_STYLE_POLYGON);
        }

        HMENU hmenu_view_community_style = create_submenu(mii, hmenu_view, pos, menu, IDM_VIEW_COMMUNITY_STYLE);

        {
#ifdef __APPLE__
          unsigned int pos = 0;
#endif
          create_menuitem(mii, hmenu_view_community_style, pos, menu, IDM_VIEW_COMMUNITY_STYLE_POLYGON_CIRCLE);

          create_menuitem(mii, hmenu_view_community_style, pos, menu, IDM_VIEW_COMMUNITY_STYLE_TEXTURE);
        }

        HMENU hmenu_view_community_edge_style = create_submenu(mii, hmenu_view, pos, menu, IDM_VIEW_COMMUNITY_EDGE_STYLE);

        {
#ifdef __APPLE__
          unsigned int pos = 0;
#endif
          create_menuitem(mii, hmenu_view_community_edge_style, pos, menu, IDM_VIEW_COMMUNITY_EDGE_STYLE_LINE);

          create_menuitem(mii, hmenu_view_community_edge_style, pos, menu, IDM_VIEW_COMMUNITY_EDGE_STYLE_POLYGON);
        }
      }


      ////////////////////////////////////////////////////////////////////////////////
      // STRING

      HMENU hmenu_string = create_submenu(mii, hmenu, main_menu_id, menu, IDM_STRING);

      {
        unsigned int pos = 0;

        create_menuitem(mii, hmenu_string, pos, menu, IDM_STRING_SHOW_NODE_NAME);

        create_menuitem(mii, hmenu_string, pos, menu, IDM_STRING_SHOW_EDGE_NAME);

        create_menuitem(mii, hmenu_string, pos, menu, IDM_STRING_SHOW_COMMUNITY_NAME);

        create_menuitem(mii, hmenu_string, pos, menu, IDM_STRING_SHOW_COMMUNITY_EDGE_NAME);

        create_separator(mii, hmenu_string, pos);

        HMENU hmenu_string_node_name_size = create_submenu(mii, hmenu_string, pos, menu, IDM_STRING_NODE_NAME_SIZE);

        {
#ifdef __APPLE__
          unsigned int pos = 0;
#endif
          create_menuitem(mii, hmenu_string_node_name_size, pos, menu, IDM_STRING_NODE_NAME_SIZE_VARIABLE);

          create_separator(mii, hmenu_string_node_name_size, pos);

          create_menuitem(mii, hmenu_string_node_name_size, pos, menu, IDM_STRING_NODE_NAME_SIZE_0);

          create_menuitem(mii, hmenu_string_node_name_size, pos, menu, IDM_STRING_NODE_NAME_SIZE_1);

          create_menuitem(mii, hmenu_string_node_name_size, pos, menu, IDM_STRING_NODE_NAME_SIZE_2);

          create_menuitem(mii, hmenu_string_node_name_size, pos, menu, IDM_STRING_NODE_NAME_SIZE_3);

          create_menuitem(mii, hmenu_string_node_name_size, pos, menu, IDM_STRING_NODE_NAME_SIZE_4);
        }

        HMENU hmenu_string_edge_name_size = create_submenu(mii, hmenu_string, pos, menu, IDM_STRING_EDGE_NAME_SIZE);

        {
#ifdef __APPLE__
          unsigned int pos = 0;
#endif
          create_menuitem(mii, hmenu_string_edge_name_size, pos, menu, IDM_STRING_EDGE_NAME_SIZE_VARIABLE);

          create_separator(mii, hmenu_string_edge_name_size, pos);

          create_menuitem(mii, hmenu_string_edge_name_size, pos, menu, IDM_STRING_EDGE_NAME_SIZE_0);

          create_menuitem(mii, hmenu_string_edge_name_size, pos, menu, IDM_STRING_EDGE_NAME_SIZE_1);

          create_menuitem(mii, hmenu_string_edge_name_size, pos, menu, IDM_STRING_EDGE_NAME_SIZE_2);

          create_menuitem(mii, hmenu_string_edge_name_size, pos, menu, IDM_STRING_EDGE_NAME_SIZE_3);

          create_menuitem(mii, hmenu_string_edge_name_size, pos, menu, IDM_STRING_EDGE_NAME_SIZE_4);
        }

        HMENU hmenu_string_community_name_size = create_submenu(mii, hmenu_string, pos, menu, IDM_STRING_COMMUNITY_NAME_SIZE);

        {
#ifdef __APPLE__
          unsigned int pos = 0;
#endif
          create_menuitem(mii, hmenu_string_community_name_size, pos, menu, IDM_STRING_COMMUNITY_NAME_SIZE_VARIABLE);

          create_separator(mii, hmenu_string_community_name_size, pos);

          create_menuitem(mii, hmenu_string_community_name_size, pos, menu, IDM_STRING_COMMUNITY_NAME_SIZE_0);

          create_menuitem(mii, hmenu_string_community_name_size, pos, menu, IDM_STRING_COMMUNITY_NAME_SIZE_1);

          create_menuitem(mii, hmenu_string_community_name_size, pos, menu, IDM_STRING_COMMUNITY_NAME_SIZE_2);

          create_menuitem(mii, hmenu_string_community_name_size, pos, menu, IDM_STRING_COMMUNITY_NAME_SIZE_3);

          create_menuitem(mii, hmenu_string_community_name_size, pos, menu, IDM_STRING_COMMUNITY_NAME_SIZE_4);
        }

        HMENU hmenu_string_community_edge_name_size = create_submenu(mii, hmenu_string, pos, menu, IDM_STRING_COMMUNITY_EDGE_NAME_SIZE);

        {
#ifdef __APPLE__
          unsigned int pos = 0;
#endif
          create_menuitem(mii, hmenu_string_community_edge_name_size, pos, menu, IDM_STRING_COMMUNITY_EDGE_NAME_SIZE_VARIABLE);

          create_separator(mii, hmenu_string_community_edge_name_size, pos);

          create_menuitem(mii, hmenu_string_community_edge_name_size, pos, menu, IDM_STRING_COMMUNITY_EDGE_NAME_SIZE_0);

          create_menuitem(mii, hmenu_string_community_edge_name_size, pos, menu, IDM_STRING_COMMUNITY_EDGE_NAME_SIZE_1);

          create_menuitem(mii, hmenu_string_community_edge_name_size, pos, menu, IDM_STRING_COMMUNITY_EDGE_NAME_SIZE_2);

          create_menuitem(mii, hmenu_string_community_edge_name_size, pos, menu, IDM_STRING_COMMUNITY_EDGE_NAME_SIZE_3);

          create_menuitem(mii, hmenu_string_community_edge_name_size, pos, menu, IDM_STRING_COMMUNITY_EDGE_NAME_SIZE_4);
        }

        create_separator(mii, hmenu_string, pos);

        HMENU hmenu_string_type = create_submenu(mii, hmenu_string, pos, menu, IDM_STRING_FONT_TYPE);

        {
#ifdef __APPLE__
          unsigned int pos = 0;
#endif
          create_menuitem(mii, hmenu_string_type, pos, menu, IDM_STRING_FONT_TYPE_POLYGON);

          create_menuitem(mii, hmenu_string_type, pos, menu, IDM_STRING_FONT_TYPE_TEXTURE);
        }

        create_separator(mii, hmenu_string, pos);

        create_menuitem(mii, hmenu_string, pos, menu, IDM_STRING_SHOW_LAYER_NAME);

        create_menuitem(mii, hmenu_string, pos, menu, IDM_STRING_SHOW_FPS);
      }


      ////////////////////////////////////////////////////////////////////////////////
      // LAYOUT

      HMENU hmenu_layout = create_submenu(mii, hmenu, main_menu_id, menu, IDM_LAYOUT);

      {
        unsigned int pos = 0;

        create_menuitem(mii, hmenu_layout, pos, menu, IDM_LAYOUT_UPDATE);

        create_menuitem(mii, hmenu_layout, pos, menu, IDM_LAYOUT_CANCEL);

        create_separator(mii, hmenu_layout, pos);

        create_menuitem(mii, hmenu_layout, pos, menu, IDM_LAYOUT_KAMADA_KAWAI_METHOD);

        HMENU hmenu_layout_hde = create_submenu(mii, hmenu_layout, pos, menu, IDM_LAYOUT_HIGH_DIMENSIONAL_EMBEDDING);

        {
#ifdef __APPLE__
          unsigned int pos = 0;
#endif
          create_menuitem(mii, hmenu_layout_hde, pos, menu, IDM_LAYOUT_HIGH_DIMENSIONAL_EMBEDDING_1_2);

          create_menuitem(mii, hmenu_layout_hde, pos, menu, IDM_LAYOUT_HIGH_DIMENSIONAL_EMBEDDING_1_3);

          create_menuitem(mii, hmenu_layout_hde, pos, menu, IDM_LAYOUT_HIGH_DIMENSIONAL_EMBEDDING_2_3);
        }

        create_separator(mii, hmenu_layout, pos);

        create_menuitem(mii, hmenu_layout, pos, menu, IDM_LAYOUT_CIRCLE);

        create_menuitem(mii, hmenu_layout, pos, menu, IDM_LAYOUT_CIRCLE_IN_SIZE_ORDER);

        create_menuitem(mii, hmenu_layout, pos, menu, IDM_LAYOUT_LATTICE);

        create_menuitem(mii, hmenu_layout, pos, menu, IDM_LAYOUT_RANDOM);

        create_menuitem(mii, hmenu_layout, pos, menu, IDM_LAYOUT_CARTOGRAMS);

        create_separator(mii, hmenu_layout, pos);

        HMENU hmenu_layout_fde = create_submenu(mii, hmenu_layout, pos, menu, IDM_LAYOUT_FORCE_DIRECTION);

        {
#ifdef __APPLE__
          unsigned int pos = 0;
#endif
          create_menuitem(mii, hmenu_layout_fde, pos, menu, IDM_LAYOUT_FORCE_DIRECTION_RUN);

          create_separator(mii, hmenu_layout_fde, pos);

          create_menuitem(mii, hmenu_layout_fde, pos, menu, IDM_LAYOUT_FORCE_DIRECTION_KAMADA_KAWAI_METHOD);

          create_menuitem(mii, hmenu_layout_fde, pos, menu, IDM_LAYOUT_FORCE_DIRECTION_KAMADA_KAWAI_METHOD_WITH_COMMUNITY_SEPARATION);

          create_menuitem(mii, hmenu_layout_fde, pos, menu, IDM_LAYOUT_FORCE_DIRECTION_COMMUNITY_ORIENTED);

          create_separator(mii, hmenu_layout_fde, pos);

          create_menuitem(mii, hmenu_layout_fde, pos, menu, IDM_LAYOUT_FORCE_DIRECTION_SPRING_AND_REPULSIVE_FORCE);

          create_menuitem(mii, hmenu_layout_fde, pos, menu, IDM_LAYOUT_FORCE_DIRECTION_LATTICE_GAS_METHOD);
#if 0
          create_menuitem(mii, hmenu_layout_fde, pos, menu, IDM_LAYOUT_FORCE_DIRECTION_DESIGNTIDE);
#endif
        }

        create_separator(mii, hmenu_layout, pos);

        create_menuitem(mii, hmenu_layout, pos, menu, IDM_LAYOUT_SHOW_LAYOUT_FRAME);

        create_menuitem(mii, hmenu_layout, pos, menu, IDM_LAYOUT_INITIALIZE_LAYOUT_FRAME);

        create_separator(mii, hmenu_layout, pos);

        create_menuitem(mii, hmenu_layout, pos, menu, IDM_LAYOUT_SHOW_GRID);

        create_menuitem(mii, hmenu_layout, pos, menu, IDM_LAYOUT_SHOW_CENTER);

        create_separator(mii, hmenu_layout, pos);

        create_menuitem(mii, hmenu_layout, pos, menu, IDM_LAYOUT_INITIALIZE_EYEPOINT);

        create_menuitem(mii, hmenu_layout, pos, menu, IDM_LAYOUT_ZOOM_IN);

        create_menuitem(mii, hmenu_layout, pos, menu, IDM_LAYOUT_ZOOM_OUT);
      }


      ////////////////////////////////////////////////////////////////////////////////
      // COMMUNITY

      HMENU hmenu_community = create_submenu(mii, hmenu, main_menu_id, menu, IDM_COMMUNITY_DETECTION);

      {
        unsigned int pos = 0;

        create_menuitem(mii, hmenu_community, pos, menu, IDM_COMMUNITY_DETECTION_UPDATE);

        create_menuitem(mii, hmenu_community, pos, menu, IDM_COMMUNITY_DETECTION_CANCEL);

        create_separator(mii, hmenu_community, pos);

        HMENU hmenu_community_connected_components = create_submenu(mii, hmenu_community, pos, menu, IDM_COMMUNITY_DETECTION_CONNECTED_COMPONENTS);

        {
#ifdef __APPLE__
          unsigned int pos = 0;
#endif
          create_menuitem(mii, hmenu_community_connected_components, pos, menu, IDM_COMMUNITY_DETECTION_WEAKLY_CONNECTED_COMPONENTS);

          create_menuitem(mii, hmenu_community_connected_components, pos, menu, IDM_COMMUNITY_DETECTION_STRONGLY_CONNECTED_COMPONENTS);
        }

        HMENU hmenu_community_modularity_maximization = create_submenu(mii, hmenu_community, pos, menu, IDM_COMMUNITY_DETECTION_MODULARITY_MAXIMIZATION);

        {
#ifdef __APPLE__
          unsigned int pos = 0;
#endif
          create_menuitem(mii, hmenu_community_modularity_maximization, pos, menu, IDM_COMMUNITY_DETECTION_MODULARITY_MAXIMIZATION_USING_GREEDY_METHOD);

          create_menuitem(mii, hmenu_community_modularity_maximization, pos, menu, IDM_COMMUNITY_DETECTION_MODULARITY_MAXIMIZATION_USING_TEO_METHOD);

          create_separator(mii, hmenu_community_modularity_maximization, pos);

          create_menuitem(mii, hmenu_community_modularity_maximization, pos, menu, IDM_COMMUNITY_DETECTION_USE_WEIGHTED_MODULARITY);
        }

        HMENU hmenu_community_clique_percolaion = create_submenu(mii, hmenu_community, pos, menu, IDM_COMMUNITY_DETECTION_CLIQUE_PERCOLATION);

        {
#ifdef __APPLE__
          unsigned int pos = 0;
#endif
          create_menuitem(mii, hmenu_community_clique_percolaion, pos, menu, IDM_COMMUNITY_DETECTION_CLIQUE_PERCOLATION_3);

          create_menuitem(mii, hmenu_community_clique_percolaion, pos, menu, IDM_COMMUNITY_DETECTION_CLIQUE_PERCOLATION_4);

          create_menuitem(mii, hmenu_community_clique_percolaion, pos, menu, IDM_COMMUNITY_DETECTION_CLIQUE_PERCOLATION_5);
        }

        HMENU hmenu_community_others = create_submenu(mii, hmenu_community, pos, menu, IDM_COMMUNITY_DETECTION_OTHERS);

        {
#ifdef __APPLE__
          unsigned int pos = 0;
#endif
          create_menuitem(mii, hmenu_community_others, pos, menu, IDM_COMMUNITY_DETECTION_BETWEENNESS_CENTRALITY_SEPARATION);
#if 0
          create_menuitem(mii, hmenu_community_others, pos, menu, IDM_COMMUNITY_DETECTION_INFORMATION_FLOW_MAPPING);
#endif
        }

        create_separator(mii, hmenu_community, pos);

        create_menuitem(mii, hmenu_community, pos, menu, IDM_COMMUNITY_TRANSITION_DIAGRAM);

        create_menuitem(mii, hmenu_community, pos, menu, IDM_COMMUNITY_TRANSITION_DIAGRAM_SCOPE_WIDER);

        create_menuitem(mii, hmenu_community, pos, menu, IDM_COMMUNITY_TRANSITION_DIAGRAM_SCOPE_NARROWER);

        create_separator(mii, hmenu_community, pos);

        create_menuitem(mii, hmenu_community, pos, menu, IDM_COMMUNITY_DETECTION_CLEAR);
      }


      ////////////////////////////////////////////////////////////////////////////////
      // TIMELINE

      HMENU hmenu_timeline = create_submenu(mii, hmenu, main_menu_id, menu, IDM_TIMELINE);

      {
        unsigned int pos = 0;

        create_menuitem(mii, hmenu_timeline, pos, menu, IDM_TIMELINE_NEXT);

        create_menuitem(mii, hmenu_timeline, pos, menu, IDM_TIMELINE_PREV);

        create_separator(mii, hmenu_timeline, pos);

        HMENU hmenu_timeline_auto = create_submenu(mii, hmenu_timeline, pos, menu, IDM_TIMELINE_AUTO_RUN);

        {
#ifdef __APPLE__
          unsigned int pos = 0;
#endif
          create_menuitem(mii, hmenu_timeline_auto, pos, menu, IDM_TIMELINE_STOP);

          create_separator(mii, hmenu_timeline_auto, pos);

          create_menuitem(mii, hmenu_timeline_auto, pos, menu, IDM_TIMELINE_FORWARD_1);

          create_menuitem(mii, hmenu_timeline_auto, pos, menu, IDM_TIMELINE_FORWARD_2);

          create_menuitem(mii, hmenu_timeline_auto, pos, menu, IDM_TIMELINE_FORWARD_3);

          create_menuitem(mii, hmenu_timeline_auto, pos, menu, IDM_TIMELINE_FORWARD_4);

          create_separator(mii, hmenu_timeline_auto, pos);

          create_menuitem(mii, hmenu_timeline_auto, pos, menu, IDM_TIMELINE_BACKWARD_1);

          create_menuitem(mii, hmenu_timeline_auto, pos, menu, IDM_TIMELINE_BACKWARD_2);

          create_menuitem(mii, hmenu_timeline_auto, pos, menu, IDM_TIMELINE_BACKWARD_3);

          create_menuitem(mii, hmenu_timeline_auto, pos, menu, IDM_TIMELINE_BACKWARD_4);
        }

        create_separator(mii, hmenu_timeline, pos);

        create_menuitem(mii, hmenu_timeline, pos, menu, IDM_TIMELINE_SHOW_SLIDER);
      }

#ifdef __APPLE__
      CFRelease(bundle);
#elif _MSC_VER
      SetMenu(hwnd, hmenu);
      FreeLibrary(handle);
#else
#error Not implemented
#endif
    }
示例#7
0
文件: main.c 项目: TARRANUM/ppp
/* ----------------------------------------------------------------------------- 
get the socket ready to start doing PPP.
That is, open the socket and run the connector
----------------------------------------------------------------------------- */
int pppoe_connect(int *errorcode)
{
    char 	dev[32], name[MAXPATHLEN]; 
    int 	err = 0, len, s;  
    CFURLRef	url;
    struct ifreq 	ifr;
    
	*errorcode = 0;

    snprintf(dev, sizeof(dev), "socket[%d:%d]", PF_PPP, PPPPROTO_PPPOE);
    strlcpy(ppp_devnam, dev, sizeof(ppp_devnam));

    hungup = 0;
    kill_link = 0;
    linkdown = 0;
	
	err = -1;
    s = socket(PF_SYSTEM, SOCK_RAW, SYSPROTO_EVENT);
    if (s >= 0) {
        
        len = strlen(device);
        if (len <= sizeof(ifr.ifr_name)) {

            bzero(&ifr, sizeof(ifr));
            bcopy(device, ifr.ifr_name, len);
            if (ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) >= 0) {
                // ensure that the device is UP
                ifr.ifr_flags |= IFF_UP;
                if (ioctl(s, SIOCSIFFLAGS, (caddr_t) &ifr) >= 0)
                    err = 0;
            }
        }
        
        close(s);
    }
	if (err) {
		error("PPPoE cannot use interface '%s'.", device);
		status = EXIT_OPEN_FAILED;
		return -1;
	}

    if (strcmp(mode, MODE_ANSWER)) {
        /* open the socket */
        sockfd = socket(PF_PPP, SOCK_DGRAM, PPPPROTO_PPPOE);
        if (sockfd < 0) {
            if (!noload) {
                if (url = CFBundleCopyBundleURL(bundle)) {
                    name[0] = 0;
                    CFURLGetFileSystemRepresentation(url, 0, (UInt8 *)name, MAXPATHLEN - 1);
                    CFRelease(url);
                    strlcat(name, "/", sizeof(name));
                    if (url = CFBundleCopyBuiltInPlugInsURL(bundle)) {
                        CFURLGetFileSystemRepresentation(url, 0, (UInt8 *)(name + strlen(name)), 
                            MAXPATHLEN - strlen(name) - strlen(PPPOE_NKE) - 1);
                        CFRelease(url);
                        strlcat(name, "/", sizeof(name));
                        strlcat(name, PPPOE_NKE, sizeof(name));
#if !TARGET_OS_EMBEDDED // This file is not built for Embedded
                        if (!load_kext(name, 0))
#else
                        if (!load_kext(PPPOE_NKE_ID, 1))
#endif
                            sockfd = socket(PF_PPP, SOCK_DGRAM, PPPPROTO_PPPOE);
                    }	
                }
            }
            if (sockfd < 0) {
                error("Failed to open PPPoE socket: %m");
                status = EXIT_OPEN_FAILED;
                return -1;
            }
        }
    }

    if (loopback || debug) {
        u_int32_t 	flags;
        flags = (loopback ? PPPOE_FLAG_LOOPBACK : 0)
            + ((kdebugflag & 1) ? PPPOE_FLAG_DEBUG : 0);
        if (setsockopt(sockfd, PPPPROTO_PPPOE, PPPOE_OPT_FLAGS, &flags, 4)) {
            error("PPPoE can't set PPPoE flags...\n");
            return errno;
        }
        if (loopback) 
            notice("PPPoE loopback activated...\n");
    }

    if (connecttimer) {
        u_int16_t 	timer = connecttimer;
        if (setsockopt(sockfd, PPPPROTO_PPPOE, PPPOE_OPT_CONNECT_TIMER, &timer, 2)) {
            error("PPPoE can't set PPPoE connect timer...\n");
            return errno;
        }
    }

    if (retrytimer) {
        u_int16_t 	timer = retrytimer;
        if (setsockopt(sockfd, PPPPROTO_PPPOE, PPPOE_OPT_RETRY_TIMER, &timer, 2)) {
            error("PPPoE can't set PPPoE retry timer...\n");
            return errno;
        }
    }

    if (setsockopt(sockfd, PPPPROTO_PPPOE, PPPOE_OPT_INTERFACE, device, strlen(device))) {
        error("PPPoE can't specify interface...\n");
        return errno;
    }

    if (!strcmp(mode, MODE_ANSWER)) {
        // nothing to do
    }
    else if (!strcmp(mode, MODE_LISTEN)) {
        err = pppoe_listen();
    }
    else if (!strcmp(mode, MODE_CONNECT)) {
        err = pppoe_dial();
    }
    else 
        fatal("PPPoE incorrect mode : '%s'", mode ? mode : "");

    if (err) {
        if (err != -2) {
            if (err != -1)
                devstatus = err;
            status = EXIT_CONNECT_FAILED;
        }
        return -1;
    }
    
    return sockfd;
}
示例#8
0
static CFPlugInRef MyLoadPlugIn( void )
{
	CFPlugInRef		newPlugIn;
	CFURLRef		bundleURL;
	CFURLRef		plugInURL;
	Boolean			foundInterface	= false;

	//  Obtain a URL to the PlugIns directory inside our application.
	bundleURL	= CFBundleCopyBuiltInPlugInsURL( CFBundleGetMainBundle() );

	//  We just want to load our test plug-in, so append its name to the URL.
	plugInURL	= CFURLCreateCopyAppendingPathComponent( NULL, bundleURL, CFSTR( kPlugInName ), FALSE );

	//  Create a CFPlugin using the URL. This step causes the plug-in's types and factories to
	//  be registered with the system. Note that the plug-in's code is not actually loaded at
	//  this stage unless the plug-in is using dynamic registration.

	newPlugIn	= CFPlugInCreate( NULL, plugInURL );

	CFRelease( bundleURL );
	CFRelease( plugInURL );

	//  The plug-in was located. Now locate the interface.
	if( newPlugIn )
	{
		CFArrayRef	factories;
		
		//  See if this plug-in implements the Test type.
		factories	= CFPlugInFindFactoriesForPlugInTypeInPlugIn( kTestTypeID, newPlugIn );

		//  If there are factories for the Test type, attempt to get the IUnknown interface.
		if ( factories != NULL )
		{
			CFIndex	factoryCount;
			CFIndex	index;

	    	factoryCount	= CFArrayGetCount( factories );
	    	if ( factoryCount > 0 )
	    	{
	    		for ( index = 0 ; (index < factoryCount) && (foundInterface == false) ; index++ )
	    		{
	    			CFUUIDRef	factoryID;

	        		//  Get the factory ID for the first location in the array of IDs.
	       			factoryID = (CFUUIDRef) CFArrayGetValueAtIndex( factories, index );
	       			if ( factoryID )
	       			{
						IUnknownVTbl **iunknown;
						
						//  Use the factory ID to get an IUnknown interface. Here the plug-in code is loaded.
						iunknown	= (IUnknownVTbl **) CFPlugInInstanceCreate( NULL, factoryID, kTestTypeID );
						
						if ( iunknown )
						{
	        				//  If this is an IUnknown interface, query for the test interface.
							(*iunknown)->QueryInterface( iunknown, CFUUIDGetUUIDBytes( kTestInterfaceID ), (LPVOID *)( &gDrawBallInterface ) );

			                // Now we are done with IUnknown
			                (*iunknown)->Release( iunknown );
			                
			                if ( gDrawBallInterface )
			                {
			                	//	We found the interface we need
			                	foundInterface	= true;
			                }
						}
	       			}
	       		}
			}
		}
		
		CFRelease( factories );
	}

	if ( foundInterface == false )
	{
	    CFRelease( newPlugIn );
	    newPlugIn	= NULL;
	}

	return( newPlugIn );
}
示例#9
0
///////////////////////////////////////////////////////////////////////
// Class				:	COptions
// Method				:	COptions
// Description			:
/// \brief					All the default frame specific settings are defined here
// Return Value			:	-
// Comments				:
COptions::COptions() {
	atomicIncrement(&stats.numOptions);

	xres					=	640;
	yres					=	480;

	frame					=	-1;

	pixelAR					=	1;
	frameAR					=	4.0f/3.0f;

	cropLeft				=	0;
	cropRight				=	1;
	cropTop					=	0;
	cropBottom				=	1;

	screenLeft				=	-4.0f/3.0f;
	screenRight				=	4.0f/3.0f;
	screenTop				=	1;
	screenBottom			=	-1;
	
	clipMin					=	C_EPSILON;
	clipMax					=	C_INFINITY;

	pixelVariance			=	0.05f;

	jitter					=	0.99f;

	hider					=	strdup("stochastic");
	
#ifdef __APPLE__
	// Support for finding resources in Mac OS X bundles and standard Mac OS X file system locations
	
	// Find the application bundle's plug-in and Resources directory
	char path[OS_MAX_PATH_LENGTH];
	char pathtmp[OS_MAX_PATH_LENGTH];
	CFBundleRef bundle = CFBundleGetMainBundle();
	if (bundle) {
		CFURLRef url = CFBundleCopyBuiltInPlugInsURL(bundle);
		if (url) {
			Boolean validpath = CFURLGetFileSystemRepresentation(url,true,(UInt8*)path,OS_MAX_PATH_LENGTH);
			if (validpath)
				setenv("PIXIEAPPPLUGINS", (const char*)path, 1);
			CFRelease(url);
		}
		url = CFBundleCopyResourcesDirectoryURL(bundle);
		if (url) {
			Boolean validpath = CFURLGetFileSystemRepresentation(url,true,(UInt8*)path,OS_MAX_PATH_LENGTH);
			if (validpath)
				setenv("PIXIEAPPRESOURCES", (const char*)path, 1);
			CFRelease(url);
		}
		CFRelease(bundle);
	}
	
	// Find the application support directory (~/Library/Application Support/Pixie/PlugIns), and set the
	// PIXIEUSERDIR environment variable to that directory
	FSRef appsupport;
    if (FSFindFolder(kUserDomain, kApplicationSupportFolderType, kCreateFolder, &appsupport) == noErr) {
		FSRefMakePath(&appsupport, (UInt8*)path, OS_MAX_PATH_LENGTH);
		sprintf(pathtmp, "%s/" PACKAGE, path);
		mkdir(pathtmp, 0755);
		setenv("PIXIEUSERDIR", (const char*)pathtmp, 1);
	}
	
	// Find the application support directory (/Library/Application Support/Pixie/PlugIns), and set the
	// PIXIELOCALDIR environment variable to that directory
    if (FSFindFolder(kLocalDomain, kApplicationSupportFolderType, kCreateFolder, &appsupport) == noErr) {
		FSRefMakePath(&appsupport, (UInt8*)path, OS_MAX_PATH_LENGTH);
		snprintf(pathtmp, OS_MAX_PATH_LENGTH, "%s/" PACKAGE, path);
		mkdir(pathtmp, 0755);
		setenv("PIXIELOCALDIR", (const char*)pathtmp, 1);
	}
	
	// Default home, unless overridden with environment
	setenv("PIXIEHOME","/Library/Pixie",0);
	
	archivePath             =   optionsGetSearchPath(".:%RIBS%:%PIXIEHOME%/ribs" ,NULL);
	proceduralPath          =   optionsGetSearchPath(".:%PROCEDURALS%:%PIXIEUSERDIR%/procedurals:%PIXIELOCALDIR%/procedurals:%PIXIEAPPPLUGINS%:%PIXIEHOME%/procedurals",NULL);
	texturePath             =   optionsGetSearchPath(".:%TEXTURES%:%PIXIEUSERDIR%/textures:%PIXIELOCALDIR%/textures:%PIXIEAPPRESOURCES%/textures:%PIXIEHOME%/textures",NULL);
	shaderPath              =   optionsGetSearchPath(".:%SHADERS%:%PIXIEUSERDIR%/shaders:%PIXIELOCALDIR%/shaders:%PIXIEAPPRESOURCES%/shaders:%PIXIEHOME%/shaders",NULL);
	displayPath             =   optionsGetSearchPath("%DISPLAYS%:%PIXIEUSERDIR%/displays:%PIXIELOCALDIR%/displays:%PIXIEAPPPLUGINS%:%PIXIEHOME%/displays",NULL);
	modulePath              =   optionsGetSearchPath("%MODULES%:%PIXIEUSERDIR%/modules:%PIXIELOCALDIR%/modules:%PIXIEAPPPLUGINS%:%PIXIEHOME%/modules",NULL);

#else
	archivePath				=	optionsGetSearchPath(".:%RIBS%:" PIXIE_RIBS,NULL);
	proceduralPath			=	optionsGetSearchPath(".:%PROCEDURALS%:" PIXIE_PROCEDURALS,NULL);
	texturePath				=	optionsGetSearchPath(".:%TEXTURES%:" PIXIE_TEXTURES,NULL);
	shaderPath				=	optionsGetSearchPath(".:%SHADERS%:" PIXIE_SHADERS,NULL);
	displayPath				=	optionsGetSearchPath(".:%DISPLAYS%:" PIXIE_DISPLAYS,NULL);
	modulePath				=	optionsGetSearchPath(".:%MODULES%:" PIXIE_MODULES,NULL);
#endif

	pixelXsamples			=	2;
	pixelYsamples			=	2;

	gamma					=	1;
	gain					=	1;	

	pixelFilterWidth		=	2;
	pixelFilterHeight		=	2;
	pixelFilter				=	RiCatmullRomFilter;

	colorQuantizer[0]		=	0;				// Zero
	colorQuantizer[1]		=	255;			// One
	colorQuantizer[2]		=	0;				// Min
	colorQuantizer[3]		=	255;			// Max
	colorQuantizer[4]		=	0.5;
	depthQuantizer[0]		=	0;				// Zero
	depthQuantizer[1]		=	0;				// One
	depthQuantizer[2]		=	0;				// Min
	depthQuantizer[3]		=	0;				// Max
	depthQuantizer[4]		=	0;

	initv(opacityThreshold,0.996f);
	initv(zvisibilityThreshold,0.996f);
	
	// We default to sampling motion, but this can be turned off.
	// Additionally, if there's no motionblur in the scene, it will be turned off
	flags					=	OPTIONS_FLAGS_SAMPLEMOTION;

	displays				=	NULL;

	clipPlanes				=	NULL;

	relativeDetail			=	1;

	projection				=	OPTIONS_PROJECTION_ORTHOGRAPHIC;
	fov						=	90;

	nColorComps				=	3;
	fromRGB					=	NULL;
	toRGB					=	NULL;

	fstop					=	C_INFINITY;
	focallength				=	1;
	focaldistance			=	1;

	shutterOpen				=	0;
	shutterClose			=	0;
	shutterOffset			=	0;

	endofframe				=	0;
	filelog					=	NULL;

	numThreads              =   osAvailableCPUs();
	if (numThreads < 1)
		numThreads          =   DEFAULT_NUM_THREADS;

	maxTextureSize			=	DEFAULT_MAX_TEXTURESIZE;
	maxBrickSize			=	DEFAULT_MAX_BRICKSIZE;

	maxGridSize				=	DEFAULT_MAX_GRIDSIZE;

	maxRayDepth				=	5;
	maxPhotonDepth			=	10;

	bucketWidth				=	DEFAULT_TILE_WIDTH;
	bucketHeight			=	DEFAULT_TILE_HEIGHT;

	netXBuckets				=	DEFAULT_NET_XBUCKETS;
	netYBuckets				=	DEFAULT_NET_YBUCKETS;

	threadStride			=	DEFAULT_THREAD_STRIDE;
	
	geoCacheMemory			=	DEFAULT_GEO_CACHE_SIZE;

	maxEyeSplits			=	10;

	tsmThreshold			=	DEFAULT_TSM_THRESHOLD;

	causticIn				=	NULL;
	causticOut				=	NULL;

	globalIn				=	NULL;
	globalOut				=	NULL;

	numEmitPhotons			=	10000;

	shootStep				=	1000;

	depthFilter				=	DEPTH_MIN;
}
示例#10
0
文件: main.c 项目: TARRANUM/ppp
/* -----------------------------------------------------------------------------
plugin entry point, called by vpnd
ref is the vpn bundle reference
pppref is the ppp bundle reference
bundles can be layout in two different ways
- As simple vpn bundles (bundle.vpn). the bundle contains the vpn bundle binary.
- As full ppp bundles (bundle.ppp). The bundle contains the ppp bundle binary, 
and also the vpn kext and the vpn bundle binary in its Plugins directory.
if a simple vpn bundle was used, pppref will be NULL.
if a ppp bundle was used, the vpn plugin will be able to get access to the 
Plugins directory and load the vpn kext.
----------------------------------------------------------------------------- */
int start(struct vpn_channel* the_vpn_channel, CFBundleRef ref, CFBundleRef pppref, int debug_mode, int log_verbose)
{
    char 	name[MAXPATHLEN]; 
    CFURLRef	url;
    size_t		len; 
	int			nb_cpu = 1, nb_threads = 0;

    debug = debug_mode;
    
    /* first load the kext if we are loaded as part of a ppp bundle */
    if (pppref) {
        while ((listen_sockfd = socket(PF_PPP, SOCK_DGRAM, PPPPROTO_L2TP)) < 0)
            if (errno != EINTR)
                break;
        if (listen_sockfd < 0) {
            vpnlog(LOG_DEBUG, "L2TP plugin: first call to socket failed - attempting to load kext\n");
            if (url = CFBundleCopyBundleURL(pppref)) {
                name[0] = 0;
                CFURLGetFileSystemRepresentation(url, 0, (UInt8 *)name, MAXPATHLEN - 1);
                CFRelease(url);
                strlcat(name, "/", sizeof(name));
                if (url = CFBundleCopyBuiltInPlugInsURL(pppref)) {
                    CFURLGetFileSystemRepresentation(url, 0, (UInt8 *)(name + strlen(name)), 
                                MAXPATHLEN - strlen(name) - strlen(L2TP_NKE) - 1);
                    CFRelease(url);
                    strlcat(name, "/", sizeof(name));
                    strlcat(name, L2TP_NKE, sizeof(name));
#if !TARGET_OS_EMBEDDED // This file is not built for Embedded
                    if (!load_kext(name, 0))
#else
                    if (!load_kext(L2TP_NKE_ID, 1))
#endif
                        while ((listen_sockfd = socket(PF_PPP, SOCK_DGRAM, PPPPROTO_L2TP)) < 0)
                            if (errno != EINTR)
                                break;
                }	
            }
            if (listen_sockfd < 0) {
                vpnlog(LOG_ERR, "L2TP plugin: Unable to load L2TP kernel extension\n");
                return -1;
            }
        }
    }
    
#if !TARGET_OS_EMBEDDED // This file is not built for Embedded
	/* increase the number of threads for l2tp to nb cpus - 1 */
    len = sizeof(int); 
	sysctlbyname("hw.ncpu", &nb_cpu, &len, NULL, 0);
    if (nb_cpu > 1) {
		sysctlbyname("net.ppp.l2tp.nb_threads", &nb_threads, &len, 0, 0);
		if (nb_threads < (nb_cpu - 1)) {
			nb_threads = nb_cpu - 1;
			sysctlbyname("net.ppp.l2tp.nb_threads", 0, 0, &nb_threads, sizeof(int));
		}
	}
#endif

    /* retain reference */
    bundle = ref;
    CFRetain(bundle);
    
    pppbundle = pppref;
    if (pppbundle)
        CFRetain(pppbundle);
            
    // hookup our socket handlers
    bzero(the_vpn_channel, sizeof(struct vpn_channel));
    the_vpn_channel->get_pppd_args = l2tpvpn_get_pppd_args;
    the_vpn_channel->listen = l2tpvpn_listen;
    the_vpn_channel->accept = l2tpvpn_accept;
    the_vpn_channel->refuse = l2tpvpn_refuse;
    the_vpn_channel->close = l2tpvpn_close;
    the_vpn_channel->health_check = l2tpvpn_health_check;
    the_vpn_channel->lb_redirect = l2tpvpn_lb_redirect;

    return 0;
}