Ejemplo n.º 1
1
int SkpModel::LoadVertices(){
	SUResult res;
	int out = 0;

	for (int f=0; f<faces_.size(); f++){
		//Form the mesh
		SUMeshHelperRef mesh = SU_INVALID;
		res = SUMeshHelperCreate(&mesh, faces_[f]);
		ErrorHandler(res);
		
		// Get number of vertices. 
		size_t num_vertices;
		res = SUMeshHelperGetNumVertices(mesh, &num_vertices);
		ErrorHandler(res);

		//Get vertices.
		std::vector<SUPoint3D>   vertices(num_vertices);
		res = SUMeshHelperGetVertices(mesh, num_vertices, &vertices[0], &num_vertices);
		ErrorHandler(res);
		vertices_.add(vertices);
		
		//Get Normals
		std::vector<SUVector3D>  normals(num_vertices);
		res = SUMeshHelperGetNormals (mesh, num_vertices, &normals[0], &num_vertices);
		ErrorHandler(res);
		normals_.add(normals);

		//Front Texture Coordinates
		std::vector<SUPoint3D> texture_coords(num_vertices);
		size_t num_coords;
		res = SUMeshHelperGetFrontSTQCoords(mesh, num_vertices, &texture_coords[0], &num_coords);
		ErrorHandler(res);
		assert(num_coords == num_vertices);
		stqcoords_front_.add(texture_coords);

		//Back Texture Coordinates
		std::vector<SUPoint3D> texture_coords_back(num_vertices);
		res = SUMeshHelperGetFrontSTQCoords(mesh, num_vertices, &texture_coords_back[0], &num_coords);
		ErrorHandler(res);
		assert(num_coords == num_vertices);
		stqcoords_back_.add(texture_coords_back);

		SUMeshHelperRelease(&mesh);
		//*/
		/*
		size_t num_vertices;
		SUFaceGetNumVertices(faces_[f], &num_vertices);
		std::vector<SUVertexRef> vertices(num_vertices);
		SUFaceGetVertices(faces_[f], num_vertices, &vertices[0], &num_vertices);
		vertices_.add(vertices);
		*/

	}
	return out;
}
Ejemplo n.º 2
0
BOOL ServiceControl(int ctrl)
{
    SC_HANDLE service;
    SC_HANDLE scm;
    BOOL res;
    SERVICE_STATUS status;

    scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
    if (!scm) {
        ErrorHandler("OpenSCManager", GetLastError());
    }

    service = OpenService(scm, ServiceName, SERVICE_ALL_ACCESS);
    if (!service) {
        ErrorHandler("OpenService", GetLastError());
    }

    if (ctrl == SERVICE_CONTROL_STOP) {
        printf("Service is stopping...\n");
        res = ControlService(service, SERVICE_CONTROL_STOP, &status);
    } else if (ctrl == SERVICE_CONTROL_PAUSE) {
        printf("Service is pausing...\n");
        res = ControlService(service, SERVICE_CONTROL_PAUSE, &status);
    } else if (ctrl == SERVICE_CONTROL_CONTINUE) {
        printf("Service is resuming...\n");
        res = ControlService(service, SERVICE_CONTROL_CONTINUE, &status);
    }

    if (!res) {
        ErrorHandler("ControlService", GetLastError());
    } else {
        srvc.GetStatus(service);
    }

    CloseServiceHandle(service);
    CloseServiceHandle(scm);

    return TRUE;
}
Ejemplo n.º 3
0
void CService::PreInit()
{
    // set up the system context
    

   // Initialize Events
   for(int i = 0 ; i < NUMEVENTS ; i++)
   {
      m_hEvents[i] = CreateEvent(NULL, FALSE, FALSE, NULL);
      if(!m_hEvents[i])
         ErrorHandler(NTEXT("CreateEvent"));
   }
}
Ejemplo n.º 4
0
void CFat32FileSystem::Execute(Long64 aPartitionSize,EntryList aNodeList,
							   ofstream& aOutPutStream,ConfigurableFatAttributes* aConfigurableFatAttributes)
{
	CDirRegion* dirRegionPtr = NULL;
	try
	{
		CreateBootSector(aPartitionSize,aConfigurableFatAttributes);
		ComputeTotalClusters(aPartitionSize);
		WriteBootSector(aOutPutStream);
		dirRegionPtr = new CDirRegion(aNodeList,this);
		dirRegionPtr->Execute();
		iClustersPerEntry = dirRegionPtr->GetClustersPerEntryMap();
		CreateFSinfoSector(aOutPutStream);
		RestReservedSectors(aOutPutStream);
		CreateFatTable(aOutPutStream);
		dirRegionPtr->WriteClustersIntoFile(aOutPutStream);
		delete dirRegionPtr;
		dirRegionPtr = NULL;
	}
	catch(ErrorHandler &aError)
	{
		delete dirRegionPtr;
		dirRegionPtr = NULL;
		throw ErrorHandler(aError.iMessageIndex,(char*)aError.iSubMessage.c_str(),(char*)aError.iFileName.c_str(),aError.iLineNumber);
	}
	/**
	Irrespective of successful or unsuccessful data drive image generation ROFSBUILD
	may try to generate images for successive ".oby" file input.
	During this course unhandled exceptions may cause leaving some memory on heap 
	unused. so the unhandled exceptions handling is used to free the memory allocated 
	on heap. 
	*/
	catch(...)
	{
		delete dirRegionPtr;
		dirRegionPtr = NULL;
		throw ErrorHandler(UNKNOWNERROR,__FILE__,__LINE__);
	}
}
Ejemplo n.º 5
0
Archivo: main.c Proyecto: shjere/common
/**
  * @brief  System Clock Configuration
  *         The system Clock is configured as follow : 
  *            System Clock source            = MSI
  *            SYSCLK(Hz)                     = 2000000
  *            HCLK(Hz)                       = 2000000
  *            AHB Prescaler                  = 1
  *            APB1 Prescaler                 = 1
  *            APB2 Prescaler                 = 1
  *            Flash Latency(WS)              = 0
  *            Main regulator output voltage  = Scale3 mode
  * @param  None
  * @retval None
  */
