Beispiel #1
0
void Load_Range_Index(RQINDEX & R,int STRINGLENGTH,FMFILES F,unsigned & Entries)
{
#undef READ_ASSERT
#define READ_ASSERT(X,Y) {if ((X)<(Y)) {if(LOG_SUCCESS_FILE)fprintf(Log_SFile,"Load_Range_Index(): Read error...\n"); printf("Load_Range_Index(): Read error...\n");exit(-1);}}
	unsigned Index_Size,Block_Size;
	int T1=strlen(F.INDFILE);
	int T2=strlen(F.BLKFILE);

	sprintf(F.INDFILE+strlen(F.INDFILE),"%d",STRINGLENGTH);
	sprintf(F.BLKFILE+strlen(F.BLKFILE),"%d",STRINGLENGTH);
	FILE* Index=File_Open(F.INDFILE,"rb");
	FILE* Blocks=File_Open(F.BLKFILE,"rb");
	R.SA_Index=(SA*)malloc((Index_Size=Get_File_Size(Index)));//contains the index to blocks...
	R.SA_Blocks=(int*)malloc((Block_Size=Get_File_Size(Blocks)));
	if (!R.SA_Index || !R.SA_Blocks)
	{
		if(LOG_SUCCESS_FILE) fprintf(Log_SFile,"Load_Range_Index(): Memory allocation failed!..\n");
		printf ("Load_Range_Index(): Memory allocation failed!..\n");
		exit(-1);
	}
	READ_ASSERT(fread(&R.COMPRESS,1,1,Blocks),1);
	READ_ASSERT(fread(&Entries,sizeof(Entries),1,Blocks),1);
	READ_ASSERT(fread(R.SA_Index,Index_Size,1,Index),1);
	READ_ASSERT(fread(R.SA_Blocks,Block_Size-sizeof(Entries)-1,1,Blocks),1);

	*(F.INDFILE+T1)=0;
	*(F.BLKFILE+T2)=0;
}
Beispiel #2
0
/**
 * Initialize the logging and tracing functionality (open the log files etc.).
 * 
 * Return zero if that fails.
 */
int Log_Init(void)
{
	TextLogLevel = ConfigureParams.Log.nTextLogLevel;
	AlertDlgLogLevel = ConfigureParams.Log.nAlertDlgLogLevel;

	hLogFile = File_Open(ConfigureParams.Log.sLogFileName, "w");
	TraceFile = File_Open(ConfigureParams.Log.sTraceFileName, "w");
   
	return (hLogFile && TraceFile);
}
Beispiel #3
0
def(void, Parse) {
	String path =
		Storage_GetCfgPath(
			Application_GetStorage(this->app));

	if (!Path_Exists(path)) {
		Logger_Fatal(this->logger,
			$("The subscriptions file % does not exist!"), path);

		goto out;
	}

	File file;
	File_Open(&file, path, FileStatus_ReadOnly);

	BufferedStream stream;
	BufferedStream_Init(&stream, File_AsStream(&file));
	BufferedStream_SetInputBuffer(&stream, 1024, 128);

	YAML yml;
	YAML_Init(&yml, 4, &BufferedStreamImpl, &stream);
	YAML_Parse(&yml);

	call(ParseSubscriptions, YAML_GetRoot(&yml));

	YAML_Destroy(&yml);

	BufferedStream_Close(&stream);
	BufferedStream_Destroy(&stream);

out:
	String_Destroy(&path);
}
Beispiel #4
0
int WaveFile_Save(WaveFile* This, String* Dest)
{
    int SaveStatus = File_Open(WStream, Dest, CREATE);
    if(! SaveStatus)
        return 0;

    File_Write_Buffer(WStream, "RIFF", 4);
    File_Write_Int32(WStream, 0); //Size = 0 by default
    File_Write_Buffer(WStream, "WAVE", 4);

    File_Write_Buffer(WStream, "fmt ", 4);
    File_Write_Int32(WStream, 16); //No extra
    File_Write_Int16(WStream, 1); //FormatTag = 0x0001
    File_Write_Int16(WStream, Header.Channel);
    File_Write_Int32(WStream, Header.SamplePerSecond);
    File_Write_Int32(WStream, Header.BytePerSecond);
    File_Write_Int16(WStream, Header.BlockAlign);
    File_Write_Int16(WStream, Header.BitPerSample);

    File_Write_Buffer(WStream, "data", 4);
    File_Write_Int32(WStream, 0); //DataSize = 0 by default

    This -> WritePosition = File_GetPosition(WStream);
    This -> WriteCounter = 0;
    Header.BytePerSample = Header.BitPerSample / 8;
    return 1;
}
Beispiel #5
0
/**
 * Pass byte from emulator to printer.  Opens the printer file appending
 * if it isn't already open. Returns false if connection to "printer"
 * failed
 */
