
_open

㭪            뢠 䠩  ⥭  .

⠪          #include <fcntl.h>
                   int _open(const char *filename, int oflags);

, ᮤঠ騩   io.h
⨯

ᠭ           㭪 _open   뢠   䠩,       ண
                   ।  ࠬ஬  filename,   ⠢
                         ᫥  権  ⥭  /
                   ,   ।塞   ࠬ஬   oflags.  
                   뢠  ०, ।塞 _fmode.

                    㭪樨   _open   ࠬ  oflags    DOS  2.x
                   ࠭稢 ६ 祭ﬨ: O_RDONLY, O_WRONLY
                   O_RDWR.  DOS 3.x  ⥫ 祭:

                   O_NOINHERIT - 砥, ᫨ 䠩   
                                 । ୥ ணࠬ.

                   O_DENYALL -    䠩 ⮫쪮 
                                 ⥪饬  handle.

                   O_DENYWRITE -   㣮 
                                 䠩 ⮫쪮 ⥭.

                   O_DENYREAD -   㣮 
                                 䠩 ⮫쪮 .

                   O_DENYNONE - 蠥 ࠧ ⨥ 䠩-
                                 .

                    ᨬ᪨ ⠭ (O_...) । 
                   䠩 fcntl.h.

                    맮 㭪樨 open  ᨥ DOS 3.x  
                   祭 ⮫쪮     祭  O_DENYxxx.  
                   ਡ   ࠧ   㯠     䠩    
                      ஢.

                   ᨬ쭮 ᫮  ६     䠩
                   ,  HANDLE_MAX.

頥        ᯥ譮 襭 _open 頥 楫
祭           ⥫쭮 ᫮ handle - ᪨ 
                   ⮣ 䠩. ⥫ 䠩 (㪠⥫ ⥪饩
                   樨)  ⠭    砫  䠩.   
                   訡  _open 頥 祭 -1,   ६
                   errno 砥   ᫥ 祭:

                   ENOENT -    䠩  .
                   EMFILE - 誮   䠩.
                   EACCES -  饭.
                   EINVACC -   㯠.

७ᨬ      㭪 _open 㭨쭠  DOS.

 ⠪     open, read, sopen.

ਬ:

#include <string.h>
#include <stdio.h>
#include <fcntl.h>
#include <io.h>

int main(void)
{
   int handle;
   char msg[] = "Hello world!";
   if((handle = _open("TEST.$$$",O_RDWR)) == -1) {
      perror("Error:");
      return 1;
   }
   _write(handle,msg,strlen(msg));
   _close(Handle);
   return 0;
}


open

㭪            뢠 䠩  ⥭  .

⠪          #include <fcntl.h>
                   #include <sys\stat.h>
                   int open(const char *filename, int access
                                  [, unsigned mode]);

, ᮤঠ騩   io.h
⨯