static void SystemClock_Config(void)
{
  RCC_ClkInitTypeDef RCC_ClkInitStruct;
  RCC_OscInitTypeDef RCC_OscInitStruct;
  
  /* Enable Power Control clock */
  __PWR_CLK_ENABLE();
  
  /* The voltage scaling allows optimizing the power consumption when the device is 
     clocked below the maximum system frequency, to update the voltage scaling value 
     regarding system frequency refer to product datasheet.  */
  __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE3);
  
  /* Enable MSI Oscillator */
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;
  RCC_OscInitStruct.MSIState = RCC_MSI_ON;
  RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_5;
  RCC_OscInitStruct.MSICalibrationValue = 0x00;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
  if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  {
    /* Error */
    ErrorHandler();
  }
  
  /* Select MSI as system clock source and configure the HCLK, PCLK1 and PCLK2 
     clocks dividers */
  RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_MSI;
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;  
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;  
  if(HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
  {
    /* Error */
    ErrorHandler();
  }
}
Ejemplo n.º 6
0
Calculadora criarThread(Calculadora calc, int opt, int integer)
{
    PMYDATA pDataArray[MAX_THREADS];
    DWORD   dwThreadIdArray[MAX_THREADS];
    HANDLE  hThreadArray[MAX_THREADS]; 

	for( int i=0; i<MAX_THREADS; i++ )
	{
        pDataArray[i] = (PMYDATA) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
                sizeof(MYDATA));

        if( pDataArray[i] == NULL )
        {
            ExitProcess(2);
        }

		pDataArray[i]->opt = opt;
		pDataArray[i]->n = i;
		pDataArray[i]->c1 = &calc;
		pDataArray[i]->val = integer;


        hThreadArray[i] = CreateThread( 
            NULL,                   // default security attributes
            0,                      // use default stack size  
            conversaoThread,       // thread function name
            pDataArray[i],          // argument to thread function 
            0,                      // use default creation flags 
            &dwThreadIdArray[i]);   // returns the thread identifier 

        if (hThreadArray[i] == NULL) 
        {
           ErrorHandler(TEXT("CreateThread"));
           ExitProcess(3);
        }
    }

    WaitForMultipleObjects(MAX_THREADS, hThreadArray, TRUE, INFINITE);

    for(int i=0; i<MAX_THREADS; i++)
    {
        CloseHandle(hThreadArray[i]);
        if(pDataArray[i] != NULL)
        {
            HeapFree(GetProcessHeap(), 0, pDataArray[i]);
            pDataArray[i] = NULL;    // Ensure address is not reused.
        }
    }
	return calc;
}
Ejemplo n.º 7
0
/******************************************************************************

MODULE:  GetSpectralSubset

PURPOSE:  read a list of spectral subset values and store them for actual
    use in the read parameter file routine

RETURN VALUE:
Type = int
Value           Description
-----           -----------
n               number of things found
	
HISTORY:
Version  Date   Programmer       Code  Reason
-------  -----  ---------------  ----  -------------------------------------
         05/00  John Weiss             Original Development
         01/01  John Rishea            Standardized formatting

NOTES:

******************************************************************************/
int GetSpectralSubset
(
    ModisDescriptor *P,		/* O:  session info */
    char *str			/* I:  string to be parsed */
)

