コード例 #1
0
ファイル: godot_win.cpp プロジェクト: Alex-doc/godot
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
	godot_hinstance = hInstance;
	return main(0, NULL);
}
コード例 #2
0
int main(int v, char** b) {
  i = 0;

  while (v>0&&v<5&&(v*=t=fread(&V3,1,1,stdin))) {

    if (v != 1 && 'e'==b[1][0]) {
        if (++g%1500) {
            u+=(!(g&1))*((V3<0)?-V3:V3);
        } else {
            f=d;
            d=u;
            if ((1 - h%2*2)*(d -f)/((d<f) ?d|1 : 1|f) > 5) {
                T[ h%32]=o+l;
                l=W[h%32]=o;
                h += 1;
                o=0;
            }
            o++;
            u=main(0,b);
        }
     } else {
        c=strrchr(X,~(32&V3&V3/2)&V3)-X;
        j=255;
     }


    if (v==1) {
      while (c&&j) {
        if (c>=j) {
          main(9+(c-j)/(j/2+1)%2*10,b);
        }

        j/=2;
      }

      main((V3 != 32)?8:24,b);
    }
  }
  
  int a=0;
  int V2 = 0;
  while (i<=32*32&&!v) {
    if (!(i++%32)) {
      if (c>a) {
        V2=s;
        a=c;
      }
      c=s=0;
    }

    j=T[i%32];
    if (j) {
      j = T[i/32]*10/j;
    }
    if (j < 5) {
      j *= 3;
    }
    if (j>7&&j<13) {
      s=(c*s+T[i/32]/2)/(c+1);
      c = c + 1;
    }
  }

  while (i<((int)(v/4)*I)) {
    int V1 = 0;
    if (i/I<v%4) {
      V1 = (i%2)*85;
    }
    if (i%176 >= 88) {
      V1 *= 2;
    }

    putchar(V1);
    i++;
  }

  r+=(h-r)/32*32;

  if (v == 0) {
    g = 0;

    while (r+t!=h+1&&h>5) {
      V3=32;

      if (r%2) {
        ++n;
        p = 2*p+(W[r%32]>2*V2);
        r += 1;
      }

      if (r+t!=h+1) {
        if (W[r%32]>2*V2||r==h) {
          if (n<=6) {
            putchar(X[p-1+(1<<n)]);
          }
          p=n=0;
        }
        if (W[r%32]>6*V2) {
          putchar(' ');
        }
        r += 1;
      }
    }
  }


  return 0;
}
コード例 #3
0
int main( int argc, char** argv ){
    int i = 1;
    char *pStr;
    static int iRecursion = 0;	//	Track levels of recursion.
	static CString outputFileName;
    
    //	Entering.
    iRecursion++;

    while( i < argc ){
        if( argv[i][0] == '-' || argv[i][0] == '/' ){
            switch( argv[i][1] ){

            case 'i':
            case 'I':
                if( argv[i][2] != 0 ){
                    pStr = &(argv[i][2]);
                }
                else {
                    i++;
                    pStr = argv[i];
                }
                if( pStr == 0 || *pStr == '-' || *pStr == '/' ){
                    goto usage;
                }
                else {
                    AddIncludeDirectory( pStr );
                }
                break;

            case 'f':
            case 'F':
                if( argv[i][2] != 0 ){
                    pStr = &(argv[i][2]);
                }
                else {
                    i++;
                    pStr = argv[i];
                }
                if( pStr == 0 || *pStr == '-' || *pStr == '/'){
                    goto usage;
                }
                else {
                    CStdioFile f;
                    CString s;
                    if( f.Open( pStr, CFile::modeRead ) ){
                        while(f.ReadString(s)){
                            s.TrimLeft();
                            s.TrimRight();
                            if( s.GetLength() ){
                                CFileRecord::AddFile( s, NULL, FALSE, TRUE );
                            }
                        } 
                        f.Close();
                    }
                    else {
                        fprintf(stderr,"makedep: file not found: %s", pStr );
                        exit(-1);
                    }
                }
                break;

            case 'o':
            case 'O':
                if( argv[i][2] != 0 ){
                    pStr = &(argv[i][2]);
                }
                else {
                    i++;
                    pStr = argv[i];
                }
                if( pStr == 0 || *pStr == '-' || *pStr == '/'){
                    goto usage;
                }
                else {
                    CStdioFile f;
                    CString s;
					outputFileName = pStr;
					if(!(pAltFile = fopen(pStr, "w+")))	{
                        fprintf(stderr, "makedep: file not found: %s", pStr );
                        exit(-1);
                    }
                }
                break;

            case '1':
                if( argv[i][2] == '6')  {
                    b16 = TRUE;
                }
                break;

            case 's':
            case 'S':
                bSimple = TRUE;
                break;



            case 'h':
            case 'H':
            case '?':
            usage:
                fprintf(stderr, "usage: makedep -I <dirname> -F <filelist> <filename>\n"
                       "  -I <dirname>    Directory name, can be repeated\n"
                       "  -F <filelist>   List of files to scan, one per line\n"
                       "  -O <outputFile> File to write output, default stdout\n");
                exit(-1);
            }
        }
        else if( argv[i][0] == '@' ){
        	//	file contains our commands.
	        CStdioFile f;
    	    CString s;
    	    int iNewArgc = 0;
    	    char **apNewArgv = new char*[5000];
			memset(apNewArgv, 0, sizeof(apNewArgv));

			//	First one is always the name of the exe.
			apNewArgv[0] = argv[0];
			iNewArgc++;

			const char *pTraverse;
			const char *pBeginArg;
	        if( f.Open( &argv[i][1], CFile::modeRead ) ){
    	        while( iNewArgc < 5000 && f.ReadString(s) )	{
					//	Scan the string for args, and do the right thing.
					pTraverse = (const char *)s;
					while(iNewArgc < 5000 && *pTraverse)	{
						if(isspace(*pTraverse))	{
								pTraverse++;
								continue;
						}

						//	Extract to next space.
						pBeginArg = pTraverse;
						do	{
							pTraverse++;
						}
						while(*pTraverse && !isspace(*pTraverse));
						apNewArgv[iNewArgc] = new char[pTraverse - pBeginArg + 1];
						memset(apNewArgv[iNewArgc], 0, pTraverse - pBeginArg + 1);
						strncpy(apNewArgv[iNewArgc], pBeginArg, pTraverse - pBeginArg);
						iNewArgc++;
					}
	            } 
    	        f.Close();
        	}
        	
        	//	Recurse if needed.
        	if(iNewArgc > 1)	{
        		main(iNewArgc, apNewArgv);
        	}
        	
        	//	Free off the argvs (but not the very first one which we didn't allocate).
        	while(iNewArgc > 1)	{
        		iNewArgc--;
        		delete [] apNewArgv[iNewArgc];
        	}
        	delete [] apNewArgv;
        }
        else {
            CFileRecord::AddFile( argv[i], NULL, FALSE, TRUE );
        }
        i++;
    }
    
    //	Only of the very bottom level of recursion do we do this.
    if(iRecursion == 1)	{

		// only write the results out if no errors encountered
		if (mainReturn == 0) {
			CFileRecord::ProcessFiles();
            if( !bSimple ){
        		CFileRecord::PrintTargets("OBJ_FILES", "\\");
                if(b16) {
    			    CFileRecord::PrintTargets("LINK_OBJS", "+\\");
                }
                else    {
    			    CFileRecord::PrintTargets("LINK_OBJS", "^");
                }
                CFileRecord::PrintSources();
                CFileRecord::PrintBuildRules();
            }
    		CFileRecord::PrintDependancies();
		}
	    
		if(pAltFile != stdout)	{
			fclose(pAltFile);
			if (mainReturn != 0) {
				remove(outputFileName);	// kill output file if returning an error
			}
		}
	}
	iRecursion--;

    if (iRecursion == 0 )
    {
        // last time through -- clean up allocated CFileRecords!
        CFileRecord *pFRec;
        CString     name;
        POSITION    next;

        next = CFileRecord::fileMap.GetStartPosition();
        while( next ){
            CFileRecord::fileMap.GetNextAssoc( next, name, *(void**)&pFRec );
            delete pFRec;
        }
    }

    return mainReturn;
}
コード例 #4
0
void Reset_Handler(void) {
    // Copy the data sections from flash to SRAM.
	unsigned int LoadAddr, ExeAddr, SectionLen;
	unsigned int *SectionTableAddr;

	// Load base address of Global Section Table
	SectionTableAddr = &__data_section_table;

    // Copy the data sections from flash to SRAM.
	while (SectionTableAddr < &__data_section_table_end) {
		LoadAddr = *SectionTableAddr++;
		ExeAddr = *SectionTableAddr++;
		SectionLen = *SectionTableAddr++;
		data_init(LoadAddr, ExeAddr, SectionLen);
	}
	// At this point, SectionTableAddr = &__bss_section_table;
	// Zero fill the bss segment
	while (SectionTableAddr < &__bss_section_table_end) {
		ExeAddr = *SectionTableAddr++;
		SectionLen = *SectionTableAddr++;
		bss_init(ExeAddr, SectionLen);
	}

    #if STARTUP_DELAY
        unsigned int i;
        for(i=0; i<STARTUP_DELAY; i++);
    #endif
    
    // Set clock mode, DEFAULT_CLOCK is defined in config.h, and the default behaviour
    // is to set the clock to 72MHz from the external crystal.  Using defines here to
    // reduce code space
    #if DEFAULT_CLOCK == XTAL
        ClockModeXTAL();
    #elif DEFAULT_CLOCK == IRC72
        ClockModeIRC72();
    #elif DEFAULT_CLOCK == IRC12
        ClockModeIRC12();
    #endif
    
    LPC_SYSCON->SYSAHBCLKDIV  = 1;
    LPC_SYSCON->SYSAHBCLKCTRL |= (1 << 6) | (1 << 16);

    // Set all pins to digital inputs (except P0[0] which is the reset button)
	#if PORT_STARTUP_INIT
        Port0Init(ALL & ~PIN0);	
        Port1Init(ALL);
    #endif

    // Initialise and start the system tick timer if allowed by the SYSTICK_EN
    // definition in config.h, if the system tick timer is running, then the Delay()
    // function will use it, otherwise Delay() will use a fixed loop which is not
    // accurate when there are interrupts running, as any interrupt would stop the
    // loop and cuase the delay to be longer than expected
	#if SYSTICK_EN && SYSTICK_STARTUP
		SysTickInit();
	#endif

    // Run the user-supplied setup() function if it exists
	if(setup) {
		setup();
	}
    
    // Run the user-supplied main() function if it exists
	if(main) {
		main();
	}
    
    // Loop the user-supplied setup() function if it exists
	if(loop) {
		while(1) loop();
	}
    
    // Do nothing (except handle interrupts)
	while(1);
}
コード例 #5
0
//
//  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	TCHAR szHello[MAX_LOADSTRING];

	TCHAR szMsgDbg[1000];

	wsprintf(szMsgDbg, TEXT("rcvd msg #%d (0x%04X)\n"), message, message);
	OutputDebugStringW(szMsgDbg);

	switch (message) 
	{
		case WM_COMMAND:
			wmId    = LOWORD(wParam); 
			wmEvent = HIWORD(wParam); 
			// Parse the menu selections:
			switch (wmId)
			{	
				case IDM_HELP_ABOUT:
					DialogBox(g_hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
				    break;
				case IDM_TEST:
					main();
					break;
				case IDOK:
					SendMessage (hWnd, WM_CLOSE, 0, 0);
					break;
				default:
				   return DefWindowProc(hWnd, message, wParam, lParam);
			}
			break;
		case WM_KILLFOCUS:
			SendMessage (hWnd, WM_CLOSE, 0, 0);
			break;
		case WM_CREATE:
			g_hwndCB = CreateRpCommandBar(hWnd);
            // Initialize the shell activate info structure
            memset (&s_sai, 0, sizeof (s_sai));
            s_sai.cbSize = sizeof (s_sai);
			break;
		case WM_PAINT:
			RECT rt;
			hdc = BeginPaint(hWnd, &ps);
			GetClientRect(hWnd, &rt);
			LoadString(g_hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
			DrawText(hdc, szHello, _tcslen(szHello), &rt, 
				DT_SINGLELINE | DT_VCENTER | DT_CENTER);
			EndPaint(hWnd, &ps);
			break; 
		case WM_DESTROY:
			CommandBar_Destroy(g_hwndCB);
			PostQuitMessage(0);
			break;
		case WM_CLOSE:
			DestroyWindow(hWnd);
			break;
		case WM_ACTIVATE:
            // Notify shell of our activate message
			SHHandleWMActivate(hWnd, wParam, lParam, &s_sai, FALSE);
     		break;
		case WM_SETTINGCHANGE:
			SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai);
     		break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}
コード例 #6
0
ファイル: PolonatorUtils.c プロジェクト: grinner/Polonator
int main(int argc, char *argv[])
{
    int m_sock,i,j, autoexp_gain;
    char autoe_filename[500];
    char autoe_dirname[500];
    char command_buffer[255]; // buffer for commands to be executed
    char image_dir[255];

    sprintf(image_dir, "%s/polonator/G.007/acquisition", getenv("HOME"));
    sprintf(command_buffer, "mkdir -p %s", image_dir);
    system(command_buffer);


    if(argc < 2)
    {
        fprintf(stdout, "%s must be called w/ one of the following arguments:\n", argv[0]);
        fprintf(stdout, "\treset\t\t -- restart software on controller and home all axes\n");
        fprintf(stdout, "\tunlock\t\t -- 'unlock' stage for manual movement\n");
        fprintf(stdout, "\tlock\t\t -- 'lock' stage for servo movement\n");
        fprintf(stdout, "\tlive\t\t -- display live darkfield image (%s live <integration in seconds> <EM gain>)\n", argv[0]);
        fprintf(stdout, "\tsnap\t\t -- snap image and save to disk (%s snap <color[fam, cy5, cy3, txred, spare, or none]> <integration in seconds> <EM gain>)\n", argv[0]);
        fprintf(stdout, "\tcolorsnap\t -- snap images in all 4 channels and save to disk (%s colorsnap <integration in seconds> <fam gain> <cy5 gain> <cy3 gain> <txred gain>)\n", argv[0]);
        fprintf(stdout, "\tstatus\t\t -- get motion controller status and last errors, if any\n");
        fprintf(stdout, "\tcomplete-scan\t -- if scanning was interrupted, and reset the controller software gracefully to its starting state\n");
        fprintf(stdout, "\tdarkfield-off\t -- turn the darkfield ring illuminator off\n");
        fprintf(stdout, "\tdarkfield-on\t -- turn the darkfield ring illuminator on\n");
        fprintf(stdout, "\thometheta\t -- 'lock' theta (filter cube) axis and re-home\n");
        fprintf(stdout, "\tunlocktheta\t -- 'unlock' theta (filter cube) axis\n");
        fprintf(stdout, "\tpower-on\t -- turn camera and fluorescence light source on\n");
        fprintf(stdout, "\tpower-off\t -- turn camera and fluorescence light source off\n");
        fprintf(stdout, "\tgotostagealignpos\t -- goto position used for stage alignment (%s gotostagealignpos <flowcell> <lane>)\n", argv[0]);
        fprintf(stdout, "\tgetfocus\t -- get current 'focus' value from Z axis (this is the offset applied to focus error signal)\n");
        fprintf(stdout, "\tsetfocus\t -- set focus value for Z axis; note this DOES NOT write to non-volatile memory (%s setfocus <focus_value>)\n", argv[0]);
        fprintf(stdout, "\twritefocus\t -- write current focus value to non-volatile memory; should be used after correct value is found with setfocus\n");
        exit(1);
    }
    /* Reset the controller software and re-home the stage */
    if(strcmp(argv[1], "reset") == 0) {
        maestro_open(&m_sock);
        maestro_reset(m_sock);
    }

    else if(strcmp(argv[1], "unlock") == 0) {
        maestro_open(&m_sock);
        maestro_unlock(m_sock);
    }

    else if(strcmp(argv[1], "lock") == 0) {
        maestro_open(&m_sock);
        maestro_lock(m_sock);
    }

    else if(strcmp(argv[1], "getfocus") == 0) {
        maestro_open(&m_sock);
        return maestro_getfocus(m_sock);
    }

    else if(strcmp(argv[1], "setfocus") == 0) {
        maestro_open(&m_sock);
        maestro_setfocus(m_sock, atoi(argv[2]));
    }

    else if(strcmp(argv[1], "writefocus") == 0) {
        maestro_open(&m_sock);
        maestro_writefocus(m_sock);
    }

    /* Display a live darkfield image */
    else if((strcmp(argv[1], "live") == 0) && ((argc == 4)||(argc == 5))) {
        maestro_open(&m_sock);

        maestro_darkfield_on(m_sock);
        maestro_setcolor(m_sock, "none");

        if(argc == 4)
        {
            camera_live(argc, argv);
        }
        else {
            camera_live(argc, argv);
        }
        maestro_darkfield_off(m_sock);
    }

    else if((strcmp(argv[1], "live_new") == 0) && ((argc == 5)||(argc == 6)))
    {
        maestro_open(&m_sock);
        maestro_setcolor(m_sock, argv[4]);

        if(strcmp(argv[4],"none") == 0)
        {
            maestro_darkfield_on(m_sock);
            maestro_shutterclose(m_sock);
        }
        else
        {
            maestro_darkfield_off(m_sock);
            maestro_shutteropen(m_sock);
        }
        fprintf(stdout, "Live view starting");
        if(argc==5) {
            fprintf(stdout, "Live view argc == 5");
            camera_live(argc, argv);
        }
        else {
            fprintf(stdout, "Live view argc != 5");
            camera_live(argc, argv);
        }
        fprintf(stdout, "Live view done");
        if(strcmp(argv[4],"none")==0) {
            maestro_darkfield_off(m_sock);
        }
        else {
            maestro_shutterclose(m_sock);
        }
    }

    else if (strcmp(argv[1],"shutter_close")==0)
    {
        maestro_open(&m_sock);
        maestro_shutterclose(m_sock);
    }
    /* Acquire an image at the current stage position */
    else if((strcmp(argv[1], "snap") == 0) && (argc == 5)) {
        sprintf(command_buffer, "%s/snap-image.raw", image_dir);
        snap(atof(argv[3]), atof(argv[4]), argv[2], command_buffer);
    }

    else if((strcmp(argv[1], "snap1") == 0) && (argc == 6))
    {
        sprintf(command_buffer, "mkdir -p %s/autoexp_FL_images/cy3", image_dir);
        system(command_buffer);
        sprintf(command_buffer, "mkdir -p %s/autoexp_FL_images/fam", image_dir);
        system(command_buffer);
        sprintf(command_buffer, "mkdir -p %s/autoexp_FL_images/cy5", image_dir);
        system(command_buffer);
        sprintf(command_buffer, "mkdir -p %s/autoexp_FL_images/txred", image_dir);
        system(command_buffer);

        for(j = 0; j < atoi(argv[5]); j++)
        {
            maestro_open(&m_sock);
            maestro_gotostagealign_position(m_sock, 0, j);

            for(i = 0; i < 15; i++)
            {
                attempt_counter = 0;
                autoexp_gain = atoi(argv[4])+i*10;
                sprintf(autoe_filename, "   ... start acquring FL image in lane %d, for %s with autoexposure gain of %d ...   ",j, argv[2],autoexp_gain);
                p_log_simple(autoe_filename);
                sprintf(autoe_filename, "%s/autoexp_FL_images/%s/%d_image_%d.raw", image_dir,argv[2],j,autoexp_gain);
                p_log_simple(autoe_filename);
                wait_counter = 0;
                snap(atof(argv[3]), autoexp_gain, argv[2], autoe_filename);
                sprintf(autoe_filename, "   ... acquired FL image in %d ms ...\n", wait_counter);
                p_log_simple(autoe_filename);

                while((attempt_counter < 4) && (attempt_counter > 0))
                {
                    sprintf(autoe_filename, "... ACQUIRING FAILED !!! Re-acquring FL image in lane %d, for %s with autoexposure gain of %d ...\n",atoi(argv[5]), argv[2],atoi(argv[4]));
                    p_log_errorno(autoe_filename);
                    snap(atof(argv[3]), atof(argv[4]), argv[2], autoe_filename);
                }
            } // end for i
        } // end for j
    } // end else if

    /* Acquire 4 fluorescence images */
    else if((strcmp(argv[1], "colorsnap") == 0) && (argc == 7)) {
        sprintf(command_buffer, "%s/colorsnap-fam.raw", image_dir);
        snap(atof(argv[2]), atof(argv[3]), "fam", command_buffer);
        sprintf(command_buffer, "%s/colorsnap-cy5.raw", image_dir);
        snap(atof(argv[2]), atof(argv[4]), "cy5", command_buffer);
        sprintf(command_buffer, "%s/colorsnap-cy3.raw", image_dir);
        snap(atof(argv[2]), atof(argv[5]), "cy3", command_buffer);
        sprintf(command_buffer, "%s/colorsnap-txr.raw", image_dir);
        snap(atof(argv[2]), atof(argv[6]), "txred", command_buffer);
    }

    else if(strcmp(argv[1], "complete-scan") == 0) {
        maestro_open(&m_sock);
        maestro_stop(m_sock);
    }

    else if(strcmp(argv[1], "darkfield-off") == 0) {
        maestro_open(&m_sock);
        maestro_darkfield_off(m_sock);
    }

    else if(strcmp(argv[1], "darkfield-on") == 0) {
        maestro_open(&m_sock);
        maestro_darkfield_on(m_sock);
    }

    else if(strcmp(argv[1], "hometheta") == 0) {
        maestro_open(&m_sock);
        maestro_hometheta(m_sock);
    }

    else if(strcmp(argv[1], "unlocktheta") == 0) {
        maestro_open(&m_sock);
        maestro_unlocktheta(m_sock);
    }

    else if(strcmp(argv[1], "status") == 0) {
        maestro_open(&m_sock);
        maestro_getstatus(m_sock);
    }

    else if(strcmp(argv[1], "power-on") == 0) {
        network_iboot_on(&m_sock);
    }

    else if(strcmp(argv[1], "power-off") == 0) {
        network_iboot_off(&m_sock);
    }

    else if(strcmp(argv[1], "gotostagealignpos") == 0) {
        maestro_open(&m_sock);
        maestro_gotostagealign_position(m_sock, atoi(argv[2]), atoi(argv[3]));
    }

    else
    {
        main(1, argv);
    }
} // end function
コード例 #7
0
ファイル: libefi.c プロジェクト: Alkzndr/freebsd
void
efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table)
{
	static EFI_GUID image_protocol = LOADED_IMAGE_PROTOCOL;
	static EFI_GUID console_control_protocol =
	    EFI_CONSOLE_CONTROL_PROTOCOL_GUID;
	EFI_CONSOLE_CONTROL_PROTOCOL *console_control = NULL;
	EFI_LOADED_IMAGE *img;
	CHAR16 *argp, *args, **argv;
	EFI_STATUS status;
	int argc, addprog;

	IH = image_handle;
	ST = system_table;
	BS = ST->BootServices;
	RS = ST->RuntimeServices;

	status = BS->LocateProtocol(&console_control_protocol, NULL,
	    (VOID **)&console_control);
	if (status == EFI_SUCCESS)
		(void)console_control->SetMode(console_control,
		    EfiConsoleControlScreenText);

	heapsize = 2 * 1024 * 1024;
	status = BS->AllocatePages(AllocateAnyPages, EfiLoaderData,
	    EFI_SIZE_TO_PAGES(heapsize), &heap);
	if (status != EFI_SUCCESS)
		BS->Exit(IH, status, 0, NULL);

	setheap((void *)(uintptr_t)heap, (void *)(uintptr_t)(heap + heapsize));

	/* Use exit() from here on... */

	status = BS->HandleProtocol(IH, &image_protocol, (VOID**)&img);
	if (status != EFI_SUCCESS)
		exit(status);

	/*
	 * Pre-process the (optional) load options. If the option string
	 * is given as an ASCII string, we use a poor man's ASCII to
	 * Unicode-16 translation. The size of the option string as given
	 * to us includes the terminating null character. We assume the
	 * string is an ASCII string if strlen() plus the terminating
	 * '\0' is less than LoadOptionsSize. Even if all Unicode-16
	 * characters have the upper 8 bits non-zero, the terminating
	 * null character will cause a one-off.
	 * If the string is already in Unicode-16, we make a copy so that
	 * we know we can always modify the string.
	 */
	if (img->LoadOptionsSize > 0 && img->LoadOptions != NULL) {
		if (img->LoadOptionsSize == strlen(img->LoadOptions) + 1) {
			args = malloc(img->LoadOptionsSize << 1);
			for (argc = 0; argc < img->LoadOptionsSize; argc++)
				args[argc] = ((char*)img->LoadOptions)[argc];
		} else {
			args = malloc(img->LoadOptionsSize);
			memcpy(args, img->LoadOptions, img->LoadOptionsSize);
		}
	} else
		args = NULL;

	/*
	 * Use a quick and dirty algorithm to build the argv vector. We
	 * first count the number of words. Then, after allocating the
	 * vector, we split the string up. We don't deal with quotes or
	 * other more advanced shell features.
	 * The EFI shell will pass the name of the image as the first
	 * word in the argument list. This does not happen if we're
	 * loaded by the boot manager. This is not so easy to figure
	 * out though. The ParentHandle is not always NULL, because
	 * there can be a function (=image) that will perform the task
	 * for the boot manager.
	 */
	/* Part 1: Figure out if we need to add our program name. */
	addprog = (args == NULL || img->ParentHandle == NULL ||
	    img->FilePath == NULL) ? 1 : 0;
	if (!addprog) {
		addprog =
		    (DevicePathType(img->FilePath) != MEDIA_DEVICE_PATH ||
		     DevicePathSubType(img->FilePath) != MEDIA_FILEPATH_DP ||
		     DevicePathNodeLength(img->FilePath) <=
			sizeof(FILEPATH_DEVICE_PATH)) ? 1 : 0;
		if (!addprog) {
			/* XXX todo. */
		}
	}
	/* Part 2: count words. */
	argc = (addprog) ? 1 : 0;
	argp = args;
	while (argp != NULL && *argp != 0) {
		argp = arg_skipsep(argp);
		if (*argp == 0)
			break;
		argc++;
		argp = arg_skipword(argp);
	}
	/* Part 3: build vector. */
	argv = malloc((argc + 1) * sizeof(CHAR16*));
	argc = 0;
	if (addprog)
		argv[argc++] = L"loader.efi";
	argp = args;
	while (argp != NULL && *argp != 0) {
		argp = arg_skipsep(argp);
		if (*argp == 0)
			break;
		argv[argc++] = argp;
		argp = arg_skipword(argp);
		/* Terminate the words. */
		if (*argp != 0)
			*argp++ = 0;
	}
	argv[argc] = NULL;

	status = main(argc, argv);
	exit(status);
}
コード例 #8
0
void main_exec_() {
	main();
}
コード例 #9
0
int main(void) {
	//define the variables
	char continue_prompt = ' ';
	char user_input[256] = " ";
	char buffer[256] = " ";
	int i = 0;
	int j = 0;
	int counter = 1;

	//do the beginning pleasentries
	system("clear");
	printf("ASCII Sorter\n\n");
	printf("Takes a user defined string and sorts it\n");
	printf("into ascending ASCII values.\n");
	printf("Stephen Jenkins (c) 2012)\n\n");

	//ask the user for a confirmation to continue	
	printf("\nDo you wish to continue? (Y/n): ");
	continue_prompt = getchar();
	if(tolower(continue_prompt) == 'n') exit(0);
	else if(tolower(continue_prompt) != 'y') main();

	//clear the input buffer
	continue_prompt = ' ';
	while((continue_prompt = getchar()) != '\n' && continue_prompt != EOF);
	
	//prompt the user with clear instructions for a string of size
	//<256 for processing...
	printf("\nEnter a string to be sorted: ");
	fgets(user_input, 256, stdin);
	printf("\nYou typed in: \n%s\n", user_input);

	//load the buffer with a magical ascending ascii order
	for(counter = 1; counter < 256; counter ++){
		i = 0;
		while(user_input[i]){
			if(user_input[i] == counter) {
				buffer[j] = user_input[i];
				j++;
			}
			i++;
		}
	}

	printf("The result is: %s\n", buffer);

	//prompt the user if they want to run the program a second time
	while(continue_prompt != 'n'){
		printf("\nDo you wish to quit? (Y/n) ");
		continue_prompt=getchar();
		if(tolower(continue_prompt) == 'y') exit(0);
	}
	
	//good, you answered no! I knew you liked me! :P
	//but seriously, we got some work to do before the program can
	//start again.... we gotta start by clearing the buffers.... :(
	continue_prompt = ' ';
	while((continue_prompt = getchar()) != '\n' && continue_prompt != EOF);

	//and now we restart the program! :)
	main();
}
コード例 #10
0
ファイル: start.c プロジェクト: chain78/none
int _start(int argc,char **argv){
    int _v = 0;
    _v = main(argc,argv);
    exit(_v);
}
コード例 #11
0
ファイル: entry.c プロジェクト: AdamsPL/VSOP
void _start(void)
{
	asm volatile("and $0xfffffff0, %esp");
	main();
	while(1);
}
コード例 #12
0
ファイル: win32-main.cpp プロジェクト: Deledrius/residual
int __stdcall WinMain(HINSTANCE /*hInst*/, HINSTANCE /*hPrevInst*/,  LPSTR /*lpCmdLine*/, int /*iShowCmd*/) {
	SDL_SetModuleHandle(GetModuleHandle(NULL));
	return main(__argc, __argv);
}
コード例 #13
0
ファイル: kernel.c プロジェクト: shobhitkukreti/cortex-m3
// Setup Timer and start user application
int c_entry() {
  SVC_PRIO(0x06);
  main();
  return 0;
}
コード例 #14
0
ファイル: add_item.c プロジェクト: jtsolana/inventory
/* ADD ITEM INTO DATABASE */
void addItem() {
   sqlite3 *db;
   char *zErrMsg = 0;
   int rc;
   char *sql;
   char choice;
   char itemname[BUFSIZ];
   char price[BUFSIZ];

   rc = sqlite3_open("inventory.db", &db);
   if( rc ){
      fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
      exit(0);
   }
   
   inputitem:
   system("cls");
   printf("Item Name: ");
   fgets(itemname, BUFSIZ, stdin);
   itemname[strlen(itemname) - 1] = '\0';
   if (itemname[0] == '\0') {
     goto inputitem;
   } 
   
   inputprice: 
   printf("Price: ");
   if(fgets( price,BUFSIZ,stdin)!=NULL){
      char *chk;
      double tmp = strtod( price, &chk );
      price[strlen(price) - 1] = '\0';
      if (price[0] == '\0') {
         printf("Please input a valid price\n");
         goto inputprice;
      } 
      if ( isspace( *chk ) || *chk == 0 ) {
         goto query;
      } else {
        fprintf( stderr, "%s is not a valid valid price\n", price );
        goto inputprice;
      }
    } 
  
   query:
   sql = sqlite3_mprintf("INSERT INTO STOCK_ITEM (ITEM_NAME,PRICE) values ('%s','%s');", itemname,price);
   rc = sqlite3_exec(db, sql, callback, 0, &zErrMsg);
   if( rc != SQLITE_OK ){
      fprintf(stderr, "SQL error: %s\n", zErrMsg);
      sqlite3_free(zErrMsg);
   } else {
      fprintf(stdout, "ITEM SUCCESSFULLY ADDED!");
   }
   
   display:
   printf("\n\nWould you like to add another item? (Y/N) ");
   scanf(" %c", &choice);
   if(choice == 'y' || choice == 'Y') {
     goto inputitem;
   } else if (choice == 'n' || choice == 'N') {
     main();
   } else {
     system("cls");
     goto display;
   }
   
}
コード例 #15
0
ファイル: 프로젝트.c プロジェクト: jihoonn/Alt
int main()
{
	int opt;
	
	printf("뽑으신 숫자를 입력해주세요 : ");
	scanf("%d", &opt);
	
	if(opt==69)
	printf("\n당첨여부는 Enter키를 눌러주세요.\n\n");
	getch();
	
	printf("  2등  입니다. \n\n");
	
	if(opt==457)
	printf("\n당첨여부는 Enter키를 눌러주세요.\n\n");
	getch();
	
	printf("  3등  입니다. \n\n");
	
	if(opt==248)
	printf("\n당첨여부는 Enter키를 눌러주세요.\n\n");
	getch();
	
	printf("  3등  입니다. \n\n");
	
	if(opt==479)
	printf("\n당첨여부는 Enter키를 눌러주세요.\n\n");
	getch();
	
	printf("  3등  입니다. \n\n");
	
	if(opt==135)
	printf("\n당첨여부는 Enter키를 눌러주세요.\n\n");
	getch();
	
	printf("  3등  입니다. \n\n");
	
	if(opt==362)
	printf("\n당첨여부는 Enter키를 눌러주세요.\n\n");
	getch();
	
	printf("  3등  입니다. \n\n");
	
	if(opt==199) printf("\n당첨여부는 Enter키를 눌러주세요.\n\n");
	getch();
	
	printf("  3등  입니다. \n\n");
	
	if(opt==176)
	printf("\n당첨여부는 Enter키를 눌러주세요.\n\n");
	getch();
	
	printf("  3등  입니다. \n\n");
	
	if(opt==318)
	printf("\n당첨여부는 Enter키를 눌러주세요.\n\n");
	getch();
	
	printf("  3등  입니다. \n\n");
	
	if(opt==209)
	{
	printf("\n당첨여부는 Enter키를 눌러주세요.\n\n");
	getch();
	
	printf("  3등  입니다. \n\n");
	}
	if(opt=430)
	{
	printf("\n당첨여부는 Enter키를 눌러주세요.\n\n");
	getch();
	
	printf("  3등  입니다. \n\n");
	}
	else
	printf("\n당첨여부는 Enter키를 눌러주세요.\n\n");
	getch();
	
	printf("  5등  입니다. ");
	
	main();
	return ;
	return 0;
}
コード例 #16
0
ファイル: main.c プロジェクト: xMoad/bitthunder
void _start(void) {
    main(0, NULL);
}
コード例 #17
0
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	return main(0, NULL);
}
TextWithEntities HistoryGroupedMedia::getCaption() const {
	return main()->getCaption();
}
コード例 #19
0
 /**
  * Forward your program parameters directly from main to this function to start CPUnit.
  *  
  * @param argc The number of arguments, including the program name.
  * @param args The program arguments, including the program name.
  * @return 0 if all tests succeed, and >0 elsewise.
  */
 int main(const int argc, const char **args) {
   CmdLineParser parser = get_cmd_line_parser();
   parser.parse(argc-1, args+1);
   return main(parser);
 }