bool Printer_TransferByteTo(Uint8 Byte)
{
	/* Do we want to output to a printer/file? */
	if (!ConfigureParams.Printer.bEnablePrinting)
		return false;   /* Failed if printing disabled */

	/* Have we made a connection to our printer/file? */
	if (!pPrinterHandle)
	{
		/* open printer file... */
		pPrinterHandle = File_Open(ConfigureParams.Printer.szPrintToFileName, "a+");
		if (!pPrinterHandle)
		{
			Log_AlertDlg(LOG_ERROR, "Printer output file open failed. Printing disabled.");
			ConfigureParams.Printer.bEnablePrinting = false;
			return false;
		}
	}
	if (fputc(Byte, pPrinterHandle) != Byte)
	{
		fprintf(stderr, "ERROR: Printer_TransferByteTo() writing failed!\n");
		return false;
	}
	bUnflushed = true;
	return true;
}
Beispiel #6
0
int  RUCE_Roto_CtorLoad(RUCE_Roto* This, String* Path)
{
    int Ret = 1;
    
    File RotoFile;
    String RotoContent;
    String_Ctor(& RotoContent);
    File_Ctor(& RotoFile);
    
    if(! File_Open(& RotoFile, Path, READONLY))
    {
        Ret = 0;
        goto End;
    }
    File_Read_String(& RotoFile, & RotoContent);
    This -> Ptr = cJSON_Parse(String_GetChars(& RotoContent));
    if(! This -> Ptr)
        Ret = 0;
    
    End:
    File_Close(& RotoFile);
    File_Dtor(& RotoFile);
    String_Dtor(& RotoContent);
    
    RInit(RUCE_Roto);
    return Ret;
}
Beispiel #7
0
/* write config to file */
void writeconfig(_In_ Config* config)
{
    FILE* configfile = File_Open(config->configFilepath, "w");
    if (!configfile)
    {
        return;
    }
    LOGMSG(("created config file (%s)", config->configFilepath));
    fprintf(configfile, gformat1,
            config->testGroup,
            config->intervalMS,
            config->failAfterCount,
            config->failResult,
            config->initBehavior,
            config->initResultCode,
            config->initTimeoutMS,
            config->finalizeBehavior,
            config->finalizeResultCode,
            config->postBehavior,
            config->miscTestSubGroup,
            config->evalResult,
            config->logLoadUnloadCall);

    fprintf(configfile, gformat2,
            config->subscribeBookmark,
            config->providerBookmark,
            config->dialect,
            config->expression);
    File_Close(configfile);
}
Beispiel #8
0
int MIDI_SetMimpiMap(char *filename) {

	BYTE		b;
	FILEH		fh;
	char		buf[128];

	LOADED_TONEMAP = 0;
	ZeroMemory(TONE_CH, sizeof(TONE_CH));
	ZeroMemory(TONEBANK[0], sizeof(TONEBANK));
	for (b=0; b<128; b++) {
		TONEMAP[0][b] = b;
		TONEMAP[1][b] = b;
		TONEMAP[2][b] = b;
	}
	TONE_CH[9] = MIMPI_RHYTHM;

	if ((filename == NULL) || (!filename[0])) {
		ENABLE_TONEMAP = 0;
		return(FALSE);
	}
	fh = File_Open(filename);
	if (fh == (FILEH)-1) {
		ENABLE_TONEMAP = 0;
		return(FALSE);
	}
	while(file_readline(fh, buf, sizeof(buf)) >= 0) {
		mimpidefline_analaize(buf);
	}
	File_Close(fh);

	LOADED_TONEMAP = 1;
	return(TRUE);
}
Beispiel #9
0
/**
 * Pass byte from emulator to printer.  Opens the printer file appending
 * if it isn't already open. Returns FALSE if connection to "printer"
 * failed
 */
