home *** CD-ROM | disk | FTP | other *** search
/ APDL Public Domain 1 / APDL_PD1A.iso / program / assembler / as / src / c / riscos < prev    next >
Encoding:
Text File  |  1992-07-30  |  3.0 KB  |  118 lines

  1. /*
  2.  * riscos.c
  3.  * Copyright © 1992 Niklas Röjemo
  4.  */
  5.  
  6. #include <stdio.h>
  7. #include <string.h>
  8. #include <stdlib.h>
  9. #include "error.h"
  10. #include "riscos.h"
  11.  
  12. char *toriscos(char *name, char *oldsuffixes, char newsuffix)
  13. {
  14.   char *suf,*last;
  15.  
  16.   if((suf = strrchr(name,'.')) == 0) {
  17.     if(newsuffix != 'o')
  18.       error(ErrorError,TRUE,"Missing suffix/prefix in %s.",name);
  19.   } else if(strchr(oldsuffixes,suf[1]) != 0 && suf[2] == 0) { /* Unix style name.[so] */
  20.     last = strrchr(name,0); /* End of file name */
  21.     while(--suf >= name && *suf != '.')
  22.       *--last = *suf;   
  23.     suf[1] = newsuffix;
  24.     suf[2] = '.';
  25.   } else if(suf > name && strchr(oldsuffixes,suf[-1]) != 0 && (suf == name+1 || suf[-2] == '.')) {
  26.         suf[-1] = newsuffix;     /* RISC/OS style name s.name */
  27.   } else
  28.     if(newsuffix != 'o')
  29.       error(ErrorWarning,TRUE,"File %s is not an assembler file (s.name or name.s)",name);
  30.  
  31.   return name;
  32. }
  33.  
  34.  
  35.  
  36.  
  37. #define OS_FSControl                 0x29
  38. #define DDEUtils_ThrowbackRegister   0x42585
  39. #define DDEUtils_ThrowbackUnRegister 0x42586
  40. #define DDEUtils_ThrowbackStart      0x42587
  41. #define DDEUtils_ThrowbackSend       0x42588
  42. #define DDEUtils_ThrowbackEnd        0x42580
  43. #define Throwback_ReasonProcessing     0
  44. #define Throwback_ReasonErrorDetails   1
  45. #define Throwback_ReasonInfoDetails    2
  46.  
  47.  
  48.  
  49. os_error *ThrowbackStart(void)
  50. {
  51.   return os_swi0(os_X|DDEUtils_ThrowbackStart);
  52. }
  53.  
  54. static char *ErrorFile;
  55.  
  56. os_error *ThrowbackSendStart(char *filename)
  57. {
  58.   ErrorFile = filename;
  59.   return os_swi3(os_X|DDEUtils_ThrowbackSend,
  60.                  Throwback_ReasonProcessing,0,(int)filename);
  61. }
  62.  
  63. os_error *ThrowbackSendError(int level,int lineno,char *error)
  64. {
  65.   if(level == ThrowbackInfo)
  66.     return os_swi6(os_X|DDEUtils_ThrowbackSend,
  67.                    Throwback_ReasonInfoDetails,0,(int)ErrorFile,
  68.                    lineno,0,(int)error);
  69.   else
  70.     return os_swi6(os_X|DDEUtils_ThrowbackSend,
  71.                    Throwback_ReasonErrorDetails,0,(int)ErrorFile,
  72.                    lineno,level,(int)error);
  73. }
  74.  
  75. os_error *ThrowbackEnd(void)
  76. {
  77.   return os_swi0(os_X|DDEUtils_ThrowbackEnd);
  78. }
  79.  
  80.  
  81. #define FSControl_CanonicalisePath   37
  82.  
  83.  
  84. int OSCanonicalisePath(char *path,
  85.                        char *buffer, int bufferSize,
  86.                        char *systemVar, char *defaultPath)
  87. {
  88.   int r0,r1,r2,r3,r4,r5;
  89.   os_swi6r(OS_FSControl,FSControl_CanonicalisePath,
  90.            (int)path,(int)buffer,(int)systemVar,(int)defaultPath,bufferSize,
  91.            &r0,&r1,&r2,&r3,&r4,&r5);
  92.   return r5;
  93. }
  94.  
  95. static char filename[1024];
  96. extern int dde;
  97.  
  98. char *CanonicalisePath(char *path)
  99. {
  100.   int size;
  101.   char *buffer;
  102.   if(dde && *path == '@') { /* Replace @ with <Prefix$Dir> if dde flags */
  103.     strcpy(filename,"<Prefix$Dir>");
  104.     strcat(filename,path+1);
  105.   } else {
  106.     strcpy(filename,path);
  107.   }
  108.   size = 1-OSCanonicalisePath(filename,0,0,0,0);
  109.   buffer = malloc(size);
  110.   size = OSCanonicalisePath(filename,buffer,size,0,0);
  111.   if(size != 1) {
  112.     error(ErrorAbort,TRUE,"Internal error in CanonicalisePath (%d).",size);
  113.     exit(-1);
  114.   }
  115.   return buffer;
  116. }
  117.  
  118.