{
    int i, count = 0;
    char errmsg[SMALL_STRING];

    /* check for valid values */
    for ( i = 0; i < (int) strlen( str ); i++ )
    {
        if ( str[i] != '0' && str[i] != '1' && str[i] != ' ' )
        {
            sprintf( errmsg, "Error processing spectral subset (%s) for "
                "resampler. Only '0's and '1's are allowed.", optarg );
            ErrorHandler( FALSE, "GetSpectralSubset", ERROR_GENERAL,
                errmsg );
            return 0;
        }
        else if ( str[i] == '0' || str[i] == '1' )
            count++;
    }

    /* Copy the spectral subset string to the tmpspectralsubset string in
       the ModisDescriptor */
    P->tmpspectralsubset = strdup (str);
    if (P->tmpspectralsubset == NULL)
    {
        ErrorHandler( FALSE, "GetSpectralSubset", ERROR_GENERAL,
           "Error copying the spectral subset string to the MODIS descriptor");
        return 0;
    }

    return count;
}
Ejemplo n.º 8
0
Archivo: fscanf_m.c Proyecto: hpc/give
errno_t
scanf_m(const string_m format, int *count, ...){
  va_list ap;
  errno_t rv;

  if(!format){
    ErrorHandler("scanf_m: 1st Argument NULL Pointer", format, EINVAL);
    ERROR(EINVAL);
  }

  va_start(ap, count);
  rv = vfscanf_m(stdin, format, count, ap);
  va_end(ap);
  return rv;
}
Ejemplo n.º 9
0
Archivo: printf_m.c Proyecto: hpc/give
errno_t
printf_m(const string_m fmt, int *count, ...){
  errno_t rv;

  if (!fmt){
    ErrorHandler("printf_m: 1st Argument NULL pointer", fmt, EINVAL);
    ERROR(EINVAL);
  }
  VA_OPEN(ap, count);
  VA_FIXEDARG(ap, const string_m, fmt);
  VA_FIXEDARG(ap, int *, count);
  rv = vprintf_m(fmt, count, ap);
  VA_CLOSE(ap);
  return rv;
}
Ejemplo n.º 10
0
BOOL GetConfiguration()
{
    SC_HANDLE service;
    SC_HANDLE scm;
    BOOL res;
    LPQUERY_SERVICE_CONFIG buffer;
    DWORD sizeNeeded;

    scm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
    if (!scm) {
        ErrorHandler("OpenSCManager", GetLastError());
    }

    service = OpenService(scm, ServiceName, SERVICE_QUERY_CONFIG);
    if (!service) {
        ErrorHandler("OpenService", GetLastError());
    }

    buffer = (LPQUERY_SERVICE_CONFIG)LocalAlloc(LPTR, 4096);
    res = QueryServiceConfig(service, buffer, 4096, &sizeNeeded);
    if (!res) {
        ErrorHandler("QueryServiceConfig", GetLastError());
    }

    printf("Service name:\t%s\n", buffer->lpDisplayName);
    printf("Service type:\t%d\n", buffer->dwServiceType);
    printf("Start type:\t%d\n",buffer->dwStartType);
    printf("Start name:\t%s\n",buffer->lpServiceStartName);
    printf("Path:\t\t%s\n",buffer->lpBinaryPathName);

    LocalFree(buffer);

    CloseServiceHandle(service);
    CloseServiceHandle(scm);
    return TRUE;
}
Ejemplo n.º 11
0
Archivo: fscanf_m.c Proyecto: hpc/give
errno_t
fscanf_m(FILE *file, const string_m format, int *count, ...){
  va_list ap;
  errno_t rv;

  if(!format){
    ErrorHandler("fscanf_m: 2nd Argument NULL Pointer", format, EINVAL);
    ERROR(EINVAL);
  }

  va_start(ap, count);
  rv = vfscanf_m(file, format, count, ap);
  va_end(ap);
  return rv;
}
Ejemplo n.º 12
0
//
// DoRegisterDeviceInterfaceToHwnd
//
BOOL DoRegisterDeviceInterfaceToHwnd(
	IN GUID InterfaceClassGuid,
	IN HWND hWnd,
	OUT HDEVNOTIFY *hDeviceNotify
	)
	// Routine Description:
	//     Registers an HWND for notification of changes in the device interfaces
	//     for the specified interface class GUID. 

	// Parameters:
	//     InterfaceClassGuid - The interface class GUID for the device 
	//         interfaces. 

	//     hWnd - Window handle to receive notifications.

	//     hDeviceNotify - Receives the device notification handle. On failure, 
	//         this value is NULL.

	// Return Value:
	//     If the function succeeds, the return value is TRUE.
	//     If the function fails, the return value is FALSE.

	// Note:
	//     RegisterDeviceNotification also allows a service handle be used,
	//     so a similar wrapper function to this one supporting that scenario
	//     could be made from this template.
{
	DEV_BROADCAST_DEVICEINTERFACE NotificationFilter;

	ZeroMemory(&NotificationFilter, sizeof(NotificationFilter));
	NotificationFilter.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE);
	NotificationFilter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
	NotificationFilter.dbcc_classguid = InterfaceClassGuid;

	*hDeviceNotify = RegisterDeviceNotification(
		hWnd,                       // events recipient
		&NotificationFilter,        // type of device
		DEVICE_NOTIFY_WINDOW_HANDLE // type of recipient handle
		);

	if (NULL == *hDeviceNotify)
	{
		ErrorHandler(TEXT("RegisterDeviceNotification"));
		return FALSE;
	}

	return TRUE;
}
Ejemplo n.º 13
0
void Senddde(char* tempstr)
{
  try
  {
    //Connect to the service and request the topic
    if ((hcnv = DdeConnect(idInst, hszService, hszTopic, NULL)) == 0)
    {
      ColorStop();
      return;
    }

    //Start a DDE transaction
    if (DdeClientTransaction((LPBYTE)tempstr, strlen(tempstr)+1,
          hcnv, hszItem, CF_TEXT, XTYP_POKE, 5000, &dwResult) == 0)
    {
      UINT result = DdeGetLastError(idInst);
      switch (result)
      {
        case DMLERR_ADVACKTIMEOUT:
        case DMLERR_BUSY:
        case DMLERR_DATAACKTIMEOUT:
        case DMLERR_DLL_NOT_INITIALIZED:
        case DMLERR_EXECACKTIMEOUT:
        case DMLERR_INVALIDPARAMETER:
        case DMLERR_MEMORY_ERROR:
        case DMLERR_NO_CONV_ESTABLISHED:
        case DMLERR_NO_ERROR:
        case DMLERR_NOTPROCESSED:
        case DMLERR_POKEACKTIMEOUT:
        case DMLERR_POSTMSG_FAILED:
        case DMLERR_REENTRANCY:
        case DMLERR_SERVER_DIED:
        case DMLERR_UNADVACKTIMEOUT:
        default:
          ColorStop();
      }
    }

    //Free DDE
    DdeDisconnect(hcnv);
  }
  catch(...)
  {
    ErrorHandler("Exception thrown in Senddde()!");
  }
}
Ejemplo n.º 14
0
void ButtonLaunch::Launch()
{
    // If Description mode is on, Save the application launch, launch a description if one is 
    // available, otherwise run the application as normal
    if(m_pMControl->getDescMode() == "On" && m_pAppDescription != "" && m_showTestMenu )
    {
        SaveLaunch();
        MenuPage * pMenuPage = new MenuPage(m_pMdiArea, m_pAppDescription, false , m_pParentWindow, m_pMControl);
        pMenuPage->Launch();
    }
    else
    {
        m_showTestMenu = true;

       // Create a process to run the app.
       m_pProcess = new QProcess(this);
       m_pProcess->setProcessChannelMode(QProcess::MergedChannels);
       // Disable parent menu while this process is running to prevent false button triggering.
       m_pParentWindow->Disable();

       connect(m_pProcess, SIGNAL(error(QProcess::ProcessError)), this, SLOT(ErrorHandler()));
       if (m_appTextFlag)
       {
           // Hook signals for apps that generate stdout text.
           connect(m_pProcess, SIGNAL(readyRead()), this, SLOT(TextOutput()));
       }
       else    // For apps that do not need a window to display stdout text.
       {
           connect(m_pProcess, SIGNAL(finished(int, QProcess::ExitStatus)), m_pParentWindow, SLOT(Enable()));
       }
       // Launch the app by its stored name.
       QStringList appParameters;
       appParameters << m_appParameter;

       if (!m_terminateMatrix) {
           m_pProcess->start(m_appName, appParameters, QIODevice::ReadOnly | 
               QIODevice::Text);
       }
       else {
           // If we need to terminate the matrix we must start the application as 
           // a detached process.
           m_pProcess->startDetached(m_appName, appParameters);
       } 
    }
    //qDebug() << "Launched App: " << m_appName << " " << m_appParameter;
}
Ejemplo n.º 15
0
Mailbox::Mailbox(char* name, unsigned numSubjects):
	mail()
{
	// Copy args
	strcpy(sName, name);
	iSubjects = numSubjects;
	
	// Copy the rest of the args derived from the mailbox name
	strcpy(sSetting, name);
	strcat(sSetting, "server");
	if(GetRCString(sSetting, sServer, NULL, MAX_LINE_LENGTH))
	{
		strcpy(sSetting, name);
		strcat(sSetting, "type");
		GetRCString(sSetting, sType, "pop3", MAX_LINE_LENGTH);
		strcpy(sSetting, name);
		strcat(sSetting, "user");
		GetRCString(sSetting, sUser, "anonymous", MAX_LINE_LENGTH);
		strcpy(sSetting, name);
		strcat(sSetting, "port");
		if (!strcmp("imap", sType)) GetRCString(sSetting, sPort, "143", MAX_LINE_LENGTH);
		else GetRCString(sSetting, sPort, "110", MAX_LINE_LENGTH);
		strcpy(sSetting, name);
		strcat(sSetting, "password");
		GetRCString(sSetting, sPass, "", MAX_LINE_LENGTH);
		strcpy(sSetting, name);
		strcat(sSetting, "folder");
		GetRCString(sSetting, sFolder, "inbox", MAX_LINE_LENGTH);

		// If no password was found in config, get it from database/dialog
		if (!(*sPass)) GetPass();

		// Set evars
		strcpy(sEvar, "AcidMail");
		strcat(sEvar, name);
		LSSetVariable(sEvar, "0");
		strcpy(sErrorVar, sEvar);
		strcat(sErrorVar, "Error");
		LSSetVariable(sErrorVar, "none");		
	}
	else
	{
		ErrorHandler(Error(false, LOG_ERROR, "No host found in config files", NULL));
		mail.bError = true;		
	}
}
Ejemplo n.º 16
0
Archivo: fscanf_m.c Proyecto: hpc/give
errno_t vfscanf_m(FILE *file, const string_m format, int *count, va_list args){
  int orientation;
  errno_t rv;

  if(!format){
    ErrorHandler("vfscanf_m: 2nd Argument NULL Pointer", format, EINVAL);
    ERROR(EINVAL);
  }

  orientation = fwide(file, 0);

  if(orientation > 0)
    rv = wvfscanf_m(file, format, count, args);
  else 
    rv = cvfscanf_m(file, format, count, args);
  if (rv) ERROR(rv);
  return rv;
}
	void IoServicesImpl::AsyncConnect(ConnectCallback&& connectCb, ErrorCallback&& errCb, std::string ipAddress, int port)
	{
		auto errCbCopy = std::move(errCb);
		auto errHandler = [this, errCbCopy](std::shared_ptr<TcpPeerConnection> conn, const boost::system::error_code& ec) {
			// Call the application error handler first.
			errCbCopy(conn, ec);

			// Then call our cleanup handler.
			ErrorHandler(conn, ec);
		};

		auto conn = std::make_shared<TcpConnection>(&_ioService, std::move(errHandler));

		// All access is from the context of the IO service so should not need mutexing.
		_clientConnections[conn] = conn;

		conn->AsyncConnect(std::move(connectCb), ipAddress, port);
	}
