예제 #1
0
void TestCompareF( void )
{
    char            bufA[80] = "FoO baR gOoBeR bLaH";
    char            bufLower[80] = "foo bar goober blah";
    char            bufUpper[80] = "FOO BAR GOOBER BLAH";
    int             status;

    status = _fstrcmp( bufA, bufA );            /* ensure same */
    VERIFY( status == 0 );

    status = _fstrcmp( bufA, bufLower );        /* ensure not same */
    VERIFY( status != 0 );

    status = _fstricmp( bufA, bufUpper );       /* ensure same */
    VERIFY( status == 0 );

    status = _fstricmp( bufA, "foo" );          /* ensure not same */
    VERIFY( status != 0 );

    status = _fstrncmp( bufA, bufA, 100 );      /* ensure same */
    VERIFY( status == 0 );

    status = _fstrncmp( bufA, bufLower, 1 );    /* ensure not same */
    VERIFY( status != 0 );

    status = _fstrnicmp( bufA, bufUpper, 100 ); /* ensure same */
    VERIFY( status == 0 );

    status = _fstrnicmp( bufA, "fOo B!!!", 5 ); /* ensure same */
    VERIFY( status == 0 );

    status = _fstrnicmp( bufA, "fOo B!!!", 6 ); /* ensure not same */
    VERIFY( status != 0 );
}
예제 #2
0
void TestCaseF( void )
{
    char            bufA[80] = "FoO baR gOoBeR bLaH";
    char            bufB[80];
    char            bufLower[80] = "foo bar goober blah";
    char            bufUpper[80] = "FOO BAR GOOBER BLAH";
    char __far      *bufPtr;
    int             status;

    bufPtr = _fstrcpy( bufB, bufA );            /* copy string */
    VERIFY( bufPtr == bufB );

    bufPtr = _fstrlwr( bufB );                  /* lowercase */
    VERIFY( bufPtr == bufB );

    status = _fstrcmp( bufB, bufLower );        /* ensure ok */
    VERIFY( status == 0 );

    bufPtr = _fstrcpy( bufB, bufA );            /* copy string */
    VERIFY( bufPtr == bufB );

    bufPtr = _fstrupr( bufB );                  /* uppercase */
    VERIFY( bufPtr == bufB );

    status = _fstrcmp( bufB, bufUpper );        /* ensure ok */
    VERIFY( status == 0 );
}
예제 #3
0
void TestMoveF( void )
{
    char            bufA[80] = "FoO baR gOoBeR bLaH";
    char            bufB[80];
    char __far      *bufPtr;
    char __far      *newBuf;
    int             status;

    bufPtr = _fstrcpy( bufB, "FoO baR" );       /* copy string */
    VERIFY( bufPtr == bufB );

    bufPtr = _fstrcat( bufB, " gOoBeR bLaH" );  /* append the rest */
    VERIFY( bufPtr == bufB );

    status = _fstrcmp( bufA, bufB );            /* check result */
    VERIFY( status == 0 );

    bufPtr = _fstrset( bufB, 0x00 );            /* zero out buffer */
    VERIFY( bufPtr == bufB );

    bufPtr = _fstrncpy( bufB, "ABCDEFGHIJ", 2 );/* copy two bytes */
    VERIFY( bufPtr == bufB );

    bufPtr = _fstrncat( bufB, "CDEFGHIJ", 3 );  /* copy three more */
    VERIFY( bufPtr == bufB );

    status = _fstrcmp( bufB, "ABCDE" );         /* ensure only five bytes */
    VERIFY( status == 0 );

    bufPtr = _fstrnset( bufB, 0x00, 10 );       /* blank string */
    VERIFY( bufPtr == bufB );

    status = _fstrcmp( bufB, "" );              /* verify empty */
    VERIFY( status == 0 );

    bufPtr = _fstrcpy( bufB, "abcdefghij" );    /* copy string */
    VERIFY( bufPtr == bufB );

    bufPtr = _fstrrev( bufB );                  /* reverse it */
    VERIFY( bufPtr == bufB );

    status = _fstrcmp( bufB, "jihgfedcba" );    /* ensure reversed ok */
    VERIFY( status == 0 );

    newBuf = _fstrdup( bufA );                  /* duplicate string */
    status = _fstrcmp( bufA, newBuf );
    VERIFY( status == 0 );
}
예제 #4
0
파일: tsr.c 프로젝트: hirataya/tsr
/* tsr_get_stayed_seg
 * 
 * 解説: プログラムの常駐セグメントを取得します
 * 宣言: WORD tsr_get_stayed_seg(WORD idofs, const char *idstr);
 * 引数: WORD idofs --- 常駐id文字列の開始オフセット
 *       const char *idstr --- 常駐id文字列
 * 戻値: WORD --- 0x0000: 常駐していない  ≠0x0000: 常駐セグメント
 * 備考: 
 */
