Lines Matching defs:ctx
85 const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
89 if (ctx == NULL || directory == NULL) {
95 if (*ctx == NULL) {
96 *ctx = malloc(sizeof(**ctx));
97 if (*ctx == NULL) {
101 memset(*ctx, 0, sizeof(**ctx));
108 (*ctx)->expect_file_generations = 1;
112 (*ctx)->dir = opendir(directory);
113 if ((*ctx)->dir == NULL) {
115 free(*ctx);
116 *ctx = NULL;
123 strncpy((*ctx)->previous_entry_name, (*ctx)->entry_name,
124 sizeof((*ctx)->previous_entry_name));
129 direntry = readdir((*ctx)->dir);
134 OPENSSL_strlcpy((*ctx)->entry_name, direntry->d_name,
135 sizeof((*ctx)->entry_name));
137 if ((*ctx)->expect_file_generations) {
138 char *p = (*ctx)->entry_name + strlen((*ctx)->entry_name);
140 while(p > (*ctx)->entry_name && isdigit(p[-1]))
142 if (p > (*ctx)->entry_name && p[-1] == ';')
144 if (OPENSSL_strcasecmp((*ctx)->entry_name,
145 (*ctx)->previous_entry_name) == 0)
149 return (*ctx)->entry_name;
152 int LP_find_file_end(LP_DIR_CTX **ctx)
154 if (ctx != NULL && *ctx != NULL) {
155 int ret = closedir((*ctx)->dir);
157 free(*ctx);