ᠭ           㭪 open    뢠    䠩,      ண
                   । ࠬ஬  filename,    ⠢
                     ᫥騬  ⥭ / ,  
                   ᨬ  ࠬ access.

                    ᮧ  䠩    筮  ०,   
                   ᢮ ᮮ⢥饥 祭 _fmode,   
                   ⨨  䠩  㪠  樨  O_CREAT   O_TRUNC
                   易 樥 ⮢ ᪮ ᫮
                   (OR)  室 ० ।.  ਬ:

                      open("xmp",O_CREAT|O_TRUNC|O_BINARY,S_IREAD);

                   ᮧ  䠩  ਡ⮬ ⮫쪮  ⥭
                     XMP, 祬, ᫨  㦥 ,  
                   १  㫥 .

                    㭪樨  open  ࠬ  access  
                   ⥬  ᪮  ⮢   ᫮   䫠,
                   ᫥   ᫥ ᯨ᪠.   ࢮ
                   ᯨ᪠    ᯮ짮  ⮫쪮    䫠;
                   ⠫   䫠      ਬ      
                   ᪨ .

                   ᮪ 1: 䫠 ⥭/.

                   O_RDONLY   ⨥ ⮫쪮  ⥭.
                   O_WRONLY   ⨥ ⮫쪮  .
                   O_RDWR     ⨥  ⥭  .


                   ᮪ 2: ⠫ 䫠 㯠.

                   O_NDELAY    ᯮ;  ᮢ⨬ 
                              ⥬ UNIX.
                   O_APPEND   ᫨ 䫠 ⠭,  । 
                              樥 , 㪠⥫ 䠩 -
                               ⠭   䠩.
                   O_CREAT    ᫨ 䠩 ,  䫠 
                                祭. ᫨ 䠩 
                              ,  㤥 ᮧ,   
                              㬥 mode  ᯮ짮
                               ⠭ ⮢-ਡ⮢ 䠩,
                                 㭪樨 chmod.
                   O_TRUNC    ᫨ 䠩 ,   ᥪ-
                                0. ਡ 䠩  -
                              묨.
                   O_EXCL     ᯮ ⮫쪮   O_CREAT.
                              ᫨ 䠩 㦥 ,  ந室
                                訡.
                   O_BINARY    䫠   ⠭ 
                              ࠭஢  䠩 
                              筮 ०.
                   O_TEXT      䫠   ⠭ 
                              ࠭஢  䠩  ⥪-
                              ⮢ ०.

                    ⠭ (O_...) ।  䠩 fcntl.h.

                   ᫨    O_BINARY,    O_TEXT    㪠,  䠩
                   뢠    ०  ࠭樨,  ᮮ⢥⢥
                   쭮 ६ _fmode.

                   ᫨   ஥  ࠬ access  䫠
                   O_CREAT,   室 㪠 㬥  mode  
                   ᫥  ᨬ᪨  ⠭,  । 
                   䠩 sys\stat.h.

                   
                   祭 ࠬ     㯠
                   mode
                   
                   S_IWRITE              襭  .
                   S_IREAD               襭  ⥭.
                   S_IREAD|S_IWRITE      襭  ⥭/.
                   

頥        ᯥ譮 襭 open 頥 楫
祭           ⥫쭮 ᫮ handle - ᪨ 
                   ⮣ 䠩.    ⥫   䠩   (㪠⥫
                   ⥪饩 樨) ⠭  砫  䠩.
                     訡  㭪  頥  祭  -1,  
                   ६  errno  砥        ᫥
                   祭:

                   ENOENT -    䠩  .
                   EMFILE - 誮   䠩.
                   EACCES -  饭.
                   EINVACC -   㯠.

७ᨬ      㭪 open ন  ⥬ UNIX.
                    ᨨ  7  ⥬  UNIX    O_⨯   
                   ।. ⥬ UNIX SYSTEM 3  ᥬ
                    O_⨯  ᪫祭 O_BINARY.

 ⠪     chmod, chsize, close, _creat, creat, creatnew,
                   creattemp, dup, dup2, fdopen, filelenth, fopen,
                   freopen, gettime, lseek, lock, _open, read,
                   sopen, _write, write.

ਬ:

#include <string.h>
#include <stdio.h>
#include <fcntl.h>
#include <io.h>

int main(void)
{
   int handle;
   char msg[] = "Hello world!";
   if((handle = open("TEST.$$$",O_RDWR)) == -1) {
      perror("Error:");
      return 1;
   }
   _write(handle,msg,strlen(msg));
   _close(Handle);
   return 0;
}



outport

㭪            ந 뢮 ᫮  .

⠪          void outport(int portid, int value);

, ᮤঠ騩   dos.h
⨯

ᠭ           outport 뢠  祭  ࠬ  value   
                   室 , ।塞 ࠬ஬ portid.

頥       .
祭

७ᨬ       㭪      㭨쭠            ᥬ⢠
                   ய஢ 8086.

ਬ:

#include <stdio.h>
#include <dos.h>

int main(void)
{
   int value = 64;
   int port = 0;
   outport(port,value);
   printf("祭 %d ᫠   %d",value,port);
   return 0;
}



outportb

㭪            ந 뢮   .

⠪          void outport(int portid, unsigned char value);

, ᮤঠ騩   dos.h
⨯