WORD tsr_get_stayed_seg(WORD idofs, const char *idstr)
{
	BYTE by;
	struct mcb far *pmcb;
	
	if(_osmajor>=5)
	{
		by=dos_get_umb_link();
		dos_set_umb_link(0x0000);
	}
	
	pmcb=dos_get_top_mcb();
	for(;;)
	{
		if((pmcb->owner!=0x0000)&&
		(_fstrcmp(MK_FP(FP_SEG(pmcb)+1, idofs), idstr)==0))
		{
			if(_osmajor>=5)
				dos_set_umb_link(by? 0x0000: 0x0001);
			return FP_SEG(pmcb)+1;
		}
		if(pmcb->id=='Z')
			break;
		pmcb=dos_get_next_mcb(pmcb);
	}
	
	if(_osmajor>=5)
		dos_set_umb_link(by? 0x0000: 0x0001);
	
	return 0x0000;
}
예제 #5
0
/*********************************************
**
**  Read window erasing color for non-scrolling
**  window. 
**
*********************************************/
void __far __pascal ReadNonScrollBGColor( COLORREF __far * ColorRefPtr )
{
  short int nBytesRead;
  char szEntry[ COLOR_ENTRY_BUFF_SIZE ];
  char szINIFilePath[ _MAX_PATH ];
  

  /* Get path to the INI file. */
  GetINIPath( szINIFilePath );
  
  /* Entry "NoScrollBG" */
  nBytesRead = GetPrivateProfileString( INI_COLORS_SECTION, 
                                        INI_NOSCROLLBG_ENTRY, 
                                        INI_ENTRY_NOT_FOUND, 
                                        szEntry, 
                                        COLOR_ENTRY_BUFF_SIZE, 
                                        szINIFilePath );
   
  /* No bytes read or no entry. */
  if( nBytesRead == 0 || _fstrcmp( szEntry, INI_ENTRY_NOT_FOUND ) == 0 )
  {
    /* Set to default. */
    *ColorRefPtr = DEFAULT_BKCOLOR;
  }
  
  /* Parse and make COLORREF value. */
  else
  {
    if( ! ParseColorEntry( szEntry, ColorRefPtr ) )
    {
      /* Set to default. */
      *ColorRefPtr = DEFAULT_BKCOLOR;
    }
  }
} 
예제 #6
0
/*********************************************
**
**  Read hotspot underlining color from INI file.
**
*********************************************/
void __far __pascal ReadINIHotSpotColor( COLORREF __far * HotSpotColor )
{
  short int nBytesRead;
  char szEntry[ COLOR_ENTRY_BUFF_SIZE ];
  char szINIFilePath[ _MAX_PATH ];
  

  /* Get path to the INI file. */
  GetINIPath( szINIFilePath );
  
  /* Entry "Hotspot" */
  nBytesRead = GetPrivateProfileString( INI_COLORS_SECTION, 
                                        INI_HOTSPOTCOLOR_ENTRY, 
                                        INI_ENTRY_NOT_FOUND, 
                                        szEntry, 
                                        COLOR_ENTRY_BUFF_SIZE, 
                                        szINIFilePath );
   
  /* No bytes read. */
  if( nBytesRead == 0 || _fstrcmp( szEntry, INI_ENTRY_NOT_FOUND ) == 0 )
  {
    /* Set to default. */
    *HotSpotColor = DEFAULT_HOTSPOTCOLOR;
    return;
  }
  
  /* Parse and make COLORREF value. */
  if( ! ParseColorEntry( szEntry, HotSpotColor ) )
  {
    /* Set to default. */
    *HotSpotColor = DEFAULT_HOTSPOTCOLOR;
  }
} 
예제 #7
0
static void sel_sort(PGENSEL gs)
   {

   SHORT bound, j, t;
   char  temp[21];

   /* B1: initialize BOUND.  We correct for zero origin here. */
   bound = gs->sCountNames - 1;

   do
     {
     /* B2: Loop on j */
     for (t = -1, j = 0; j < bound; j++)
         {
         /* B3: Compare/Exchange R[j], R[j+1] */
         /*   if R[j] > R[j+1] ... */
         if (0 < _fstrcmp(gs->szNames[j], gs->szNames[j+1]) )
            {
            /* swap */
            _fstrcpy(temp, gs->szNames[j]);
            _fstrcpy(gs->szNames[j], gs->szNames[j+1]);
            _fstrcpy(gs->szNames[j+1], temp);
            t = j;
            }
         }
         bound = t;  /* B4: set for restart ... */
      }
                     /*     if we swapped anything */
      while (t >= 0);

   }
