int main(int argc, char **argv) { int i; t_option_struct option_struct; i = 0; option_struct.pathname = malloc(sizeof(char*)); option_struct.pathname[0] = NULL; if (get_option(argc, argv, &option_struct) == 1) { my_printf("\nmy_ls: invalid option\n"); return (1); } if (option_struct.pathname[0] != NULL) while (option_struct.pathname[i] != NULL) { my_printf("\n%s:\n", option_struct.pathname[i]); get_files_list(option_struct.pathname[i], &option_struct); if (option_struct.R == 1) recursivity(option_struct.pathname[i], &option_struct); i++; } else { get_files_list(".", &option_struct); if (option_struct.R == 1) recursivity(".", &option_struct); } return (0); }
int CMakeAstDebugVisitor::walk(const QString& filename, const CMakeFileContent & fc, int line) { kDebug(9042) << "-----------------------------------------------------------"; kDebug(9042) << "Walking file:" << filename; CMakeFileContent::const_iterator it=fc.constBegin()+line, itEnd=fc.constEnd(); for(; it!=itEnd; ) { Q_ASSERT( line<fc.count() ); Q_ASSERT( line>=0 ); // kDebug(9042) << "@" << line; // kDebug(9042) << it->writeBack() << "==" << fc[line].writeBack(); Q_ASSERT( *it == fc[line] ); // kDebug(9042) << "At line" << line << "/" << fc.count(); CMakeAst* element = AstFactory::self()->createAst(it->name); if(!element) { element = new MacroCallAst; } CMakeFunctionDesc func = *it; QString funcName=func.name; bool correct = element->parseFunctionInfo(func); if(!correct) { kDebug(9042) << "error! found an error while processing" << func.writeBack() << "was" << it->writeBack() << endl << " at" << func.filePath << ":" << func.line << endl; //FIXME: Should avoid to run } RecursivityType r = recursivity(funcName); if(r==End) { // kDebug(9042) << "Found an end." << func.writeBack(); delete element; return line; } if(element->isDeprecated()) kDebug(9042) << "Warning: Using the function: " << funcName << " which is deprecated by cmake."; element->setContent(fc, line); int lines=element->accept(this); line+=lines; it+=lines; delete element; } kDebug(9042) << "Walk stopped @" << line; kDebug(9042) << "-----------------------------------------------------------"; return line; }
int recursivity(char *pathname,t_option_struct *option_struct) { DIR *dirp; struct dirent *entry; char *new_pathname; if ((dirp = opendir(pathname)) == NULL) return (1); while ((entry = readdir(dirp)) != NULL) { if (entry->d_name[0] != '.' && entry->d_type == 4) { new_pathname = add_str_m(pathname, entry->d_name); my_printf("\n%s:\n", new_pathname); get_files_list(new_pathname, option_struct); recursivity(new_pathname, option_struct); free(new_pathname); } } closedir(dirp); return(0); }