예제 #1
0
/*(up to 2View.99)*/
void determinePortName(char *portName)
{
   ULONG c=1;
   UBYTE len;

   strcpy(portName,"2View.");

   do
   {
      len=stcu_d(&portName[6],c++);
      portName[6+len]='\0';
   }
   while(FindPort(portName)!=NULL && c<100);
   if(FindPort(portName)!=NULL)
      exit(50);
   return;
}
예제 #2
0
extern int _vsnprintf(char *pszOutput, size_t uSize, const char *pszFormat, va_list pArgs)
    {
    int *pparms;	    // Pointer to the optional arguments following the format
    char c;
    char cFill;
    char szTempBuf[80];
    char far *lpszTemp;
    char *pszOutput0 = pszOutput;
    int iRequested;	    // Requested width for an output field
    int iAvailable;	    // Number of characters available for output
    int iLong;		    // TRUE if the %l modifier has been provided

    pparms = (int *)pArgs;

    while (c = *(pszFormat++))
	{
	if (c == '%')	  // If c is the format escape character.
	    {
	    cFill = ' ';   // Default filler for the left side of output fields
	    if (*pszFormat == '0')
		{
		cFill = '0';		// Optional filler
		pszFormat += 1; 	// Skip the 0
		}

	    if (*pszFormat == '*')	// If variable length format
		{
		iRequested = *(pparms++); // Get the size from the argument list
		pszFormat += 1; 	  // Skip the *
		}
	    else			// Else fixed length format
		{
		// Convert the field size to an int, and advance past the size in format.
		pszFormat += stcd_i(pszFormat, &iRequested);
		}

	    iLong = FALSE;
test_format:
	    switch (*(pszFormat++))    // The next char is the format ID.
		{
		case 'd':
		    if (!iLong)
			iAvailable = stci_d(szTempBuf, *(pparms++)); // Convert int to string
		    else
			iAvailable = stcli_d(szTempBuf, *(((long *)pparms)++)); // Convert int to string
		    pszOutput += strcpyform(pszOutput, szTempBuf, iRequested, iAvailable, cFill);
		    break;
		case 'u':
		    iAvailable = stcu_d(szTempBuf, *(pparms++)); // Convert uint to string
		    pszOutput += strcpyform(pszOutput, szTempBuf, iRequested, iAvailable, cFill);
		    break;
		case 'p':
		    if (iLong)
			pszOutput += sprintf(pszOutput, "%04X:", pparms[1]);
		    pszOutput += sprintf(pszOutput, "%04X", pparms[0]);
		    pparms += iLong+1;
		    break;
		case 'x':   // Incompatible! Processed as %X to save space.
		case 'X':
		    if (!iLong)
			iAvailable = stci_h(szTempBuf, *(pparms++)); // Convert uint to hex. string
		    else
			iAvailable = stcli_h(szTempBuf, *(((long *)pparms)++)); // Convert uint to hex. string
		    pszOutput += strcpyform(pszOutput, szTempBuf, iRequested, iAvailable, cFill);
		    break;
		case 's':
		    if (!iLong)
			lpszTemp = *(((char **)pparms)++);		 // Pointer on the given string
		    else
			lpszTemp = *(((char far **)pparms)++);		 // Pointer on the given string
		    pszOutput += strcpyform(pszOutput, lpszTemp, iRequested, fstrlen(lpszTemp), cFill);
		    break;
		case 'c':
		    *pparms &= 0x00FF;	 // Make sure the char is followed by a NUL.
		    pszOutput += strcpyform(pszOutput, (char *)(pparms++), iRequested, 1, ' ');
		    break;
		case '%':
		    *(pszOutput++) = '%';
		    break;
		case 'l':
		case 'F':
		    iLong = TRUE;
		    goto test_format;	 // Ignore long integer specifications
		default:    // Unsupported format. Just output question marks
		    pszOutput += strcpyform(pszOutput, "", iRequested, 0, '?');
		    break;
		}
	    }
	else		  // Else c is a normal character
	    {
	    *(pszOutput++) = c;  // Just copy it to the output
	    }
	}
    *pszOutput = '\0';
    return pszOutput - pszOutput0;   // Number of characters written
    }