예제 #8
0
int _fFNameCmp( const char FAR *a, const char FAR *b )
/***********************************************************/
{
#if defined( __OS2__ ) || defined( __NT__ ) || defined( __DOS__ )
    return( _fstricmp( a, b ) );
#else
    return( _fstrcmp( a, b ) );
#endif
}
예제 #9
0
void TestTokenF( void )
{
    char            buf[] = "Find!all;the.tokens,";
    char __far      *ptr;

    ptr = _fstrtok( buf, " ;.,!" );             /* find a token */
    VERIFY( !_fstrcmp(ptr,"Find") );

    ptr = _fstrtok( NULL, " ;.,!" );            /* find a token */
    VERIFY( !_fstrcmp(ptr,"all") );

    ptr = _fstrtok( NULL, " ;.,!" );            /* find a token */
    VERIFY( !_fstrcmp(ptr,"the") );

    ptr = _fstrtok( NULL, " ;.,!" );            /* find a token */
    VERIFY( !_fstrcmp(ptr,"tokens") );

    ptr = _fstrtok( NULL, " '.,!" );            /* try to find another */
    VERIFY( ptr == NULL );
}
예제 #10
0
ID   ListPCB::getIdByName(TName name){
	LOCK();
	curr=head;

	while(curr){
		if( !( _fstrcmp(curr->ptr->Name, name )) ){
			UNLOCK();
			return curr->ptr->threadID;
		}
		curr=curr->next;
	} 

	UNLOCK();
	return NULL;
}
예제 #11
0
/*
 * AboutProc - callback routine for settings dialog
 */
WINEXPORT INT_PTR CALLBACK AboutProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
    char        buff[256];
    LPABOUTINFO pai;

    lparam = lparam;

    switch( msg ) {
    case WM_INITDIALOG:
        pai = (LPABOUTINFO)lparam;
        if( pai->title != NULL ) {
            SetWindowText( hwnd, pai->title );
        }
        if( pai->name != NULL ) {
            sprintf( buff, banner1p1( "%s" ), pai->name );
            SetDlgItemText( hwnd, ABOUT_NAME, buff );
        }
        if( pai->version != NULL ) {
            SetDlgItemText( hwnd, ABOUT_VERSION, pai->version );
        }
        if( pai->first_cr_year != NULL ) {
#if defined( __WATCOMC__) && !defined( __ALPHA__ )
            if( _fstrcmp( pai->first_cr_year, CURR_YEAR ) ) {
#else
            if( strcmp( pai->first_cr_year, CURR_YEAR ) ) {
#endif
                sprintf( buff, banner2a( "%s" ), pai->first_cr_year );
            } else {
                strcpy( buff, banner2a( "1984" ) );
            }
            SetDlgItemText( hwnd, ABOUT_COPYRIGHT, buff );
        }
#if defined( __WINDOWS__ ) || defined( __WINDOWS_386__ )
        {
            DWORD       flags;
            DWORD       kfree;
            WORD        pcfree;
            SYSHEAPINFO shi;
            char        work[16];
            char        info[50];

            flags = GetWinFlags();
            if( flags & WF_ENHANCED ) {
                CopyRCString( ABT_386_ENH, info, sizeof( info ) );
            } else {
                CopyRCString( ABT_STD_MODE, info, sizeof( info ) );
            }
            SetDlgItemText( hwnd, ABOUT_INFO1, info );
            kfree = GetFreeSpace( 0 ) / 1024L;
            ltoa( kfree, work, 10 );
            RCsprintf( buff, ABT_MEM_X_KB_FREE, (LPSTR)work );
            SetDlgItemText( hwnd, ABOUT_INFO2, buff );

            shi.dwSize = sizeof( shi );
            if( SystemHeapInfo( &shi ) ) {
                pcfree = shi.wGDIFreePercent;
                if( pcfree > shi.wUserFreePercent )
                    pcfree = shi.wUserFreePercent;
                RCsprintf( buff, ABT_SYS_RESOURCES_FREE, pcfree );
            } else {
                CopyRCString( ABT_SYS_RESOURCES_N_A, buff, sizeof( buff ) );
            }
            SetDlgItemText( hwnd, ABOUT_INFO3, buff );
        }
#else
        {
            SYSTEM_INFO         si;
            MEMORYSTATUS        ms;

            GetSystemInfo( &si );
            switch( si.dwProcessorType ) {
            case PROCESSOR_INTEL_386:
                CopyRCString( ABT_RUNNING_ON_386, buff, sizeof( buff ) );
                break;
            case PROCESSOR_INTEL_486:
                CopyRCString( ABT_RUNNING_ON_486, buff, sizeof( buff ) );
                break;
            case PROCESSOR_INTEL_PENTIUM:
                CopyRCString( ABT_RUNNING_ON_586, buff, sizeof( buff ) );
                break;
            case PROCESSOR_MIPS_R4000:
            case PROCESSOR_ALPHA_21064:
            default:
                buff[0] = '\0';
                break;
            }
            SetDlgItemText( hwnd, ABOUT_INFO1, buff );

            ms.dwLength = sizeof( ms );
            GlobalMemoryStatus( &ms );
            RCsprintf( buff, ABT_VIRT_MEM,
                       (ms.dwAvailPhys + ms.dwAvailPageFile) / 1024L );
            SetDlgItemText( hwnd, ABOUT_INFO2, buff );
            RCsprintf( buff, ABT_MEM_LOAD, ms.dwMemoryLoad );
            SetDlgItemText( hwnd, ABOUT_INFO3, buff );

        }
#endif
        return( TRUE );
#ifndef NOUSE3D
    case WM_SYSCOLORCHANGE:
        CvrCtl3dColorChange();
        break;
#endif
    case WM_CLOSE:
        EndDialog( hwnd, 0 );
        break;
    case WM_COMMAND:
        switch( LOWORD( wparam ) ) {
        case IDOK:
        case IDCANCEL:
            EndDialog( hwnd, 0 );
            break;
        }
    }
    return( FALSE );

} /* AboutProc */

/*
 * DoAbout - show the startup dialog
 */
void DoAbout( LPABOUTINFO ai )
{
    FARPROC     proc;

    proc = MakeDlgProcInstance( AboutProc, ai->inst );
    DialogBoxParam( ai->inst, "About", ai->owner, (DLGPROC)proc, (LPARAM)ai );
    FreeProcInstance( proc );

} /* DoAbout */
예제 #12
0
파일: isobar.c 프로젝트: FDOS/shsucd
int main( int argc, char* argv[] )
{
  int	i;
  int	fdout = 0;
  char *outfile = NULL, *isofile = NULL, cdbuf[8];
  DWORD bootfound;
  int	drive = 0;
  int	type;
  DWORD n;
  UINT	len, w;

#ifndef _WIN32
  union REGS regs;

  _fmode = O_BINARY;
#endif

  if (argc > 1)
  {
    if (argv[1][0] == '?' || argv[1][1] == '?' || !strcmp( argv[1], "--help" ))
      usage();

    for (i = 1; i < argc; ++i)
    {
      if (*argv[i] == '-' || *argv[i] == '/')
      {
	switch (argv[i][1] | 0x20)
	{
	  case 'o':
	    if (argv[i][2] == '\0' && argv[i+1] == NULL)
	    {
	      fputs( "ERROR: -o requires filename.\n", stderr );
	      return E_OPT;
	    }
	    outfile = (argv[i][2] == '\0') ? argv[++i] : argv[i] + 2;
	  break;

	  case 'd':
	    drive = 1;
	  break;

	  default:
	    fprintf( stderr, "ERROR: unknown option: %s.\n", argv[i] );
	    return E_OPT;
	}
      }
      else
      {
	isofile = argv[i];
      }
    }
  }

#ifdef _WIN32
  if (!isofile)
  {
    char buf[32*4+1];
    len = GetLogicalDriveStrings( sizeof(buf)-1, buf );
    for (isofile = buf; len; isofile += 4, len -= 4)
    {
      if (GetDriveType( isofile ) == DRIVE_CDROM)
      {
	CD = *isofile - 'A';
	break;
      }
    }
    if (CD == -1)
    {
      fputs( "ERROR: No CD-ROM drives assigned.\n", stderr );
      return E_NOCD;
    }
  }
  else if (isofile[1] == '\0' || (isofile[1] == ':' && isofile[2] == '\0'))
  {
    CD = (*isofile | 0x20) - 'a';
    cdbuf[0] = CD + 'A';
    cdbuf[1] = ':';
    cdbuf[2] = '/';
    cdbuf[3] = '\0';
    if (GetDriveType( cdbuf ) != DRIVE_CDROM)
    {
      fprintf( stderr, "ERROR: %c: is not a CD-ROM drive.\n", cdbuf[0] );
      return E_NOCD;
    }
  }
  if (CD != -1)
  {
    sprintf( cdbuf, "//./%c:", CD + 'A' );
    isofile = cdbuf;
  }
  fdin = CreateFile( isofile, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE,
		     NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL );
  if (fdin == INVALID_HANDLE_VALUE)
  {
    fprintf( stderr, "ERROR: Cannot open %s.\n", isofile );
    return E_NOCD;
  }
  if (CD != -1)
    isofile = cdbuf + 4;

#else
  if (!isofile)
  {
    regs.x.ax = 0x1500;
    regs.x.bx = 0;
    int86( 0x2f, &regs, &regs );
    CD = regs.x.cx;
  }
  else if (isofile[1] == '\0' || (isofile[1] == ':' && isofile[2] == '\0'))
  {
    CD = (*isofile | 0x20) - 'a';
    regs.x.ax = 0x150B;
    regs.x.cx = CD;
    int86( 0x2f, &regs, &regs );
    if (regs.x.bx != 0xADAD)
      regs.x.bx = 0;
    else if (regs.x.ax == 0)
    {
      fprintf( stderr, "ERROR: %c: is not a CD-ROM drive.\n", CD + 'A' );
      return E_NOCD;
    }
  }
  else
  {
    fdin = open( isofile, O_RDONLY );
    if (fdin < 0)
    {
      fprintf( stderr, "ERROR: Cannot open %s.\n", isofile );
      return E_NOCD;
    }
    regs.x.bx = 1;
  }
  if (regs.x.bx == 0)
  {
    fputs( "ERROR: No CD-ROM drives assigned.\n", stderr );
    return E_NOCD;
  }
  else if (CD != -1)
  {
    cdbuf[0] = CD + 'A';
    cdbuf[1] = ':';
    cdbuf[2] = '\0';
    isofile = cdbuf;
  }
#endif

  buf = farmalloc( MAX << 11 ); // transfer up to MAX blocks at a time
  if (buf == NULL)
  {
    fputs( "ERROR: Not enough memory.\n", stderr );
    return E_MEM;
  }

  if (!CDReadLong( 1, 0x11 ))
  {
    fputs( "Read error!\n", stderr );
    return E_ABORTED;
  }

  if (_fstrcmp( buf+1, "CD001\01EL TORITO SPECIFICATION" ))
  {
    fprintf( stderr, "ERROR: %s is not EL TORITO.\n", isofile );
    return E_NOCD;
  }
  bootfound = *(DWORD far*)(buf+0x47);
  printf( "Catalog Sector:\t%lx\n", bootfound );

  if (!CDReadLong( 1, bootfound ))
  {
    fputs( "Read error!\n", stderr );
    return E_ABORTED;
  }

  // Just check the key bytes, don't worry about the checksum.
  if (buf[0x1e] != (char)0x55 || buf[0x1f] != (char)0xAA)
  {
    fprintf( stderr, "ERROR: %s has an invalid boot catalog.\n", isofile );
    return E_NOCD;
  }
  type = (BYTE)buf[1];
  printf( "Platform:\t%s (%02x)\n", (type < 3) ? platform[type] : "unknown",
				    type );
  printf( "ID String:\t%.24"SFMT"\n", (buf[4]) ? buf+4 : "not recorded" );
  printf( "Bootable:\t%s (%02x)\n", (buf[0x20] == (char)0x88) ? "yes" : "no",
				    (BYTE)buf[0x20] );
  type = buf[0x21] & 15;
  printf( "Boot Type:\t%s (%02x)\n", (type < 5) ? boot_type[type] : "unknown",
				     (BYTE)buf[0x21] );
  i = *(WORD far*)(buf+0x22);
  printf( "Load Segment:\t%04x\n", (i == 0) ? 0x7c0 : i );
  printf( "System Type:\t%02x\n", (BYTE)buf[0x24] );
  imgsize = *(WORD far*)(buf+0x26);
  printf( "Sector Count:\t%02x (%d)\n", (UINT)imgsize, (UINT)imgsize );
  offset = *(DWORD far*)(buf+0x28);
  printf( "Image Sector:\t%lx\n", offset );

  if (type == 0)		// no emulation
  {
    blksize = 0x200;
  }
  else
  {
    CDReadLong( 1, offset );
    if (type == 4 && !drive)	// hard disk, keep MBR
    {
      blksize = 0x200;
      imgsize = *(DWORD far*)(buf+0x1ca);
    }
    else
    {
      if (type == 4)		// hard disk, skip MBR
      {
	offset += *(DWORD far*)(buf+0x1c6) >> 2;	// diff between HD & CD
	CDReadLong( 1, offset );
      }
      blksize = *(WORD far*)(buf+11);
      imgsize = *(WORD far*)(buf+19);
      if (imgsize == 0)
	imgsize = *(DWORD far*)(buf+32);
    }
  }
예제 #13
0
파일: kzenque.c 프로젝트: DeegC/ZeidonTools
/////////////////////////////////////////////////////////////////////////////
//
//   OPERATION:   EnqueueInstance
//
//   PARAMETERS:  zVIEW  vInstance - View to the instance to be enqueued
//                zPCHAR szEntityNames - A string containing 1 or
//                                  more entity names on which to enqueue
//                                  the instance. The first entity name
//                                  MUST BE the root of the object and
//                                  the remaining entity names MUST be
//                                  separated by the plus '+' character.
//
//   RETURN CODES:  0 - Enqueue successful
//                  1 - Enqueue unsuccessful, the instance is already
//                      Enqueued
//                 zCALL_ERROR - Enqueue unsuccessful, error in processing
//
/////////////////////////////////////////////////////////////////////////////
zSHORT OPERATION
EnqueueInstance( zVIEW vInstance, zPCHAR szEntityNames )
{
   zVIEW  vEnqueue;
   zVIEW  vEnqueueHolder;
   zVIEW  vQual;
   zVIEW  vWkInstance;
   zPCHAR szEntityNamePtr;
   zCHAR  szCurrentEntity[ 34 ];
   zCHAR  szLevel[ 2 ];
   zSHORT nEntity, nEnqueue, nIdx, nRC, nRetries;
   zLONG  lER_Token;
   zCHAR  szTimestamp[ 6 ];
   zCHAR  szObjectName[ 34 ];
   zCHAR  szUserID[ 34 ];
   zCHAR  szPassword[ 34 ];
   zCHAR  szKey[ 64 ];
   zCHAR  szMsg[ 256 ];

   // We put the enqueue logic in a for loop so we can restart the
   // enqueue if the enqueue fails and we cannot find the owner of
   // the enqueue.
   nRetries = 4;
   if ( MiGetObjectNameForView( szObjectName, vInstance ) < 0 )
      return( zCALL_ERROR );

   for ( ; ; )
   {
      // Set up work variables
      szEntityNamePtr = szEntityNames;
      _fstrcpy( szLevel, "R" );
      nEntity = nEnqueue = 0;

      // Set up a multiple root instance for enqueueing
      if ( ActivateEmptyObjectInstance( &vEnqueue, szlCGENQUEU,
                                        vInstance, zMULTIPLE ) != 0 )
      {
         return( zCALL_ERROR );
      }

      // Create a view on the instance so we do not step on the applications
      // cursor positions.
      CreateViewFromViewForTask( &vWkInstance, vInstance, 0 );

      // Get timestamp and user information for enqueue
      MiGetDateTimeForOI( szTimestamp, vWkInstance );
      SysGetUserID( vInstance, szUserID, szPassword );
      if ( szUserID[ 0 ] == 0 )
         _fstrcpy( szUserID, "(null)" );

      // Loop for each entity type to be enqueued
      while ( szEntityNamePtr[ 0 ] )
      {
         // Gather the next entity name on which to enqueue
         nIdx = 0;
         while ( szEntityNamePtr[ 0 ] && szEntityNamePtr[ 0 ] != '+' )
         {
            szCurrentEntity[ nIdx++ ] = szEntityNamePtr[ 0 ];
            szEntityNamePtr++;
         }

         szCurrentEntity[ nIdx ] = 0;
         if ( szEntityNamePtr[ 0 ] == '+' )
            szEntityNamePtr++;

         nEntity++;

         // Now that an entity name has been gathered, troll the instance
         // for every occurrence of that entity type and create an
         // enqueue instance for it
         nRC = SetCursorFirstEntity( vWkInstance, szCurrentEntity,
                                     zSCOPE_OI );
         if ( nRC == zCALL_ERROR )
         {
            DropView( vWkInstance );
            DropObjectInstance( vEnqueue );
            return( zCALL_ERROR );
         }

         if ( nRC >= zCURSOR_SET )
         {
            lER_Token = MiGetERTokenForEntity( vWkInstance, szCurrentEntity );
            do
            {
               // Set up an enqueue instance, The ER_Token and the Instance
               // key are the unique keys to the object, a duplicate instance
               // on the database will result in an enqueue failure with the
               // instance in use. The UserID combined with the Timestamp is
               // the non-unique key for deletion of a logical enqueue.

               // The object name and level ( 'R' - root, 'C' - child ) are
               // informational only.

               CreateEntity( vEnqueue, szlEnqueue, zPOS_AFTER );
               SetAttributeFromInteger( vEnqueue,
                           szlEnqueue, szlER_Token, lER_Token );
               MiGetKeyFromInstance( szKey, 61, vWkInstance, szCurrentEntity );
               SetAttributeFromString( vEnqueue, szlEnqueue, szlInstanceKey,
                                       szKey );
               SetAttributeFromVariable( vEnqueue, szlEnqueue, szlTimestamp,
                                       szTimestamp, zTYPE_DATETIME,
                                       6, 0, 0 );
               SetAttributeFromString( vEnqueue, szlEnqueue, szlType,
                                       "U" );
               SetAttributeFromString( vEnqueue, szlEnqueue, szlUser,
                                       szUserID );
               SetAttributeFromString( vEnqueue, szlEnqueue, szlObject,
                                       szObjectName );
               SetAttributeFromString( vEnqueue, szlEnqueue, szlLevel,
                                       szLevel );
               nEnqueue++;
            }  while ( SetCursorNextEntity( vWkInstance, szCurrentEntity,
                                            zSCOPE_OI ) >= zCURSOR_SET );
         }

         // After processing an entity type, all other enqueues are at the
         // child level
         szLevel[ 0 ] = 'C';
      }

      // Now that we're done gathering the enqueue information, we can drop
      // the view to the instance
      DropView( vWkInstance );

      // The enqueue instance has been built, now it is time to insert it
      // into the database for locking the instance.
      nRC = CommitObjectInstance( vEnqueue );
      if ( nRC != zDUPLICATE_ROOT )
      {
         DropObjectInstance( vEnqueue );
         return( nRC );
      }

      // The enqueue failed, now we will determine the owner of the enqueue
      // to see if we are conflicting with ourself or to report the owner
      // to the enqueue requestor
      SetCursorFirstEntity( vEnqueue, szlEnqueue, 0 );
      do
      {
         fnBuildQualForEnqueue( vEnqueue, &vQual );
         nRC = ActivateObjectInstance( &vEnqueueHolder, szlCGENQUEU,
                                       vInstance, vQual, zSINGLE );
         DropObjectInstance( vQual );
         if ( nRC < -1 )
            return( zCALL_ERROR );
         else
         if ( nRC >= 0 )
            break;
         else
            DropObjectInstance( vEnqueueHolder );

      } while ( SetCursorNextEntity( vEnqueue, szlEnqueue, 0 ) >= zCURSOR_SET );

      // If the enqueue holder was not found, then the enqueue may have
      // disappeared while trying to find the holder, retry the enqueue
      // operation.
      nRetries--;
      if ( nRC == -1 )
      {
         if ( nRetries == 0 )
            return( zCALL_ERROR );
      }

      // Report on the enqueue holder
      GetStringFromAttribute( szKey, vEnqueueHolder, szlEnqueue, szlUser );
      GetStringFromAttribute( &szKey[ 30 ],
                              vEnqueueHolder, szlEnqueue, szlObject );

      // if the current enqueue holder is the current user for the
      // same object type, then offer to drop the previous enqueue and
      // re-establish the enqueue for the current user
      if ( _fstrcmp( szUserID, szKey ) == 0 &&
           _fstrcmp( szObjectName, &szKey[ 30 ] ) == 0 && nRetries )
      {
         // we will retry this once and once only
         nRetries = 1;
         _fstrcpy( szMsg, "The " );
         _fstrcat( szMsg, szObjectName );
         _fstrcat( szMsg, " is already enqueued by you in this session or"
                          " a previous session. Would you like to release"
                          " the previously held enqueue?" );
         nRC = MessagePrompt( vInstance, "1", szlEnqueue, szMsg, 0,
                              zBUTTONS_YESNO, zRESPONSE_YES,
                              zICON_QUESTION );
         if ( nRC == zRESPONSE_NO )
         {
            DropObjectInstance( vEnqueue );
            DropObjectInstance( vEnqueueHolder );
            return( 1 );
         }

         // The user wants to delete a previous enqueue for the same
         // object type, build the qualification for the delete and remove
         // the prior enqueue.
         fnBuildQualForEnqueueDelete( vEnqueueHolder, &vQual );
         DropObjectInstance( vEnqueueHolder );
         nRC = ActivateObjectInstance( &vEnqueueHolder, szlCGENQUEU,
                                       vInstance, vQual, zMULTIPLE );
         DropObjectInstance( vQual );
         if ( nRC < 0 )
            return( zCALL_ERROR );

         nRC = SetCursorFirstEntity( vEnqueueHolder, szlEnqueue, 0 );
         while ( nRC >= zCURSOR_SET )
            nRC = DeleteEntity( vEnqueueHolder, szlEnqueue, zREPOS_NEXT );

         nRC = CommitObjectInstance( vEnqueueHolder );
         DropObjectInstance( vEnqueueHolder );

         // If the attempt to reuse the enqueue failed on a database error,
         // return that error. Otherwise, return zero ==> the enqueue was
         // reused.
         if ( nRC < 0 )
            return( zCALL_ERROR );
         else
            return( 0 );
      }
      else
      {
         // Report on the owner of the enqueue
         _fstrcpy( szMsg, "The " );
         _fstrcat( szMsg, szObjectName );
         _fstrcat( szMsg, " is currently in use by " );
         _fstrcat( szMsg, szKey );
         if ( _fstrcmp( szObjectName, &szKey[ 30 ] ) != 0 )
         {
            _fstrcat( szMsg, " under the object " );
            _fstrcat( szMsg, &szKey[ 30 ] );
         }
         _fstrcat( szMsg, "." );
         MessagePrompt( vInstance, "1", szlEnqueue, szMsg, 0,
                        zBUTTONS_OK, zRESPONSE_OK, 0 );
         DropObjectInstance( vEnqueue );
         DropObjectInstance( vEnqueueHolder );
         return( 1 );
      }
   }  // End of for loop for enqueueing

   // If we reach here, then the enqueue was in use and failed.
   return( 1 );
}
예제 #14
0
/****************************************************
**
**  Read last position and size of main help window.
**
****************************************************/
BOOL __far __pascal ReadLastMainWndPos( WINDOWPLACEMENT __far * WndPlacePtr )
{ 
  BOOL bMaxmized;
  
  char __far * TokenPtr; 
  char szString[ MAX_WNDPOS_STRING ];
  char szINIFilePath[ _MAX_PATH ];

  short int nBytesRead;

  
  /* Get path to the INI file. */
  GetINIPath( szINIFilePath );
  
  /* Read entry "LastPos" */
  nBytesRead = GetPrivateProfileString( INI_GENERAL_SECTION, INI_WNDPOS_ENTRY, 
                           INI_ENTRY_NOT_FOUND, szString, MAX_WNDPOS_STRING, 
                           szINIFilePath );            
                           
  /* No bytes read or entry not there. */
  if( nBytesRead == 0 || _fstrcmp( szString, INI_ENTRY_NOT_FOUND ) == 0 )
  {
    /* Set to default. */
    WndPlacePtr->showCmd = SW_SHOWNORMAL;
    WndPlacePtr->rcNormalPosition.left   = CW_USEDEFAULT;
    WndPlacePtr->rcNormalPosition.top    = CW_USEDEFAULT;
    WndPlacePtr->rcNormalPosition.right  = CW_USEDEFAULT;
    WndPlacePtr->rcNormalPosition.bottom = CW_USEDEFAULT;
  
    /* Setting not found. */
    return( FALSE );
  }
                                                                
  /* 
  ** Parse entry. 
  */

  /* Get maximize state. */
  TokenPtr = _fstrtok( szString, INI_WNDPOS_TOKEN );
  if( TokenPtr != NULL )
  { 
    bMaxmized = (BOOL) atoi( TokenPtr ); 
  }
  
  /* If maximized. */
  if( bMaxmized )
  {
    WndPlacePtr->showCmd = SW_SHOWMAXIMIZED;
    WndPlacePtr->rcNormalPosition.left   = CW_USEDEFAULT;
    WndPlacePtr->rcNormalPosition.top    = CW_USEDEFAULT;
    WndPlacePtr->rcNormalPosition.right  = CW_USEDEFAULT;
    WndPlacePtr->rcNormalPosition.bottom = CW_USEDEFAULT;

    /* Setting found. */
    return( TRUE );
  }

  /* Not maximized. */
  WndPlacePtr->showCmd = SW_SHOWNORMAL;
    
  /* Get x position. */
  TokenPtr = _fstrtok( NULL, INI_WNDPOS_TOKEN );
  if( TokenPtr != NULL )
  { 
    WndPlacePtr->rcNormalPosition.left = atoi( TokenPtr ); 
  }
  
  /* Get y position. */
  TokenPtr = _fstrtok( NULL, INI_WNDPOS_TOKEN );
  if( TokenPtr != NULL )
  { 
    WndPlacePtr->rcNormalPosition.top = atoi( TokenPtr ); 
  }
  
  /* Get width. */
  TokenPtr = _fstrtok( NULL, INI_WNDPOS_TOKEN );
  if( TokenPtr != NULL )
  { 
    WndPlacePtr->rcNormalPosition.right = atoi( TokenPtr ); 
  }

  /* Get height. */
  TokenPtr = _fstrtok( NULL, INI_WNDPOS_TOKEN );
  if( TokenPtr != NULL )
  { 
    WndPlacePtr->rcNormalPosition.bottom = atoi( TokenPtr ); 
  }

  /* Setting found. */
  return( TRUE );
}
예제 #15
0
/*--------------------------------------------------
  This function backs the General Selection dialog box.
  It is called during processing of File/New to
  get the L-System or Formula name after a list has
  been generated from the file selected by the user.

  The user may select from the list box.
  The result is returned on OK or double-click in the list box.

  Help sends an appropriate message using the
  SMPLHELP system.
 --------------------------------------------------*/
MRESULT EXPENTRY SelWhatDlgProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
     {
     SHORT i, isSelected;

     switch (msg)
          {
          case WM_INITDLG:

               CenterDialogBox(hwnd);

               /* Begin by setting the Title */
               WinSetDlgItemText(hwnd, IDD_SEL_LIST_WHAT, gs.pszTitle);

               /* Load the list box from the list of names */
               WinSendDlgItemMsg (hwnd, IDD_SEL_LIST_LB,
                          LM_DELETEALL, MPFROMP(NULL), MPFROMP(NULL) );
               isSelected = 0;   /* default if old not found in current list */
               for (i = 0; i < gs.sCountNames; i++)
                   {
                   WinSendDlgItemMsg (hwnd, IDD_SEL_LIST_LB,
                          LM_INSERTITEM, MPFROM2SHORT(LIT_END, 0),
                          MPFROMP(gs.szNames[i]) );
                   if (0 == _fstrcmp(gs.szNames[i], gs.szSelected) )
                        isSelected = i;
                   }

               /* Flag the current Selection in the list box */
               WinSendDlgItemMsg (hwnd, IDD_SEL_LIST_LB,
                          LM_SELECTITEM, MPFROMSHORT (isSelected),
                                 MPFROMSHORT(TRUE) ) ;
               /* and put it near the middle */
               WinSendDlgItemMsg (hwnd, IDD_SEL_LIST_LB,
                          LM_SETTOPINDEX,
                          MPFROMSHORT(max(isSelected-4, 0) ),
                          MPFROMP(NULL) ) ;

               return 0;

          case WM_CONTROL:
               {
               SHORT sWho = SHORT1FROMMP(mp1);
               SHORT sWhat = SHORT2FROMMP(mp1);

               switch (sWho)
                    {
                    case IDD_SEL_LIST_LB:
                         switch (sWhat)
                              {
                              case LN_ENTER:
                                   /* fake the OK button on double click */
                                   WinSendMsg(hwnd, WM_COMMAND,
                                   MPFROMSHORT(DID_OK),
                                   MPFROM2SHORT(CMDSRC_PUSHBUTTON, FALSE) ) ;
                              return 0;

                              }
                    }
               break;
               }

          case WM_COMMAND:
               switch (COMMANDMSG(&msg)->cmd)
                    {
                    case DID_OK:
                         isSelected = (SHORT) WinSendDlgItemMsg(hwnd,
                             IDD_SEL_LIST_LB, LM_QUERYSELECTION,
                             MPFROMSHORT(0), MPFROMP(NULL) );

                         _fstrcpy(gs.szSelected, gs.szNames[isSelected]);

                         npTempParms.fNewParms = TRUE;
                         WinDismissDlg (hwnd, TRUE) ;
                         return 0 ;

                    case DID_CANCEL:
                         npTempParms.fNewParms = FALSE;
                         WinDismissDlg (hwnd, FALSE) ;
                         return 0 ;
                    }
               break ;

          case WM_HELP:
               SimpleHelp(hab, hwnd, szTitleBar,
                       (HMODULE) 0, IDT_TEXT, IDT_HELP_TYPES);

               return 0;

               break;
          }
     return WinDefDlgProc (hwnd, msg, mp1, mp2) ;
     }