bool Printer_TransferByteTo(Uint8 Byte)
{
	/* Do we want to output to a printer/file? */
	if (!ConfigureParams.Printer.bEnablePrinting)
		return FALSE;   /* Failed if printing disabled */

	/* Have we made a connection to our printer/file? */
	if (!bConnectedPrinter)
	{
		/* open printer file... */
		pPrinterHandle = File_Open(ConfigureParams.Printer.szPrintToFileName, "a+");
		bConnectedPrinter = (pPrinterHandle != NULL);

		/* Reset the printer */
		Printer_ResetInternalBuffer();
	}

	/* Is all OK? */
	if (bConnectedPrinter)
	{
		/* Add byte to our buffer. */
		Printer_AddByteToInternalBuffer(Byte);
		return TRUE;    /* OK */
	}
	else
		return FALSE;   /* Failed */
}
Beispiel #10
0
/* 
 * ===  FUNCTION  ======================================================================
 *         Name:  Load_Hits_File
 *  Description:  opens the BAT file containing hits and passed the information in it 
 *  		  to some global variables... else load mate files..
 * =====================================================================================
 */
void Load_Hits_File(BATPARAMETERS BP,FILELIST & FList,In_File & IN,char MODE)
{
#define READ_ASSERT(X,Y) {if ((X)<(Y)) {if(LOG_SUCCESS_FILE)fprintf(Log_SFile,"Load_Hits_File(): Read error...\n"); printf("Load_Hits_File(): Read error...\n");exit(-1);}}

if (BATFILEMODE == MODE)
{
	Header Head;
	char MAX_MISMATCHES,ROLLOVER,SCANBOTH;

	FList.Head=File_Open(BP.PATTERNFILE,"rb");
	IN.File_Size=Get_File_Size(FList.Head);
	READ_ASSERT(fread(&Head,1,sizeof(Header),FList.Head),sizeof(Header));
	if(!(Head.ID[0]=='B'&&Head.ID[1]=='A'&&Head.ID[2]=='T')) 
	{
		if (LOG_SUCCESS_FILE) fprintf(Log_SFile,"Not a BAT file\n");
		printf("Not a BAT file\n");
		exit(-1);
	}
	IN.MAXHITS=Head.MAXHITS;
	IN.STRINGLENGTH=Head.Tag_Length;
	IN.PRINT_DESC=Head.Print_Desc;
	IN.LOADREVERSEONLY=Head.Index_Count;

	//read(Data_File,&MAX_MISMATCHES,sizeof(MAX_MISMATCHES));if (MAX_MISMATCHES >5) Stat_Size=7*sizeof(unsigned short); else Stat_Size=(MAX_MISMATCHES+1)*sizeof(unsigned short);
	READ_ASSERT(fread(&MAX_MISMATCHES,sizeof(MAX_MISMATCHES),1,FList.Head),1);if (MAX_MISMATCHES >5) IN.Stat_Size=7*sizeof(unsigned short); else IN.Stat_Size=(MAX_MISMATCHES+1)*sizeof(unsigned short);
	//gzread(Data_File,&TAG_COPY_LEN,sizeof(int));
	READ_ASSERT(fread(&IN.TAG_COPY_LEN,sizeof(int),1,FList.Head),1);
	//gzread(Data_File,&ROLLOVER,sizeof(char));
	READ_ASSERT(fread(&ROLLOVER,sizeof(char),1,FList.Head),1);
	//gzread(Data_File,&SCANBOTH,sizeof(char));
	READ_ASSERT(fread(&SCANBOTH,sizeof(char),1,FList.Head),1);


	//gzread(Data_File,&Length_Array[1],sizeof(int));
	READ_ASSERT(fread(&IN.Length_Array[1],sizeof(int),1,FList.Head),1); IN.HEAD_LENGTH=IN.Length_Array[1];
	//gzread(Data_File,&Length_Array[2],sizeof(int));
	READ_ASSERT(fread(&IN.Length_Array[2],1,sizeof(int),FList.Head),sizeof(int)); IN.TAIL_LENGTH=IN.Length_Array[2];
	IN.FILETYPE=Head.FILETYPE;
}
else
{
	FList.Head=File_Open(BP.PATTERNFILE,"rb");
	FList.Tail=File_Open(BP.PATTERNFILE1,"rb");
}
}
Beispiel #11
0
/**
 * Reads length bytes from filename into buffer.
 *
 * @param filename Then name of the file to read.
 * @param buffer The buffer to read into.
 * @param length The amount of bytes to read.
 * @return The amount of bytes truly read, or 0 if there was a failure.
 */
