Lines Matching refs:ctx
70 const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
74 if (ctx == NULL || directory == NULL) {
80 if (*ctx == NULL) {
81 *ctx = (LP_DIR_CTX *)malloc(sizeof(LP_DIR_CTX));
82 if (*ctx == NULL) {
86 memset(*ctx, '\0', sizeof(LP_DIR_CTX));
88 (*ctx)->dir = opendir(directory);
89 if ((*ctx)->dir == NULL) {
91 free(*ctx);
92 *ctx = NULL;
98 direntry = readdir((*ctx)->dir);
103 strncpy((*ctx)->entry_name, direntry->d_name,
104 sizeof((*ctx)->entry_name) - 1);
105 (*ctx)->entry_name[sizeof((*ctx)->entry_name) - 1] = '\0';
106 return (*ctx)->entry_name;
109 int LP_find_file_end(LP_DIR_CTX **ctx)
111 if (ctx != NULL && *ctx != NULL) {
112 int ret = closedir((*ctx)->dir);
114 free(*ctx);