ᠭ           outportb -   ப,    뢠
                   祭   ࠬ   value      室  ,
                   ।塞 ࠬ஬ portid.

                    맮 outportb  㪠 砥 䠩
                   dos.h,   outportb ᬠਢ   ,  
                     ஥ 設 . ᫨  
                   砥  䠩  dos.h,    ᫨      ⬥
                   outportb    #undef,      㭪
                   outportb.

頥       .
祭

७ᨬ       㭪      㭨쭠            ᥬ⢠
                   ய஢ 8086.

 ⠪     inport, outport, inportb.

ਬ:

#include <stdio.h>
#include <dos.h>

int main(void)
{
   int value = 64;
   int port = 0;
   outport(port,value);
   printf("祭 %d ᫠   %d",value,port);
   return 0;
}


outtext

㭪             ⮡ࠦ ப   ࠭.

⠪           #include <graphics.h>
                    void far outtext(char far *textstring);

, ᮤঠ騩    graphics.h
⨯

ᠭ
                   outtext ⮡ࠦ ப ⥪  , ᯮ
                   ⥪騥   ⠭   ࠬ   ࠢ
                   ⥪,    ⠪  ⥪騥  ,  ࠢ  
                   ࠧ.

                   outtext 뢮  ⥪    ⥪  .  ᫨
                   ਧ⠫쭮 ࠢ ⥪ ࠢ LEFT_TEXT
                     ࠢ  뢮  ⥪  ⠭ ࠢ
                   HORIZ_DIR,   न    x    ⥪饩    樨
                   த   textwidth(textstring).
                   ⥪  ⠥ .

                    ᯥ祭 ᮢ⨬  প  
                   ᯮ짮 ࠧ    ⮢,    ᯮ
                   textwidth  textheight    ।  ࠧ஢
                   ப.

                   砭. ᫨ ப ⠥ ⠭ 
                   㬮砭 ⮬    㭪樨  outtext,  
                       ப ,   室  ।
                   ⥪饣 , ᥪ.

                   砭. outtext  ।祭     ࠡ   
                   ᪮ ०   㤥 ࠡ  ⥪⮢
                   ०.

頥       .
祭

७ᨬ       㭪  㭨쭠     Borland   C++.   
                   ਣ   ⮫쪮      ஢   IBM  PC  
                   ᮢ⨬      ,   ᭠饭   ᯫ묨
                   ࠬ,   ন騬  ᪨  ०.
                   㭪  ᮢ⨬  Windows.

 ⠪     gettextsettings,outtextxy,settextjustify,
                   textheight, textwidth.
 
ਬ:
                   
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

int main(void)
{
   /* request auto detection */
   int gdriver = DETECT, gmode, errorcode;
   int midx, midy;

   /* initialize graphics and local variables */
   initgraph(&gdriver, &gmode, "");

   /* read result of initialization */
   errorcode = graphresult();
   if (errorcode != grOk)  /* an error occurred */
   {
      printf("Graphics error: %s\n", grapherrormsg(errorcode));
      printf("Press any key to halt:");
      getch();
      exit(1); /* terminate with an error code */
   }

   midx = getmaxx() / 2;
   midy = getmaxy() / 2;

   /* move the C.P. to the center of the screen */
   moveto(midx, midy);

   /* output text starting at the C.P. */
   outtext("This ");
   outtext("is ");
   outtext("a ");
   outtext("test.");

   /* clean up */
   getch();
   closegraph();
   return 0;
}
                   

outtextxy

㭪             ⮡ࠦ ப  㪠 .

⠪           #include <graphics.h>
                    void far outtextxy(int x,int y,
                                       char far *textstring);

, ᮤঠ騩    graphics.h
⨯

ᠭ            outtext ⮡ࠦ ப ⥪  
                    ࠭   樨 (x,y), ᯮ ⥪-
                    騥 ⠭ ࠬ ࠢ ⥪,
                     ⠪ ⥪騥 , ࠢ  ࠧ.

                     ᯥ祭 ᮢ⨬  প
                     ᯮ짮 ࠧ ⮢,ᯮ
                    textwidth  textheight  । ࠧ஢
                    ப.

                    砭. ᫨ ப ⠥ ⠭
                     㬮砭 ⮬   㭪権 outtext 
                    outtextxy,    ப ,  -
                      । ⥪饣  ᥪ.

                    砭. outtext ।祭  ࠡ 
                    ᪮ ०   㤥 ࠡ  ⥪-
                     ०.

