/* Changed to char type to return 1 on successful language detemrination, 0 otherwise * -- Robert */ char determine_language(char *filename, FILE *fd, int forcelang) { char * dot; dot = strrchr(filename, '.'); if (forcelang) { if (forcelang == LANG_PYTHON) setup_python(fd); else if (forcelang == LANG_C) setup_c(fd); else if (forcelang == LANG_PERL) setup_perl(fd); else if ( forcelang == LANG_PHP) setup_php(fd); else if ( forcelang == LANG_RUBY) setup_ruby(fd); return 1; } if (!dot) { if(flags |= RECURSIVE_FILE_SCAN) { /* Skip the file if there's no dot on a recurssive file scan */ return 0; } setup_c(fd); return 1; } if (!strcasecmp(dot, ".py")) setup_python(fd); else if (!strcasecmp(dot, ".pl") || !strcasecmp(dot, ".pm")) setup_perl(fd); else if (!strcasecmp(dot, ".php")) setup_php(fd); else if (!strcasecmp(dot, ".rb")) setup_ruby(fd); else if (!strcasecmp(dot, ".c")|| !strcasecmp(dot, ".c++")|| !strcasecmp(dot, ".cp")|| !strcasecmp(dot, ".cpp")|| !strcasecmp(dot, ".cc")|| !strcasecmp(dot, ".cxx")|| !strcasecmp(dot, ".c++")|| !strcasecmp(dot, ".C")|| !strcasecmp(dot, ".i")|| !strcasecmp(dot, ".ii")) { setup_c(fd); } /* For now, we skip it if it's not a match -- Robert */ else { return 0; } return 1; }
int main(int argc, char *argv[]) { // Set the python interpreter. setup_python(argc, argv); std::string filepath(argv[0]); // Get the path to the helper script. std::string helper_path; size_t path_end = filepath.find_last_of('\\'); if (path_end != std::string::npos) helper_path = filepath.substr(0, path_end + 1); helper_path += "wbadminhelper.py"; // Configures the execution of the script to take the same // parameters as this helper tool. Py_SetProgramName(argv[0]); PySys_SetArgv(argc, argv); // Executes the helper script. PyObject *pFileObject = PyFile_FromString(const_cast<char *>(helper_path.c_str()), "r"); PyRun_SimpleFileEx(PyFile_AsFile(pFileObject), "wbadminhelper.py", 1); finalize_python(); return 0; }
void __init chrp_find_bridges(void) { struct device_node *dev; int *bus_range; int len, index = -1; struct pci_controller *hose; unsigned int *dma; char *model, *machine; int is_longtrail = 0, is_mot = 0, is_pegasos = 0; struct device_node *root = find_path_device("/"); /* * The PCI host bridge nodes on some machines don't have * properties to adequately identify them, so we have to * look at what sort of machine this is as well. */ machine = get_property(root, "model", NULL); if (machine != NULL) { is_longtrail = strncmp(machine, "IBM,LongTrail", 13) == 0; is_mot = strncmp(machine, "MOT", 3) == 0; if (strncmp(machine, "Pegasos2", 8) == 0) is_pegasos = 2; else if (strncmp(machine, "Pegasos", 7) == 0) is_pegasos = 1; } for (dev = root->child; dev != NULL; dev = dev->sibling) { if (dev->type == NULL || strcmp(dev->type, "pci") != 0) continue; ++index; /* The GG2 bridge on the LongTrail doesn't have an address */ if (dev->n_addrs < 1 && !is_longtrail) { printk(KERN_WARNING "Can't use %s: no address\n", dev->full_name); continue; } bus_range = (int *) get_property(dev, "bus-range", &len); if (bus_range == NULL || len < 2 * sizeof(int)) { printk(KERN_WARNING "Can't get bus-range for %s\n", dev->full_name); continue; } if (bus_range[1] == bus_range[0]) printk(KERN_INFO "PCI bus %d", bus_range[0]); else printk(KERN_INFO "PCI buses %d..%d", bus_range[0], bus_range[1]); printk(" controlled by %s", dev->type); if (dev->n_addrs > 0) printk(" at %lx", dev->addrs[0].address); printk("\n"); hose = pcibios_alloc_controller(); if (!hose) { printk("Can't allocate PCI controller structure for %s\n", dev->full_name); continue; } hose->arch_data = dev; hose->first_busno = bus_range[0]; hose->last_busno = bus_range[1]; model = get_property(dev, "model", NULL); if (model == NULL) model = "<none>"; if (device_is_compatible(dev, "IBM,python")) { setup_python(hose, dev); } else if (is_mot || strncmp(model, "Motorola, Grackle", 17) == 0) { setup_grackle(hose); } else if (is_longtrail) { void __iomem *p = ioremap(GG2_PCI_CONFIG_BASE, 0x80000); hose->ops = &gg2_pci_ops; hose->cfg_data = p; gg2_pci_config_base = p; } else if (is_pegasos == 1) { setup_indirect_pci(hose, 0xfec00cf8, 0xfee00cfc); } else if (is_pegasos == 2) { setup_peg2(hose, dev); } else { printk("No methods for %s (model %s), using RTAS\n", dev->full_name, model); hose->ops = &rtas_pci_ops; } pci_process_bridge_OF_ranges(hose, dev, index == 0); /* check the first bridge for a property that we can use to set pci_dram_offset */ dma = (unsigned int *) get_property(dev, "ibm,dma-ranges", &len); if (index == 0 && dma != NULL && len >= 6 * sizeof(*dma)) { pci_dram_offset = dma[2] - dma[3]; printk("pci_dram_offset = %lx\n", pci_dram_offset); } } /* Do not fixup interrupts from OF tree on pegasos */ if (is_pegasos == 0) ppc_md.pcibios_fixup = chrp_pcibios_fixup; }