uint32 File_ReadBlockFile(const char *filename, void *buffer, uint32 length)
{
	uint8 index;

	index = File_Open(filename, 1);
	length = File_Read(index, buffer, length);
	File_Close(index);
	return length;
}
Beispiel #12
0
/* 
 * ===  FUNCTION  ======================================================================
 *         Name:  Load_Range_Index
 *  Description:  Loads the range index sturcture..
 * =====================================================================================
 */
void Load_Range_Index(char* INDFILE, char* BLKFILE,RANGEINDEX & Range_Index)
{
	unsigned Index_Size,Block_Size;

	Range_Index.Index=File_Open(INDFILE,"rb");
	Range_Index.Blocks=File_Open(BLKFILE,"rb");
	Range_Index.SA_Index=(SA*)malloc((Index_Size=Get_File_Size(Range_Index.Index)));//contains the index to blocks...
	Range_Index.SA_Blocks=(int*)malloc((Block_Size=Get_File_Size(Range_Index.Blocks)));
	if (!Range_Index.SA_Index || !Range_Index.SA_Blocks)
	{
		printf ("Load_Range_Index(): Memory allocation failed!..\n");
		exit(0);
	}
	fread(&Range_Index.COMPRESS,1,1,Range_Index.Blocks);
	fread(&Range_Index.Hits,1,sizeof(Range_Index.Hits),Range_Index.Blocks);
	fread(Range_Index.SA_Index,Index_Size,1,Range_Index.Index);
	fread(Range_Index.SA_Blocks,Block_Size,1,Range_Index.Blocks);
}
Beispiel #13
0
void
Random_Init (void)
{
   File fd;

   fd = File_Open ("/dev/urandom", O_RDONLY, 0);
   if (fd == FILE_INVALID) {
      LOG_WARNING ("Failed to open /dev/urandom.");
      fd = File_Open ("/dev/random", O_RDONLY, 0);
      if (fd == FILE_INVALID) {
         LOG_WARNING ("Failed to open /dev/random.");
         ASSERT (false);
         return;
      }
   }

   gRandom = fd;
}
Beispiel #14
0
FILE* _reopenAPIlogfile(_In_ Config* config)
{
    FILE* file;
    File_Remove(config->APIlogFilepath);
    file = File_Open(config->APIlogFilepath, "w");
    if (file == NULL)
        LOGMSG(("!!Failed to create apilog file (%s)!!", config->APIlogFilepath));
    return file;
}
int File_Exist( 
        _In_z_ const char *path)
{
    FILE *fp = File_Open(path, "r");
    if( !fp)
        return -1;

    File_Close(fp);
    return 0;
}
Beispiel #16
0
int File_Touch(
    _In_z_ const char* path)
{
    FILE* fp = File_Open(path, "w");

    if (!fp)
        return -1;

    File_Close(fp);
    return 0;
}
Beispiel #17
0
Datei: main.c Projekt: wakaw/bws
//定荷重免荷と左右方向のコンプライアンスを同時制御
void BWS_and_Compliance(void)
{
	int Flag=1;
	int yes;
	int ch;
	
	while(Flag){
		Display_Title();                                            //タイトル表示
		printf(" <BWS_and_Compliance_test>\n");                     //サブタイトル表示
		Sensors_Display();
		
		printf("\n Input Target Force (BWS) (0 - 630)[N]) >> ");			//免荷力入力
		M[2].Target_Force = Double_Stdin(0,630);
		
		printf("\n Input Gain (horizontal) (0 - 1000)[rpm/N]) >> ");
		M[1].Gain1 = Double_Stdin(0,1000);
		
		printf("\n Input Gain (UP) (0 - 1000)[rpm/N]) >> ");            //ゲイン入力(のぼり(ch1))
		M[2].Gain1 = Double_Stdin(0,1000);
		printf("\n Input Gain (DOWN) (0 - 1000)[rpm/N]) >> ");			//ゲイン入力(くだり(ch2))
		M[2].Gain2 = Double_Stdin(0,1000);

		printf("\n Input Target Range (horizontal) (0 - 100)[mm]) >> ");         //片側可動域入力
		M[1].Target_Range = Double_Stdin(0,100);
		printf("\n Input Target Range (BWS) (0 - 100)[mm]) >> ");                //片側可動域入力
		M[2].Target_Range = Double_Stdin(0,100);
		
		printf("\n Input Compliance (horizontal) (0.0 - 20.0)[mm/N]) >> ");      //コンプライアンス定数入力
		M[1].Compliance = Double_Stdin(0,20);
		
		Input_Timer_Parameter();                                    //サンプリング間隔と記録時間を入力
		
		M[1].Counter_Past = Count_Read(1);                          //カウンタ初期値
		M[2].Counter_Past = Count_Read(2);
		
		File_Open();												//ファイルオープン
		BWS_and_Compliance_h();
		////////////////////////////////////////////////////////////////////////
		Timer1(Samp_Cycle,Rec_Time,BWS_and_Compliance_drive);			//タイマon
		////////////////////////////////////////////////////////////////////////
		DA_Write(1,2048);											//2.5V出力
		DA_Write(2,2048);
		File_Close();												//ファイルクローズ
		
		sleep(1);
		Savexy();
		Sensors_Display();
		Returnxy();													//カーソル位置復帰
		printf("\n Now Check is End. Again? -- Y or N >> ");
		yes = Yes_or_No();
		if(yes=='n')Flag=0;
	}
}
Beispiel #18
0
/**
 * Open a chunk file (starting with FORM) for reading.
 *
 * @param filename The name of the file to open.
 * @return An index value refering to the opened file, or FILE_INVALID.
 */
