/* */ /* 株価検索 */ /* 1996.04.02 Y.Noizumi */ /* Rev.0.9 */ /* 注意:このプログラムによって株価検索システムを構築する場合、 */ /* SYSTEC TELECHART-AIのデータを利用する訳ですが、このデータ */ /* は加工してあるとは言え、テレモ日本の2次著作物です。 */ /* 従って、個人利用以外に使用すると著作権法侵害の恐れがある事 */ /* を警告しておきます。 */ #include #include #include #include #include #include #include /* Type Define */ typedef unsigned int WORD; typedef unsigned char BYTE; typedef struct { float A; float B; float C; float D; float E; float F; WORD G; } TCDATREC; typedef TCDATREC TCFILETYPE[261]; typedef struct { double market; double TodayDate; double Hajimene; double Takane; double Yasune; double Owarine; double Dekidaka; } MEIINFOREC; typedef struct { WORD mcode; char mname[12]; char market; } MDIC; /* Groval Variable */ char DataDrv[MAXPATH]; float B2PSingle( float n ) { unsigned long BitDat; unsigned long E; unsigned long F; memcpy( &BitDat,&n,sizeof(BitDat) ); /* BitDat = (unsigned long)n ;*/ E = (BitDat >> 24) & 0x00000FFL; E = E - 2; E = E << 23; E = E | ((BitDat & 0x00800000L) << 8); F = BitDat & 0x007FFFFFL; BitDat = E | F; memcpy( &n,&BitDat,sizeof(n) ); return( n ); } /* 単位価格の算出 */ /* 100円台のものならば1円単位、1000円台ならば10円単位で値が動く */ double GetTaniNedan( double x ) { double dum_x; double result; result = 100000000; dum_x = x; while(dum_x <= result){ dum_x = x; dum_x = floor(dum_x / result); dum_x *= result; result /= 10; } result /= 10; if(result<1) result = 1; return(result); } /* 指定の銘柄コードから記録日付と終わり値を得る */ int Get4Nedan( WORD mcode, MEIINFOREC *Meigara ){ int i,fh; WORD fsize; TCFILETYPE tcfile; char TmpStr[10],NumStr[10],fname[256]; int StrLn; itoa( mcode,(char *)&NumStr,10 ); strcpy( (char *)&TmpStr ,(char *)"000" ); strcat( (char *)&TmpStr ,(char *)&NumStr ); StrLn = strlen( TmpStr ); StrLn -= 4; strcpy( NumStr,(char *)&TmpStr + StrLn ); strcpy( fname,DataDrv ); strcat( fname,"\\tcdat\\dd" ); strncat( fname,NumStr,1 ); strcat( fname,"\\dd" ); strcat( fname,NumStr ); if((fh = open( fname,O_RDONLY+O_BINARY))!=EOF){ fsize = filelength(fh); read(fh,tcfile,fsize); close(fh); i = floor(B2PSingle(tcfile[0].B)); i--; if(i<=0) i=260; Meigara->TodayDate = floor(B2PSingle(tcfile[i].A)); Meigara->Hajimene = floor(B2PSingle(tcfile[i].B)); Meigara->Takane = floor(B2PSingle(tcfile[i].C)); Meigara->Yasune = floor(B2PSingle(tcfile[i].D)); Meigara->Owarine = floor(B2PSingle(tcfile[i].E)); Meigara->Dekidaka = floor(B2PSingle(tcfile[i].F)); } else{ /* *Date = 0; */ /* *Tanka = 0; */ } return(fh); } void main( int argc,char *argv[] ) { char OutFile[MAXPATH],DicPath[MAXPATH]; char MeiName[12],McodeStr[10],MarketName[10]; int fh; WORD fsize; FILE *fp; int i,j,k; double TodayDate; MDIC *mdic; int res; MEIINFOREC Meigara; double mcode; /* _stklen = 32000;*/ strcpy( &OutFile[0],getenv("OUTPUT_FILE")); fp = fopen(OutFile,"w"); /* HTML Header */ fprintf(fp,"Content-type:text/html\n"); fprintf(fp,"\n"); strcpy( &DataDrv[0],"A:"); /* TELECHARTデータドライブはここで指定 */ if(strcmp("code=",argv[1])==0){ strcpy( &McodeStr[0] ,"code=0100" ); } else{ strcpy( &McodeStr[0] ,argv[1] ); if(argc>2) strcpy( DataDrv ,argv[2] ); } sscanf(McodeStr,"code=%lf",&mcode); /* 銘柄辞書読み込み */ strcpy( DicPath ,DataDrv ); strcat( DicPath ,"\\tcai\\mcode.dat" ); if((fh = open( DicPath,O_RDONLY+O_BINARY))==EOF){ fprintf(fp,"ファイルが見つかりません。:%s\n",DicPath); exit(1); } fsize = filelength(fh); mdic = (MDIC *)malloc(fsize); read(fh,mdic,fsize); close(fh); /* 保有銘柄のコードから銘柄名を辞書から参照 */ j = fsize / sizeof(MDIC); for(i=0;(i"); fprintf(fp,"%sの株価",MeiName); fprintf(fp,"%6.0lf大引け\n",TodayDate); fprintf(fp,"
\n"); fprintf(fp,"\n"); /* fprintf(fp,"\n"); fprintf(fp," \n"); fprintf(fp," \n"); fprintf(fp," \n"); fprintf(fp," \n",mcode,MarketName,MeiName,Meigara.Hajimene,Meigara.Takane,Meigara.Yasune,Meigara.Owarine,Meigara.Dekidaka); fprintf(fp," \n"); fprintf(fp,"

損益試算表

\n"); */ fprintf(fp,"
コード 市場 銘柄 始値 高値 安値 終値 出来高
%4.0lf %-4s %-12s %8.0lf %8.0lf %8.0lf %8.0lf%8.0lf
\n"); fprintf(fp,"
\n"); fprintf(fp,"
\n"); fprintf(fp,"

\n"); fprintf(fp,"


\n"); fprintf(fp,"

\n"); fprintf(fp,"Return to NOIZUMI SERVER HOME"); fprintf(fp,"


\n"); fprintf(fp,"
\n"); fprintf(fp,"%s",getenv("SERVER_ADMIN"),getenv("SERVER_ADMIN")); fprintf(fp,"
\n"); fprintf(fp,""); fclose(fp); free(mdic); return; }