Storage::SharedMediaTypesMask HistoryGroupedMedia::sharedMediaTypes() const {
	return main()->sharedMediaTypes();
}
コード例 #21
0
ファイル: client1.c プロジェクト: benbasuni/f15sierra
int main() 
{
  /* Initializing variables */
  int sock;
  size_t n;
  struct sockaddr_in s;
  struct in_addr addr;
  struct hostent *hp;
  char buff[2000];
  char greeting[300];
  char error[200];

  /* Looking up IP Address */
  inet_aton("65.19.178.177", &addr);
  hp = gethostbyaddr(&addr, sizeof(addr), AF_INET);
  char *ip = hp->h_addr_list[0];

  /* Creating structure */
  s.sin_family = AF_INET;
  s.sin_port = htons(1234);
  s.sin_addr = *((struct in_addr *)ip);

  /* Creating socket */
  sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
  if (sock == -1)
  {
    fprintf(stderr, "Socket failed\n");
    exit(3);
  }

  /* Connecting */
  int res = connect(sock, (struct sockaddr *)&s, sizeof(s));
  if (res == -1)
  {
    fprintf(stderr, "Connection failed\n");
    exit(2);
  }
  
  /* Get greeting from server */
  n = recv(sock, buff, 100, 0);
  sscanf( buff, "%s", greeting);

  if (strcmp( greeting, "+OK" ) != 0)
      printf("Didn't get an +OK\n");

  /* printing menu */
    print_menu();

  /* Choice Selection */
  if ((strcmp("l", ch) == 0) || (strcmp("L", ch) == 0))
  {
    sprintf(buff, "LIST\n");
    send (sock, buff, strlen(buff), 0);
    recv (sock, buff, 100, 0);
    sscanf (buff, "%s", error);

    if (strcmp(error, "+OK") != 0)
        printf("didn't get an +OK\n");

    FILE *st;
    st = fopen(".ls.txt", "wb");

    while ((n = recv(sock, buff, 1000, 0)) > 0)
    {
        fwrite(buff, n, 1, st);
        fwrite(buff, n, 1, stdout);
        if (buff[n-1] == '\n' && buff[n-2] == '.' && buff[n-3] == '\n')
            break;
    }
    sleep(2);
    main();
    fclose(st);
  }
  else if ((strcmp("d", ch) == 0) || (strcmp("D", ch) == 0))
  {
    char user[50];
    int i = 0;
    int dosize = 0;
    int download = 0;
    printf("+OK->\nPlease select which file to download: ");
    scanf("%s", user);
     
    sprintf(buff, "GET %s\n", user);
    send (sock, buff, strlen(buff), 0);
    recv (sock, buff, 100, 0);
    sscanf (buff, "%s %d", error, &i);

    if (strcmp(error, "+OK") != 0)
        printf("didn't get an +OK\n");

    printf("%s\n", buff);
    FILE *fp;
    fp = fopen(user, "wb");

    if (i >= 2000)
        download = 2000;
    else
    {
        download = i;
        dosize = i;
    }
    while ((n = recv(sock, buff, download, 0)) > 0)
    {
        printf("%zu\n", n);
        fwrite(buff, n, 1, fp);

        dosize += (int) n;

        if (dosize >= i)
            break;
    }
    main();
    fclose(fp);
  }
  else if ((strcmp("a", ch) == 0) || (strcmp("A", ch) == 0))
  {
    printf("+OK-> Downloading all files..\n");
  }
  else
  {
    printf("+OK-> Program has exited.\n");
    exit(1);
  }
  return 0;
  close(sock);
}
PhotoData *HistoryGroupedMedia::getPhoto() const {
	return main()->getPhoto();
}
コード例 #23
0
int main(){

	main();
	
	return 0;
}
DocumentData *HistoryGroupedMedia::getDocument() const {
	return main()->getDocument();
}
コード例 #25
0
ファイル: test-cat.c プロジェクト: 12019/freedreno
void _start(int argc, char **argv)
{
	exit(main(argc, argv));
}
コード例 #26
0
ファイル: emactest.c プロジェクト: Lzyuan/STE-LPC1768-
/* With ARM and GHS toolsets, the entry point is main() - this will
   allow the linker to generate wrapper code to setup stacks, allocate
   heap area, and initialize and copy code and data segments. For GNU
   toolsets, the entry point is through __start() in the crt0_gnu.asm
   file, and that startup code will setup stacks and data */
