Rev 6446 | Rev 6618 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6446 | Rev 6447 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #define _MAIN_ |
1 | #define _MAIN_ |
Line 2... | Line 2... | ||
2 | 2 | ||
- | 3 | #ifdef _UNIX_ |
|
- | 4 | #define DIV_PATH ':' //äåëèòåëü ïóòåé â ïåðåìåííîé îêðóæåíèÿ PATH |
|
- | 5 | #define DIV_FOLD '/' //ýòèì ñèìâîëîì ðàçäåëÿþòñÿ ïàïêè â ïóòè ê ôàéëó |
|
- | 6 | #endif |
|
- | 7 | ||
3 | #ifdef _UNIX_ |
8 | #ifdef _WIN32_ |
- | 9 | #define DIV_PATH ';' |
|
4 | #define DIV_PATH ':' |
10 | #define DIV_FOLD '\\' |
- | 11 | #endif |
|
- | 12 | ||
5 | #else |
13 | #ifdef _KOS_ |
- | 14 | #define DIV_PATH ';' |
|
6 | #define DIV_PATH ';' |
15 | #define DIV_FOLD '/' |
Line 7... | Line 16... | ||
7 | #endif |
16 | #endif |
8 | 17 | ||
9 | #include |
18 | #include |
Line 23... | Line 32... | ||
23 | char *stubfile=NULL; |
32 | char *stubfile=NULL; |
24 | char *winstub=NULL; |
33 | char *winstub=NULL; |
25 | FILE *hout=NULL; |
34 | FILE *hout=NULL; |
26 | char *namestartupfile="startup.h--"; |
35 | char *namestartupfile="startup.h--"; |
Line 27... | Line -... | ||
27 | - | ||
28 | 36 | ||
29 | char outext[4]="com"; |
37 | char outext[4]="com"; |
30 | short extflag=TRUE;//ðàñøèðåíèå ìîæíî ïðèñâîèòü |
38 | short extflag=TRUE;//ðàñøèðåíèå ìîæíî ïðèñâîèòü |
31 | //int scrsize; |
39 | //int scrsize; |
32 | unsigned char gwarning=FALSE; |
40 | unsigned char gwarning=FALSE; |
Line 230... | Line 238... | ||
230 | 238 | ||
231 | int main(int argc,char *argv[]) |
239 | int main(int argc,char *argv[]) |
232 | { |
240 | { |
233 | int count; |
241 | int count; |
- | 242 | unsigned char pari=FALSE; |
|
Line 234... | Line 243... | ||
234 | unsigned char pari=FALSE; |
243 | char *buffer; |
Line 235... | Line 244... | ||
235 | 244 | ||
236 | printf("\nSPHINX C-- Compiler Version %d.%d%s %s\r\n",ver1,ver2,betta,__DATE__); |
245 | printf("\nSPHINX C-- Compiler Version %d.%d%s %s\r\n",ver1,ver2,betta,__DATE__); |
Line 241... | Line 250... | ||
241 | bufstr=(char *)MALLOC(SIZEBUF); |
250 | bufstr=(char *)MALLOC(SIZEBUF); |
242 | output=(unsigned char *)MALLOC((size_t)MAXDATA); |
251 | output=(unsigned char *)MALLOC((size_t)MAXDATA); |
243 | outputdata=output; |
252 | outputdata=output; |
244 | postbuf=(postinfo *)MALLOC(MAXPOSTS*sizeof(postinfo)); |
253 | postbuf=(postinfo *)MALLOC(MAXPOSTS*sizeof(postinfo)); |
245 | strcpy((char *)string,argv[0]); |
254 | strcpy((char *)string,argv[0]); |
246 | rawext=strrchr((char *)string,'\\'); |
255 | rawext=strrchr((char *)string,DIV_FOLD); |
Line 247... | Line 256... | ||
247 | 256 | ||
248 | if(rawext!=NULL){ |
257 | if(rawext!=NULL){ |
249 | rawext[0]=0; |
258 | rawext[0]=0; |
250 | IncludePath((char *)string); |
259 | IncludePath((char *)string); |
Line 254... | Line 263... | ||
254 | 263 | ||
255 | rawfilename=rawext=NULL; |
264 | rawfilename=rawext=NULL; |
Line 256... | Line 265... | ||
256 | LoadIni("c--.ini"); |
265 | LoadIni("c--.ini"); |
257 | 266 | ||
- | 267 | for(count=1;count |
|
258 | for(count=1;count |
268 | //if(argv[count][0]=='/'||argv[count][0]=='-'){ |
259 | if(argv[count][0]=='/'||argv[count][0]=='-'){ |
269 | if(argv[count][0]=='-'){ |
260 | if(SelectComand(argv[count]+1,&count)==c_end) BadCommandLine(argv[count]); |
270 | if(SelectComand(argv[count]+1,&count)==c_end) BadCommandLine(argv[count]); |
261 | } |
271 | } |
262 | else{ |
272 | else{ |
263 | if(pari==FALSE){ |
273 | if(pari==FALSE){ |
264 | rawfilename=argv[count]; |
274 | rawfilename=argv[count]; |
265 | pari=TRUE; |
275 | pari=TRUE; |
266 | if((rawext=strrchr(rawfilename,'.'))!=NULL){ |
276 | if((rawext=strrchr(rawfilename,'.'))!=NULL){ |
267 | if(stricmp(rawext,".ini")==0){ //óêàçàí ini ôàéë |
277 | if(stricmp(rawext,".ini")==0){ //óêàçàí ini ôàéë |
268 | rawfilename=NULL; |
278 | rawfilename=NULL; |
269 | rawext=NULL; |
279 | rawext=NULL; |
270 | //LoadIni(argv[count]); |
280 | LoadIni(argv[count]); |
271 | if(rawfilename==NULL)pari=FALSE; |
281 | if(rawfilename==NULL)pari=FALSE; |
272 | } |
282 | } |
273 | else{ |
283 | else{ |
Line 1047... | Line 1057... | ||
1047 | { |
1057 | { |
1048 | FILE *inih; |
1058 | FILE *inih; |
1049 | char m1[256]; |
1059 | char m1[256]; |
Line 1050... | Line 1060... | ||
1050 | 1060 | ||
1051 | // load name |
- | |
1052 | //printf("pth: %s\r\n",name); |
1061 | // load name |
1053 | //if (inih = fopen(name,"rb")) |
1062 | if (inih = fopen(name,"rb")) |
Line 1054... | Line 1063... | ||
1054 | //{_loadIni(inih);return;} |
1063 | {_loadIni(inih);return;} |
1055 | 1064 | ||
Line 1056... | Line 1065... | ||
1056 | //if(strcmp(name,"c--.ini")!=0) |
1065 | if(strcmp(name,"c--.ini")!=0) |
1057 | // return; |
1066 | return; |
1058 | 1067 | ||
1059 | //load findpath[0]\c--.ini |
1068 | //load findpath[0]\c--.ini |
1060 | /*if (findpath[0]!=0) |
- | |
1061 | { |
1069 | if (findpath[0]!=0) |
1062 | sprintf(m1,"%s\\%s",findpath[0],name); |
1070 | { |
1063 | printf("pth: %s\r\n",m1); |
- | |
- | 1071 | sprintf(m1,"%s%s",findpath[0],name); |
|
1064 | if (inih = fopen(m1,"rb")) |
1072 | if (inih = fopen(m1,"rb")) |
1065 | {_loadIni(inih);return;} |
1073 | {_loadIni(inih);return;} |
1066 | } //http://android-films.net/download4/iz_mashiny_mp4_480x320_android-films.net.torrent |
1074 | } |
1067 | //load PATH[i=0..end]/c--.ini |
1075 | //load PATH[i=0..end]/c--.ini |
1068 | char* pth = 0;//getenv("PATH"); |
1076 | char* pth = getenv("PATH"); |
1069 | if (pth != 0) |
1077 | if (pth != 0) |
1070 | { |
1078 | { |
Line 1076... | Line 1084... | ||
1076 | size = 0; |
1084 | size = 0; |
1077 | char* endp = strchr(start, DIV_PATH); |
1085 | char* endp = strchr(start, DIV_PATH); |
1078 | size = (endp == 0)? strlen(start): endp-start; |
1086 | size = (endp == 0)? strlen(start): endp-start; |
1079 | strncpy(m1, start, size); |
1087 | strncpy(m1, start, size); |
1080 | start += size + 1; |
1088 | start += size + 1; |
1081 | if ((m1[size - 1] != '/') && (m1[size - 1] != '\\')) |
1089 | if (m1[size - 1] != DIV_FOLD) |
1082 | m1[size++] = '/'; |
1090 | m1[size++] = '/'; |
Line 1083... | Line 1091... | ||
1083 | 1091 | ||
1084 | strcpy(m1 + size,"c--.ini"); |
- | |
1085 | printf("pth: %s\r\n",m1); |
1092 | strcpy(m1 + size,"c--.ini"); |
1086 | if (inih = fopen(m1,"rb")) |
1093 | if (inih = fopen(m1,"rb")) |
1087 | {_loadIni(inih);return;} |
1094 | {_loadIni(inih);return;} |
1088 | } |
1095 | } |
1089 | } |
1096 | } |
Line 1095... | Line 1102... | ||
1095 | while ((*(m1+p)!='/') && (p != 0)) |
1102 | while ((*(m1+p)!='/') && (p != 0)) |
1096 | p--; |
1103 | p--; |
1097 | if (p){ |
1104 | if (p){ |
1098 | p++; |
1105 | p++; |
1099 | strcpy(m1+p,"c--.ini"); |
1106 | strcpy(m1+p,"c--.ini"); |
1100 | printf("pth: %s\r\n",m1); |
- | |
1101 | //if (inih = fopen(m1,"rb")) |
1107 | if (inih = fopen(m1,"rb")) |
1102 | //{_loadIni(inih);return;} |
1108 | {_loadIni(inih);return;} |
1103 | } |
1109 | } |
1104 | */ //for KolibriOS: load /rd/0/settings/c--.ini |
1110 | //for KolibriOS: load /rd/0/settings/c--.ini |
1105 | inih = fopen("/rd/1/settings/c--.ini","rb"); |
1111 | inih = fopen("/rd/1/settings/c--.ini","rb"); |
1106 | //for(;;){ |
1112 | for(;;){ |
1107 | // if(fgets(m1,255,inih)==NULL)break; |
1113 | if(fgets(m1,255,inih)==NULL)break; |
1108 | // if(SelectComand(m1,0)==c_end)BadCommandLine(m1); |
1114 | if(SelectComand(m1,0)==c_end)BadCommandLine(m1); |
1109 | //} |
1115 | } |
1110 | fclose(inih); |
1116 | fclose(inih); |
1111 | //return; |
1117 | return; |
1112 | //#endif //_KOS_ |
1118 | #endif //_KOS_ |
1113 | } |
1119 | } |
Line 1114... | Line 1120... | ||
1114 | 1120 | ||
1115 | /***************************************************************************** |
1121 | /***************************************************************************** |
1116 | * .NAME : MALLOC |
1122 | * .NAME : MALLOC |
Line 1144... | Line 1150... | ||
1144 | return mem; |
1150 | return mem; |
1145 | } |
1151 | } |
Line 1146... | Line 1152... | ||
1146 | 1152 | ||
1147 | void IncludePath(char *buf) |
1153 | void IncludePath(char *buf) |
- | 1154 | { |
|
- | 1155 | char divfold[3]; |
|
1148 | { |
1156 | sprintf(divfold,"%c",DIV_FOLD); |
1149 | if(numfindpath |
1157 | if(numfindpath |
1150 | int len=strlen(buf); |
1158 | int len=strlen(buf); |
1151 | if(buf[len-1]=='\\')buf[len-1]=0; |
1159 | if(buf[len-1]==DIV_FOLD)buf[len-1]=0; |
1152 | else len++; |
1160 | else len++; |
1153 | char *a=(char *)MALLOC(len+1); |
1161 | char *a=(char *)MALLOC(len+1); |
1154 | strcpy(a,buf); |
1162 | strcpy(a,buf); |
1155 | strcat(a,"\\"); |
1163 | strcat(a,divfold); |
1156 | findpath[numfindpath]=a; |
1164 | findpath[numfindpath]=a; |
1157 | numfindpath++; |
1165 | numfindpath++; |
1158 | findpath[numfindpath]=""; |
1166 | findpath[numfindpath]=""; |
1159 | } |
1167 | } |