Ejemplo n.º 18
0
			void Renderer::End() {
				HRESULT tmpResult;

				memcpy(MappedSubresource.pData, &Vertices[0], sizeof(SVertex)*Vertices.size());                 // copy the data
				DeviceContext->Unmap(VertexBuffer, NULL);

				// draw vertices
				DeviceContext->Draw(Vertices.size(), 0);

				// present screen
				tmpResult = SwapChain->Present(VSync, 0);
				if (ErrorHandler(tmpResult)) {
					return;
				}

#ifdef FRAMEWORK_DEBUG
				std::cout << "X11 End" << std::endl;
#endif
			}
Ejemplo n.º 19
0
void
nsSetupTypeDlg::CreateDestYes(GtkWidget *aWidget, gpointer aData)
{
    DUMP("CreateDestYes");
    int err = 0; 
    char path[PATH_MAX + 1];
    int  pathLen = strlen(gCtx->opt->mDestination);

    if (pathLen > PATH_MAX)
        pathLen = PATH_MAX;
    memcpy(path, gCtx->opt->mDestination, pathLen);
    path[pathLen] = '/';  // for uniform handling

    struct stat buf;

    for (int i = 1; !err && i <= pathLen; i++) 
    {
        if (path[i] == '/') 
        {
            path[i] = '\0';
            if (stat(path, &buf) != 0) 
            {
                err = mkdir(path, 0755);
            }
            path[i] = '/';
        }
    }

    if (gCtx->opt->mMode == nsXIOptions::MODE_DEFAULT)
    {
        gtk_widget_destroy(sCreateDestDlg);
    }

    if (err != 0)
    {
        ErrorHandler(E_MKDIR_FAIL);
    }
    else
    {
        // try to move forward to installer dialog again
        nsSetupTypeDlg::Next((GtkWidget *)NULL, NULL);
    }
}
Ejemplo n.º 20
0
BOOL DataBase::Execute(char* CmdStr, long * lRecordAffected, long Option)
{
	VARIANT var;
	var.vt = VT_I4;
	try
	{
		m_Conn->Execute(CmdStr, &var, Option);
		*lRecordAffected = var.iVal;
	}
	catch(_com_error &e)
	{
		ErrorHandler(e, m_ErrStr);
		MessageBox(NULL, m_ErrStr, "´íÎó", MB_OK);
		return FALSE;
	}

	sprintf(m_ErrStr, "Success");
	return TRUE;
}
Ejemplo n.º 21
0
/*this function starts the first pass procedure*/
void SecondPass(char* fileName)
{
	CmdQueue layoutQueue;
	Cmd tempRecord;
	printf("\nBegining second pass...\n");
	CalculateAddressesForLabels(_labels,IC);
	UpdateEntryLabels(&Linkage_List,_labels);
	layoutQueue=CreateCmdQueue();
	while(IsCmdQueueEmpty(computerLanguage)==FALSE)
	{
		tempRecord=RetrieveRecord(computerLanguage);
		AddItemToLayout(tempRecord,layoutQueue);
	}
	layoutQueue=KindOfSort_CmdQ(layoutQueue);
	if(WasThereCompilingError()==TRUE)
		ErrorHandler(FatalError," cannot proceed!\n");
	WriteObjFile(fileName,layoutQueue,IC,DC);
	WriteExtAndEntFiles(fileName,&Linkage_List);
	printf("\nCompilation was successful, files were created.\n");
}
int AcceptTCPConnection(int servSock)
{
    int clntSock;                    /* Socket descriptor for client */
    struct sockaddr_in echoClntAddr; /* Client address */
    unsigned int clntLen;            /* Length of client address data structure */
    
    /* Set the size of the in-out parameter */
    clntLen = sizeof(echoClntAddr);
    
    /* Wait for a client to connect */
    if ((clntSock = accept(servSock, (struct sockaddr *) &echoClntAddr, 
                           &clntLen)) < 0)
        ErrorHandler("accept() failed");
    
    /* clntSock is connected to a client! */
    
    printf("Handling client %s\n", inet_ntoa(echoClntAddr.sin_addr));
    
    return clntSock;
}
Ejemplo n.º 23
0
/* a function that analyzes what the comman is ought to do and if its legal */
char *AnalyzeCommand(char *temp)
{
	char *word,*label=NULL,*cmd=NULL;
	enum Boolean cmdFound=FALSE;
	int *curPos,pos=0;
	opcode op;
	curPos=&pos;
	while(cmdFound==FALSE)
	{
		word=ReadWord(temp,curPos,' ');

		if(word==NULL || strlen(word)==0)
			return NULL;
		if(word[strlen(word)-1]==':')
		{
			ALLOCATE_STRING(label,strlen(word));
			strcpy(label,word);
			label[strlen(label)-1]='\0';
			AddLabelItem(_labels,label,ConvertIntToCharByBase(IC,ConversionToAddress,10),ConvertIntToCharByBase(IC,ConversionToAddress,12),'c');
			continue;
		}
		ALLOCATE_STRING(cmd,strlen(word));
		strcpy(cmd,word);
		cmdFound=TRUE;

	}

	op=GetOpcodeDefinition(cmd,opcodes);
	if(strcmp(op.op,"?")==0)
	{
		ErrorHandler(CompilingError,"command not recognized:"); /* add command to error */
			return NULL;
	}
	else
	{
		HandleCommand(temp,curPos,op,label);
	}
	return op.op;
}
Ejemplo n.º 24
0
bool CWfpNET::IPC_Session_Connect(void) // Establish NULL IPC$ Sessions
{
	NETRESOURCE nr;
	DWORD nStatus = 0;
	TCHAR RemoteResource[23]; // UNC Name length (17) + \\IPC$\0 (6) = 23 
	
	_snprintf_s(RemoteResource, _countof(RemoteResource), _TRUNCATE, _T("%s\\IPC$"),node.szComputerM);
	
	nr.dwType				= RESOURCETYPE_ANY;
	nr.lpLocalName			= NULL;
	nr.lpProvider			= NULL;
	nr.lpRemoteName			= RemoteResource;

	// First attempt: Use currently logged in user
	nStatus = WNetAddConnection3(NULL,
			&nr,
			NULL, // password
			NULL, // username
			0);

	if(nStatus == NO_ERROR)
		return(true);
	else
	{
		nStatus = WNetAddConnection3(NULL,
			&nr,
			(LPTSTR) _T(""),
			(LPTSTR) _T(""),
			0);
	
		if(nStatus != NO_ERROR)
		{
			ErrorHandler("WNetAddConnection3",nStatus);
			return (false);
		}
	}
	return (true);
}
Ejemplo n.º 25
0
//
// InitWindowClass
//
BOOL InitWindowClass()
// Routine Description:
//      Simple wrapper to initialize and register a window class.

