home *** CD-ROM | disk | FTP | other *** search
- /*
- * riscos.c
- * Copyright © 1992 Niklas Röjemo
- */
-
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include "error.h"
- #include "riscos.h"
-
- char *toriscos(char *name, char *oldsuffixes, char newsuffix)
- {
- char *suf,*last;
-
- if((suf = strrchr(name,'.')) == 0) {
- if(newsuffix != 'o')
- error(ErrorError,TRUE,"Missing suffix/prefix in %s.",name);
- } else if(strchr(oldsuffixes,suf[1]) != 0 && suf[2] == 0) { /* Unix style name.[so] */
- last = strrchr(name,0); /* End of file name */
- while(--suf >= name && *suf != '.')
- *--last = *suf;
- suf[1] = newsuffix;
- suf[2] = '.';
- } else if(suf > name && strchr(oldsuffixes,suf[-1]) != 0 && (suf == name+1 || suf[-2] == '.')) {
- suf[-1] = newsuffix; /* RISC/OS style name s.name */
- } else
- if(newsuffix != 'o')
- error(ErrorWarning,TRUE,"File %s is not an assembler file (s.name or name.s)",name);
-
- return name;
- }
-
-
-
-
- #define OS_FSControl 0x29
- #define DDEUtils_ThrowbackRegister 0x42585
- #define DDEUtils_ThrowbackUnRegister 0x42586
- #define DDEUtils_ThrowbackStart 0x42587
- #define DDEUtils_ThrowbackSend 0x42588
- #define DDEUtils_ThrowbackEnd 0x42580
- #define Throwback_ReasonProcessing 0
- #define Throwback_ReasonErrorDetails 1
- #define Throwback_ReasonInfoDetails 2
-
-
-
- os_error *ThrowbackStart(void)
- {
- return os_swi0(os_X|DDEUtils_ThrowbackStart);
- }
-
- static char *ErrorFile;
-
- os_error *ThrowbackSendStart(char *filename)
- {
- ErrorFile = filename;
- return os_swi3(os_X|DDEUtils_ThrowbackSend,
- Throwback_ReasonProcessing,0,(int)filename);
- }
-
- os_error *ThrowbackSendError(int level,int lineno,char *error)
- {
- if(level == ThrowbackInfo)
- return os_swi6(os_X|DDEUtils_ThrowbackSend,
- Throwback_ReasonInfoDetails,0,(int)ErrorFile,
- lineno,0,(int)error);
- else
- return os_swi6(os_X|DDEUtils_ThrowbackSend,
- Throwback_ReasonErrorDetails,0,(int)ErrorFile,
- lineno,level,(int)error);
- }
-
- os_error *ThrowbackEnd(void)
- {
- return os_swi0(os_X|DDEUtils_ThrowbackEnd);
- }
-
-
- #define FSControl_CanonicalisePath 37
-
-
- int OSCanonicalisePath(char *path,
- char *buffer, int bufferSize,
- char *systemVar, char *defaultPath)
- {
- int r0,r1,r2,r3,r4,r5;
- os_swi6r(OS_FSControl,FSControl_CanonicalisePath,
- (int)path,(int)buffer,(int)systemVar,(int)defaultPath,bufferSize,
- &r0,&r1,&r2,&r3,&r4,&r5);
- return r5;
- }
-
- static char filename[1024];
- extern int dde;
-
- char *CanonicalisePath(char *path)
- {
- int size;
- char *buffer;
- if(dde && *path == '@') { /* Replace @ with <Prefix$Dir> if dde flags */
- strcpy(filename,"<Prefix$Dir>");
- strcat(filename,path+1);
- } else {
- strcpy(filename,path);
- }
- size = 1-OSCanonicalisePath(filename,0,0,0,0);
- buffer = malloc(size);
- size = OSCanonicalisePath(filename,buffer,size,0,0);
- if(size != 1) {
- error(ErrorAbort,TRUE,"Internal error in CanonicalisePath (%d).",size);
- exit(-1);
- }
- return buffer;
- }
-
-