uint8 ChunkFile_Open(const char *filename)
{
	uint8 index;
	uint32 header;

	index = File_Open(filename, 1);
	File_Close(index);

	index = File_Open(filename, 1);

	File_Read(index, &header, 4);

	if (header != HTOBE32('FORM')) {
		File_Close(index);
		return FILE_INVALID;
	}

	File_Seek(index, 4, 1);

	return index;
}
Beispiel #19
0
Result FStream_Open(FStream* pfStream,
                    const char* fileName)
{
  Result result = File_Open(&pfStream->file,
                            fileName);
  if (result == RESULT_OK)
  {
    result = String_Change(&pfStream->fileName,
                           fileName);
  }
  return result;
}
Beispiel #20
0
/**
 * Saves the game options.
 */
void GameOptions_Save(void)
{
	uint8 index;

	index = File_Open("OPTIONS.CFG", 2);

	File_Write(index, &g_gameConfig, sizeof(g_gameConfig));

	File_Close(index);

	if (g_gameConfig.music == 0) Music_Play(0);
}
Beispiel #21
0
/**
 * Reads the whole file into buffer.
 *
 * @param filename The name of the file to open.
 * @param buf The buffer to read into.
 * @return The length of the file.
 */
uint32 File_ReadFile(const char *filename, void *buf)
{
	uint8 index;
	uint32 length;

	index = File_Open(filename, 1);
	length = File_Seek(index, 0, 2);
	File_Seek(index, 0, 0);
	File_Read(index, buf, length);
	File_Close(index);

	return length;
}
Beispiel #22
0
int WaveFile_Open(WaveFile* This, String* Sorc)
{
    int OpenStatus = File_Open(WStream, Sorc, READONLY);
    if(! OpenStatus)
        return 0;

    char RIFFChars[5];
    char WAVEChars[5];
    char FACTChars[5];
    RIFFChars[4] = 0;
    WAVEChars[4] = 0;
    FACTChars[4] = 0;

    File_Read_Buffer(WStream, RIFFChars, 4); //RIFF
    File_Read_Int(WStream); //Size
    File_Read_Buffer(WStream, WAVEChars, 4); //WAVE

    if(strcmp(RIFFChars, "RIFF"))
        return 0;
    if(strcmp(WAVEChars, "WAVE"))
        return 0;

    File_Read_Int32(WStream); //fmt
    int fmtSize            = File_Read_Int32(WStream);
    File_Read_Int16(WStream); //FormatTag
    Header.Channel         = File_Read_Int16(WStream);
    Header.SamplePerSecond = File_Read_Int32(WStream);
    Header.BytePerSecond   = File_Read_Int32(WStream);
    Header.BlockAlign      = File_Read_Int16(WStream);
    Header.BitPerSample    = File_Read_Int16(WStream);

    if(fmtSize == 16)
    {
        //No extra info
    }else
        File_Read_Int16(WStream); //Extra info
    File_Read_Buffer(WStream, FACTChars, 4);

    if(! strcmp(FACTChars, "fact"))
    {
        int factSize = File_Read_Int32(WStream);
        File_SetPosition(WStream, File_GetPosition(WStream) + factSize + 4);
    }

    Header.DataSize = File_Read_Int32(WStream);
    Header.DataPosition = File_GetPosition(WStream);
    Header.BytePerSample = Header.BitPerSample / 8;
    Header.DataNum = Header.DataSize / Header.BytePerSample / Header.Channel;

    return 1;
}
Beispiel #23
0
int D88_SetFD(int drv, char* filename)
{
	int trk, sct;
	FILEH fp;
	D88_SECTOR d88s;

	strncpy(D88File[drv], filename, MAX_PATH);
	D88File[drv][MAX_PATH-1] = 0;

	fp = File_Open(D88File[drv]);
	if ( !fp ) {
		ZeroMemory(D88File[drv], MAX_PATH);
		return FALSE;
	}
	File_Seek(fp, 0, FSEEK_SET);
	if ( File_Read(fp, &D88Head[drv], sizeof(D88_HEADER))!=sizeof(D88_HEADER) ) goto d88_set_error;

	if ( D88Head[drv].protect ) {
		FDD_SetReadOnly(drv);
	}

	for (trk=0; trk<164; trk++) {
		long ptr = D88Head[drv].trackp[trk];
		D88_SECTINFO *si, *oldsi = NULL;
		if ( (ptr>=(long)sizeof(D88_HEADER))&&(ptr<D88Head[drv].fd_size) ) {
			d88s.sectors = 65535;
			File_Seek(fp, ptr, FSEEK_SET);
			for (sct=0; sct<d88s.sectors; sct++) {
				if ( File_Read(fp, &d88s, sizeof(D88_SECTOR))!=sizeof(D88_SECTOR) ) goto d88_set_error;
				si = (D88_SECTINFO*)malloc(sizeof(D88_SECTINFO)+d88s.size);
				if ( !si ) goto d88_set_error;
				if ( sct ) {
					oldsi->next = si;
				} else {
					D88Trks[drv][trk] = si;
				}
				memcpy(&si->sect, &d88s, sizeof(D88_SECTOR));
				if ( File_Read(fp, ((unsigned char*)si)+sizeof(D88_SECTINFO), d88s.size)!=d88s.size ) goto d88_set_error;
				si->next = 0;
				if (oldsi) oldsi = si;
			}
		}
	}
	File_Close(fp);
	return TRUE;

d88_set_error:
	File_Close(fp);
	FDD_SetReadOnly(drv);
	return FALSE;
}
Beispiel #24
0
int D88_Eject(int drv)
{
	int trk, pos;
	FILEH fp;

	if ( !D88File[drv][0] ) return FALSE;

	if ( !FDD_IsReadOnly(drv) ) {
		fp = File_Open(D88File[drv]);
		if ( fp ) {
			pos = sizeof(D88_HEADER);
			for (trk=0; trk<164; trk++) {
				D88_SECTINFO *si = D88Trks[drv][trk];
				if ( si )
					D88Head[drv].trackp[trk] = pos;
				else
					D88Head[drv].trackp[trk] = 0;
				while ( si ) {
					pos += (sizeof(D88_SECTOR)+si->sect.size);
					si = si->next;
				}
			}
			D88Head[drv].fd_size = pos;
			File_Write(fp, &D88Head[drv], sizeof(D88_HEADER));
			for (trk=0; trk<164; trk++) {
				D88_SECTINFO *si = D88Trks[drv][trk];
				while ( si ) {
					File_Write(fp, &si->sect, sizeof(D88_SECTOR)+si->sect.size);
					si = si->next;
				}
				D88Trks[drv][trk] = 0;
			}
			File_Close(fp);
		}
	}

	for (trk=0; trk<164; trk++) {
		D88_SECTINFO *si = D88Trks[drv][trk];
		while ( si ) {
			D88_SECTINFO *nextsi = si->next;
			free(si);
			si = nextsi;
		}
		D88Trks[drv][trk] = 0;
	}
	ZeroMemory(&D88Head[drv], sizeof(D88_HEADER));
	ZeroMemory(D88File[drv], MAX_PATH);

	return TRUE;
}
Beispiel #25
0
/**
 * Open (or close) given log file.
 */
