2: 2010-02-01 (月) 21:14:43 lina |
現: 2024-01-08 (月) 12:58:58 lina |
| | | |
| include ../z_tools/command.txt | | include ../z_tools/command.txt |
| + | |
| TARGET = osalink1 | | TARGET = osalink1 |
| MODE = g01 | | MODE = g01 |
| OBJS = $(TARGET).obj | | OBJS = $(TARGET).obj |
| + | |
| INCPATH = ../z_tools/guigui01/ | | INCPATH = ../z_tools/guigui01/ |
| include ../z_tools/com_mak.txt | | include ../z_tools/com_mak.txt |
| [[ここ>http://osask.net/w/201.html]]に手がかりがあったがすこし違う。もしかして新しくなってる? | | [[ここ>http://osask.net/w/201.html]]に手がかりがあったがすこし違う。もしかして新しくなってる? |
| | | |
| + | **一旦棚上げ(毎度乙!) [#f1b254b3] |
| + | fprintfって、ファイルに書き込む命令でそ? [[こっち>http://osask.net/w/544.html]]でとりあえず読み込みがわかったので、まずは書くのは後回し(コメントアウトとかで)して、osalink1.optとかを読み込んでみよう |
| + | |
| + | **再開・・・ [#tc628d7f] |
| + | まずはこういう手の表記。 |
| + | FILE *fp0, *fp1; |
| + | .g01では''スロット''というものを使ってファイルハンドルと同じ操作をするので、これは撤廃。(当然fpとかの表記もコメントアウト) |
| + | |
| + | // OPTIONFILEの読み込みと各ファイルのサイズ取得 |
| + | fp0 = fopen(optfile, "r"); |
| + | if (fp0 == NULL) { |
| + | fprintf(stderr, "Can't open \"%s\".\n", optfile); |
| + | return 1; |
| + | } |
| + | ここでosalink1.optを開いてるよね。これを・・・・ |
| + | |
| + | // OPTIONFILEの読み込みと各ファイルのサイズ取得 |
| + | char *buffer1 = g01_bss1a1; |
| + | jg01_fopen(1, 4, optfile); |
| + | jg01_fread0_4(2 * 1024 * 1024, buffer1); |
| + | if (strlen(buffer1) == 0) { |
| + | g01_putstr0("Can't open optfile\n"); |
| + | return 1; |
| + | } |
| + | |
| + | こういうことでいいのかな・・・ |
| + | |
| + | COLOR(red){ちょっと面白いこと発見。このosalink1は、元々内部コードで2MBのバッファを確保してるんだけど、これを文字列配列でやってたのよね。で、これがあると、G01Mainがまったく動かなくなっちゃうらしいww。ちゃんとmallocやg01_bss1a1で確保すると大丈夫だというwww} |
| + | |
| + | |
| + | |
| + | g01のapiでは、''一行読み込み''はない。すでにbuffer1内に全部入っちゃってる。つーことは・・・・~ |
| + | 改行コードを元に、自分で配列とかを作って割ってやらないといけない・・・のかな。例えば・・・ |
| + | |
| + | //まずは改行コードを一旦統一する |
| + | for ( i = 0; i < strlen(buffer1); i++){ |
| + | //とりあえずLFに統一するか・・・ |
| + | if (buffer1[i] == 0x0D) buffer1[i] = 0x0A; |
| + | //これで、CRが全部LFに置換されるはず。 |
| + | } |
| + | |
| + | //先頭にある邪魔なLFなどを排除するため、開始地点を探っておく |
| + | int stppoint; stppoint = 0; |
| + | for ( i =0; i < strlen(buffer1); i++){ |
| + | if ( buffer1[i] != 0x0A ){ |
| + | stppoint = i; |
| + | break; |
| + | } |
| + | } |
| + | //これでもし先頭にLFがあっても全て飛ばした位置から開始できる |
| + | |
| + | //新しい配列変数を確保する。 |
| + | int ii2; ii2 = 0; |
| + | int lfs; lfs = 0; |
| + | unsigned char files[strlen(buffer1)+1]; |
| + | for ( i = stppoint; i < strlen(buffer1); i++){ |
| + | if ( buffer1[i] == 0x0A && buffer1[i-1] == 0x0A ){ |
| + | // 連続したLFだったらシカトして進める。 |
| + | } |
| + | else { |
| + | if ( buffer1[i] == 0x0A ){ |
| + | files[ii2] = 0; |
| + | lfs++; |
| + | } |
| + | else { |
| + | files[ii2] = buffer1[i]; |
| + | } |
| + | ii2++; |
| + | // LFを終端コードに置換 |
| + | } |
| + | } |
| + | //最後に終端コードを打っておく |
| + | files[ii2+1] = 0; |
| + | |
| + | //これで、0によって区切られた配列になったはず。 |
| + | //files配列内の、0の位置を記憶する配列を用意する。 |
| + | //厳密には0の前。行頭というべきか・・・ |
| + | int zeropoint[lfs + 1]; |
| + | //↑の処理で先頭は必ず行頭になってるはずなので・・・ |
| + | zeropoint[0]=0; |
| + | int i3; i3 = 1; |
| + | for (i = 1; i < ii2 +1; i++){ |
| + | if (files[i] != 0 && files[i-1] == 0){ |
| + | //ここが行頭になるはず。位置を記憶 |
| + | zeropoint[i3] = i; |
| + | i3++; |
| + | } |
| + | } |
| + | |
| + | //これで、有効な行数はi3個。lfpointが行の先頭になっているはず。 |
| + | |
| + | for ( i = 0; i < i3; i++){ |
| + | g01_putstr0(files + zeropoint[i] ); g01_putstr0("\n"); |
| + | } |
| + | |
| + | |
| + | これでどおぉぉぉだあぁぁぁ!! コンツクショー!!! (レベル低いですかそうですか・・・orz) |
| + | |
| + | |
| + | |
| + | *とりあえず動いたぞ(笑 [#j30546d1] |
| + | |
| + | [[この辺>http://sourceforge.jp/projects/osask/svn/view/28GO/28GO_K/trunk/osalink1/?root=osask&pathrev=161]]から取れますw |
| + | |
| + | あとはコマンドラインを受け取れるようにしたいんだが・・・うーん・・・・ |
| + | |
| + | |
| + | *ダメだ。一旦固める! [#a6f7aecc] |
| + | コマンドライン引数のファイルパスタイプの「規定値」がどうしてもわからん。しょうがないので、オプションファイルの指定は文字列型で受け取ってお茶を濁そう・・・ |
| + | |
| + | -COLOR(blue){・・・どうも、intタイプ以外のコマンドライン取得関数は''規定値を持たない''仕様らしい・・・仕方がないので自前でコードを書くか・・・} |
| + | |
| + | -COLOR(red){があぁぁぁん! testslot関数は廃止されている!?? じゃ、やっぱ、readやwriteで計るno???} |
| | | |
- | osalink1.ca:52: `stderr' undeclared (first use in this function) | + | -COLOR(red){・・・まいったなぁ・・・g01アプリでは、''ファイルをオープンしてみて、ダメならその時点でエラー''っていう処理が出来ない!? ・・・・いや、そんなバカなはずは・・・} |
- | osalink1.ca:52: (Each undeclared identifier is reported only once | + | |
- | osalink1.ca:52: for each function it appears in.) | + | |
- | osalink1.ca:57: `FILE' undeclared (first use in this function) | + | |
- | osalink1.ca:57: `fp0' undeclared (first use in this function) | + | |
- | osalink1.ca:57: `fp1' undeclared (first use in this function) | + | |
- | osalink1.ca:57: warning: left-hand operand of comma expression has no effect | + | |
- | osalink1.ca:77: warning: implicit declaration of function `fopen' | + | |
- | osalink1.ca:83: warning: implicit declaration of function `fgets' | + | |
- | osalink1.ca:83: warning: comparison between pointer and integer | + | |
- | osalink1.ca:92: warning: implicit declaration of function `strcpy' | + | |
- | osalink1.ca:97: warning: implicit declaration of function `fclose' | + | |
- | osalink1.ca:104: warning: implicit declaration of function `fread' | + | |
- | osalink1.ca:163: warning: implicit declaration of function `fwrite' | + | |
- | osalink1.ca: In function `script': | + | |
- | osalink1.ca:338: `FILE' undeclared (first use in this function) | + | |
- | osalink1.ca:338: `fp' undeclared (first use in this function) | + | |
- | osalink1.ca:362: warning: implicit declaration of function `fseek' | + | |
- | osalink1.ca:362: `SEEK_SET' undeclared (first use in this function) | + | |
- | make[1]: *** [osalink1.gas] Error 1 | + | |
- | rm osalink1.ca osalink1.gas | + | |
- | make[1]: Leaving directory `D:/SFjp_SVN作業/28GO_SVN/hidetol9/k2/osalink1' | + | |
- | ..\z_tools\make.exe: *** [ALL] Error 2 | + | |
| | | |
- | D:\SFjp_SVN作業\28GO_SVN\hidetol9\k2\osalink1> | + | - 確認しました。testslotは無効にされているようです(#ifdefをとれば復活できますが)。ファイルオープンに失敗したらアプリに帰らずエラーという仕様は、efg01のグローバル変数errmodを0にすればやめられるようです。その場合、エラーチェックをefgにまかせているアプリが誤動作すると思われます。 -- [[Sero]] 2010/02/08 19:30ごろ |