Пример #1
0
//=======================================================
int main(int argc, char* argv[])
{
    if(argc != 3)
    {
        std::cout << "usage: " << argv[0] << " <raw data dir> <vmap dest dir>" << std::endl;
		WaitForInput();
        return 1;
    }

    std::string src = argv[1];
    std::string dest = argv[2];

    std::cout << "using " << src << " as source directory and writing output to " << dest << std::endl;

    VMAP::TileAssembler* ta = new VMAP::TileAssembler(src, dest);

    if(!ta->convertWorld2())
    {
        std::cout << "exit with errors" << std::endl;
        delete ta;
		WaitForInput();
        return 1;
    }

    delete ta;
    std::cout << "Ok, all done" << std::endl;
	WaitForInput();
    return 0;
}
Пример #2
0
void Window_Message::Update() {
	Window_Selectable::Update();
	number_input_window->Update();

	if (visible && !Game_Message::visible) {
		// The Event Page ended but the MsgBox was used in this Event
		// It can be closed now.
		TerminateMessage();
		SetCloseAnimation(5);
		// Remove this when the Close Animation is implemented
		// The close animation must set the visible false flag
		visible = false;
	}
	else if (pause) {
		WaitForInput();
	} else if (active) {
		InputChoice();
	} else if (number_input_window->GetVisible()) {
		InputNumber();
	} else if (!text.empty()) {
		// Output the remaining text for the current page
		UpdateMessage();
	}
	else if (IsNextMessagePossible()) {
		// Output a new page
		StartMessageProcessing();
		//printf("Text: %s\n", text.c_str());
		if (!visible) {
			// The MessageBox is not open yet but text output is needed
			SetOpenAnimation(5);
			visible = true;
		}
		Game_Message::visible = true;
	}
}
Пример #3
0
void RunClient(string ip, unsigned short port) {
	client = new NetworkClient(ip, port);

	for(;;) {
		WaitForInput();
	}
}
Пример #4
0
void
YDebug()
{
	if(bDebugStatus)
	{
		YDebugBegin();
		WaitForInput();
	}
}
Пример #5
0
void
YDebug(const char* s)
{
	if(bDebugStatus)
	{
		YDebugBegin();
		std::puts(s);
		WaitForInput();
	}
}
void Window_Message::Update() {
	Window_Selectable::Update();
	number_input_window->Update();
	gold_window->Update();

	if (pause) {
		WaitForInput();
	} else if (active) {
		InputChoice();
	} else if (number_input_window->GetVisible()) {
		InputNumber();
	} else if (!text.empty()) {
		// Output the remaining text for the current page
		UpdateMessage();
	} else if (IsNextMessagePossible()) {
		// Output a new page
		if (Game_Temp::inn_calling) {
			ShowGoldWindow();
		}

		StartMessageProcessing();
		//printf("Text: %s\n", text.c_str());
		if (!visible) {
			// The MessageBox is not open yet but text output is needed
			// Open and Close Animations are skipped in battle
			SetOpenAnimation(Game_Temp::battle_running ? 0 : 5);
		} else if (closing) {
			// Cancel closing animation
			SetOpenAnimation(0);
		}
		Game_Message::visible = true;
	} else if (!Game_Message::message_waiting && Game_Message::visible) {
		if (visible && !closing) {
			// Start the closing animation
			SetCloseAnimation(Game_Temp::battle_running ? 0 : 5);
		} else if (!visible) {
			// The closing animation has finished
			Game_Message::visible = false;
			Game_Message::owner_id = 0;
		}
	}
}
Пример #7
0
int
yprintf(const char* str, ...)
{
	int t = -1;

	if(bDebugStatus)
	{
		YDebugBegin();

		std::va_list list;

		va_start(list, str);

		t = std::vprintf(str, list);

		va_end(list);
		WaitForInput();
	}
	return t;
}
Standard_Boolean OCCDemo_Presentation::WaitForInput (unsigned long aMilliSeconds)
{
  //::WaitForSingleObject(::CreateEvent (NULL, FALSE, FALSE, NULL), aMilliSeconds);
  if (::MsgWaitForMultipleObjects(0, NULL, FALSE, aMilliSeconds,
    QS_KEY | QS_MOUSEBUTTON) != WAIT_TIMEOUT)
  {
    MSG msg;
    if (::PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE))
    {
      if (msg.message == WM_KEYUP)
      {
        ::PeekMessage (&msg, NULL, 0, 0, PM_REMOVE);
        return WaitForInput (aMilliSeconds);
      }
      else
        return Standard_True;
    }
  }
  return Standard_False;
}
Пример #9
0
int
WriteFileFromMemory (char *file, char *buffer, unsigned bsize,
		     unsigned long floppysize, int askdisk, int fallthrough,
		     int overwrite)
{
  unsigned long i;
  int criterr = 0, wrhandle;

  if (askdisk)
    {
      puts ("\n");
      NLS_PUTSTRING (1, 21, "Insert TARGET diskette into drive");
      puts ("");
      NLS_PRINTSTRING (1, 9, "Press any key to continue . . .");
      WaitForInput ();
    }

  /* Check disk capacity is the same as that of the original
     diskette. */
  for (;;)
    {
      if (!DiskLargeEnough (file, floppysize) ||
	  ((criterr = CriticalErrorOccured ()) != 0))
	{
	  puts ("");
	  if (criterr)
	    {
	      NLS_PUTSTRING (1, 10, "Disk not ready!");
	    }
	  else
	    NLS_PUTSTRING (1, 12, "Not enough disk space on target drive!");

	  if (fallthrough)
	    return FALSE;

	  puts ("");
	  NLS_PRINTSTRING (1, 23, "Put a diskette with the right capacity in drive");
	  printf (" %c:,\n", GetDiskFromPathName (file));
	  NLS_PUTSTRING (1, 24, "or press CTRL-C to cancel.");
	  WaitForInput ();	/* When the user presses CTRL-C this function does not return */
	}
      else
	break;
    }

  if (access (file, EXISTS) == 0)
    {
      if (overwrite)
	{
	  if (remove (file) == -1)
	    {
	      puts ("");
	      NLS_PUTSTRING (1, 4, "File is write protected!");
	      return FALSE;
	    }
	}
      else
	{
	  puts ("\n");
	  NLS_PUTSTRING (1, 7, "File already exists!");
	  return FALSE;
	}
    }

  wrhandle = open (file, O_WRONLY | O_BINARY | O_CREAT);

  if (wrhandle == -1)
    return FALSE;

  for (i = 0; i < floppysize / bsize; i++)
    {
      if (!ReadMemoryBlock (buffer, bsize) ||
	  (write (wrhandle, buffer, bsize) != bsize))
	{
	  close (wrhandle);
	  if (access (file, EXISTS) == 0)
	    {
	      chmod (file, S_IWRITE);
	      remove (file);
	    }
	  return FALSE;
	}
    }

  close (wrhandle);
  chmod (file, S_IWRITE);
  return TRUE;
}
Пример #10
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrev, LPSTR szCmdLine,
                   int nShow)
{
    /* Structure with the data and settings for the application */
    /* data is: hwnd, lpdi, joy[], num_joy, cur_joy, chosen_joy, poll_time, axes_max, axes_min, buffered */
    struct JoystickData data =
    { NULL, NULL, NULL, 0, 0, 0, 0, 1000, -1000, FALSE };
    HRESULT hr;

    hr = DirectInput8Create(GetModuleHandleA(NULL), DIRECTINPUT_VERSION,
                            &IID_IDirectInput8A, (void **)&data.di, NULL);

    if (FAILED(hr)) {
        printf("Failed to initialize DirectInput: 0x%08x\n", hr);
        return 1;
    }

    /* First count how many joysticks are there */
    hr = IDirectInput8_EnumDevices(data.di, DI8DEVCLASS_GAMECTRL,
                                   EnumCallback, &data, DIEDFL_ATTACHEDONLY);
    data.joysticks = malloc(sizeof(struct Joystick) * data.num_joysticks);

    /* Get all the joysticks */
    hr = IDirectInput8_EnumDevices(data.di, DI8DEVCLASS_GAMECTRL,
                                   EnumCallback, &data, DIEDFL_ATTACHEDONLY);

    /* Get settings from the command line */
    ProcessCmdLine(&data, szCmdLine);

    /* Apply settings for all joysticks */
    for (data.cur_joystick = 0; data.cur_joystick < data.num_joysticks;
            data.cur_joystick++) {
        IDirectInputDevice8_EnumObjects(data.joysticks[data.cur_joystick].
                                        device, EnumObjectsCallback, &data,
                                        DIDFT_AXIS | DIDFT_BUTTON);
    }

    printf("Found %d joysticks.\n", data.num_joysticks);

    /* Default case just lists the joysticks */
    if (data.poll_time == 0) {

        int i = 0;
        for (i = 0; i < data.num_joysticks; i++)
            printf("%d: %s\n", i, data.joysticks[i].instance.tszInstanceName);
    }
    else {

        /* If we'll poll the joystick for input */
        if (data.num_joysticks > 0) {

            if (data.chosen_joystick >= data.num_joysticks
                    || data.chosen_joystick < 0) {
                printf("Joystick '%d' is not connected\n",
                       data.chosen_joystick);
                exit(1);
            }

            WaitForInput(&data);
        }
    }
    return 0;
}
Пример #11
0
void
MediaCodecDataDecoder::DecoderLoop()
{
  bool isOutputDone = false;
  AutoLocalJNIFrame frame(jni::GetEnvForThread(), 1);
  MediaFormat::LocalRef outputFormat(frame.GetEnv());
  nsresult res = NS_OK;

  while (WaitForInput()) {
    RefPtr<MediaRawData> sample = PeekNextSample();

    {
      MonitorAutoLock lock(mMonitor);
      if (State() == kDrainDecoder) {
        MOZ_ASSERT(!sample, "Shouldn't have a sample when pushing EOF frame");
        res = QueueEOS();
        BREAK_ON_DECODER_ERROR();
      }
    }

    if (sample) {
      res = QueueSample(sample);
      if (NS_SUCCEEDED(res)) {
        // We've fed this into the decoder, so remove it from the queue.
        MonitorAutoLock lock(mMonitor);
        MOZ_RELEASE_ASSERT(mQueue.size(), "Queue may not be empty");
        mQueue.pop_front();
        isOutputDone = false;
      }
    }

    if (isOutputDone) {
      continue;
    }

    BufferInfo::LocalRef bufferInfo;
    nsresult res = BufferInfo::New(&bufferInfo);
    BREAK_ON_DECODER_ERROR();

    int32_t outputStatus = -1;
    res = mDecoder->DequeueOutputBuffer(bufferInfo, kDecoderTimeout,
                                        &outputStatus);
    BREAK_ON_DECODER_ERROR();

    if (outputStatus == MediaCodec::INFO_TRY_AGAIN_LATER) {
      // We might want to call mCallback->InputExhausted() here, but there seems
      // to be some possible bad interactions here with the threading.
    } else if (outputStatus == MediaCodec::INFO_OUTPUT_BUFFERS_CHANGED) {
      res = ResetOutputBuffers();
      BREAK_ON_DECODER_ERROR();
    } else if (outputStatus == MediaCodec::INFO_OUTPUT_FORMAT_CHANGED) {
      res = mDecoder->GetOutputFormat(ReturnTo(&outputFormat));
      BREAK_ON_DECODER_ERROR();
    } else if (outputStatus < 0) {
      NS_WARNING("Unknown error from decoder!");
      INVOKE_CALLBACK(Error);
      // Don't break here just in case it's recoverable. If it's not, other
      // stuff will fail later and we'll bail out.
    } else {
      // We have a valid buffer index >= 0 here.
      int32_t flags;
      nsresult res = bufferInfo->Flags(&flags);
      BREAK_ON_DECODER_ERROR();

      if (flags & MediaCodec::BUFFER_FLAG_END_OF_STREAM) {
        HandleEOS(outputStatus);
        isOutputDone = true;
        // We only queue empty EOF frames, so we're done for now.
        continue;
      }

      res = ProcessOutput(bufferInfo, outputFormat, outputStatus);
      BREAK_ON_DECODER_ERROR();
    }
  }

  Cleanup();

  // We're done.
  MonitorAutoLock lock(mMonitor);
  State(kShutdown);
  mMonitor.Notify();
}
Пример #12
0
LiquidModelInstance::LiquidModelInstance(MPQFile &f, uint32 base_pos, uint32 tileID, MH20_Header* header, uint32 mapID, uint32 tileX, uint32 tileY, FILE *pDirfile) : Info(false)
{
	memset(&LiqHeader, 0, sizeof(LiquidHeader));
	LiqHeader.layerCount = header->layerCount;
	if(header->ofsInformation == 0)
	{
		Info = false;
		return;
	}

#ifdef _DEBUG
	printf("Information offset: %i\n", header->ofsInformation);
#endif
	f.seek(header->ofsInformation+base_pos);
	f.read(&LiqHeader.info, sizeof(MH20_Information));

#ifdef _DEBUG
	if(LiqHeader.info.LiquidType != 2) // Skip oceans
	{
		printf("Liquid Data Dump:\n");
		printf("Flags: %08i |\n", LiqHeader.info.flags);
//		printf("Height %08i |\n", LiqHeader.info.height);
//		printf("Level1 %08f |\n", LiqHeader.info.heightLevel1);
//		printf("Level2 %08f |\n", LiqHeader.info.heightLevel2);
		printf("LType: %08i |\n", LiqHeader.info.LiquidType);
		printf("Width: %08i |\n", LiqHeader.info.width);
		printf("xOfset %08i |\n", LiqHeader.info.xOffset);
		printf("yOfset %08i |\n", LiqHeader.info.yOffset);
		WaitForInput();
	}
#endif

	uint16* buff = new uint16[3];
	buff[0] = buff[1] = buff[2] = 0;
	if(LiqHeader.info.ofsHeightmap > 0)
	{
#ifdef _DEBUG
		printf("Height Map Offset: %i\n", LiqHeader.info.ofsHeightmap);
#endif
		f.seek(LiqHeader.info.ofsHeightmap+base_pos);
		f.read(&LiqHeader.heightMap.heightMap, sizeof(float)*2);
		f.read(&LiqHeader.heightMap.transparency, sizeof(char)*2);
		buff[0] = sizeof(LiqHeader.heightMap);
	}

	if(LiqHeader.info.ofsMask2 > 0)
	{
#ifdef _DEBUG
		printf("Mask Offset: %i\n", LiqHeader.info.ofsMask2);
#endif
		f.seek(LiqHeader.info.ofsMask2+base_pos);
		f.read(&LiqHeader.Mask2, sizeof(uint8));
		buff[1] = sizeof(uint8);
	}

	if(header->ofsRender > 0)
	{
#ifdef _DEBUG
		printf("Render offset: %i\n", header->ofsRender);
#endif
		f.seek(header->ofsRender+base_pos);
		f.read(&LiqHeader.Render, sizeof(uint64));
		buff[2] = sizeof(uint64);
	}

	fwrite(&LiqHeader.layerCount, sizeof(uint32), 1, pDirfile);
	fwrite(&LiqHeader.info, sizeof(MH20_Information), 1, pDirfile);

	fwrite(&buff[0], sizeof(uint16), 1, pDirfile);
	if(buff[0])
		fwrite(&LiqHeader.heightMap, sizeof(MH2O_HeightMapData), 1, pDirfile);
	fwrite(&buff[1], sizeof(uint16), 1, pDirfile);
	if(buff[1])
		fwrite(&LiqHeader.Mask2, sizeof(uint8), 1, pDirfile);
	fwrite(&buff[2], sizeof(uint16), 1, pDirfile);
	if(buff[2])
		fwrite(&LiqHeader.Render, sizeof(uint64), 1, pDirfile);
}
Пример #13
0
int main(int argc, char ** argv)
{
    bool success=true;
    const char *versionString = "V3.00 2010_07";

    // Use command line arguments, when some
    if(!processArgv(argc, argv, versionString))
        return 1;

    // some simple check if working dir is dirty
    else
    {
        std::string sdir = std::string(szWorkDirWmo) + "/dir";
        std::string sdir_bin = std::string(szWorkDirWmo) + "/dir_bin";
        struct stat status;
        if (!stat(sdir.c_str(), &status) || !stat(sdir_bin.c_str(), &status))
        {
            printf("Your output directory seems to be polluted, please use an empty directory!\n");
            printf("<press return to exit>");
            char garbage[2];
            scanf("%c", garbage);
            return 1;
        }
    }

    printf("Extract %s. Beginning work ....\n",versionString);
    //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    // Create the working directory
#ifdef __linux__
    if(mkdir(szWorkDirWmo, 0711))
		success = (errno == EEXIST);
#else
    if(mkdir(szWorkDirWmo))
		success = (errno == EEXIST);
#endif

    // prepare archive name list
    std::vector<std::string> archiveNames;
    fillArchiveNameVector(archiveNames);
    for (size_t i=0; i < archiveNames.size(); ++i)
    {
        MPQArchive *archive = new MPQArchive(archiveNames[i].c_str());
        if(!gOpenArchives.size() || gOpenArchives.front() != archive)
            delete archive;
    }

    if(gOpenArchives.empty())
    {
        printf("FATAL ERROR: None MPQ archive found by path '%s'. Use -d option with proper path.\n",input_path);
        return 1;
    }
    ReadLiquidTypeTableDBC();

    // extract data
    if(success)
        success = ((ExtractWmo() > 0) ? true : false);

    //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    //map.dbc
    if(success)
    {
        DBCFile * dbc = new DBCFile("DBFilesClient\\Map.dbc");
        if(!dbc->open())
        {
            delete dbc;
            printf("FATAL ERROR: Map.dbc not found in data file.\n");
            return 1;
        }
        map_count=dbc->getRecordCount ();
        map_ids=new map_id[map_count];
        for(unsigned int x=0;x<map_count;++x)
        {
            map_ids[x].id=dbc->getRecord (x).getUInt(0);
            strcpy(map_ids[x].name,dbc->getRecord(x).getString(1));
            printf("Map - %s\n",map_ids[x].name);
        }


        delete dbc;
        ParsMapFiles();
        delete [] map_ids;
        //nError = ERROR_SUCCESS;
    }

    printf("\n");
    if(!success)
        printf("ERROR: Extract %s. Work NOT complete.\n   Precise vector data=%d.\n",versionString, preciseVectorData);

    printf("Extract %s. Work complete. No errors.\n",versionString);
    delete [] LiqType;
	WaitForInput();
    return 0;
}
Пример #14
0
int main(int argc, const char* argv[]) {
	// Load Twitter graph.
	PNGraph graph = TSnap::LoadEdgeList<PNGraph>("twitter_combined.txt", 0, 1);
	int numOfNodes = graph->GetNodes();
	int numOfEdges = graph->GetEdges();
	printf("Number of nodes: %d\n", numOfNodes);
	printf("Number of edges: %d\n", numOfEdges);
	
	// Load all node list.
	std::vector<int> nodeIds;
	exportNodeList(graph, nodeIds);
	
	// Load verified node list.
	std::vector<int> verifiedIds;
	loadIdsFromFile("v.txt", verifiedIds);
	printf("%d\n", verifiedIds.size());
	
	// Load spammer list.
	std::vector<int> spammerIds;
	loadIdsFromFile("labeled_spammers.txt", spammerIds);
	printf("%d\n", spammerIds.size());

	// Load suspect list.
	std::vector<int> suspectIds;
	loadIdsFromFile("suspect.txt", suspectIds);
	std::random_shuffle(suspectIds.begin(), suspectIds.end());
	printf("%d\n", suspectIds.size());


	getPageRankFromVect(graph, verifiedIds, spammerIds, 1000, "pr_VS2.txt");
	getPageRankFromVect(graph, verifiedIds, verifiedIds, 1000, "pr_VV2.txt");

	/*
	TFltPrV vvPR;
	plotPR("pr_VV2.txt", vvPR);
	TFltPrV vsPR;
	plotPR("pr_VS2.txt", vsPR);
	TGnuPlot plot3("prcom2", "");
	plot3.AddCmd("set key right top");
	plot3.SetXRange(0, 2500);
	plot3.AddPlot(vvPR, gpwLinesPoints, "Legitimate users to legitimate users");
	plot3.AddPlot(vsPR, gpwLinesPoints, "Legitimate users to Spammers");
	plot3.SetXLabel("Page rank score x 1000");
	plot3.SetYLabel("Count");
	// plot3.SetScale(gpsLog10XY);
	plot3.SavePng();
	*/
	/*
	TFltPrV vvPR;
	plotpaths("numOfPaths_VV.txt", vvPR);
	TFltPrV vsPR;
	plotpaths("numOfPaths_VS.txt", vsPR);
	TGnuPlot plot3("pathcom", "");
	plot3.AddCmd("set key right top");
	plot3.SetXRange(0, 100);
	plot3.AddPlot(vvPR, gpwLinesPoints, "Legitimate users to legitimate users");
	plot3.AddPlot(vsPR, gpwLinesPoints, "Legitimate users to Spammers");
	plot3.SetXLabel("Number of indepentdent paths");
	plot3.SetYLabel("Count");
	// plot3.SetScale(gpsLog10XY);
	plot3.SavePng();
	*/
	/*
	TFltPrV regularDistance;
	getSampledDistance(graph, verifiedIds, verifiedIds, 5000, regularDistance);
	TFltPrV spamDistance;
	getSampledDistance(graph, verifiedIds, spammerIds, 5000, spamDistance);

	TGnuPlot plot3("Distance", "");
	plot3.AddCmd("set key right top");
	plot3.SetXRange(1, 9);
	plot3.AddPlot(regularDistance, gpwLinesPoints, "Legitimate users to legitimate users");
	plot3.AddPlot(spamDistance, gpwLinesPoints, "Legitimate users to Spammers");
	plot3.SetXLabel("Distance");
	plot3.SetYLabel("Count");
	// plot3.SetScale(gpsLog10XY);
	plot3.SavePng();
	*/



	// Distance Analysis
	// plotDegDistribution(graph);
	// plotParitialDegDistribution(graph, suspectIds);
	// getDistance(graph, verifiedIds, spammerIds);

	//getPageRankFromVect(graph, verifiedIds, 30, verifiedIds, 30, "pageRankResult_VV.txt");
	//getPageRankFromVect(graph, verifiedIds, 30, spammerIds, 30, "pageRankResult_VS.txt");

	// getNumOfPathsFromVect(graph, verifiedIds, 30, verifiedIds, 30, "numOfPaths_VV.txt");
	// getNumOfPathsFromVect(graph, verifiedIds, 30, spammerIds, 30, "numOfPaths_VS.txt");
	/*

	// double aveClusterCoeff = TSnap::GetClustCf(graph);
	// printf("%f\n", aveClusterCoeff);

	int srcNodeID = 783214; // graph->GetRndNId();
	int dstNodeID = 657863; // graph->GetRndNId();
	printf("src: %d, dst: %d\n", srcNodeID, dstNodeID);

	PNGraph subgraph = getFourHopGraph(graph, srcNodeID, dstNodeID);

	TIntFltH pageRanks;
	TSnap::GetPageRank(subgraph, pageRanks);

	pageRanks.Sort(false, false);
	TVec<TInt, int> keyV;
	pageRanks.GetKeyV(keyV);

	int ccc = 0;
	for (TVec<TInt, int>::TIter itr = keyV.BegI(); itr != keyV.EndI(); itr++) {
		printf("%d, %f\n", itr->Val, pageRanks.GetDat(itr->Val).Val);
		if (++ccc % 50 == 0) {
			WaitForInput();
		}
	}
	*/

	/*
	int numPaths = getNumOfIndependentPaths(subgraph, srcNodeID, dstNodeID);
	printf("Num Of paths: %d", numPaths);
	*/
	WaitForInput();
	return 0;
}
Пример #15
0
CROSSCUT_NLS_DATA

