void pyepg_init ( void ) { char buf[256]; RB_INIT(&_pyepg_channels); /* Internal module */ if (find_exec("pyepg", buf, sizeof(buf)-1)) epggrab_module_int_create(NULL, "pyepg-internal", "PyEPG", 4, buf, NULL, _pyepg_parse, NULL, NULL); /* External module */ _pyepg_module = (epggrab_module_t*) epggrab_module_ext_create(NULL, "pyepg", "PyEPG", 4, "pyepg", _pyepg_parse, NULL, &_pyepg_channels); }
static void _xmltv_load_grabbers ( void ) { int outlen; size_t i, p, n; char *outbuf; char name[1000]; char *tmp, *tmp2 = NULL, *path; /* Load data */ outlen = spawn_and_store_stdout(XMLTV_FIND, NULL, &outbuf); /* Process */ if ( outlen > 0 ) { p = n = i = 0; while ( i < outlen ) { if ( outbuf[i] == '\n' || outbuf[i] == '\0' ) { outbuf[i] = '\0'; sprintf(name, "XMLTV: %s", &outbuf[n]); epggrab_module_int_create(NULL, &outbuf[p], name, 3, &outbuf[p], NULL, _xmltv_parse, NULL, NULL); p = n = i + 1; } else if ( outbuf[i] == '|' ) { outbuf[i] = '\0'; n = i + 1; } i++; } free(outbuf); /* Internal search */ } else if ((tmp = getenv("PATH"))) { tvhlog(LOG_DEBUG, "epggrab", "using internal grab search"); char bin[256]; char desc[] = "--description"; char *argv[] = { NULL, desc, NULL }; path = strdup(tmp); tmp = strtok_r(path, ":", &tmp2); while (tmp) { DIR *dir; struct dirent *de; struct stat st; if ((dir = opendir(tmp))) { while ((de = readdir(dir))) { if (strstr(de->d_name, XMLTV_GRAB) != de->d_name) continue; snprintf(bin, sizeof(bin), "%s/%s", tmp, de->d_name); if (epggrab_module_find_by_id(bin)) continue; if (stat(bin, &st)) continue; if (!(st.st_mode & S_IEXEC)) continue; if (!S_ISREG(st.st_mode)) continue; if ((outlen = spawn_and_store_stdout(bin, argv, &outbuf)) > 0) { if (outbuf[outlen-1] == '\n') outbuf[outlen-1] = '\0'; snprintf(name, sizeof(name), "XMLTV: %s", outbuf); epggrab_module_int_create(NULL, bin, name, 3, bin, NULL, _xmltv_parse, NULL, NULL); free(outbuf); } } closedir(dir); } tmp = strtok_r(NULL, ":", &tmp2); } free(path); } }