]> Shamusworld >> Repos - rln/blobdiff - rln.c
Patch to add -y option.
[rln] / rln.c
diff --git a/rln.c b/rln.c
index a117a86b27fc2e75fa0e4beb1ddf22230e4f57a3..43678377824ec1dcbbae5a3f07db49f8ac9deb20 100644 (file)
--- a/rln.c
+++ b/rln.c
@@ -2448,7 +2448,8 @@ int LoadArchive(char * fname, int fd)
                }
 
                // Check to see if a long filename was requested
-               if (objName[0] == 0x20)
+               // N.B.: " " is for GNU archives, and "/" is for BSD archives
+               if ((objName[0] == 0x20) || (objName[0] == '/'))
                {
                        uint32_t fnSize = atoi(objName + 1);
 
@@ -2976,6 +2977,22 @@ int doargs(int argc, char * argv[])
 
                                wflag = 1;
                                break;
+                       case 'y':
+                       case 'Y':
+                               if (i >= argc)
+                               {
+                                       printf("No directory filename following -y switch\n");
+                                       return 1;
+                               }
+
+                               if (strlen(argv[i]) > FARGSIZE * 3)
+                               {
+                                       printf("Directory file name too long (sorry!)\n");
+                                       return 1;
+                               }
+
+                               strcpy(libdir, argv[i++]);
+                               break;
                        case 'z':
                        case 'Z':                                       // Suppress banner flag
                                if (zflag)
@@ -3114,6 +3131,21 @@ int main(int argc, char * argv[])
                ExitLinker();
        }
 
+       // Check to see if include paths actually exist
+       if (strlen(libdir) > 0)
+       {
+               DIR * test = opendir(libdir);
+
+               if (test == NULL)
+               {
+                       printf("Invalid include path: %s\n", libdir);
+                       errflag = 1;
+                       ExitLinker();
+               }
+
+               closedir(test);
+       }
+
        if (!zflag && !vflag)
        {
                ShowVersion();                          // Display version information