// Parameters:
//     None

// Return Value:
//     TRUE on success, FALSE on failure.

// Note: 
//     wndClass.lpfnWndProc and wndClass.lpszClassName are the
//     important unique values used with CreateWindowEx and the
//     Windows message pump.
{
	WNDCLASSEX wndClass;

	wndClass.cbSize = sizeof(WNDCLASSEX);
	wndClass.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
	wndClass.hInstance = reinterpret_cast<HINSTANCE>(GetModuleHandle(0));
	wndClass.lpfnWndProc = reinterpret_cast<WNDPROC>(WinProcCallback);
	wndClass.cbClsExtra = 0;
	wndClass.cbWndExtra = 0;
	wndClass.hIcon = LoadIcon(0, IDI_APPLICATION);
	wndClass.hbrBackground = CreateSolidBrush(RGB(192, 192, 192));
	wndClass.hCursor = LoadCursor(0, IDC_ARROW);
	wndClass.lpszClassName = WND_CLASS_NAME;
	wndClass.lpszMenuName = NULL;
	wndClass.hIconSm = wndClass.hIcon;


	if (!RegisterClassEx(&wndClass))
	{
		ErrorHandler(TEXT("RegisterClassEx"));
		return FALSE;
	}
	return TRUE;
}
Ejemplo n.º 26
0
int c_invert( double incoef[6],	/* Transformation coefficients--input */
	      double coef[6]	/* Inverted transformation coefficients */
     )
{
    double det;			/* Determinate */
    double maximum;		/* Maximum input coefficient value */
    double max1, max2;		/* Temporary variables for max calculation */

/* Find the determinate 
 ---------------------*/
    det = ( incoef[3] * incoef[1] ) - ( incoef[4] * incoef[0] );

/* Find the maximum coefficent value 
 ----------------------------------*/
    max1 = CMAX( fabs( incoef[0] ), fabs( incoef[1] ) );
    max2 = CMAX( fabs( incoef[3] ), fabs( incoef[4] ) );
    maximum = CMAX( max1, max2 );

/* Is the determinant of the coefficients too near zero?
 ----------------------------------------------------------------------*/
    if ( fabs( det ) < ( EPSLNX * maximum ) )
    {
	ErrorHandler( FALSE, "c_invert", ERROR_PROJECTION_MATH,
		      "Determinant too near zero" );
	return ( E_GEO_FAIL );
    }

/* Compute inverse coefficients 
 -----------------------------*/
    coef[0] = -( incoef[4] ) / det;
    coef[1] = incoef[1] / det;
    coef[2] = ( ( incoef[4] * incoef[2] ) - ( incoef[1] * incoef[5] ) ) / det;
    coef[3] = incoef[3] / det;
    coef[4] = -( incoef[0] ) / det;
    coef[5] = ( ( incoef[0] * incoef[5] ) - ( incoef[3] * incoef[2] ) ) / det;

    return ( E_GEO_SUCC );
}
Ejemplo n.º 27
0
bool_t lockFile() {  

  hAppend = CreateFile(gStrLockFile,   // open TWO.TXT 
    GENERIC_WRITE,                // open for writing 
    0,                            // do not share 
    NULL,                         // no security 
    OPEN_ALWAYS,                  // open or create 
    FILE_ATTRIBUTE_NORMAL,        // normal file 
    NULL);                        // no attr. template 

  if (hAppend == INVALID_HANDLE_VALUE) 
  { 
    ErrorHandler("Could not open TWO.");    // process error 
    return FALSE;
  } 

  // Append the first file to the end of the second file. 
  // Lock the second file to prevent another process from 
  // accessing it while writing to it. Unlock the 
  // file when writing is finished. 

  return LockFile(hAppend, 0, 0, 0, 0);
}
Ejemplo n.º 28
0
pascal void 
DoScrollProc(ControlHandle theControl, short part)
{
	short		amount;
	TEPtr		te;
	
	if ( part != 0 ) {
		switch (gCurrWin)
		{
			case kLicenseID:				
				te = *(gControls->lw->licTxt);
				break;
			default:
				ErrorHandler(eUnknownDlgID, nil);
				break;
		}
		
		switch ( part ) {
			case kControlUpButtonPart:
			case kControlDownButtonPart:		// one line
				amount = 1;
				break;
			case kControlPageUpPart:			// one page
			case kControlPageDownPart:
				amount = (te->viewRect.bottom - te->viewRect.top) / kScrollAmount;
				break;
		}
		if ( (part == kControlDownButtonPart) || (part == kControlPageDownPart) )
			amount = -amount;
		CalcChange(theControl, &amount);
		if (amount) {
			TEScroll(0, amount * kScrollAmount, &te);
            ShowTxt();
		}
	}
}
Ejemplo n.º 29
0
/******************************************************************************

MODULE:  CloseFile

PURPOSE:  Case for closing files (multi-file, HDF-EOS, and GeoTIFF)

RETURN VALUE:
Type = int
Value           Description
-----           -----------
TRUE            Success
FALSE           Failure

HISTORY:
Version  Date   Programmer       Code  Reason
-------  -----  ---------------  ----  -------------------------------------
         05/00   Rob Burrell            Original Development
         01/01   John Rishea            Standardized formatting

NOTES:

******************************************************************************/
int CloseFile
(
    FileDescriptor *filedescriptor      /* I:  file to close */
)