int
main (int argc, char *argv[])
{
  int memkind, handle;
  char loop1, loop2;
  struct dfree free;
  char buf[BUFFERSIZE];
  char cmpbuf[BUFFERSIZE];
  unsigned long sector, total, disksize, allocated, beginsector, endsector;
  unsigned long FilledDiskSize, FilledTotal, FileSize = 0;
  int Arg1IsFile, Arg2IsFile;
  int UseImageFile, ImageModus, Overwrite;
  int i, enable;
  int audible, verify, fallthrough, askdisk, asktdisk;
  char sdrive, tdrive;
  int HardDiskOk;
  int informative, copyfast;
  char switchchar;
  int tocopysectors;
  unsigned tobuffer;
#ifndef ALL_RECOVERY_MODE
  int recoverymode;
#endif
  int bytespersector;
  int CopyingToSameDisk = FALSE;
  int action, success;
  struct LFNAttribute attr;

  struct IniParserStruct *ParsedData;
  struct TwoDriveCopyData tdrvdata;

  attr.output = TRUE;

  memkind = UNALLOCATED;
  UseImageFile = FALSE;

  SetExePath (argv[0]);		/* Remember executable's path.     */
  CriticalHandlerOn ();		/* Install critical handler.       */
  InitLFNAPI ();		/* Initialise LFN API.             */

  CROSSCUT_NLS_OPEN

    switchchar = SwitchChar ();

  /* Check arguments */
  if ((argc == 2) && ((argv[1][0] == '/') || (argv[1][0] == switchchar)) &&
      (argv[1][1] == '?') && (argv[1][2] == '\0'))
    {
      ShowHelp (switchchar);
      return COPYSUCCESS;
    }

  if (argc > 2)
    {
      Arg1IsFile = IsFile (argv[1]);
      Arg2IsFile = IsFile (argv[2]);
    }

#ifdef DEF_HELP
  if (argc < 3)
    {
      /* The way we do it.                */
      ShowHelp (switchchar);
      return INITERROR;
    }
  else if ((!HasFloppyForm (argv[1]) && !Arg1IsFile) ||
	   (!HasFloppyForm (argv[2]) && !Arg2IsFile))
#else
  if ((argc < 3) || (!HasFloppyForm (argv[1]) && !Arg1IsFile)
      || (!HasFloppyForm (argv[2]) && !Arg2IsFile))
#endif
    {
      /* The way (DR and MS) DOS does it. */
      NLS_PUTSTRING (1, 0, "Invalid drive specification or non removable media.");
      return INITERROR;
    }

  if (ParseIniFile (NULL) < 0)	/* Parse .ini file. */
    {
      NLS_PUTSTRING (1, 1, "Error reading configuration file.");
      return INITERROR;
    }

  ParsedData = GetParsedData ();

  audible = ParsedData->audible;
  verify = ParsedData->verify;
  HardDiskOk = ParsedData->UseSWAP;
  informative = ParsedData->informative;
  Overwrite = ParsedData->overwrite;
  fallthrough = ParsedData->autoexit;
  askdisk = ParsedData->askdisk;
  asktdisk = ParsedData->asktdisk;
  copyfast = (ParsedData->speed == FAST);
#ifndef ALL_RECOVERY_MODE
  recoverymode = ParsedData->mode;
#endif

  /* Check arguments. */
  for (i = 3; i < argc; i++)
    {
      if (strlen (argv[i]) > 3)
	{
	  NLS_PRINTSTRING (1, 2, "Invalid switch:");
	  printf (" %s\n", argv[i]);
	  return INITERROR;
	}

      enable = TRUE;
      if (strlen (argv[i]) == 3)
	{
	  if (argv[i][2] == '-')
	    {
	      enable = FALSE;
	    }
	  else
	    {
	      NLS_PRINTSTRING (1, 2, "Invalid switch");
	      printf (" %s\n", argv[i]);
	      return INITERROR;
	    }
	}

      if ((argv[i][0] == switchchar) || (argv[i][0] == '/'))
	switch (argv[i][1])
	  {
	  case 'a':		/* DOS is case insensitive. */
	  case 'A':
	    audible = enable;
	    break;
	  case 'v':
	  case 'V':
	    verify = enable;
	    break;
	  case 'm':
	  case 'M':
	    HardDiskOk = !enable;
	    break;
	  case 'i':
	  case 'I':
	    informative = enable;
	    break;
	  case 'o':
	  case 'O':
	    Overwrite = enable;
	    break;
	  case 'x':
	  case 'X':
	    fallthrough = enable;
	    break;
	  case 'd':
	  case 'D':
	    askdisk = !enable;
	    break;

	  case 'f':
	  case 'F':
	    copyfast = enable;
	    break;

#ifndef ALL_RECOVERY_MODE
	  case 'r':
	  case 'R':
	    recoverymode = enable;
	    break;
#else
	  case 'r':
	  case 'R':
#endif
	  case 't':
	  case 'T':
	    asktdisk = !enable;
	    break;

	  case '1':
	    NLS_PRINTSTRING (2, 0, "Warning: option");
	    printf (" %s ", argv[i]);
	    NLS_PUTSTRING (2, 1, "doesn't do anything!");
	    break;

	  default:
	    NLS_PRINTSTRING (1, 2, "Invalid switch");
	    printf (" %s\n", argv[i]);
	    return INITERROR;
	  }
      else
	{
	  NLS_PRINTSTRING (1, 3, "Too many parameters:");
	  printf (" %s\n", argv[i]);
	  return INITERROR;
	}
    }

  if (Arg1IsFile && Arg2IsFile)
    {
      ConvertToSFN (argv[1], INFILE_ID);
      ConvertToSFN (argv[2], OUTFILE_ID);

      SetLFNAttribute (&attr, OUTFILE_ID);

      if ((access (GetSFN (OUTFILE_ID), EXISTS) == 0) &&
	  Overwrite &&
	  (remove (GetSFN (OUTFILE_ID)) == -1))
	{
	  NLS_PUTSTRING (1, 4, "File is write protected!");
	  return INITERROR;
	}

      if (CopyFile (GetSFN (INFILE_ID), GetSFN (OUTFILE_ID)))
	{
	  printf ("%s ", argv[1]);
	  NLS_PRINTSTRING (1, 5, "copied to");
	  printf (" %s", argv[2]);
	  if (audible)
	    Beep ();

	  SynchronizeLFNs ();
	  return COPYSUCCESS;
	}
      else
	{
	  NLS_PRINTSTRING (3, 0, "Problem copying");
	  printf (" %s ", argv[1]);
	  NLS_PRINTSTRING (3, 1, "to");
	  printf (" %s.\n", argv[2]);
	  return CRITICAL;
	}
    }
  else if (Arg1IsFile)
    {
      ConvertToSFN (argv[1], INFILE_ID);

      if (access (GetSFN (INFILE_ID), READPERMISSION) != 0)
	{
	  NLS_PRINTSTRING (1, 6, "File not found:");
	  printf (" %s\n", argv[1]);
	  return INITERROR;
	}

      CopyingToSameDisk = IsCopyToSameDisk (argv[1], argv[2]);
      UseImageFile = TRUE;
      ImageModus = READIMAGE;
    }
  else if (Arg2IsFile)
    {
      CopyingToSameDisk = IsCopyToSameDisk (argv[2], argv[1]);

      ConvertToSFN (argv[2], OUTFILE_ID);

      SetLFNAttribute (&attr, OUTFILE_ID);

      if (!CopyingToSameDisk)
	{
	  if (access (GetSFN (OUTFILE_ID), EXISTS) == 0)
	    {
	      if (Overwrite)
		{
		  if (remove (GetSFN (OUTFILE_ID)) != 0)
		    {
		      NLS_PRINTSTRING (1, 4, "File is write protected!");
		      return INITERROR;
		    }
		}
	      else
		{
		  NLS_PRINTSTRING (1, 7, "File already exists!");
		  return INITERROR;
		}
	    }
	}

      if (CopyingToSameDisk)
	copyfast = TRUE;
      UseImageFile = TRUE;
      ImageModus = WRITEIMAGE;
    }

  sdrive = (char) toupper (argv[1][0]) - 65;
  tdrive = (char) toupper (argv[2][0]) - 65;

  loop1 = CatYES;		/* initialize loop1         */
  loop2 = CatYES;		/* initialize loop2         */

  ctrlbrk (OnCBreak);
  SavedCBreak = getcbrk ();
  setcbrk (1);			/* set control-break to ON  */
  atexit (OnExit);		/* make sure that all allocated memory is released when
				   program stops. */

  if ((sdrive != tdrive) && (!UseImageFile) && BiosReportsTwoDrives ())
    {
      tdrvdata.sourcedrv = sdrive;
      tdrvdata.destdrv = tdrive;
      tdrvdata.cpybuf = buf;
      tdrvdata.cmpbuf = cmpbuf;
      tdrvdata.bufsize = BUFFERSIZE;
      tdrvdata.bel = audible;
      tdrvdata.fallthrough = fallthrough;
      tdrvdata.askdisk = askdisk;
      tdrvdata.copyfast = copyfast;
      tdrvdata.verify = verify;
#ifndef ALL_RECOVERY_MODE
      tdrvdata.recoverymode = recoverymode;
#endif
#ifdef UPDATE_SERIALNUM
      tdrvdata.updateserial = ParsedData->serialnumber;
#endif

      TwoDriveCopy (&tdrvdata);

      return COPYSUCCESS;
    }

  endsector = 0;
  while (!NLS_TEST_NO (loop1))	/* loop1 */
    {
      if (!UseImageFile || (ImageModus == WRITEIMAGE))
	{
	  if (askdisk)
	    {
	      puts ("");
	      NLS_PRINTSTRING (1, 8, "Insert SOURCE diskette into drive");
	      printf (" %s\n\n", argv[1]);
	      NLS_PRINTSTRING (1, 9, "Press any key to continue . . .");
	      WaitForInput ();
	      puts ("");
	    }
	  else
	    askdisk = TRUE;	/* Always ask after the first run. */
	}

      if (endsector == 0)
	{
	  if (!UseImageFile || (ImageModus == WRITEIMAGE))
	    {
	      if (!DiskReadBootInfo (sdrive, &free) ||
                  (DetermineFATType() != FAT12))
		{
		  puts ("");
		  NLS_PUTSTRING (1, 10, "Disk not ready!");
		  return CRITICAL;
		}
	    }
	  else
	    {
	      /* Remember file size */
	      handle = open (GetSFN (INFILE_ID), O_RDONLY | O_BINARY);
	      if (handle < 0)
		{
		  puts ("");
		  NLS_PUTSTRING (1, 11, "Unable to open image file.");
		  return INITERROR;
		}
	      FileSize = filelength (handle);
	      close (handle);

	      if (!FileReadBootInfo (GetSFN (INFILE_ID), &free))
		{
		  puts ("");
		  NLS_PUTSTRING (1, 11, "Unable to open image file.");
		  return INITERROR;
		}
	    }

	  total = free.df_total * free.df_sclus;
	  bytespersector = free.df_bsec;
	  disksize = total * bytespersector;

	  if (disksize == 0)
	    {
	      puts ("");
	      NLS_PUTSTRING (1, 0, "Invalid drive specification or non removable media.");
	      return INITERROR;
	    }

	  /* Initialize fast copy:
	     - After checking if disk in drive is ok, BUT
	     - before initializing memory                  */
	  /*
	     In case of writing an image file to disk. We'd like the
	     program to succeed regardless of wether we used the
	     /f switch or corresponding .ini file entry             */
	  if (((copyfast) ||
	       ((UseImageFile && (ImageModus == READIMAGE)) &&
		disksize != FileSize)) &&
	      (disksize != FileSize))
	    {
	      SetCopySpeed (FAST);

	      if (!UseImageFile || (ImageModus == WRITEIMAGE))
		{
		  if (!DiskReadFatInfo (sdrive))
		    SetCopySpeed (FULL);
		}
	      else if (!FileReadFatInfo (GetSFN (INFILE_ID)))
		{
		  NLS_PUTSTRING (1, 32, "Can not copy image file");
		  return INITERROR;
		}
	    }
	  else
	    SetCopySpeed (FULL);
	}

      puts ("");

      /* Get the size of the meaningfull data on the disk */
      FilledDiskSize = GetDiskFilledSize (BUFFERSIZE);
      FilledTotal = (FilledDiskSize / free.df_bsec) / free.df_sclus;

      if ((UseImageFile) && (!CopyingToSameDisk))
	switch (SetImageFile (GetSFN (ImageModus - 1), ImageModus, FilledDiskSize))
	  {
	  case EZERO:
	    allocated = disksize;
	    break;

	  case DISKTOSMALL:
	    puts ("");
	    NLS_PUTSTRING (1, 12, "Not enough disk space on target drive!");
	    return INITERROR;

	  default:
	    NLS_PRINTSTRING (1, 13, "Error accessing image file:");
	    printf (" %s\n", argv[ImageModus]);
	    return INITERROR;
	  }
      else
	{
	  if (CopyingToSameDisk)
	    switch (ImageModus)
	      {
	      case READIMAGE:
		memkind = InitializeFittingMemory (FilledDiskSize, HardDiskOk, &allocated,
						   '\0', argv[2][0]);
		break;
	      case WRITEIMAGE:
		memkind = InitializeFittingMemory (FilledDiskSize, HardDiskOk, &allocated,
						   argv[1][0], '\0');
		break;
	      }
	  else
	    memkind = InitializeFittingMemory (FilledDiskSize, HardDiskOk, &allocated,
					       argv[1][0], argv[2][0]);

	  if (memkind == 0)
	    {
	      NLS_PUTSTRING (1, 14, "Insufficient memory for disk copy.\n");
	      return INITERROR;
	    }
	}

      if (CopyingToSameDisk)
	{
	  if (allocated != FilledDiskSize)
	    {
	      NLS_PUTSTRING (1, 14, "Insufficient memory for disk copy.\n");
	      return INITERROR;
	    }

	  if (ImageModus == READIMAGE)
	    {
	      PrepareForWriting ();
	      if (!ReadFileIntoMemory (GetSFN (INFILE_ID), buf, BUFFERSIZE))
		{
		  NLS_PUTSTRING (1, 33, "Problem reading image file.");
		  return CRITICAL;
		}
	    }
	  else
	    /* ImageModus == WRITEIMAGE */ if (!asktdisk)
	    {
	      if (!DiskLargeEnough (GetSFN (OUTFILE_ID), FilledDiskSize))
		{
		  puts ("");
		  NLS_PUTSTRING (1, 12, "Not enough disk space on target drive!");
		  return INITERROR;
		}
	    }
	}

      if (!UseImageFile || (ImageModus == WRITEIMAGE))
	{
	  beginsector = endsector;
	  endsector += allocated / BYTESPERSECTOR;
	  if ((endsector > total) || (allocated == FilledDiskSize))
	    endsector = total;
	}

      if (!UseImageFile || (ImageModus == WRITEIMAGE))
	{
	  NLS_PRINTSTRING (4, 0, "Copying");
	  printf (" %d ", (int) FilledTotal);
	  NLS_PRINTSTRING (4, 1, "clusters");
	  printf (", %d ", free.df_sclus);
	  NLS_PRINTSTRING (4, 2, "sectors per cluster");
	  printf (", %d ", free.df_bsec);
	  NLS_PRINTSTRING (4, 3, "bytes per sector");
	  puts (".");
	  NLS_PRINTSTRING (4, 4, "Relevant drive size is");
	  printf (" %lu ", FilledDiskSize);
	  NLS_PRINTSTRING (4, 5, "bytes");
	  printf (".");
	}

      if (informative && (!UseImageFile))
	{
	  printf (" ");
	  NLS_PRINTSTRING (1, 15, "Using");
	  printf (" ");

	  switch (memkind)
	    {
	    case EMS:
	      puts ("EMS.\n");
	      break;
	    case XMS:
	      puts ("XMS.\n");
	      break;
	    case HARDDISK:
	      NLS_PUTSTRING (1, 16, "temporary file");
	      puts ("");
	      break;
	    case BUFFERS:
	      NLS_PRINTSTRING (5, 0, "buffer of");
	      printf (" %ld ", allocated);
	      NLS_PUTSTRING (5, 1, "bytes.");
	      puts ("");
	      break;
	    }
	}
      else if (!UseImageFile || (ImageModus == WRITEIMAGE))
	puts ("\n");

      if (!UseImageFile || (ImageModus == WRITEIMAGE))
	{

	  for (action = DISKREADING;
	       (verify) ? (action <= VERIFICATION) : (action < VERIFICATION);
	       action++)
	    {
	      if (action == DISKREADING)
		{
		  if (!UseImageFile)
		    {
		      NLS_PRINTSTRING (1, 17, "Reading SOURCE diskette . . .");
		    }
		  else
		    NLS_PRINTSTRING (1, 34, "Creating image file . . .");

		  PrepareForWriting ();
		}
	      else
		{
		  puts ("");
		  NLS_PRINTSTRING (1, 38, "Verifying . . .");

		  PrepareForReading ();
		}

	      for (sector = beginsector; sector < endsector;
		   sector = sector + TOCOPYSECTORS)
		{
		  if (sector < endsector - TOCOPYSECTORS)
		    tocopysectors = TOCOPYSECTORS;
		  else
		    tocopysectors = (int) (endsector - sector);
		  tobuffer = (unsigned) (tocopysectors * BYTESPERSECTOR);

		  if (IsDiskReadRequired (sector, tocopysectors))	/* Fast copy */
		    {
#ifndef ALL_RECOVERY_MODE
		      if (recoverymode)
#endif

			ReadSectors (sdrive, tocopysectors, (int) sector, buf,
				     bytespersector);
#ifndef ALL_RECOVERY_MODE
		      else if (absread (sdrive, tocopysectors, (int) sector, buf) != 0)
			{
			  puts ("");
			  NLS_PRINTSTRING (1, 18, "Media error reading from sector");
			  printf (" %ld.\n", sector);
			}
#endif
		      if (action == DISKREADING)
			success = WriteMemoryBlock (buf, tobuffer);
		      else
			success = ReadMemoryBlock (cmpbuf, tobuffer);

		      if (!success)
			{
			  puts ("");
			  NLS_PUTSTRING (1, 20, "Unsuspected memory error.");
			  SetErrorStopped ();
			  return CRITICAL;
			}

		      if (action == VERIFICATION)
			{
			  if (memcmp (buf, cmpbuf, 5 /*tobuffer */ ) != 0)
			    {
			      puts ("");
			      NLS_PRINTSTRING (1, 37, "Compare error on sector");
			      printf (" %ld.\n", sector);
			    }
			}
		    }
		}
	    }
	}

      if (audible && (!UseImageFile))
	Beep ();

      if (!UseImageFile || (ImageModus == READIMAGE))
	{
	  while (!NLS_TEST_NO (loop2))	/* loop2 */
	    {
	      if (askdisk)
		{
		  if (!UseImageFile)
		    puts ("\n");
		  NLS_PRINTSTRING (1, 21, "Insert TARGET diskette into drive");
		  printf (" %s\n\n", argv[2]);
		  NLS_PRINTSTRING (1, 9, "Press any key to continue . . .");
		  WaitForInput ();
		}
	      else
		askdisk = TRUE;

	      /* Check disk capacity is the same as that of the original
	         diskette. */
	      for (;;)
		{
		  if (!DiskReadBootInfo (tdrive, &free))
		    {
		      puts ("");
		      NLS_PUTSTRING (1, 10, "Disk not ready!");
		      total = 0;
		    }
		  else
		    total = free.df_total * free.df_sclus;

		  if (((UseImageFile) && (FileSize != FilledDiskSize)) ||
		      (disksize != total * free.df_bsec))
		    {
		      puts ("");
		      NLS_PUTSTRING (1, 22, "Diskette does not have the same capacity as the original.");

		      if (fallthrough)
			return NONFATAL;

		      puts ("");
		      NLS_PRINTSTRING (1, 23, "Put a diskette with the right capacity in drive");
		      printf (" %s, \n", argv[2]);
		      NLS_PUTSTRING (1, 24, "or press CTRL-C to cancel.");
		      WaitForInput ();	/* When the user presses CTRL-C this function does not return */
		    }
		  else
		    break;
		}

	      if (UseImageFile)
		{
		  puts ("\n");
		  NLS_PRINTSTRING (4, 0, "Copying");
		  printf (" %d ", (int) FilledTotal);
		  NLS_PRINTSTRING (4, 1, "clusters");
		  printf (", %d ", free.df_sclus);
		  NLS_PRINTSTRING (4, 2, "sectors per cluster");
		  printf (", %d ", free.df_bsec);
		  NLS_PRINTSTRING (4, 3, "bytes per sector");
		  puts (".");
		  NLS_PRINTSTRING (4, 4, "Relevant drive size is");
		  printf (" %lu ", FilledDiskSize);
		  NLS_PRINTSTRING (4, 5, "bytes");
		  puts (".");

		  beginsector = endsector;
		  endsector += allocated / BYTESPERSECTOR;
		  if (endsector > total)
		    endsector = total;
		}

	      for (action = DISKWRITING;
	      (verify) ? (action <= VERIFICATION) : (action < VERIFICATION);
		   action++)
		{
		  if (action == DISKWRITING)
		    {
		      if (UseImageFile)
			{
			  puts ("");
			  NLS_PRINTSTRING (1, 35, "Writing image file . . .");
			}
		      else	

			{
			  puts ("\n");
			  NLS_PRINTSTRING (1, 25, "Writing to TARGET diskette in drive . . .");
			}
		      PrepareForReading ();
		    }
		  else	/* VERIFICATION */
		    {
		      puts ("");
		      NLS_PRINTSTRING (1, 38, "Verifying . . .");
		      PrepareForReading ();	/* Rewind */

		    }


		  for (sector = beginsector; sector < endsector;
		       sector = sector + TOCOPYSECTORS)
		    {
		      if (sector < endsector - TOCOPYSECTORS)
			tocopysectors = TOCOPYSECTORS;
		      else
			tocopysectors = (int) (endsector - sector);
		      tobuffer = (unsigned) (tocopysectors * BYTESPERSECTOR);

		      if (IsDiskReadRequired (sector, tocopysectors))
			{
			  if (!ReadMemoryBlock (buf, tobuffer))
			    {
			      puts ("");
			      NLS_PUTSTRING (1, 20, "Unsuspected memory error.");
			      SetErrorStopped ();
			      return CRITICAL;
			    }

			  if (action == DISKWRITING)
			    {
#ifdef UPDATE_SERIALNUM
			      if (sector == 0)
				{
				  if (ParsedData->serialnumber == UPDATE)
				    UpdateDiskSerialNumber (buf);
				}
#endif
			      if (abswrite (tdrive, tocopysectors, (int) sector, buf) != 0)
				{
				    if (sector == 0)
				    {
					if (abswrite(tdrive, 1, 0, buf) != 0)
					{
					    puts("\n");
					    NLS_PRINTSTRING(1, 41, "Sector 0 unwritable! Write protected?");
					    
					    if (FilledDiskSize == allocated) 
					 	break; 
					    else 
						return CRITICAL;	
					}
				     }				    				   
				    
				  puts ("");
				  NLS_PRINTSTRING (1, 27, "Media error writing to sector");
				  printf (" %ld.\n", sector);
				}
			    }
			  else
			    {

			      if (absread (tdrive, tocopysectors, (int) sector, cmpbuf) != 0)
				{
				  puts ("");
				  NLS_PRINTSTRING (1, 18, "Media error reading from sector");
				  printf (" %ld.\n", sector);
				}

			      if (sector == 0)
				{
				  if (ParsedData->serialnumber == UPDATE)
				    {
				      ClearDiskSerialNumber (buf);
				      ClearDiskSerialNumber (cmpbuf);
				    }
				}

			      if (memcmp (buf, cmpbuf, tobuffer) != 0)
				{
				  puts ("");
				  NLS_PRINTSTRING (1, 37, "Compare error on sector");
				  printf (" %ld.\n", sector);
				}
			    }
			}
		    }
		}
	      if (!UseImageFile)
		puts ("");

	      if (UseImageFile || (FilledDiskSize == allocated))	/* If everything fitted in memory */
		{
		  loop2 = (fallthrough) ? CatNO : CatNO + 1;
		  if (loop2 == CatYES)
		    loop2++;
		  while (!NLS_TEST_YES_NO (loop2))
		    {
		      ClrKbd ();
		      if (audible)
			Beep ();
		      puts ("");
		      if (UseImageFile)
			puts ("");
		      NLS_PRINTSTRING (1, 28, "Do you want another copy of this ");
		      if (UseImageFile)
			{
			  endsector = 0;
			  NLS_PRINTSTRING (1, 29, "image file (Y/N)?");
			}
		      else
			NLS_PRINTSTRING (1, 30, "disk (Y/N)?");

		      loop2 = toupper (getch ());
		      puts ("");
		    }
		  if (UseImageFile && (NLS_TEST_YES (loop2)))
		    puts ("");
		}
	      else
		{
		  puts ("");
		  loop2 = CatNO;
		}

	      /* Change the serial number of the target disk. */
#ifdef UPDATE_SERIALNUM
	      if (ParsedData->serialnumber == UPDATE)
		{
		  puts ("");
		  PrintDiskSerialNumber ();
		  puts ("");
		}
#endif
	    }			/*  loop2 */

	  loop2 = CatYES;
	  if (loop2 == CatNO)
	    loop2++;
	  ReleaseMemory ();
	}
      else
	{
	  if (CopyingToSameDisk)
	    {
	      PrepareForReading ();
	      if (!WriteFileFromMemory (GetSFN (OUTFILE_ID), buf, BUFFERSIZE,
					FilledDiskSize, asktdisk,
					fallthrough, Overwrite))
		{
		  NLS_PUTSTRING (1, 36, "Problem writing image file.");
		  return CRITICAL;
		}
	    }
	}

      loop1 = CatYES + 1;
      if (loop1 == CatNO)
	loop1++;
      if (!UseImageFile && !fallthrough && (endsector == total))
	{
	  while (!NLS_TEST_YES_NO (loop1))
	    {
	      ClrKbd ();
	      puts ("");
	      NLS_PRINTSTRING (1, 31, "Copy another disk (Y/N)?");
	      loop1 = toupper (getch ());
	      puts ("");
	      endsector = 0;
	    }
	}
      else if (UseImageFile || (fallthrough && (endsector == total)))
	{
	  loop1 = CatNO;
	  if (fallthrough)
	    puts ("");
	  else if (audible && (ImageModus == WRITEIMAGE))
	    Beep ();
	}

    }				/* end loop1 */

  if ((UseImageFile) && (ImageModus == WRITEIMAGE))
    puts ("");

  return COPYSUCCESS;
}
Пример #16
0
int main( int argc, char *argv[] )
{
#ifdef TEST_TCP_SOCKETS

  StartWinSock();

  TCPSocket listener;
  TCPSocket client;

  char *localIP = NULL;
  GetLocalIP( localIP );

  listener.SetIP( localIP );
  listener.SetPortNumber( 8000 );

  listener.Init();
  
  listener.Listen();

  while( !listener.Accept( client ) );
  
  while( true )
  {
    std::string message;
    Prompt( message, "Enter a message" );

    NetworkMessage netMessage;
    netMessage.msg_.Assign( message.c_str(), message.size() );

    client.Send( netMessage );
  }

  client.Shutdown();
  client.Close();

  listener.Shutdown();
  listener.Close();

  CloseWinSock();

#endif

  /*
  GameControl controller;

  try
  {
    controller.Init();

    try
    {
      controller.Run();
    }
    catch( BaseErrExcep e )
    {
      e.Print();
    }

    controller.Close();
  }
  catch( BaseErrExcep e )
  {
    e.Print();
  }
  */

    FileServer fileServer;

    try
    {
        fileServer.Init();

        try
        {
            fileServer.Run();
        }
        catch(BaseErrExcep& e)
        {
            e.Print();
        }

        fileServer.Close();
    }
    catch(BaseErrExcep& e)
    {
        e.Print();
    }
 
   
  printf( "\n Server is closing \n" );

  return WaitForInput();
}