static int DebugUI_SetLogFile(int nArgc, char *psArgs[])
{
	File_Close(debugOutput);
	debugOutput = NULL;

	if (nArgc > 1)
		debugOutput = File_Open(psArgs[1], "w");

	if (debugOutput)
		fprintf(stderr, "Debug log '%s' opened.\n", psArgs[1]);
	else
		debugOutput = stderr;

	return DEBUGGER_CMDDONE;
}
Beispiel #26
0
Datei: main.c Projekt: wakaw/bws
//// 4.速度ステップ入力 ////////////////////////////////////////////////
void Velocity_Step(void)
{
	int Flag=1;
	int yes;
	int ch;
	
	while(Flag){
		Display_Title();											//タイトル表示
		printf(" <Velocity Step Response Test Menu>\n");			//サブタイトル表示
		Sensors_Display();
		
		printf("\n Input Channel (1 or 2) >> ");					//チャンネル入力
		ch = Int_Stdin(1,2);
		
		printf("\n Input RPM 1 (-830 - 830)[RPM]) >> ");			//回転数入力
		M[ch].Target_RPM1 = Double_Stdin(-830,830);
		M[ch].DA_Value1 = (M[ch].Target_RPM1*0.003+2.5057)/5.0*4095.0;			//valueに変換
		
		printf("\n Input RPM 2 (-830 - 830)[RPM]) >> ");			//回転数入力
		M[ch].Target_RPM2 = Double_Stdin(-830,830);
		M[ch].DA_Value2 = (M[ch].Target_RPM2*0.003+2.5057)/5.0*4095.0;			//valueに変換
		
		printf("\n Input Sampling Cycle (1-100)[msec] >>");
		Samp_Cycle = Int_Stdin(1,100);
		
		M[ch].Counter_Past = Count_Read(ch);						//カウンタ初期値
		Rec_Time = 2.0;
		
		File_Open();												//ファイルオープン
		Step_h(ch);
		////////////////////////////////////////////////////////////////////////
		Timer2(Samp_Cycle,Rec_Time,Step_Drive1,ch);					//タイマon
		Timer2(Samp_Cycle,Rec_Time,Step_Drive2,ch);					//タイマon
		////////////////////////////////////////////////////////////////////////
		DA_Write(ch,2048);											//2.5V出力
		File_Close();												//ファイルクローズ
		
		sleep(1);
		Savexy();
		Sensors_Display();
		Returnxy();													//カーソル位置復帰
		printf("\n Now Check is End. Again? -- Y or N >> ");
		yes = Yes_or_No();
		if(yes=='n')Flag=0;
	}
}
Beispiel #27
0
Datei: main.c Projekt: wakaw/bws
//// 6.免荷一定制御(2モータ) ////////////////////////////////////////////////
void Force_Const_2(void)
{
	int Flag=1;
	int yes;
	int ch;
	
	while(Flag){
		Display_Title();											//タイトル表示
		printf(" <Constant Force Control Test Menu>\n");			//サブタイトル表示
		Sensors_Display();
		
		printf("\n Input Target Force (0 - 500)[N]) >> ");			//回転数入力
		M[1].Target_Force = Double_Stdin(0,500);
		M[2].Target_Force = Double_Stdin(0,500);
		
		printf("\n Input Gain (UP) (0 - )[rpm/N]) >> ");			//ゲイン入力(のぼり)
		M[1].Gain1 = Double_Stdin(0,1000);
		M[2].Gain1 = Double_Stdin(0,1000);
		
		printf("\n Input Gain (DOWN) (0 - )[rpm/N]) >> ");			//ゲイン入力(くだり)
		M[1].Gain2 = Double_Stdin(0,1000);
		M[2].Gain2 = Double_Stdin(0,1000);
		
		Input_Timer_Parameter();									//サンプリング間隔と記録時間を入力
		
		M[1].Counter_Past = Count_Read(1);						//カウンタ初期値
		M[2].Counter_Past = Count_Read(2);
		
		File_Open();												//ファイルオープン
		Force_Const_h2();
		////////////////////////////////////////////////////////////////////////
		Timer2(Samp_Cycle,Rec_Time,Force_Const_Drive2,1);			//タイマon
		////////////////////////////////////////////////////////////////////////
		DA_Write(1,2048);											//2.5V出力
		DA_Write(2,2048);
		File_Close();												//ファイルクローズ
		
		sleep(1);
		Savexy();
		Sensors_Display();
		Returnxy();													//カーソル位置復帰
		printf("\n Now Check is End. Again? -- Y or N >> ");
		yes = Yes_or_No();
		if(yes=='n')Flag=0;
	}
}
Beispiel #28
0
def(void, SaveText, String prefix, ListingItem *item, String text) {
	File file;

	String path = call(BuildPath, prefix, item, $("txt"));

	File_Open(&file, path,
			FileStatus_Create   |
			FileStatus_Truncate |
			FileStatus_WriteOnly);

	String_Destroy(&path);

	File_Write(&file, text);

	File_Close(&file);

	Logger_Info(this->logger, $("Saved transcript."));
}
Beispiel #29
0
/**
 * Reads the whole file in the memory.
 *
 * @param filename The name of the file to open.
 * @param mallocFlags The type of memory to allocate.
 * @return The CS:IP of the allocated memory where the file has been read.
 */
void *File_ReadWholeFile(const char *filename)
{
	uint8 index;
	uint32 length;
	void *buffer;

	index = File_Open(filename, 1);
	length = File_GetSize(index);

	buffer = malloc(length + 1);
	File_Read(index, buffer, length);

	/* In case of text-files it can be very important to have a \0 at the end */
	((char *)buffer)[length] = '\0';

	File_Close(index);

	return buffer;
}
Beispiel #30
0
/**
 * ??.
 * @param filename The name of the file to load.
 * @return Where the file is loaded.
 */
void *Sound_Unknown0823(const char *filename, uint32 *retFileSize)
{
    uint8 fileIndex;
    uint32 fileSize;
    void *res;

    if (filename == NULL || !File_Exists(filename)) return NULL;

    fileIndex = File_Open(filename, 1);
    fileSize  = File_GetSize(fileIndex);
    File_Close(fileIndex);

    fileSize += 1;
    fileSize &= 0xFFFFFFFE;

    *retFileSize = fileSize;
    res = malloc(fileSize);
    Driver_Voice_LoadFile(filename, res, fileSize);

    return res;
}