- errno = 0;
- if (*ctx == NULL)
- {
- size_t filespeclen = strlen(directory);
- char *filespec = NULL;
-
- if (filespeclen == 0)
- {
- errno = ENOENT;
- return 0;
- }
-
- /* MUST be a VMS directory specification! Let's estimate if it is. */
- if (directory[filespeclen-1] != ']'
- && directory[filespeclen-1] != '>'
- && directory[filespeclen-1] != ':')
- {
- errno = EINVAL;
- return 0;
- }
-
- filespeclen += 4; /* "*.*;" */
-
- if (filespeclen > NAMX_MAXRSS)
- {
- errno = ENAMETOOLONG;
- return 0;
- }
-
- *ctx = (LP_DIR_CTX *)malloc(sizeof(LP_DIR_CTX));
- if (*ctx == NULL)
- {
- errno = ENOMEM;
- return 0;
- }
- memset(*ctx, '\0', sizeof(LP_DIR_CTX));
-
- strcpy((*ctx)->filespec,directory);
- strcat((*ctx)->filespec,"*.*;");
+ errno = 0;
+ if (*ctx == NULL) {
+ size_t filespeclen = strlen(directory);
+ char *filespec = NULL;
+
+ if (filespeclen == 0) {
+ errno = ENOENT;
+ return 0;
+ }
+
+ /* MUST be a VMS directory specification! Let's estimate if it is. */
+ if (directory[filespeclen - 1] != ']'
+ && directory[filespeclen - 1] != '>'
+ && directory[filespeclen - 1] != ':') {
+ errno = EINVAL;
+ return 0;
+ }
+
+ filespeclen += 4; /* "*.*;" */
+
+ if (filespeclen > NAMX_MAXRSS) {
+ errno = ENAMETOOLONG;
+ return 0;
+ }
+
+ *ctx = malloc(sizeof(**ctx));
+ if (*ctx == NULL) {
+ errno = ENOMEM;
+ return 0;
+ }
+ memset(*ctx, 0, sizeof(**ctx));
+
+ strcpy((*ctx)->filespec, directory);
+ strcat((*ctx)->filespec, "*.*;");