Develop and Download Open Source Software

Browse Subversion Repository

Contents of /filemv/initial.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7 - (show annotations) (download)
Wed Jan 2 22:06:47 2008 UTC (16 years, 3 months ago) by tabasa
File MIME type: text/plain
File size: 33728 byte(s)


1
2 #include "defextern.h"
3
4 #ifndef STRICT
5 #define STRICT
6 #endif
7 #include <windows.h>
8 #include <iostream.h>
9 #include <fstream.h>
10 #include "resource.h"
11 #include "myfilemv.h"
12 #include "initial.h"
13 #include "file.h"
14 #include "main.h"
15 #include "edit.h"
16 #include "spi.h"
17 #include "paintflag.h"
18 #include "status.h"
19 #include "tab.h"
20 #include "mciplay.h"
21 #include "mode.h"
22
23 WORD GetListKeyCmd( UINT msg, WORD ky);
24 extern void AddListItem(HWND hList, char *szfname, int &iItemNo, int ,WORD);
25 extern char *GetTabPath(int num);
26 extern int GetItemCount(HWND hTab);
27 extern void AddTab(HWND hTab, char *name);
28
29
30
31 char cdir[MAX_PATH];
32 char buffer[BUFFER_LEN];
33 char buffer2[BUFFER_LEN];
34 char cmdline[BUFFER_LEN];
35 char initfile[]="filemv.ini";
36 char logfile[]="filemvlog.txt";
37 char ldirfile[]="filemvdir.txt";
38 char listfile[]="filemvlist.ini";
39 char hislfile[]="filemvhisL.ini";
40 char hisrfile[]="filemvhisR.ini";
41 char autofile[]="filemvauto.ini";
42 char keyfile[]="filemvkey.ini";
43 char keytxt[]="filemvkey.txt";
44 char initdirfile[MAX_PATH];
45 char listdirfile[MAX_PATH];
46 char hisldirfile[MAX_PATH];
47 char hisrdirfile[MAX_PATH];
48 char logdirfile[MAX_PATH];
49 char localdirfile[MAX_PATH];
50 char autodirfile[MAX_PATH];
51 char keydirfile[MAX_PATH];
52
53 char sendtoPath[MAX_PATH];
54
55 char picExts[ExtsLen]="jpg;gif;png";//jpg;png";//"jpg;jpeg;png"
56
57 char cmdstr[1000];
58 char defCmdstr[1000];
59
60 //�f�t�H���g���F���������g���q
61 #define extDefSpColor ""
62
63 char keymouseg[]="mouseTrans";
64 char keykey[]="key";
65 char keyenv[]="env";
66 char keywindow[]="setting";
67 char keystart[]="start";
68 char keyfilter[]="filter";
69 char keydirboth[]="dir set";
70 char keydirlocal[]="dir left";
71 char keydirremote[]="dir right";
72 char keycommand[]="command";
73 char keyhis[]="his";
74 int localdirnum;
75 int bothdirnum;
76 int remotedirnum;
77 int sendmenunum;
78 int findmenunum;
79
80 void setExtPaint(char *txt);
81
82
83
84 #define MAX_NAME 50
85 #define autofilesavemax 10
86 const int namenummax=50;
87 char namelist[namenummax][MAX_NAME];
88
89 DWORD keydic[8000];
90
91
92
93 // switch
94
95 class sw
96 {
97 BOOL fl;
98 char *key;
99 char name[60];
100 char *initfile;
101 public:
102 sw() { initfile =NULL; init(); };
103 sw(char *k, char *nam, BOOL f) {sw();load(k,nam,f);};
104 void init(){ setInit(initdirfile); setKey(keywindow); setFlag(TRUE); }; //default
105 void init(char *i, char *k){ setInit(i); setKey(k); setFlag(TRUE); }; //default
106 void load(char *k, char *nam, BOOL f) { setName(nam); setKey(k); setFlag(f); initfile=NULL; };
107 BOOL load(char *nam, BOOL f=FALSE)
108 {
109 setName(nam); setFlag(f);
110 return GetProfile();
111 };
112 void save(BOOL);
113 void save(char *);
114 char *getKey(){return key;};
115 char *getName(){return name;};
116 char *getInitfile(){return initfile;};
117 BOOL flag(){return fl;};
118 void setKey(char *cat) { key =cat;};
119 void setName(char *na) {sprintf(name, "%s", na);};
120 void setFlag(BOOL f) {fl =f; };
121 void flagSw() { fl = !fl; };
122 void setInit(char *f) { initfile =f; };
123 BOOL GetProfile() ;
124 };
125
126
127 void sw::save(BOOL f)
128 {
129 if(f) save("TRUE");
130 else save("FALSE");
131 }
132 void sw::save(char *val)
133 {
134 WritePrivateProfileString(key, name, val, initfile);
135 }
136
137
138 BOOL sw::GetProfile()
139 {
140 char newword[100];
141 if(fl) GetPrivateProfileString(key, name, "TRUE", newword, 100, initfile);
142 else GetPrivateProfileString(key, name, "FALSE", newword, 100, initfile);
143 if(strcmp(newword,"TRUE")==0) fl =TRUE;
144 else fl =FALSE;
145 return fl;
146 };
147
148
149
150 // switch string
151
152 class swstr : public sw
153 {
154 char str[MAX_PATH];
155 public:
156 swstr(){str[0]=0;};
157 BOOL loadstr(char *nam, BOOL f=FALSE)
158 {
159 setName(nam); setFlag(f);
160 return GetProfileStr();
161 };
162 BOOL loadstr(char *nam, char *deflt, BOOL f=FALSE)
163 {
164 setName(nam); setFlag(f);
165 if( ! GetProfileStr() ) setStr(deflt);
166 return TRUE;
167 };
168 BOOL GetProfileStr();
169 void saveStr(char*c);
170 void saveStr();
171 void setStr(char* s) {strcpy(str, s);};
172 char *getStr(){return str;};
173 };
174
175 void swstr::saveStr(char *s)
176 {
177 setStr(s);
178 saveStr();
179 };
180
181 void swstr::saveStr()
182 {
183 WritePrivateProfileString(getKey(), getName(), str, getInitfile());
184 };
185
186 BOOL swstr::GetProfileStr()
187 {
188 char buf[100];
189 GetPrivateProfileString(getKey(), getName(), "", buf, 100, getInitfile());
190 if(strlen(buf)==0)
191 {
192 //setStr(str);
193 setFlag(FALSE);
194 }
195 else
196 {
197 setFlag(TRUE);
198 strcpy(str, buf);
199 }
200 return flag();
201 };
202
203
204
205
206 swstr spipathStr;
207 swstr memoStr;
208 swstr memopathStr;
209 swstr picExtStr;
210 swstr fenrirStr;
211
212 sw autoeditSw;
213 sw editSw;
214 sw logSw;
215 sw wideSw;
216 sw paintSw;
217 sw columnheadSw;
218 sw maskSw;
219 sw mouseSw;
220 sw menuSw;
221 sw logDlgSw;
222 sw spipathSw;
223 sw clickpicSw;
224 sw mousegestureSw;
225
226 struct directory
227 {
228 int num;
229 char dir[MAX_PATH];
230 } stockdir;
231
232 int seed;
233 int sessionNum;
234
235 char *getFenrir()
236 {
237 return fenrirStr.getStr();
238 }
239
240
241 BOOL ishost(char *host)
242 {
243 BOOL flag=FALSE;
244 for (int i=0 ;i<sessionNum; i++)
245 {
246 if(strcmp(host,namelist[i])==0)
247 {
248 flag=TRUE;
249 break;
250 }
251 }
252 return flag;
253 }
254
255 // ----------------------------------
256 // �������t�H���_���`�F�b�N�����L�^
257
258 void savedirlocal(char *dir)
259 {
260 BOOL flag=FALSE;
261 ifstream in(localdirfile);
262 while(!in.eof())
263 {
264 in.getline(buffer,MAX_PATH);
265 if(in.gcount()==0) break;
266 if(strcmp(dir,buffer)==0)
267 {
268 flag=TRUE;
269 break;
270 }
271 }
272 in.close();
273 if(flag==FALSE)
274 {
275 ofstream ldir(localdirfile,ios::ate);
276 ldir<<dir<<endl;
277 }
278 }
279
280 void loaddirlocal(char *dir)
281 {
282 ifstream in(localdirfile);
283 stockdir.num++;
284 int n=stockdir.num;
285 while(1)
286 {
287 in.getline(buffer,MAX_PATH);//getline �I���q��������������
288 if(in.gcount()==0) break;
289 n--;
290 if(n<0) break;
291 }
292 if(n>=0)
293 {
294 stockdir.num=0;
295 }
296 else strcpy(dir,buffer);
297 }
298
299 char *gettimestr()
300 {
301 SYSTEMTIME st;
302 static char jikan[16];
303 char form[]="%04d%02d%02d%02d%02d%02d";
304
305 GetLocalTime(&st);
306 wsprintf(
307 jikan,
308 form,
309
310 st.wYear,
311 st.wMonth,
312 st.wDay,
313 st.wHour,
314 st.wMinute,
315 st.wSecond
316 );
317 return jikan;
318 }
319
320 void initlog(ofstream &log)
321 {
322 SYSTEMTIME st;
323 char jikan[16];
324 char form[]="%04d/%02d/%02d";
325
326 GetLocalTime(&st);
327 wsprintf(
328 jikan,
329 form,
330
331 st.wYear,
332 st.wMonth,
333 st.wDay
334 );
335 log.open(logdirfile,ios::ate);
336 if(logflag) log<<endl<<jikan<<endl;
337 }
338
339
340 void openinit()
341 {
342 ShellExecute(NULL, "open",editor,initdirfile, NULL, SW_SHOW);
343 }
344
345 void openkeyfile()
346 {
347 ShellExecute(NULL, "open",editor,keytxt, cdir, SW_SHOW);
348 }
349
350 void openinitdir()
351 {
352 ShellExecute(NULL, "open","explorer",cdir, NULL, SW_SHOW);
353 }
354
355 void initsessionnum()
356 {
357 sessionNum=0;
358 }
359
360 int getsessionNum()
361 {
362 return sessionNum;
363 }
364
365 void setseed(char *s)
366 {
367 for(int i= 0; i<5;i++)
368 {
369 seed += ((unsigned char*)s)[i];
370 }
371 seed =seed/ 5 +1;
372 }
373
374
375 //�J�����g�f�B���N�g��
376
377 void getini_cu()
378 {
379 GetCurrentDirectory(MAX_PATH,cdir);
380 wsprintf(initdirfile,"%s\\%s",cdir,initfile);
381 wsprintf(listdirfile,"%s\\%s",cdir,listfile);
382 wsprintf(logdirfile,"%s\\%s",cdir,logfile);
383 wsprintf(localdirfile,"%s\\%s",cdir,ldirfile);
384 wsprintf(autodirfile,"%s\\%s",cdir,autofile);
385 wsprintf(hisldirfile,"%s\\%s",cdir,hislfile);
386 wsprintf(hisrdirfile,"%s\\%s",cdir,hisrfile);
387 wsprintf(keydirfile,"%s\\%s",cdir,keyfile);
388 }
389
390 // �N���t�H���_
391
392 char *getCdir()
393 {
394 return cdir;
395 }
396
397
398 // spi�������t�H���_,
399 // spi path=...
400 // default���N���t�H���_
401
402 char *getSpiDir()
403 {
404 char *p =cdir;
405 if( spiPath ) p =spipathStr.getStr();
406 return p;
407 }
408
409
410 void setSpiPath(char *file)
411 {
412 *strrchr(file,'\\')=0;
413 SetCurrentDirectory( file);
414 GetCurrentDirectory( MAX_PATH, spipathStr.getStr());
415 spipathStr.saveStr();
416 Mes("Suzie Plug-in ���p�X��������������");
417 }
418
419
420 void savePicExts(char *s)
421 {
422 WritePrivateProfileString(keywindow, "pic ext", s, initdirfile);
423 }
424
425 // �}�E�X�W�F�X�`�����g��������
426
427 char mgStr[]="DRLUmMHh";
428
429 BOOL mgStrCheck(char *str)
430 {
431 for(int i=0; i<strlen(str); i++)
432 {
433 if(strchr(mgStr, str[i])==NULL) return FALSE;
434 }
435 return TRUE;
436 }
437
438 BOOL setMouseGesture(char *id, char *str)
439 {
440 //char s[10];
441 //sprintf(s, "%d",id);
442 if(!mgStrCheck(str)) return FALSE;
443 return WritePrivateProfileString(keymouseg, str, id, initdirfile);
444 }
445
446 void setPicExts(char *s)
447 {
448 strcpy(picExts, s);
449 }
450
451 char *getPicExts()
452 {
453 return picExts;
454 }
455
456
457 // aaa;bbb;ccc ��ddd;eee ����
458 void addPicExts(char *s)
459 {
460 strcat(picExts, ";");
461 strcat(picExts, s);
462 }
463
464
465 int gethostnum()
466 {
467 char key[4]="&\0\0";
468 char buffer[MAX_PATH];
469 ifstream in(listdirfile);
470 int ans=1;
471 do
472 {
473 in>>buffer;
474 if(buffer[0]==0 || in.eof()) break;
475 strncpy(namelist[ans-1],buffer,MAX_NAME);
476 if(ans<10) key[1]='0'+ans;
477 else if(ans<=35) key[1]='a'+ans-10;
478 else key[1]='-';
479 wsprintf(buffer,"%s. %s",key,namelist[ans-1]);
480 AppendMenu(hSessionMenu,MF_STRING,sessionIDBASE+ans-1,buffer);
481 ans++;
482 }
483 while (1);
484 return ans-1;
485 }
486
487 void savehostlist()
488 {
489 ofstream ou(listdirfile);
490 for(int i=0; i<namenummax ;i++)
491 {
492 if (namelist[i][0]!=0) ou<<namelist[i]<<endl;
493 }
494 }
495
496 void setlistbox(HWND &hdlg,UINT IDC)
497 {
498 for(int i=0; i<sessionNum && i<namenummax ; i++)
499 {
500 SendDlgItemMessage(hdlg,IDC,LB_ADDSTRING,0,(LPARAM)namelist[i]);
501 }
502 }
503
504
505
506
507 void getprofilepos( WINPOS *lpwinpos )
508 {
509 lpwinpos->x = GetPrivateProfileInt(keywindow, "x",0,initdirfile);
510 lpwinpos->y = GetPrivateProfileInt(keywindow, "y",0,initdirfile);
511 lpwinpos->wx = GetPrivateProfileInt(keywindow, "wx",0,initdirfile);
512 lpwinpos->wy = GetPrivateProfileInt(keywindow, "wy",0,initdirfile);
513 }
514
515 void SetSendTo()
516 {
517 char *p=getenv("userprofile");
518 if( p!=NULL )
519 {
520 wsprintf(sendtoPath, "%s\\SendTo", getenv("userprofile") );
521 }
522 else
523 {
524 wsprintf(sendtoPath, "%s", sendtoPath_0 );
525 }
526 }
527
528
529 void getprofiledir()
530 {
531 int i;
532 i=0;
533 bothdirnum=0;
534 while(1)
535 {
536 i++;
537 wsprintf(buffer,"%d name",i);
538 GetPrivateProfileString(keydirboth, buffer, "", buffer, MAX_PATH, initdirfile);
539 if(strcmp(buffer,"")==0) break;
540 AppendMenu(hBothMenu,MF_STRING,bothdirIDBASE+i-1,buffer);
541 bothdirnum++;
542 }
543 i=0;
544 localdirnum=0;
545 while(1)
546 {
547 i++;
548 wsprintf(buffer,"%d",i);
549 GetPrivateProfileString(keydirlocal, buffer, "", buffer, MAX_PATH, initdirfile);
550 if(strcmp(buffer,"")==0) break;
551 AppendMenu(hLeftMenu,MF_STRING,localdirIDBASE+i-1,buffer);
552 localdirnum++;
553 }
554 i=0;
555 remotedirnum=0;
556 while(1)
557 {
558 i++;
559 wsprintf(buffer,"%d",i);
560 GetPrivateProfileString(keydirremote, buffer, "", buffer, MAX_PATH, initdirfile);
561 if(strlen(buffer)==0) break;
562 AppendMenu(hRemoteMenu,MF_STRING,remotedirIDBASE+i-1,buffer);
563 remotedirnum++;
564 }
565 i=0;
566 findmenunum=0;
567 while(1)
568 {
569 i++;
570 wsprintf(buffer,"%d",i);
571 GetPrivateProfileString(keyfilter, buffer, "", buffer, MAX_PATH, initdirfile);
572 if(strlen(buffer)==0) break;
573 AppendMenu(hFindMenu,MF_STRING,findIDBASE+i-1,buffer);
574 findmenunum++;
575 }
576 i=0;
577 sendmenunum=0;
578 SetSendTo();
579 int ans =getnextfile(sendtoPath, "*", buffer, 0);
580
581 while(1)
582 {
583 if(strlen(buffer)==0) break;
584 if(ans == _FILE ) //folder
585 {
586 i++;
587 AppendMenu(hSendtoMenu,MF_STRING,sendIDBASE+i-1,buffer);
588 sendmenunum++;
589 }
590 ans =getnextfile(sendtoPath, "*", buffer, 1);
591 if(ans<0) break;
592 }
593 }
594
595 char *loadlastdir(int i)
596 {
597 static char buff[MAX_INFO];
598 wsprintf(buffer,"%d",i);
599 if(i==1) GetPrivateProfileString(keystart, buffer, cdir, buff, MAX_INFO, initdirfile);
600 else GetPrivateProfileString(keystart, buffer, "c:\\", buff, MAX_INFO, initdirfile);
601 return buff;
602 }
603
604 // �V�����f�B���N�g��������
605
606 void saveprofiledir(char *key, int *num, char *dir)
607 {
608 BOOL flag=TRUE;
609 char buff[MAX_PATH];
610 if(dir[0]=='\\') return;
611 //if(strcmp(dir,".")==0) return;
612
613 int i=0;
614 while(1)
615 {
616 i++;
617 wsprintf(buff,"%d",i);
618 GetPrivateProfileString(key, buff, "", buffer, MAX_PATH, initdirfile);
619 if(strcmp(buffer,dir)==0 )
620 {
621 flag=FALSE;
622 break;
623 }
624 if( strlen(buffer)==0 )
625 {
626 break;
627 }
628 }
629 if (flag==FALSE ) return;
630 (*num)++;
631 wsprintf(buff,"%d",*num);
632 WritePrivateProfileString(key, buff, dir, initdirfile);
633 }
634
635 void saveremotedir(char *dir)
636 {
637 saveprofiledir(keydirremote,&remotedirnum,dir);
638 }
639 void savelocaldir(int tab, char *dir)
640 {
641 if(tab == 1) saveprofiledir(keydirlocal,&localdirnum,dir);
642 else saveremotedir(dir);
643 }
644
645
646 static int his[2];
647 #define HISMAX 100
648
649 void hisInit()
650 {
651 GetPrivateProfileInt(keyhis, "now", his[tab_l-1], hisldirfile);
652 GetPrivateProfileInt(keyhis, "now", his[tab_r-1], hisrdirfile);
653 GetPrivateProfileString(keyhis, "now", "",buffer, MAX_PATH,hisldirfile);
654 sscanf(buffer ,"%d" ,&his[tab_l-1]);
655 GetPrivateProfileString(keyhis, "now", "",buffer, MAX_PATH,hisrdirfile);
656 sscanf(buffer ,"%d" ,&his[tab_r-1]);
657 initflag=TRUE;
658 }
659
660 void hisreset()
661 {
662 for(int i=0;i<2;i++) his[i]=1;
663 }
664
665 int readhispos(int tab)
666 {
667 char *file;
668 int no=0;
669 file = (tab==tab_r) ? hisrdirfile : hisldirfile;
670 return GetPrivateProfileInt(keyhis, "now", no, file);
671 }
672
673 int gethismax(int tab)
674 {
675 return readhispos(tab);
676 }
677
678 void writehispos(int tab, char *file)
679 {
680 wsprintf(buffer,"%d",his[tab-1]);
681 WritePrivateProfileString(keyhis, "now", buffer, file);
682 }
683
684 // ���������A���O��������������.
685 // ��������������his[]�������w��������
686
687 void savehisdir(int tab, char *dir)
688 {
689 if(!initflag) return;
690 if(tab<1 || tab>2) tab=1;
691 if(tab ==tab_l)
692 {
693 wsprintf(buffer,"%d",his[tab-1]-1);
694 GetPrivateProfileString(keyhis, buffer, "", buffer, MAX_PATH, hisldirfile);
695 if(strcmp(dir,buffer)==0) return;
696 wsprintf(buffer,"%d",his[tab-1]);
697 WritePrivateProfileString(keyhis, buffer, dir, hisldirfile);
698 writehispos(tab, hisldirfile);
699 }
700 if(tab ==tab_r)
701 {
702 wsprintf(buffer,"%d",his[tab-1]-1);
703 GetPrivateProfileString(keyhis, buffer, "", buffer, MAX_PATH, hisrdirfile);
704 if(strcmp(dir,buffer)==0) return;
705 wsprintf(buffer,"%d",his[tab-1]);
706 WritePrivateProfileString(keyhis, buffer, dir, hisrdirfile);
707 writehispos(tab, hisrdirfile);
708 }
709 his[tab-1]++;
710 if(his[tab-1]>100) his[tab-1]=1;
711 }
712
713 char *loadhisdir(int tab, char *dir, int pos)
714 {
715 if(tab<1 || tab>2) tab=1;
716 int po =his[tab-1]+pos-1;
717 if(po>HISMAX) his[tab-1] =1;
718 if(po<0) his[tab-1] =1;
719 else his[tab-1]=po;
720 wsprintf(buffer,"%d",his[tab-1]);
721 if(tab ==tab_l)
722 {
723 GetPrivateProfileString(keyhis, buffer, "", buffer, MAX_PATH, hisldirfile);
724 //if(pos<0) writehispos(tab, hisldirfile);
725 }
726 if(tab ==tab_r)
727 {
728 GetPrivateProfileString(keyhis, buffer, "", buffer, MAX_PATH, hisrdirfile);
729 //if(pos<0) writehispos(tab, hisrdirfile);
730 }
731 if(strlen(buffer)>0) wsprintf(dir,"%s",buffer);
732 his[tab-1]++;
733 return dir;
734 }
735
736 int getbothnum()
737 {
738 char buff[MAX_PATH];
739 int i =0;
740 while(1)
741 {
742 i++;
743 wsprintf(buff,"%d name",i);
744 GetPrivateProfileString(keydirboth, buff, "", buffer, MAX_PATH, initdirfile);
745 if( strlen(buffer)==0 )
746 {
747 break;
748 }
749
750 }
751 return i-1;
752 }
753
754 void loadbothdir(int num, char *ldir, char *rdir)
755 {
756 BOOL flag=TRUE;
757 char buff[MAX_PATH];
758
759 wsprintf(buff,"%d right", num);
760 GetPrivateProfileString(keydirboth, buff, "", rdir, MAX_PATH, initdirfile);
761 wsprintf(buff,"%d left", num);
762 GetPrivateProfileString(keydirboth, buff, "", ldir, MAX_PATH, initdirfile);
763
764 char *p = new char[MAX_PATH];
765 int tab=0;
766 while(1)
767 {
768 wsprintf(buff,"%d tab%d", num, tab);
769 GetPrivateProfileString(keydirboth, buff, "", p, MAX_PATH , initdirfile);
770 if(strlen(p)==0) break;
771 AddTab(hTab, p);
772 tab++;
773 }
774 delete p;
775 }
776
777 void loadhomebothdir(char *ldir, char *rdir)
778 {
779 char buff[MAX_PATH];
780
781 wsprintf(buff,"%s right", "home");
782 GetPrivateProfileString(keydirboth, buff, "", buff, MAX_PATH, initdirfile);
783 if(strlen(buff)==0) return;
784
785 wsprintf(buff,"%s right", "home");
786 GetPrivateProfileString(keydirboth, buff, "", rdir, MAX_PATH, initdirfile);
787 wsprintf(buff,"%s left", "home");
788 GetPrivateProfileString(keydirboth, buff, "", ldir, MAX_PATH, initdirfile);
789 }
790
791 void savehomebothdir(char *ldir, char *rdir)
792 {
793
794 BOOL flag=TRUE;
795 char buff[MAX_PATH];
796
797 wsprintf(buff,"%s right", "home");
798 WritePrivateProfileString(keydirboth, buff, rdir, initdirfile);
799 wsprintf(buff,"%s left", "home");
800 WritePrivateProfileString(keydirboth, buff, ldir, initdirfile);
801 }
802
803 void savebothdir(char *name, char *ldir, char *rdir)
804 {
805
806 BOOL flag=TRUE;
807 char buff[MAX_PATH];
808
809 if(strlen(name)==0) name=ldir;
810 int i=0;
811 i =getbothnum()+1;
812 wsprintf(buff,"%d name", i);
813 WritePrivateProfileString(keydirboth, buff, name, initdirfile);
814 wsprintf(buff,"%d right", i);
815 WritePrivateProfileString(keydirboth, buff, rdir, initdirfile);
816 wsprintf(buff,"%d left", i);
817 WritePrivateProfileString(keydirboth, buff, ldir, initdirfile);
818
819 for(int tab=0;tab<GetItemCount(hTab); tab++)
820 {
821 wsprintf(buff,"%d tab%d", i, tab);
822 WritePrivateProfileString(keydirboth, buff, GetTabPath(tab), initdirfile);
823 }
824 }
825
826 // �O���������A�b�v���[�h�t�@�C������������
827 // ���s���������A�b�v���[�h�t�@�C�������@shift �����A����
828
829 void AddAutofile(char *file)
830 {
831 char buff[MAX_PATH+1]="";
832 char buffer[10];
833 int i=autofilesavemax;
834
835 wsprintf(buffer,"%d",1);
836 GetPrivateProfileString("autofile", buffer, "", buff, MAX_PATH, autodirfile);
837 if( strcmp(file,buff)==0 ) return;
838
839 while(i>0)
840 {
841 wsprintf(buffer,"%d",i);
842 GetPrivateProfileString("autofile", buffer, "", buff, MAX_PATH, autodirfile);
843 if (strlen(buff)==0) break;
844 wsprintf(buffer,"%d",i+1);
845 WritePrivateProfileString("autofile", buffer, buff, autodirfile);
846 i--;
847 }
848 wsprintf(buff,"%d",1);
849 WritePrivateProfileString("autofile", buff, file, autodirfile);
850 }
851
852 BOOL SearchProfileString(char *key, char * str, char *file )
853 {
854 int num =0;
855 char buff[MAX_FILTER];
856 char buffer[10];
857
858 while(1)
859 {
860 num++;
861 wsprintf(buffer,"%d",num);
862 if( GetPrivateProfileString(key, buffer, "", buff, MAX_FILTER, file) ==0) break;
863 if(strcmp(buff, str)==0) return TRUE;
864 }
865 return FALSE;
866 }
867
868 int GetProfileNum(char *key, char *file)
869 {
870 int num =0;
871 char buff[MAX_PATH+1]="";
872 char buffer[10];
873
874 while(1)
875 {
876 num++;
877 wsprintf(buffer,"%d",num);
878 GetPrivateProfileString(key, buffer, "", buff, MAX_PATH, file);
879 if(buff[0]==0) break;
880 }
881 return num-1;
882 }
883
884
885 void GetAutoFile(int num, char *file)
886 {
887 char buff[MAX_PATH+1]="";
888 char buffer[10];
889
890 wsprintf(buffer,"%d",num);
891 GetPrivateProfileString("autofile", buffer, "", buff, MAX_PATH, autodirfile);
892 strncpy(file,buff,MAX_PATH);
893 }
894
895 // �}�E�X�W�F�X�`���������@�����@menu id ��
896 // DUD > 40000
897
898 WORD mgTrans(char *key)
899 {
900 if(key ==NULL) return 0;
901 return GetPrivateProfileInt("mouseTrans", key, 0, initdirfile);
902 }
903
904
905 // 40000 > DUD
906
907 char * mgTransRev(char *id)
908 {
909 static char key[1000];
910 key[0]=0;
911 char *p;
912 ifstream in(initdirfile, ios::nocreate);
913 while(in)
914 {
915 if(in.eof()) break;
916 in.getline(buffer,BUFFER_LEN);
917 if(strstr(buffer,"[mouseTrans]")==NULL) continue;
918 while(1)
919 {
920 if(in.eof()) break;
921 in.getline(buffer,BUFFER_LEN);
922 p =buffer;
923 if(strchr(buffer,'[')!=NULL) break;
924 p =strchr(buffer,'=');
925 if(p==NULL) continue;
926 *p =0;
927 p++;
928 if(strcmp(p,id)==0)
929 {
930 if(strlen(key)>0) strcat(key,",");
931 strcat(key,buffer);
932 }
933 }
934 }
935
936 return key;
937 }
938
939
940 #include "mouseg.h"
941
942 int menuMouse::init(HMENU hMenu, HMENU hMenu2, HMENU hMenu3)
943 {
944 menu[0] =hMenu;
945 menu[1] =hMenu2;
946 menu[2] =hMenu3;
947 num =::PrMenuList(hMenu,0);
948 return num;
949 };
950
951 WORD getkeybyId(UINT id)
952 {
953 //return 0;
954 WORD ans=0;
955 WORD i;
956 for(ans =8000; ans>0; ans--) {
957 i=GetListKeyCmd( 0,ans);
958 if(id ==i) break;
959 }
960 return ans;
961 }
962
963 int menuMouse::addlist(HWND list)
964 {
965 int num=0;
966 for(int m =0;m<3;m++)
967 {
968 for(WORD i=0;i<GetMenuItemCount(menu[m]);i++)
969 {
970 HMENU smenu=GetSubMenu(menu[m],i);
971 for(WORD i=0;i<GetMenuItemCount(smenu);i++)
972 {
973 UINT id=GetMenuItemID(smenu,i);
974 if(id>= MENU_MOUSEGESTURE_Len_MAX) continue;
975 WORD ky =getkeybyId(id);
976 GetMenuString(smenu, i, buffer, MAX_PATH,MF_BYPOSITION);
977 if(strlen(buffer)>0)
978 {
979 AddListItem( list, buffer, num, id, ky);
980 //num++;
981 }
982 }
983 }
984 }
985 return num;
986 };
987
988 int menuMouse::getNum()
989 {
990 return num;
991 };
992
993 int menuMouse::PrintList(HMENU hMenu)
994 {
995 num =::PrMenuList(hMenu,1);
996 return num;
997 };
998
999 menuMouse menuMg;
1000
1001 // menu�������t�@�C���������o��, �imode>0 ���������o���j
1002
1003 int PrMenuList(HMENU hMenu, int mode)
1004 {
1005 int num=0;
1006 ofstream ou;
1007 if(mode>0)
1008 {
1009 ou.open("menu.txt");
1010 ou<<"menu list:"<<endl<<endl;
1011 }
1012 for(WORD i=0;i<GetMenuItemCount(hMenu);i++)
1013 {
1014 HMENU smenu=GetSubMenu(hMenu,i);
1015 for(WORD i=0;i<GetMenuItemCount(smenu);i++)
1016 {
1017 UINT id=GetMenuItemID(smenu,i);
1018 if(id>= MENU_MOUSEGESTURE_Len_MAX) continue;
1019 GetMenuString(smenu, i, buffer, MAX_PATH,MF_BYPOSITION);
1020 if(strlen(buffer)>0)
1021 {
1022 if(mode>0) ou<<buffer<<","<<id<<endl;
1023 num++;
1024 }
1025 }
1026 }
1027 return num;
1028 }
1029
1030 void initkey()
1031 {
1032 keytransF =exist(keydirfile);
1033 if( !keytransF) return;
1034 int c=0;
1035 DWORD i;
1036 for( i=0; i<8000 ; i++ ) keydic[i]=i;
1037 ifstream in(keydirfile);
1038 while(1)
1039 {
1040 if(in.eof()) break;
1041 in.getline(buffer,BUFFER_LEN);
1042 if(strchr(buffer,'=')!=NULL)
1043 {
1044 *strchr(buffer,'=') =0;
1045 sscanf(buffer,"%d",&i);
1046 if(i>8000) continue;
1047 GetPrivateProfileString(keykey, buffer, "", buffer, MAX_PATH,keydirfile);
1048 if(strlen(buffer)>0) sscanf(buffer,"%d",&keydic[i]);
1049 if(keydic[i]==0 || keydic[i]>8000) keydic[i]=i;
1050 }
1051 }
1052 }
1053
1054 // vbmp3.dll �����������@-----------------------
1055
1056
1057 void mp3stopMain()
1058 {
1059 stopMp3();
1060 freeMp3();
1061 mciStop();
1062 mciPlaying =FALSE;
1063 setstatus(".");
1064 }
1065
1066
1067 // load error �����@-1
1068 int mp3playMain(char *file,char *path)
1069 {
1070 static char lastfile[MAX_PATH];
1071 /* ���������������G���[
1072 static char nowfile[MAX_PATH];
1073 GetFullName(nowfile, file, path, MAX_PATH);
1074 if(playing)
1075 {
1076 if(strcmp(nowfile,lastfile)!=0 || isMp3(file) || isWav(file))
1077 {
1078 stopMp3();
1079 freeMp3();
1080 playing =FALSE;
1081 }
1082 }
1083 */
1084 GetFullName(lastfile, file, path, MAX_PATH);
1085 int stat=MciStatus();
1086 if(mciPlaying && stat==mci_stopped)
1087 {
1088 mp3stopMain();
1089 vEnd();
1090 setstatus("play end..");
1091 mciPlaying=FALSE;
1092 }
1093 if(mciPlaying)
1094 {
1095 mp3stopMain();
1096 vEnd();
1097 setstatus("play end");
1098 mciPlaying=FALSE;
1099 return 0;
1100 }
1101 if(!mciPlaying)
1102 {
1103 if(loadvbmp3())
1104 {
1105 mciPlaying=TRUE;
1106 setstatus("play start");
1107 if( !playMp3(lastfile)) mciPlaying=FALSE;
1108 /*
1109 if(Mes("play")==IDOK) ;
1110 mp3stop();*/
1111 }
1112 else
1113 {
1114 mciPlaying=FALSE;
1115 return -1;
1116 }
1117 }
1118 //if(playing) strcpy(lastfile,file);
1119 return 0;
1120 }
1121
1122
1123 typedef struct InputInfo{
1124 char szTrackName[128]; // ����
1125 char szArtistName[128]; // ��������
1126 long channels; // �������
1127 long bitRate; // �������(kbit/s)
1128 long samplingRate; // ��������(Hz)
1129 long totalSec; // ���t����(s)
1130 } InputInfo;
1131
1132 typedef BOOL (*mopen)(char* ,InputInfo *);
1133 typedef BOOL (*mbool)();
1134 typedef long (*mstate)(long);
1135 mopen vbmp3_open;
1136 mbool vbmp3_close;
1137 mbool vbmp3_stop;
1138 mbool vbmp3_play;
1139 mbool vbmp3_init;
1140 mbool vbmp3_free;
1141 mstate vbmp3_getState;
1142 HINSTANCE hLibm =NULL;
1143
1144
1145 BOOL checkFnc()
1146 {
1147 return ((hLibm !=NULL) & (vbmp3_getState != NULL) &(vbmp3_init != NULL) &(vbmp3_open != NULL) &(vbmp3_close != NULL) &(vbmp3_stop != NULL) &(vbmp3_play != NULL));
1148 }
1149
1150 void checkFncState()
1151 {
1152 if(checkFnc())
1153 {
1154 Mes("vbmp3 fnc ready.");
1155 //freeMp3();
1156 }
1157 else Mes("vbmp3 fnc bad.");
1158
1159 }
1160
1161
1162 BOOL loadvbmp3()
1163 {
1164 if( checkFnc()) {
1165 stopMp3();
1166 freeMp3();
1167 return FALSE;
1168 }
1169 BOOL ret=TRUE;
1170 hLibm = LoadLibrary( "vbmp3.DLL");
1171 if(hLibm !=NULL)
1172 {
1173
1174 vbmp3_open = (mopen) GetProcAddress(hLibm, "vbmp3_open");
1175 vbmp3_close = (mbool) GetProcAddress(hLibm, "vbmp3_close");
1176 vbmp3_stop = (mbool) GetProcAddress(hLibm, "vbmp3_stop");
1177 vbmp3_play = (mbool) GetProcAddress(hLibm, "vbmp3_play");
1178 vbmp3_init = (mbool) GetProcAddress(hLibm, "vbmp3_init");
1179 vbmp3_free = (mbool) GetProcAddress(hLibm, "vbmp3_free");
1180 vbmp3_getState = (mstate) GetProcAddress(hLibm, "vbmp3_getState");
1181 if( checkFnc() ) ;
1182 else
1183 {
1184 ret=FALSE;
1185 Mes("vbmp3 error");
1186 freeMp3();
1187 goto end;
1188 }
1189 //long sec;
1190 //char buf[10];
1191 if(!(*vbmp3_init)())
1192 {
1193 Mes("mp3 init error");
1194 ret=FALSE;
1195 }
1196 }
1197 else
1198 {
1199 //Mes("library not found");
1200 ret=FALSE;
1201 }
1202 return ret;
1203
1204 end:
1205 return ret;
1206 }
1207
1208 BOOL playMp3(char*file)
1209 {
1210 BOOL ans=TRUE;
1211 if( !checkFnc()) return FALSE;
1212 InputInfo info;
1213 (*vbmp3_close)() ;
1214 if(!(*vbmp3_open)(file, &info))
1215 {
1216 Mes("mp3 open error");
1217 ans =FALSE;
1218 }
1219 else
1220 {
1221 //Mes(info.totalSec);
1222 }
1223 if(!(*vbmp3_play)()) ans =FALSE;//Mes("play bad");
1224 return ans;
1225 }
1226
1227 void stopMp3()//
1228 {
1229 if( !checkFnc()) return;
1230
1231 if((*vbmp3_stop)()) ;//Mes("mp3stop ok");
1232 if((*vbmp3_close)()) ;//Mes("mp3close ok");
1233 if((*vbmp3_free)()) ;//Mes("mp3free ok");;
1234 //if((*vbmp3_init)()) Mes("mp3init ok");
1235 }
1236
1237 void freeMp3()
1238 {
1239 //Mes("libfree");
1240 if(hLibm!=NULL)
1241 {
1242 if(FreeLibrary(hLibm)) ;
1243 else Mes("library free error");
1244 hLibm=NULL;
1245 }
1246 }
1247 //---------------------------------------
1248
1249
1250 void MyGetInitialData(WINPOS *lpwinpos)
1251 {
1252 char newword[100];
1253 getini_cu();
1254 hisInit();
1255 initkey();
1256
1257 dontoverwrite =FALSE;//����������
1258 getprofilepos(lpwinpos);
1259 getprofiledir();
1260 GetPrivateProfileString(keywindow, "mode", "", newword, 100, initdirfile);
1261 if(newword!="") setmode(atoi(newword));
1262 GetPrivateProfileString(keywindow, "editor", "notepad", editor, MAX_PATH, initdirfile);
1263 wsprintf(defCmdstr, "%s \%s", editor);
1264 // GetPrivateProfileString(keywindow, "memo", "memo.txt", memofile, MAX_PATH, initdirfile);
1265 // GetPrivateProfileString(keywindow, "memoPath", "", memopath, MAX_PATH, initdirfile);
1266 GetPrivateProfileString(keywindow, "special ext", extDefSpColor, newword, 100, initdirfile);
1267 setExtPaint(newword);
1268
1269 mouseGTransF =TRUE;
1270 mciPlaying =FALSE;
1271 mp3Playing =FALSE;
1272 KeyModified =FALSE;
1273 nanameON =TRUE;
1274 videoIn =FALSE;
1275 CurrentPicshow =FALSE;
1276 autoedit =autoeditSw.load( "auto edit" );
1277 mousegON =mousegestureSw.load( "mouse gesture" ,TRUE);
1278 spiPath=FALSE;
1279 //spiCdir =spiLoadTest("a.jpg"); // cdir�@������
1280
1281 spiPath =spipathStr.loadstr( "spi path" );
1282 setPicExts("jpg");//
1283 if (picExtStr.loadstr( "pic ext" )) setPicExts( picExtStr.getStr() );
1284 editflag =editSw.load( "editflag" );
1285 logflag =logSw.load( "logflag" );
1286 paintf =paintSw.load( "paint", PAINTFLAG_DEF);
1287 columnhead =columnheadSw.load( "column", TRUE);
1288 wide =wideSw.load( "wide" );
1289 mousemv =mouseSw.load( "mousemv" );
1290 showmenu =menuSw.load( "menu" , TRUE);
1291 LogDialog =logDlgSw.load( "log dialog" );
1292 clickpic =clickpicSw.load( "click pic" );
1293 showpathTitle =TRUE;
1294 fenrirPath =fenrirStr.loadstr( "fenrir path" );
1295 memoStr.loadstr( "memo", "memo-.txt" );
1296 memopathStr.loadstr( "memopath" );
1297 memofile=memoStr.getStr();
1298 memopath=memopathStr.getStr();
1299
1300
1301 iconf =maskSw.load( "icon" );
1302 if( iconf ==FALSE ) topmask =LVIF_TEXT | LVIF_PARAM;
1303 else topmask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
1304
1305 sessionNum =gethostnum();
1306 stockdir.num=0;
1307
1308 return;
1309 }
1310
1311 void GetVol(int len, char *vol)
1312 {
1313 //DWORD SectorsPerCluster;
1314 //DWORD BytesPerSector;
1315 //DWORD NumberOfFreeClusters;
1316 //DWORD TotalNumberOfClusters;
1317 const int INFOBUF_SIZE=1000;
1318 char drives[INFOBUF_SIZE];
1319 memset(vol,0,len);
1320 GetLogicalDriveStrings(INFOBUF_SIZE, drives); // �L�����h���C�u������������
1321 const char *ptr = drives;
1322 strcpy(vol,"");
1323 while( *ptr != '\0' ) { // �L�����h���C�u���c����������
1324 // uint driveType = GetDriveType(ptr);
1325 SHFILEINFO shFileInfo;
1326 SHGetFileInfo(ptr, 0, &shFileInfo, sizeof(SHFILEINFO), SHGFI_DISPLAYNAME);
1327 strcat(vol, ptr);
1328 strcat(vol, shFileInfo.szDisplayName);
1329 strcat(vol,"\xd\xa");
1330 ptr = strchr(ptr, '\0'); // �����h���C�u
1331 //ASSERT(ptr);
1332 ptr += 1;
1333 }
1334
1335
1336 }
1337
1338
1339 void savelastdir(int lr, char *dir)
1340 {
1341 char buffer[4];
1342 wsprintf(buffer,"%d",lr);
1343 WritePrivateProfileString(keystart, buffer, dir, initdirfile);
1344 }
1345
1346 void savelastTabs()
1347 {
1348 char buff[10];
1349 for(int tab=0;tab<GetItemCount(hTab); tab++)
1350 {
1351 wsprintf(buff,"tab%d", tab);
1352 WritePrivateProfileString(keystart, buff, GetTabPath(tab), initdirfile);
1353 }
1354 }
1355
1356
1357 void savefilter(char *str)
1358 {
1359 char buffer[4];
1360 int num;
1361 if ( SearchProfileString( keyfilter, str, initdirfile ) ) return;
1362 num =GetProfileNum(keyfilter, initdirfile);
1363 wsprintf(buffer,"%d",num+1);
1364 WritePrivateProfileString(keyfilter, buffer, str, initdirfile);
1365 }
1366
1367 void MySaveInitialData( WINPOS *lpwinpos)
1368 {
1369 char buffer[MAX_INFO];
1370 //itoa()
1371 wsprintf(buffer,"%d",lpwinpos->x);
1372 WritePrivateProfileString(keywindow, "x", buffer, initdirfile);
1373 wsprintf(buffer,"%d",lpwinpos->y);
1374 WritePrivateProfileString(keywindow, "y", buffer, initdirfile);
1375 wsprintf(buffer,"%d",lpwinpos->wx);
1376 WritePrivateProfileString(keywindow, "wx", buffer, initdirfile);
1377 wsprintf(buffer,"%d",lpwinpos->wy);
1378 WritePrivateProfileString(keywindow, "wy", buffer, initdirfile);
1379 wsprintf(buffer,"%d",mode);
1380 WritePrivateProfileString(keywindow, "mode", buffer, initdirfile);
1381 mousegestureSw.save(mousegON);
1382 memoStr.saveStr(memofile);
1383 memopathStr.saveStr(memopath);
1384 return;
1385 }
1386
1387
1388 WORD transkey(WORD key)
1389 {
1390 if(key>=8000 || !keytransF) return key;
1391 return keydic[key];
1392 }
1393
1394 #define LineLen 2000
1395 #define EnvLen 100
1396
1397 // ini �������������o��
1398
1399 BOOL getmyenv(char *env, char *ans)
1400 {
1401 GetPrivateProfileString(keyenv, env, "", ans, EnvLen, initdirfile);
1402 return ( strlen(ans) >0 );
1403 }
1404
1405
1406
1407 BOOL myTransEnv(char *env, char *ans)
1408 {
1409 BOOL f =FALSE;
1410 if( getmyenv(env, ans) )
1411 {
1412 f =TRUE;
1413 }
1414 else if( getenv(env) ==NULL) {}
1415 else
1416 {
1417 wsprintf(ans,"%s", getenv(env));
1418 f =TRUE;
1419 }
1420 return f;
1421 }
1422
1423 //��������������
1424 char *TransEnv(char *src, char *dest)
1425 {
1426 //return src;
1427 wsprintf(dest,"");
1428 char buff[LineLen];
1429 char env[EnvLen];
1430 char envTrans[EnvLen];
1431 if(strlen(src) >= LineLen || strchr(src, '%') ==NULL)
1432 {
1433 wsprintf(dest, "%s", src);
1434 return src;
1435 }
1436 wsprintf(buff, "%s", src);
1437
1438 char *p=buff;
1439 int len =strlen(buff);
1440 while(1)
1441 {
1442 if(len<=0) break;
1443 while( *p!=0 && *p!='%') {*dest=*p; dest++; p++; }
1444 if(*p==0)
1445 {
1446 *dest=0;
1447 break;
1448 }
1449 if(*p=='%' && strlen(p)>0)
1450 {
1451 strncpy(env,p+1,EnvLen);
1452 char *pp=strchr(env,'%');
1453 if(pp!=NULL) *pp=0;
1454 else
1455 {
1456 *dest ='%';
1457 dest++;
1458 p++;
1459 len--;
1460 continue;
1461 }
1462 if ( ! myTransEnv(env, envTrans)) //
1463 {
1464 p++;
1465 continue;
1466 }
1467 int lenenv =strlen(envTrans);
1468 strcpy(dest, envTrans);
1469 dest +=lenenv;
1470 p =strchr(p+1, '%');
1471 len -= strlen(env) +2;
1472 }
1473 p++;
1474 len--;
1475 }
1476 return dest;
1477
1478 }
1479
1480
1481 // fenrir ��instant.ini�i�������������`���������j ���p���������g��
1482 // �p�X���t���l�[���������t�@�C����
1483 // fenrir path=....
1484
1485
1486 char *TransExCmd(char *cmd, char *file, char *path)
1487 {
1488 //Mes("transEx");
1489 if (!fenrirPath) return cmd;
1490
1491 swstr fnr;
1492 fnr.init(fenrirStr.getStr(),"InstantCommand");
1493 if( fnr.loadstr(cmd, TRUE) )
1494 wsprintf(cmd, fnr.getStr());
1495
1496 return cmd;
1497 }
1498
1499 // �R�}���h���C��������$P��������������
1500
1501 char *TransCmd(char *cmd, char *file, char *path)
1502 {
1503 TransExCmd(cmd, file, path);
1504 char *cmdstr =cmd;
1505 char *buf =buffer2;
1506 char buff[LineLen];
1507
1508 TransEnv(cmd, buff);
1509 wsprintf(cmd, "%s", buff);
1510 //M2("env",buff);
1511
1512 while(1)
1513 {
1514 if(*cmdstr!='$') *buf++ = *cmdstr++ ;
1515 else
1516 {
1517 cmdstr++;
1518 if ( *cmdstr == 'F' )
1519 {
1520 strcpy( buf, file);
1521 buf += strlen(file);
1522 cmdstr++;
1523 }
1524 else if ( *cmdstr == 'P' )
1525 {
1526 strcpy( buf, path);
1527 buf += strlen(path);
1528 cmdstr++;
1529 }
1530 else if ( *cmdstr == 'O' )
1531 {
1532 strcpy( buf, GetNXPath());
1533 buf += strlen(GetNXPath());
1534 cmdstr++;
1535 }
1536 else if ( *cmdstr == 'L' )
1537 {
1538 strcpy( buf, GetLPath());
1539 buf += strlen(GetLPath());
1540 cmdstr++;
1541 }
1542 else if ( *cmdstr == 'R' )
1543 {
1544 strcpy( buf, GetRPath());
1545 buf += strlen(GetRPath());
1546 cmdstr++;
1547 }
1548 }
1549 if(*cmdstr == 0 ) break;
1550 }
1551 *buf = 0;
1552 strcpy(cmd, buffer2);
1553 return cmd;
1554 }
1555
1556 char *GetMyCmdStr( int mode )
1557 {
1558 char buff[10];
1559 wsprintf(buff,"%d",mode);
1560 GetPrivateProfileString(keycommand, buff, defCmdstr, cmdstr, MAX_PATH, initdirfile);
1561 return cmdstr;
1562 }
1563
1564 // �o�^�R�}���h�����s
1565
1566 char *cmd(char *file, char *path, int mode)
1567 {
1568 strcpy(cmdline,TransCmd(GetMyCmdStr(mode), file, path));
1569 wsprintf(buffer, cmdline, quote( GetFullName(buffer2, file, path, MAX_PATH) ) );
1570 return buffer;
1571 }
1572
1573 // �����w���R�}���h�����s
1574 char *cmdDirect(char *file, char *path, char *com)
1575 {
1576 strcpy(cmdline,TransCmd(com, file, path));
1577
1578 wsprintf(buffer, cmdline, quote( GetFullName(buffer2, file, path, MAX_PATH) ) );
1579 return buffer;
1580 }
1581
1582 // �R�}���h�����������o�����s
1583 char *cmdByNum(char *file, char *path, char *num)
1584 {
1585 GetPrivateProfileString(keycommand, num, defCmdstr, cmdstr, MAX_PATH, initdirfile);
1586 return cmdDirect(file, path, cmdstr);
1587 }
1588
1589
1590 // ""���`�F�b�N�A''���`�F�b�N��������
1591 // ������������������
1592
1593 BOOL getfirst( char *cmd, char *buf,char *buf2)
1594 {
1595 char *p;
1596 if(strlen(cmd)<3) return FALSE;
1597 strcpy(buf,cmd);
1598 p=buf;
1599 while(1)
1600 {
1601 if(*p==0) return FALSE;
1602 if(*p!='\"' && *p!=' ')
1603 {
1604 p++;
1605 continue;
1606 }
1607 if(*p=='\"') //"..."������
1608 {
1609 p=strchr(p+1,'\"');
1610 if(p==NULL) return FALSE;
1611 p++;
1612 continue;
1613 }
1614 // ' '������
1615 if(strlen(p)==1) return FALSE;
1616 strcpy(buf2, p+1);
1617 *p=0;
1618 return TRUE;
1619 }
1620 }
1621
1622 BOOL splitcmd( char *cmd, char *buf, char *buf2)
1623 {
1624 strcpy(buf,cmd);
1625 if (strchr(cmd,' ')==NULL) return FALSE;
1626 return getfirst(cmd,buf,buf2);
1627 }
1628
1629 void myexec( char *cmd)
1630 {
1631 //system(cmd);
1632 char buffer[BUFFER_LEN];
1633 char buffer2[BUFFER_LEN];
1634 strcpy(buffer,"");
1635 strcpy(buffer2,"");
1636 setstatus("cmd ", cmd);
1637 if( splitcmd(cmd, buffer,buffer2) )
1638 {
1639 ShellExecute(NULL, "open", buffer,buffer2, NULL, SW_SHOW);
1640 LogWin(cmd);
1641 }
1642 else
1643 {
1644 ShellExecute(NULL, NULL, cmd, NULL, NULL, SW_SHOW);
1645 }
1646 }
1647
1648
1649 // mode =0�@���O���Z�b�g
1650
1651 int getnextpath(int id, char *buf, char *written, int mode)
1652 {
1653 static int lastid;//���Oid(list)
1654 static char path[MAX_PATH];
1655 static char currentWritten[MAX_PATH];
1656 char newdir[MAX_PATH];
1657 static int ans=0;
1658 int _ERR =_FILE;
1659
1660 if (mode !=0)
1661 {
1662 ans =0;
1663 getnextfile(path, "*", newdir, _closeOnly);
1664 return 0;
1665 }
1666 if (ans ==0 || id!=lastid)
1667 {
1668 ans =0;
1669 wsprintf(currentWritten,"%s",written);
1670 wsprintf(path,"%s", buf);
1671 }
1672 lastid =id;
1673 if (ans ==0 || ans == _END)
1674 {
1675 ans =getnextfile(path, "*", newdir, 0);
1676 if (ans==_DIR)
1677 {
1678 if( newdir[0] !='.')
1679 {
1680 wsprintf(buf, "%s\\%s", path, newdir);
1681 if(strstr(buf, currentWritten) ==NULL ) ans =_ERR;
1682 return ans;
1683 }
1684 }
1685 }
1686 while( 1 )
1687 {
1688 ans =getnextfile(path, "*", newdir, 1);
1689 if( ans ==_END )
1690 {
1691 break;
1692 }
1693 if( ans == _DIR )
1694 {
1695 if ( newdir[0] !='.' )
1696 {
1697 wsprintf(buf, "%s\\%s", path, newdir);
1698 if(strstr(buf, currentWritten) ==NULL )
1699 {
1700 ans =_ERR;
1701 continue;
1702 }
1703 break;
1704 }
1705 continue;
1706 }
1707 if( ans == _FILE )
1708 {
1709 }
1710 }
1711 return ans;
1712 }

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision
svn:mime-type text/plain

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26