]> git.sur5r.net Git - cc65/blobdiff - src/ca65/macpack.c
Finished implemenation of commands to delete macros. Added the new commands to
[cc65] / src / ca65 / macpack.c
index a6ec607c140937d2527dd695d9483624fd322155..7efd9a56331b5bc94a1a8e8f6b094b63b2c28e31 100644 (file)
@@ -6,8 +6,8 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2005, Ullrich von Bassewitz                                      */
-/*                Rรถmerstrasse 52                                            */
+/* (C) 1998-2008, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                            */
 /*                D-70794 Filderstadt                                        */
 /* EMail:         uz@cc65.org                                                */
 /*                                                                           */
@@ -82,7 +82,7 @@ static StrBuf MacPackDir = STATIC_STRBUF_INITIALIZER;
 
 
 
-int MacPackFind (const char* Name)
+int MacPackFind (const StrBuf* Name)
 /* Find a macro package by name. The function will either return the id or
  * -1 if the package name was not found.
  */
@@ -90,7 +90,7 @@ int MacPackFind (const char* Name)
     int I;
 
     for (I = 0; I < MAC_COUNT; ++I) {
-        if (StrCaseCmp (Name, MacPackages[I].Name) == 0) {
+        if (SB_CompareStr (Name, MacPackages[I].Name) == 0) {
             /* Found */
             return I;
         }
@@ -102,9 +102,14 @@ int MacPackFind (const char* Name)
 
 
 
-void MacPackInsert (int Id)
-/* Insert the macro package with the given id in the input stream */
-{
+int MacPackInsert (int Id)
+/* Insert the macro package with the given id in the input stream. Returns
+ * true if the macro package was found and successfully inserted. Returns
+ * false otherwise.
+ */
+{                   
+    int RetCode;
+
     /* Check the parameter */
     CHECK (Id >= 0 && Id < MAC_COUNT);
 
@@ -116,6 +121,9 @@ void MacPackInsert (int Id)
         /* Insert the builtin package */
         NewInputData (MacPackages[Id].Package, 0);
 
+        /* Always successful */
+        RetCode = 1;
+
     } else {
 
         StrBuf Filename = AUTO_STRBUF_INITIALIZER;
@@ -127,24 +135,27 @@ void MacPackInsert (int Id)
         SB_Terminate (&Filename);
 
         /* Open the macro package as include file */
-        NewInputFile (SB_GetConstBuf (&Filename));
+        RetCode = NewInputFile (SB_GetConstBuf (&Filename));
 
         /* Destroy the contents of Filename */
-        DoneStrBuf (&Filename);
+        SB_Done (&Filename);
 
     }
+
+    /* Return the success code */
+    return RetCode;
 }
 
 
 
-void MacPackSetDir (const char* Dir)
+void MacPackSetDir (const StrBuf* Dir)
 /* Set a directory where files for macro packages can be found. Standard is
  * to use the builtin packages. For debugging macro packages, external files
  * can be used.
  */
 {
     /* Copy the directory name to the buffer */
-    SB_CopyStr (&MacPackDir, Dir);
+    SB_Copy (&MacPackDir, Dir);
 
     /* Make sure that the last character is a path delimiter */
     if (SB_NotEmpty (&MacPackDir)) {