頥        .
祭

७ᨬ        㭪 ਣ ⮫쪮  -
                    ஢ IBM PC  ᮢ⨬  , ᭠饭 -
                    묨 ࠬ, ন騬 ᪨
                    ०.

 ⠪      gettextsettings, outtext, textheight, textwidth.
                   
ਬ:
                   
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

int main(void)
{
   /* request auto detection */
   int gdriver = DETECT, gmode, errorcode;
   int midx, midy;

   /* initialize graphics and local variables */
   initgraph(&gdriver, &gmode, "");

   /* read result of initialization */
   errorcode = graphresult();
   if (errorcode != grOk)  /* an error occurred */
   {
      printf("Graphics error: %s\n", grapherrormsg(errorcode));
      printf("Press any key to halt:");
      getch();
      exit(1); /* terminate with an error code */
   }

   midx = getmaxx() / 2;
   midy = getmaxy() / 2;

   /* output text at the center of the screen */
   /* Note: the C.P. doesn't get changed.     */
   outtextxy(midx, midy, "This is a test.");

   /* clean up */
   getch();
   closegraph();
   return 0;
}
                   

_OvrlInitEms

㭪            樠 ⥬ 窨   ७
                     ૥.

⠪          #include<dos.h>
                   int cdecl far _OvrlInitEms(unsigned emsHandle,
                   unsigned firstPage, unsigned pages);

, ᮤঠ騩   dos.h
⨯

ᠭ           _OvrlInitEms ஢ 稥    ७
                   ( ࠩ EMS),   뤥   . ᫨
                   ࠬ  emsHandle  ࠢ  0,     
                   ૥ 뤥 ࠭  EMS  ᯮ
                     窨 ૥.  ᫨ emsHandle  ࠢ
                   0,      ⨬ ਯ஬ EMS;
                    㤥 ᯮ짮   ૥.  
                   ⮬ 砥   㪠 firstPage,  ன
                    稭 窠,  ⮩ .

                        ,   㫥   ࠬ   pages
                   ।  ᨬ쭮  ᫮  ࠭,  
                     ᯮ짮 ஬ ૥.

頥       _OvrlInitEms 頥 0, ᫨  -
祭             ᯮ짮  窨  -
                   ७.

७ᨬ      _OvrlInitEms 㭨쭠  Borland C++.

 ⠪     _OvrlInitExt, ovrbuffer (쭠 ६).

ਬ:

#include<dos.h>

int main(void)
{
   /*    ૥  ᯮ짮
      16 ࠭ (256)  ७ */
   _OvrlInitEms(0,0,16);
    .
    .
    .
}


_OvrlInitExt

㭪            樠 ⥬   窨   ⥫쭮
                      ૥.

⠪          #include<dos.h>
                   int cdecl far _OvrlInitExt(unsigned long
                   startAddress, unsigned long length);

, ᮤঠ騩   dos.h
⨯

ᠭ           _OvrlInitExt ஢    稥   ⥫쭮
                   ,  ᯮ  ⮤ ᪠  㣨
                   ணࠬ,    ⠪   ᯮ   ⥫
                   ,   뤥    .  ᫨  ࠬ
                   startAdress   ࠢ   0,     ૥
                   ।  砫      ᯮ,  
                   ᥣ, ࠧ ૥. ᫨ startAdress  ࠢ
                   0,     ૥  ᯮ  
                    ⮣ .

                       ,   㫥   ࠬ   length
                   ।  ᨬ쭨  ࠧ  ,  
                     ᯮ짮 ஬ ૥.

頥       _OvrlInitExt 頥 0, ᫨  -
祭             ᯮ짮  窨 ⥫-
                    .

७ᨬ      _OvrlInitExt 㭨쭠  Borland C++.

 ⠪     _OvrlInitEms, ovrbuffer (쭠 ६).

ਬ:

#include<dos.h>

int main(void)
{
    /* ᯮ짮 ⥫    0x200000L (2M)
       祬 ⮫쪮, ᪮쪮 室 */
   _OvrlInitExt(0x200000L,0);
    .
    .
    .
}