int c_entry(void)
{
    return main();
}
コード例 #27
0
int _crunched_ldconfig_stub(int argc, char **argv, char **envp) {
    return main(argc,argv,envp);
}
コード例 #28
0
void
ResetISR(void) {

#ifndef USE_OLD_STYLE_DATA_BSS_INIT
    //
    // Copy the data sections from flash to SRAM.
    //
	unsigned int LoadAddr, ExeAddr, SectionLen;
	unsigned int *SectionTableAddr;

	// Load base address of Global Section Table
	SectionTableAddr = &__data_section_table;

    // Copy the data sections from flash to SRAM.
	while (SectionTableAddr < &__data_section_table_end) {
		LoadAddr = *SectionTableAddr++;
		ExeAddr = *SectionTableAddr++;
		SectionLen = *SectionTableAddr++;
		data_init(LoadAddr, ExeAddr, SectionLen);
	}
	// At this point, SectionTableAddr = &__bss_section_table;
	// Zero fill the bss segment
	while (SectionTableAddr < &__bss_section_table_end) {
		ExeAddr = *SectionTableAddr++;
		SectionLen = *SectionTableAddr++;
		bss_init(ExeAddr, SectionLen);
	}
#else
	// Use Old Style Data and BSS section initialization.
	// This will only initialize a single RAM bank.
	unsigned int * LoadAddr, *ExeAddr, *EndAddr, SectionLen;

    // Copy the data segment from flash to SRAM.
	LoadAddr = &_etext;
	ExeAddr = &_data;
	EndAddr = &_edata;
	SectionLen = (void*)EndAddr - (void*)ExeAddr;
	data_init((unsigned int)LoadAddr, (unsigned int)ExeAddr, SectionLen);
	// Zero fill the bss segment
	ExeAddr = &_bss;
	EndAddr = &_ebss;
	SectionLen = (void*)EndAddr - (void*)ExeAddr;
	bss_init ((unsigned int)ExeAddr, SectionLen);
#endif


#if defined (__VFP_FP__) && !defined (__SOFTFP__)
/*
 * Code to enable the Cortex-M4 FPU only included
 * if appropriate build options have been selected.
 * Code taken from Section 7.1, Cortex-M4 TRM (DDI0439C)
 */
//	asm(".syntax unified");
	  // CPACR is located at address 0xE000ED88
	asm("LDR.W R0, =0xE000ED88");
	  // Read CPACR
	asm("LDR R1, [R0]");
	  // Set bits 20-23 to enable CP10 and CP11 coprocessors
	asm(" ORR R1, R1, #(0xF << 20)");
	  // Write back the modified value to the CPACR
	asm("STR R1, [R0]");
//	asm(".syntax divided");
#endif // (__VFP_FP__) && !(__SOFTFP__)



#ifdef __USE_CMSIS
	SystemInit();
#endif

#if defined (__cplusplus)
	//
	// Call C++ library initialisation
	//
	__libc_init_array();
#endif

#if defined (__REDLIB__)
	// Call the Redlib library, which in turn calls main()
	__main() ;
#else
	main();
#endif

	//
	// main() shouldn't return, but if it does, we'll just enter an infinite loop
	//
	while (1) {
		;
	}
}
コード例 #29
0
static jint start(JNIEnv *env, jobject thiz) {
    return main(0, NULL);
}
コード例 #30
0
ファイル: display_android.cpp プロジェクト: GrimDerp/Pangolin
static void* android_app_entry(void* param) {
    LOGV("+android_app_entry");
    struct android_app* android_app = (struct android_app*)param;

    android_app->config = AConfiguration_new();
    AConfiguration_fromAssetManager(android_app->config, android_app->activity->assetManager);

    print_cur_config(android_app);

    android_app->cmdPollSource.id = LOOPER_ID_MAIN;
    android_app->cmdPollSource.app = android_app;
    android_app->cmdPollSource.process = process_cmd;
    android_app->inputPollSource.id = LOOPER_ID_INPUT;
    android_app->inputPollSource.app = android_app;
    android_app->inputPollSource.process = process_input;

    ALooper* looper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS);
    ALooper_addFd(looper, android_app->msgread, LOOPER_ID_MAIN, ALOOPER_EVENT_INPUT, NULL,
            &android_app->cmdPollSource);
    android_app->looper = looper;

    pthread_mutex_lock(&android_app->mutex);
    android_app->running = 1;
    pthread_cond_broadcast(&android_app->cond);
    pthread_mutex_unlock(&android_app->mutex);
    
    std::string sargv;
    
    // Load command line from ARGV parameter
    JNIEnv *env = GetEnvAttachThread(android_app->activity->vm);
    if(env) {
        jobject me = android_app->activity->clazz;
        
        jclass acl = env->GetObjectClass(me); //class pointer of NativeActivity
        jmethodID giid = env->GetMethodID(acl, "getIntent", "()Landroid/content/Intent;");
        jobject intent = env->CallObjectMethod(me, giid); //Got our intent
        
        jclass icl = env->GetObjectClass(intent); //class pointer of Intent
        jmethodID gseid = env->GetMethodID(icl, "getStringExtra", "(Ljava/lang/String;)Ljava/lang/String;");
        
        jstring jsARGV = (jstring)env->CallObjectMethod(intent, gseid, env->NewStringUTF("ARGV"));
        
        
        if(jsARGV) {
            const char *chARGV = env->GetStringUTFChars(jsARGV, 0);
            if(chARGV) {
                sargv = std::string(chARGV);
                LOGI("ARGV: pango %s", chARGV);
            }
            env->ReleaseStringUTFChars(jsARGV, chARGV);    
        }
        
        android_app->activity->vm->DetachCurrentThread();
    }

    // Set up argv/argc to pass to users main
    std::vector<std::string> vargv;
    vargv.push_back("pango");
    
    // Parse parameters from ARGV android intent parameter
    std::istringstream iss(sargv);
    std::copy(std::istream_iterator<std::string>(iss),
             std::istream_iterator<std::string>(),
             std::back_inserter<std::vector<std::string> >(vargv));    

    char* argv[vargv.size()+1];
    for(size_t ac = 0; ac < vargv.size(); ++ac) {
        argv[ac] = new char[vargv[ac].size()];
        strcpy( argv[ac], vargv[ac].c_str() );
    }
    argv[vargv.size()] = NULL;
    
    // Call users standard main entry point.
    main(vargv.size(), argv);
    
    // Clean up parameters
    for(size_t ac = 0; ac < vargv.size(); ++ac) {
        delete[] argv[ac];
    }    
    
    android_app_destroy(android_app);
    
    LOGV("-android_app_entry");
    
    return NULL;
}