Home | History | Annotate | Download | only in crypto

Lines Matching refs:ctx

50   WIN32_FIND_DATA ctx;
55 const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
59 if (ctx == NULL || directory == NULL)
66 if (*ctx == NULL)
68 *ctx = (LP_DIR_CTX *)malloc(sizeof(LP_DIR_CTX));
69 if (*ctx == NULL)
74 memset(*ctx, '\0', sizeof(LP_DIR_CTX));
85 free(*ctx);
86 *ctx = NULL;
97 (*ctx)->handle = FindFirstFile(wdir, &(*ctx)->ctx);
102 (*ctx)->handle = FindFirstFile((TCHAR *)directory, &(*ctx)->ctx);
104 if ((*ctx)->handle == INVALID_HANDLE_VALUE)
106 free(*ctx);
107 *ctx = NULL;
114 if (FindNextFile((*ctx)->handle, &(*ctx)->ctx) == FALSE)
122 TCHAR *wdir = (*ctx)->ctx.cFileName;
125 while (wdir[len_0] && len_0 < (sizeof((*ctx)->entry_name) - 1)) len_0++;
129 if (!WideCharToMultiByte(CP_ACP, 0, (WCHAR *)wdir, len_0, (*ctx)->entry_name,
130 sizeof((*ctx)->entry_name), NULL, 0))
133 (*ctx)->entry_name[index] = (char)wdir[index];
136 strncpy((*ctx)->entry_name, (const char *)(*ctx)->ctx.cFileName,
137 sizeof((*ctx)->entry_name)-1);
139 (*ctx)->entry_name[sizeof((*ctx)->entry_name)-1] = '\0';
141 return (*ctx)->entry_name;
144 int LP_find_file_end(LP_DIR_CTX **ctx)
146 if (ctx != NULL && *ctx != NULL)
148 FindClose((*ctx)->handle);
149 free(*ctx);
150 *ctx = NULL;