{
    /* which type of file to close */
    switch ( filedescriptor->filetype )
    {
        case RAW_BINARY:
            return ( CloseMultiFile( filedescriptor ) );

        case HDFEOS:
            return ( CloseHdfEosFile( filedescriptor ) );

        case GEOTIFF:
            return ( CloseGeoTIFFFile( filedescriptor ) );

        default:
            ErrorHandler( TRUE, "CloseFile", ERROR_GENERAL,
                "Bad filetype passed" );
            return ( FALSE );
    }
}
Ejemplo n.º 30
0
int
nsSetupTypeDlg::CheckDestEmpty()
{
    DUMP("CheckDestEmpty");

    DIR *destDirD;
    struct dirent *de;
    nsObjectIgnore *currOI = NULL;

    /* check if the destination directory is empty */
    destDirD = opendir(gCtx->opt->mDestination);
    while (de = readdir(destDirD))
    {
        if (strcmp(de->d_name, ".") && strcmp(de->d_name, ".."))
        {
            currOI = sObjectsToIgnore;
            while (currOI)
            {
                // check if this is an Object To Ignore
                if (!strcmp(currOI->GetFilename(),de->d_name))
                    break;

                currOI = currOI->GetNext();    
            }
            if (!currOI)
            {
                closedir(destDirD);
                ErrorHandler(E_DIR_NOT_EMPTY);
                return E_DIR_NOT_EMPTY;
            }
        }
    }
    
    closedir(destDirD);
    return OK;
}