예제 #3
0
int main(void)
{
	struct 
	{
		ULONG a;
		UWORD b;
		ULONG r;
	} div[] =
	{
		{0,1,0x00000000},
		{1,1,0x00000001},
		{1,2,0x00010000},
		{1,3,0x00010000},
		{1,4,0x00010000},
		{1,1000,0x00010000},
		{1,6000,0x00010000},
		{10000,666,0x000a000f},
		{80000,666,0x01de0015},
		{80000,1,0x00003880},
	};
	const div_numof = sizeof(div) / sizeof(div[0]);
	int i;
	UBYTE tmp[256], *p;
	UBYTE t2[64];

	printf("\ndivide:\n");

	for (i = 0; i< div_numof; i++)
	{
		printf("%d / %d = 0x%08x\n", div[i].a, div[i].b, divide(div[i].a, div[i].b));
		if (divide(div[i].a, div[i].b) != div[i].r)
		{
			printf("failed!\n");
			return 5;
		}
	}

	printf("\nctodstr:\n");
	ctodstr("", tmp);
	if (tmp[0] != 0 || memcmp(tmp+1, "", 1)) { printf("failed \"\"!\n"); return 5; }
	ctodstr("foobar", tmp);
	if (tmp[0] != 6 || memcmp(tmp+1, "foobar", 6)) { printf("failed \"foobar\"!\n"); return 5; }

	printf("\nstcu_d:\n");
	stcu_d(tmp, 0);
	if (strcmp(tmp, "0")) { printf("failed 0\n"); return 5; }
	stcu_d(tmp, 123456);
	if (strcmp(tmp, "123456")) { printf("failed 123456\n"); return 5; }
	stcu_d(tmp, 10000000);
	if (strcmp(tmp, "10000000")) { printf("failed 10000000\n"); return 5; }

	printf("\nstpcpy:\n");
	p = stpcpy(tmp, "");
	if (p != tmp || strcmp(tmp, "")) { printf("failed \"\"\n"); return 5; }
	p = stpcpy(tmp, "foobar");
	if (p != tmp + 6 || strcmp(tmp, "foobar")) { printf("failed \"foobar\"\n"); return 5; }

	printf("\nintltoupper:\n");

	ctodstr("", tmp);
	intltoupper(tmp);
	if (tmp[0] != 0) { printf("failed \"\"\n"); return 5; }
	ctodstr("fooBarφδείπ!@£", tmp);
	intltoupper(tmp);
	if (tmp[0] != 14 || memcmp(tmp + 1, "FOOBARΦΔΕίΠ!@£", 14)) { printf("failed \"fooBarφδείπ!@£\"\n"); return 5; }

	printf("\nintlcmp:\n");
	ctodstr("foo", tmp);
	intltoupper(tmp);
	if (intlcmp(tmp, tmp) != 1) { printf("failed \"foo\" selfcompare\n"); return 5; }
	ctodstr("foo", tmp);
	intltoupper(tmp);
	ctodstr("foo", t2);
	if (intlcmp(tmp, t2) != 1) { printf("failed \"FOO\" vs \"foo\"\n"); return 5; }
	ctodstr("fooBarφδείπ!@£", tmp);
	intltoupper(tmp);
	if (intlcmp(tmp, tmp) != 1) { printf("failed \"fooBarφδείπ!@£\" selfcompare\n"); return 5; }
	ctodstr("fooBar", t2);
	intltoupper(t2);
	if (intlcmp(tmp, t2) != 0) { printf("failed \"fooBarφδείπ!@£\" vs \"fooBar\"\n"); return 5; }
	ctodstr("fooBarφδείπ!@£xxx", t2);
	intltoupper(t2);
	if (intlcmp(tmp, t2) != 0) { printf("failed \"fooBarφδείπ!@£\" vs \"fooBarφδείπ!@£xxx\"\n"); return 5; }
	ctodstr("fooBaxφδείπ!@£", t2);
	if (intlcmp(tmp, t2) != 0) { printf("failed \"fooBarφδείπ!@£\" vs \"fooBaxφδείπ!@£\"\n"); return 5; }
	ctodstr("fooBar", t2);
	if (intlcmp(tmp, t2) != 0) { printf("failed \"fooBarφδείπ!@£\" vs \"fooBar\"\n"); return 5; }
	ctodstr("fooBarφδείπ!@£xxx", t2);
	if (intlcmp(tmp, t2) != 0) { printf("failed \"fooBarφδείπ!@£\" vs \"fooBarφδείπ!@£xxx\"\n"); return 5; }
	ctodstr("fooBaxφδείπ!@£", t2);
	if (intlcmp(tmp, t2) != 0) { printf("failed \"fooBarφδείπ!@£\" vs \"fooBaxφδείπ!@£\"\n"); return 5; }

	printf("\nintlcdcmp:\n");
	ctodstr("", tmp);
	intltoupper(tmp);
	if (intlcdcmp("", tmp) != 1) { printf("failed \"\"\n"); return 5; }
	ctodstr("A", tmp);
	if (intlcdcmp("A", tmp) != 1) { printf("failed \"A\" vs \"A\"\n"); return 5; }
	ctodstr("a", tmp);
	if (intlcdcmp("A", tmp) != 1) { printf("failed \"A\" vs \"a\"\n"); return 5; }
	ctodstr("abcDEF", tmp);
	if (intlcdcmp("ABCDEF", tmp) != 1) { printf("failed \"ABCDEF\" vs \"abcDEF\"\n"); return 5; }
	ctodstr("fooBarφδείπ!@£", tmp);
	if (intlcdcmp("FOOBARΦΔΕίΠ!@£", tmp) != 1) { printf("failed \"FOOBARΦΔΕίΠ!@£\" vs \"fooBarφδείπ!@£\"n"); return 5; }
	ctodstr("fooBarφδείπ!@£", tmp);
	if (intlcdcmp("FOOBARΦΔΕίΠ!@£", tmp) != 1) { printf("failed \"FOOBARΦΔΕίΠ!@£\" vs \"fooBarφδείπ!@£\"\n"); return 5; }
	ctodstr("fooBarφδείπ!@£", tmp);
	if (intlcdcmp("FOOBAXΦΔΕίΠ!@£", tmp) != 0) { printf("failed \"FOOBAXΦΔΕίΠ!@£\" vs \"fooBarφδείπ!@£\"\n"); return 5; }
	ctodstr("fooBarφδείπ!@£", tmp);
	if (intlcdcmp("FOOBAR", tmp) != 0) { printf("failed \"FOOBAR\" vs \"fooBarφδείπ!@£\"\n"); return 5; }
	ctodstr("fooBarφδείπ!@£", tmp);
	if (intlcdcmp("FOOBARΦΔΕίΠ!@£XXX", tmp) != 0) { printf("failed \"FOOBARΦΔΕίΠ!@£XXX\" vs \"fooBarφδείπ!@£\"\n"); return 5; }

	return 0;
}
예제 #4
0
/*get:	This function gets information about the current picture/playlist*/
void rGet(char *p)
{
   p++;

   /*The picture's filename*/
   if(stricmp(p,"name")==0)
      strcpy(arexxBuf,picFilename);

   /*The picture width*/
   else if(stricmp(p,"width")==0)
      stcu_d(arexxBuf,prevScreen->Width);

   /*The height*/
   else if(stricmp(p,"height")==0)
      stcu_d(arexxBuf,prevScreen->Height);

   /*The number of bitplanes*/
   else if(stricmp(p,"depth")==0)
      stcu_d(arexxBuf,prevScreen->BitMap.Depth);

   /*The viewmodes of the picture (HAM, HIRES, LACE, etc.*/
   else if(stricmp(p,"viewmodes")==0)
      stci_h(arexxBuf,prevScreen->ViewPort.Modes);

   else if(stricmp(p,"specialmodes")==0)
      switch(specialModes)
      {
	 case NORMAL:
	    strcpy(arexxBuf,"NONE");
	    break;
	 case SHAM:
	    strcpy(arexxBuf,"SHAM");
	    break;
	 case MACROPAINT:
	    strcpy(arexxBuf,"MACROPAINT");
	    break;
      }

   /*The time left to display this picture*/
   else if(stricmp(p,"timeleft")==0)
      stcu_d(arexxBuf,ticksRemaining);

   /*The time to display each picture*/
   else if(stricmp(p,"timeperpicture")==0)
      stcu_d(arexxBuf,ticks);

   /*The version number and date of this program*/
   else if(stricmp(p,"version")==0)
      strcpy(arexxBuf,&version[12]);

   /*The name of the playlist, or '?NONE?' if there is no playlist*/
   else if(stricmp(p,"playlistname")==0)
      if(playListFilename==NULL)
	 strcpy(arexxBuf,"?NONE?");
      else
	 strcpy(arexxBuf,playListFilename);

   /*Returns 'TRUE' if the user specified 'loop' on the command line, 'FALSE'*/
   /*if he didn't*/
   else if(stricmp(p,"looping")==0)
      if(loop)
	 strcpy(arexxBuf,"TRUE");
      else
	 strcpy(arexxBuf,"FALSE");

   /*Returns 'TRUE' if the user specified 'print' on the command line,*/
   /*FALSE if she didn't*/
   else if(stricmp(p,"printpictures")==0)
      if(printPics)
	 strcpy(arexxBuf,"TRUE");
      else
	 strcpy(arexxBuf,"FALSE");

   else if(stricmp(p,"cyclerate")==0)
      if(numCycleColors!=0)
	 stcu_d(arexxBuf,rate);
      else
	 strcpy(arexxBuf,"-VOID-");

   else if(stricmp(p,"cyclestatus")==0)
      if(cycle)
	 strcpy(arexxBuf,"CYCLING");
      else
	 if(numCycleColors!=0)
	    strcpy(arexxBuf,"CYCLINGPAUSED");
	 else
	    strcpy(arexxBuf,"NOCYCLING");

   /*Otherwise, we don't understand, so return an error*/
   else
   {
      errorNum=100;
      strcpy(arexxBuf,"ERROR");
   }
}