⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pushd.c

📁 使用于OS/2下的小工具的C源程序,使用于OS/2下的小工具的C源程序
💻 C
字号:
/*
* PUSHD.C - Testclient for message queues.
*
*
* PROGRAMMER:	    Martti Ylikoski
* CREATED:	    17.3.1991
*/
static char *VERSION = "Version  1.0" ;
/*
*/

static char *progname ;

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INCL_DOSINFOSEG
#define INCL_DOS
#include <os2.h>
#include "queue.h"
//int send_queue(char *queue_name, char *message, USHORT cbElement, USHORT usRequest ) ;

int main(int argc, char *argv[])
{
USHORT ret ;
int i ;
PSZ pszPath;
USHORT cbPath, usDisk;
ULONG ulDrives;
SEL selPath;
SEL ginfo, linfo ;
LINFOSEG FAR *plis ;
char sga[4], drive[3] ;
int len ;

   progname = argv[0] ;

   if (argc == 2 && (strcmpi(argv[1], "-q") == 0
       || strcmpi(argv[1], "/q") == 0))
   {
      QueSend("\\queues\\popreq", "  ", 3, 1,"START /C dirserv.exe", progname) ; /* send EXIT command */
      printf("Directory stack server removed. \n") ;
      return( 0 ) ;
   }

   if (( ret = DosGetInfoSeg(&ginfo, &linfo)) != 0)
   {
      printf("%s: error in DosGetInfoSeg", progname) ;
      return(1) ;
   }

   plis = MAKEPLINFOSEG(linfo) ;
   itoa(plis->sgCurrent, sga, 10) ;

   cbPath = 0;
   DosQCurDisk(&usDisk, &ulDrives);	/* gets current drive	     */

   /* First call DosQCurDir to find out the size of the buffer needed. */

   DosQCurDir(usDisk, NULL, &cbPath);

   if ((ret = DosAllocSeg(cbPath + 12, &selPath, SEG_GIVEABLE)) != 0 )	 /* allocates memory */
   {
      fprintf(stderr, "%s: error in DosAllocSeg...\nExiting...\n", progname) ;
      return( 1 ) ;
   }

   pszPath = MAKEP(selPath, 0);	      /* assigns it to a far pointer */
   strcpy(pszPath, sga) ;	      /* include the screen group */
   drive[0] = 'A' + usDisk - 1 ;
   drive[1] = ':' ;
   drive[2] = '\0' ;
   strcat(pszPath, " ") ;
   strcat(pszPath, drive) ;
   strcat(pszPath,"\\") ;	      /* leadind back slash for dir info */
   len = strlen(pszPath) ;

   DosQCurDir(usDisk,		      /* drive number		     */
	      &pszPath[len],	      /* buffer for directory path   */
	      &cbPath);		      /* length of directory buffer  */

   QueSend("\\queues\\pushreq", pszPath, strlen(pszPath) + 1, 0, "START /C dirserv.exe", progname) ;

   printf("Directory %s pushed\n", &pszPath[len-3]) ;
   return( 0 ) ;
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -