/********************* START OF SPECIFICATIONS *************************/
/*                                                                     */
/*  SUBROUTINE NAME: NLSQUERYBIDIATT                                   */
/*                                                                     */
/*  DESCRIPTIVE NAME: Queries the contents of the control block.       */
/*                                                                     */
/*  COPYRIGHT: (c) IBM Corp. 1989                                      */
/*                                                                     */
/*  FUNCTION: The NlsQueryBidiAtt retrieves the Bidi Attributes for    */
/*            the default or current session or for any of the three   */
/*            printers connected to the system.                        */
/*                                                                     */
/*  ENTRY POINT: NlsIntQueryBidiAtt                                    */
/*      LINKAGE: CALL FAR from any application programmer.             */
/*                                                                     */
/*  INPUT:       (Effect,RetInfo)                                      */
/*               Effect (DWORD)   - Select Keyboard/Video or printer   */
/*               RetInfo (@Other) - Address of an area for the API to  */
/*                                  return the Bidi data in it.        */
/*                                                                     */
/*  EXIT-NORMAL: RC = 0                                                */
/*                                                                     */
/*  EXIT-ERROR:  RC = ERROR_BIDI_NO_SUPPORT                            */
/*               RC = ERROR_BIDI_INVALID_EFFECT                        */
/*               RC = ERROR_BIDI_INVALID_LENGTH                        */
/*                                                                     */
/*  INTERNAL REFERENCES:                                               */
/*     LOCAL DATA DEFINITION:                                          */
/*           DWORD Scope      - Session Identifier.                    */
/*           DWORD ReturnCode - Used by the called functions.          */
/*                                                                     */
/*     GLOBAL DATA DEFINITION:                                         */
/*        WORD gdt_descriptor - Holds the segment selector.            */
/*        WORD ldt_descriptor - Holds the segment selector.            */
/*        STRUCT gdt          - structure of type PGINFOSEG.           */
/*        STRUCT RETINFO      - Structure of the area in which the API */
/*                              returns the BiDi attributes.           */
/*                              It consists of the following:          */
/*                                WORD length         - Length of the  */
/*                                                      structure.     */
/*                                BYTE ReturnArea[78] - Rest of the    */
/*                                                      structure.     */
/*     ROUTINES: NONE.                                                 */
/*                                                                     */
/*  EXTERNAL REFERENCES:                                               */
/*     ROUTINES: DosGetInfoSeg()                                       */
/*               NlsIntQueryBidiAtt()                                  */
/*                                                                     */
/********************** END OF SPECIFICATIONS **************************/
#define  INCL_BASE
#include <os2.h>
#include "bdcalls.h"        /* include the Bidi Data Segment structure,  */
#include "sq.h"             /* the RetInfo Structure.                    */
                            /* include the error codes                   */
USHORT far pascal _loadds NlsQueryBidiAtt (LONG Effect, PRETINFO RetInfo)
{
/*-----------------------------------------------------------------------*/
/*                         Variables Definition                          */
/*-----------------------------------------------------------------------*/
   ULONG  Scope;
   USHORT ReturnCode;
   PLINFOSEG  ldt;
   SEL gdt_descriptor,ldt_descriptor;             /* infoseg descriptors */

/*-----------------------------------------------------------------------*/
/*                 Insure that the I/P parms are valid                   */
/*-----------------------------------------------------------------------*/

   if (!(Effect >= MIN_EFFECT && Effect <= EFFECT_LIMIT))
                                              /* Effect is out of range */
      return(ERROR_BIDI_INVALID_EFFECT);

   if (Effect == MIN_EFFECT) {
                                /* query the default session attributes */
      ReturnCode = NlsIntQueryBidiAtt(Effect, 0L, RetInfo);
      return(ReturnCode);
   }

   if (Effect == NULL) {       /* Query the current session keyboard    */
                               /* video control block contents. Get the */
                               /* current session ID in Scope           */
      DosGetInfoSeg(&gdt_descriptor, &ldt_descriptor);
      ldt = MAKEPLINFOSEG(ldt_descriptor);
                                  /* this contains forground session ID */
      Scope = ldt->sgCurrent;
      ReturnCode = NlsIntQueryBidiAtt(Scope, Effect, RetInfo);
      return(ReturnCode);
   }
   if (Effect > NULL) {               /* Get the contents of one of the */
                                      /* printers control blocks        */
      Scope = 0;
      ReturnCode = NlsIntQueryBidiAtt(Scope, Effect, RetInfo);
      return(ReturnCode);
   }
}
