コード例 #1
0
ファイル: dcpfpkt.c プロジェクト: swhobbit/UUPC
short frdmsg(char *str)
{
   char *smax;
   char *s = str;

   smax = s + MAXPACK - 1;
   for (;;) {
      if (sread(s, 1, M_fPacketTimeout) <= 0)
      {
         printmsg(0,"frdmsg: timeout reading message");
         *s++ = '\0';
         goto msgerr;
      }
      if (*s == '\r')
         break;
      if (*s < ' ')
         continue;
      if (s++ >= smax)
      {
         printmsg(0,"frdmsg: buffer overflow");
         *--s = '\0';
         goto msgerr;
      } /* if (s++ >= smax) */
   }
   *s = '\0';
   return DCP_OK;

msgerr:
   printmsg(0,"frdmsg: Message received \"%s\"", str);
   return DCP_FAILED;
} /* frdmsg */
コード例 #2
0
ファイル: imfile.c プロジェクト: swhobbit/UUPC
static void imStatus(IMFILE *imf)
{

#ifdef UDEBUG
   if (imf->buffer != NULL)
      printmsg(18,"imStatus: "
#ifdef BIT32ENV
               "%p"
#else
               "%Fp"
#endif
                  " buffer address, %ld bytes used, %ld bytes capacity, "
                  "current position %ld%s%s",
                  imf->buffer,
                  imf->inUse,
                  imf->length,
                  imf->position,
                  imeof(imf)     ? ", EOF"   : "",
                  imerror(imf) ? ", ERROR" : "");
#endif
   else if (imf->filename != NULL)
   {
      /* Only report the file is on disk once */
      if ((imf->flag & IM_FLAG_DISKR) == 0)
      {
         imf->flag |= IM_FLAG_DISKR;
         printmsg(5,"imStatus: File resides on disk as %s with %ld bytes",
                  imf->filename,
                  imlength( imf ));
      }
   }
   else
      printmsg(5,"imstatus: No backing store exists for file");

} /* imStatus */
コード例 #3
0
int main(int argc,char** argv)
{
   const char* server_name;
   int port =__COMMON_PORT__;
   if (argc > 2) {
	port = atoi(argv[2]);
	if(port <= 0) {
           printmsg("DIE! Invalid port");
           exit(1);
	}
   }
   
   if (argc > 1) {
       server_name = argv[1];
   }
   else {
       server_name = "localhost";
   }
   
   if(signal(SIGPIPE,SIG_IGN)==SIG_ERR) {
       printmsg("DIE! signal(SIGPIPE)");
       exit(1);
   }

   sOperacion ops[500];
   int totalops = cargar_archivo(&ops[0]);

   main_proc(server_name,port,ops,totalops);
   
}
コード例 #4
0
ファイル: ssleep.c プロジェクト: swhobbit/UUPC
void ddelay( const KEWSHORT milliseconds )
{
   MSG msg;
   WORD TimerId = 1;
   BOOL bTimerDone = KWFalse;

/*--------------------------------------------------------------------*/
/*          A 0-delay call means give up control to Windows           */
/*--------------------------------------------------------------------*/

   if (milliseconds == 0)
   {
      while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
      {
         TranslateMessage(&msg);

         DispatchMessage(&msg);
      }
      return;
   }

   TimerId = SetTimer( hOurWindow,
                       TimerId,
                       (milliseconds > 55) ? (WORD)milliseconds : (WORD)55 ,
                       NULL );

   if ( TimerId == 0 )
   {
      printmsg(0, "WindowsDelay: Unable to set Windows Timer");
      panic();
      return;
   } /* if */

/*--------------------------------------------------------------------*/
/*       LOCAL MESSAGE LOOP - Service Windows while waiting for       */
/*       the timer message.                                           */
/*--------------------------------------------------------------------*/

   while(!bTimerDone && GetMessage(&msg, NULL, NULL, NULL))
   {
      TranslateMessage(&msg);

      switch( msg.message )
      {
         case WM_TIMER:
            bTimerDone = KWTrue;
            /* Fall through and dispatch message   */

         default:
            DispatchMessage(&msg);
            break;

      } /* switch( msg.message ) */
   } /* while */

   if (KillTimer( hOurWindow, TimerId ) == 0)
      printmsg(0, "WindowsDelay: Unable to kill Windows Timer %d",
                  (int) TimerId );

} /* ddelay */
コード例 #5
0
/* Check if negative offsets are handled correctly by mmap.  */
static int
do_test (void)
{
  const int prot = PROT_READ | PROT_WRITE;
  const int flags = MAP_SHARED;
  const unsigned long length = 0x10000;
  const unsigned long offset = 0xace00000;
  const unsigned long size = offset + length;
  void *addr;
  int fd;
  char fname[] = "tst-mmap-offset-XXXXXX";

  fd = mkstemp64 (fname);
  if (fd < 0)
    return printmsg (1, "mkstemp");

  if (unlink (fname))
    return printmsg (1, "unlink");

  if (ftruncate64 (fd, size))
    return printmsg (0, "ftruncate64");

  addr = mmap (NULL, length, prot, flags, fd, offset);
  if (MAP_FAILED == addr)
    return printmsg (1, "mmap");

  /* This memcpy is likely to SIGBUS if mmap has messed up with offset.  */
  memcpy (addr, fname, sizeof (fname));

  return 0;
}
コード例 #6
0
ファイル: ulib14.c プロジェクト: swhobbit/UUPC
void iflowcontrol( KWBoolean flow )
{

#ifdef ARTICOMM_INT14 /* Richard H. Gumpertz ([email protected]), 28 Sep 1993 */
   union REGS regs;          /* Scratch area for interrupt calls. */

/*
   With INT14, don't open and close the port; toggle it in place
   by using INT14/AX=800A, which is again Artisoft-specific.
*/
   printmsg(4, "iflowcontrol: %sabling in-band flow control",
                               (flow ? "en" : "dis"));
   regs.x.ax = 0x800A;
   regs.h.bl = (unsigned char) (flow ? 2 : 1);
                                 /* 2 is hardware, 1 is XON/XOFF */
   regs.x.dx = portNum;
   int86(0x14, &regs, &regs);
#else /* ARTICOMM_INT14 */
   if (flow)
   {
      printmsg(4, "iflowcontrol: in-band flow control not supported");
   }
#endif /* ARTICOMM_INT14 */

   ShowModem();

} /* iflowcontrol */
コード例 #7
0
ファイル: pwinsock.c プロジェクト: swhobbit/UUPC
KWBoolean pWinSockInit( void )
{

/*--------------------------------------------------------------------*/
/*                          Load the library                          */
/*--------------------------------------------------------------------*/

   if (!hWinsock)
      hWinsock = LoadLibrary("WINSOCK.DLL");
   else {
      printmsg(0,"pWinSockInit: called twice with no termination");
      panic();
   }

   if (!hWinsock)
   {
      printmsg(0, "pWinSockInit: could not find Winsock.DLL");
      return KWFalse;
   }

/*--------------------------------------------------------------------*/
/*       Initialize pointers to functions with in the libraries       */
/*--------------------------------------------------------------------*/

#ifdef __TURBOC__
#pragma warn -sus
#endif

   paccept                = GetProcAddress(hWinsock, (LPSTR)MAKELONG(  1,0));
   pbind                  = GetProcAddress(hWinsock, (LPSTR)MAKELONG(  2,0));
   pclosesocket           = GetProcAddress(hWinsock, (LPSTR)MAKELONG(  3,0));
   pconnect               = GetProcAddress(hWinsock, (LPSTR)MAKELONG(  4,0));
   phtonl                 = GetProcAddress(hWinsock, (LPSTR)MAKELONG(  8,0));
   phtons                 = GetProcAddress(hWinsock, (LPSTR)MAKELONG(  9,0));
   pinet_addr             = GetProcAddress(hWinsock, (LPSTR)MAKELONG( 10,0));
   plisten                = GetProcAddress(hWinsock, (LPSTR)MAKELONG( 13,0));
   pntohl                 = GetProcAddress(hWinsock, (LPSTR)MAKELONG( 14,0));
   pntohs                 = GetProcAddress(hWinsock, (LPSTR)MAKELONG( 15,0));
   precv                  = GetProcAddress(hWinsock, (LPSTR)MAKELONG( 16,0));
   pselect                = GetProcAddress(hWinsock, (LPSTR)MAKELONG( 18,0));
   psend                  = GetProcAddress(hWinsock, (LPSTR)MAKELONG( 19,0));
   psetsockopt            = GetProcAddress(hWinsock, (LPSTR)MAKELONG( 21,0));
   pshutdown              = GetProcAddress(hWinsock, (LPSTR)MAKELONG( 22,0));
   psocket                = GetProcAddress(hWinsock, (LPSTR)MAKELONG( 23,0));
   pgethostbyname         = GetProcAddress(hWinsock, (LPSTR)MAKELONG( 52,0));
   pgetservbyname         = GetProcAddress(hWinsock, (LPSTR)MAKELONG( 55,0));
   pWSAGetLastError       = GetProcAddress(hWinsock, (LPSTR)MAKELONG(111,0));
   pWSACancelBlockingCall = GetProcAddress(hWinsock, (LPSTR)MAKELONG(113,0));
   pWSAIsBlocking         = GetProcAddress(hWinsock, (LPSTR)MAKELONG(114,0));
   pWSAStartup            = GetProcAddress(hWinsock, (LPSTR)MAKELONG(115,0));
   pWSACleanup            = GetProcAddress(hWinsock, (LPSTR)MAKELONG(116,0));

#ifdef __TURBOC__
#pragma warn .sus
#endif

   return KWTrue;

} /* pWinSockInit */
コード例 #8
0
bool viewcmd(char *itemName, CFErrorRef *err) {
    char *cmd, *viewname;
    SOSViewActionCode ac = kSOSCCViewQuery;
    CFStringRef viewspec;
    
    viewname = strchr(itemName, ':');
    if(viewname == NULL) return false;
    *viewname = 0;
    viewname++;
    cmd = itemName;
    
    if(strcmp(cmd, "enable") == 0) {
        ac = kSOSCCViewEnable;
    } else if(strcmp(cmd, "disable") == 0) {
        ac = kSOSCCViewDisable;
    } else if(strcmp(cmd, "query") == 0) {
        ac = kSOSCCViewQuery;
    } else {
        return false;
    }
    
    if(strchr(viewname, ',') == NULL) { // original single value version
        viewspec = convertStringToView(viewname);
        if(!viewspec) return false;
        
        SOSViewResultCode rc = SOSCCView(viewspec, ac, err);
        CFStringRef resultString = convertViewReturnCodeToString(rc);
        
        printmsg(CFSTR("View Result: %@ : %@\n"), resultString, viewspec);
        return true;
    }
    
    if(ac == kSOSCCViewQuery) return false;
    
    // new multi-view version
    char *viewlist = strdup(viewname);
    char *token;
    char *tofree = viewlist;
    CFMutableSetRef viewSet = CFSetCreateMutable(NULL, 0, &kCFCopyStringSetCallBacks);
    
    while ((token = strsep(&viewlist, ",")) != NULL) {
        CFStringRef resultString = convertStringToView(token);
        CFSetAddValue(viewSet, resultString);
    }
    
    printmsg(CFSTR("viewSet provided is %@\n"), viewSet);
    
    free(tofree);
    
    bool retcode;
    if(ac == kSOSCCViewEnable) retcode = SOSCCViewSet(viewSet, NULL);
    else retcode = SOSCCViewSet(NULL, viewSet);
    
    fprintf(outFile, "SOSCCViewSet returned %s\n", (retcode)? "true": "false");
    
    return true;
}
コード例 #9
0
ファイル: delivers.c プロジェクト: swhobbit/UUPC
static KWBoolean
AutoBounceSMTP(
   int   status,
   IMFILE *imf,
   const MAIL_ADDR *sender,
   SMTP_ADDR *toAddress,
   int count,
   const char *relay,
   const KWBoolean validate,
   const unsigned int timeout
)
{
   int subscript;

   switch(status)
   {
      case KWNSSuccess:
         /* No problem, so do not force termination */
         return KWFalse;

      case KWNSNoNet:
         printmsg(0,"Network connection lost with %s"
                    ", requeuing for retry.",
                    relay);
         shutdownSMTP(0);
         return KWTrue;

      case KWNSNetTimeout:
         printmsg(0,"Network timeout occurred, breaking off exchange with %s"
                    " and requeuing for retry.",
                    relay );
         shutdownSMTP(timeout);
         return KWTrue;

      case KWNSTransientError:
         printmsg(0,"Transient procotol error with %s"
                     ", requeuing for retry.",
                     relay);
         shutdownSMTP(timeout);
         return KWTrue;

      default:
         Bounce(imf,
                sender,
                "SMTP Protocol Permanent Error occurred",
                GET_TRACE_BUFFER(),
                relay,
                validate);
       /* Treat all bounced addresses as processed */
       for (subscript = 0; subscript < count; subscript++)
             toAddress[subscript].processed = KWTrue;
         return KWTrue;

   } /* switch(status) */

} /* SMTPAutoBounce */
コード例 #10
0
ファイル: getseq.c プロジェクト: swhobbit/UUPC
unsigned long getSeq()
{
   char seqfile[FILENAME_MAX];
   FILE *stream;
   unsigned long seq = 0;

   mkfilename(seqfile, E_spooldir, SFILENAME);

   if ((stream = FOPEN(seqfile, "r+", IMAGE_MODE)) == nil(FILE))
   {
      printerr( seqfile );

      if ((stream = FOPEN(seqfile, "w", IMAGE_MODE)) == nil(FILE))
      {
         printerr( seqfile );
         panic();
      }
   }
   else {
      if ( fread( &seq, sizeof seq, 1, stream ) != 1 )
         printerr( seqfile );
   }

/*--------------------------------------------------------------------*/
/*     Generate a new seed for our sequence if we can't read one      */
/*--------------------------------------------------------------------*/

   if ( ! seq++ )
   {
      seq = ((unsigned long) getpid()) % 10000000;
                                    /* Start number small, semi-unique*/

      printmsg(0,"Resetting sequence number to %lu (0x%08lx)",
                  seq,
                  seq );
   }

/*--------------------------------------------------------------------*/
/*                       Update sequence number                       */
/*--------------------------------------------------------------------*/

   rewind( stream );

   if ((fwrite( &seq, sizeof seq, 1, stream ) != 1) || fclose(stream))
   {
      printerr( seqfile );
      panic();
   }

#ifdef UDEBUG
   printmsg(8, "getseq: seq#=%ld", seq);
#endif

   return seq;

} /* getseq */
コード例 #11
0
ファイル: makebuf.c プロジェクト: swhobbit/UUPC
void
freeBuf( void *oldBuffer, const char *file, const size_t line )
{
   while( top != NULL )
   {
      BUFQUEUE *save = top;

      KWBoolean done = (KWBoolean) ( top->userBuffer == oldBuffer ?
                                       KWTrue : KWFalse );

      if ( top->signature != SIGNATURE )
      {
         printmsg(0, "freeBuf: Invalid buffer queue at %p", top );
         bugout( file, line );
      }

      if ( top->userBuffer == oldBuffer )
         done = KWTrue;

#ifdef UDEBUG
      printmsg(done ? 8 : 2,"%s(%d): freeBuf: %slicit "
                  "free of %p (%d,%d) for %u bytes",
                  file,
                  line,
                  done ? "ex" : "im",
                  top,
                  top->entry,
                  entries,
                  top->length );

      entries--;
#endif

/*--------------------------------------------------------------------*/
/*            Pop the current entry off the stack and free it         */
/*--------------------------------------------------------------------*/

      top = top->previous;
      free( save );

      if ( done )
         return;

   } /* while( top != NULL ) */

/*--------------------------------------------------------------------*/
/*       If we didn't find the block to free, we have a serious       */
/*       internal error -- report it and exit.                        */
/*--------------------------------------------------------------------*/

   printmsg( 0, "freeBuf: Unable to locate requested memory block at %p",
                 oldBuffer );
   bugout( file, line );

} /* freeBuf */
コード例 #12
0
ファイル: icb.c プロジェクト: JamesLinus/LiteBSD-Ports
static void
gotpacket(char msg[], int len)
{
	int	i;

	/* What did we get?  */
	switch (msg[0]) {
	case 'a':
		break;
	case 'b':
		printmsg(msg, len, 0);
		break;
	case 'c':
		printmsg(msg, len, 1);
		break;
	case 'd':
	case 'f':
		printmsg(msg, len, 2);
		break;
	case 'e':
		timestamp();
		fprintf(stdout, "%s ", tbuf);
		fputs("-!- [Error] ", stdout);
		for (i = 1; i < len; i++)
			fputc(msg[i], stdout);
		fputc('\n', stdout);
		break;
	case 'g':
		timestamp();
		fprintf(stdout, "%s ", tbuf);
		fputs("-!- [Error] Connection closed by server\n", stdout);
		running = 0;
		break;
	case 'i':
		printicmd(msg, len);
		break;
	case 'j':
		sendlogin();	/* Now we can log in.  */
		break;
	case 'k':
		timestamp();
		fprintf(stdout, "%s ", tbuf);
		fputs("-!- [Beep] You were beeped by ", stdout);
		for (i = 1; i < len; i++)
			fputc(msg[i], stdout);
		fputc('\n', stdout);
		break;
	case 'l':
	case 'm':
		break;
	default:
		fputs("Received invalid packet.\n", stdout);
		break;
	}
}
コード例 #13
0
ファイル: execute.c プロジェクト: swhobbit/UUPC
static KWBoolean internal( const char *command )
{
   static char *commands[] = { "break",   "cd",    "chdir",    "copy",
                               "ctty",    "date",  "del",      "dir",
                               "echo",    "erase", "for",      "md",
                               "mkdir",   "rd",    "rem",      "ren",
                               "rename",  "rmdir", "time",     "type",
                               "ver",     "verify",  "vol",
                               NULL };
   char **list;

/*--------------------------------------------------------------------*/
/*       Empty commands are a special signal to use the command       */
/*       processor to run the arguments.                              */
/*--------------------------------------------------------------------*/

   if ( *command == '\0' )
   {
      printmsg(4,"internal: Empty command, using command processor");
      return KWTrue;
   }

/*--------------------------------------------------------------------*/
/*                   Determine command list to use                    */
/*--------------------------------------------------------------------*/

   if (E_internal == NULL )
      list = commands;
   else
      list = E_internal;

/*--------------------------------------------------------------------*/
/*                   Scan the list for the command                    */
/*--------------------------------------------------------------------*/

   while( *list != NULL )
   {
      if (equali(*list++,command))
      {
         printmsg(4,"\"%s\" is an internal command",command);
         return KWTrue;
      } /* if */

   } /* while( *list != NULL ) */

/*--------------------------------------------------------------------*/
/*       The command is not in the list; return KWFalse (external      */
/*       command)                                                     */
/*--------------------------------------------------------------------*/

   printmsg(4,"\"%s\" is an external command",command);
   return KWFalse;

} /* internal */
コード例 #14
0
ファイル: sys.c プロジェクト: swhobbit/UUPC
KWBoolean excluded(char *list, char *path)
{
    char    *t1, *t2, *t3;
    int     temp;

    printmsg(5, "exclude: checking %s against %s", list, path);

    t1 = strtok(list, ", ");

    while (t1 != NULL)
    {
        t2 = strstr(path, t1);

        while (t2 != NULL)
        {
            /* MUST be start of string or preceded by '!' */

            if ((t2 == path) ||
                    (*(t2 - 1) == '!'))
            {
                /* is this the only entry left ? */

                if (equal(t1, t2))
                    return KWTrue;

                /* must be directly followed by a '!' */

                t3 = strchr(t2, '!');

                if (t3 != NULL)
                {
                    *t3 = 0;
                    temp = strcmp(t1, t2);
                    *t3 = '!';
                    if (temp == 0)
                        return KWTrue;
                }
            }

            /* search for another occurence */
            t2 = strstr(t2 + 1, t1);

        }

        t1 = strtok(NULL, ", ");

    } /* while (t1 != NULL) */

    printmsg(5, "exclude: results in KWFalse");
    return KWFalse;

} /* excluded */
コード例 #15
0
ファイル: usertabl.c プロジェクト: swhobbit/UUPC
struct UserTable *checkuser(const char *name)
{
   int   lower;
   int   upper;

   if ( (name == NULL) || (strlen(name) == 0) )
   {
      printmsg(0,"checkuser: Invalid argument!");
      panic();
   }

#ifdef UDEBUG
   printmsg(14,"checkuser: Searching for user id %s", name);
#endif

 /*-------------------------------------------------------------------*/
 /*             Initialize the host name table if needed              */
 /*-------------------------------------------------------------------*/

   if (userElements == 0)           /* host table initialized yet?    */
      userElements = loaduser();        /* No --> load it             */

   lower = 0;
   upper = (int) userElements - 1;

/*--------------------------------------------------------------------*/
/*              Peform a binary search on the user table              */
/*--------------------------------------------------------------------*/

   while ( lower <= upper )
   {
      int midpoint;
      int hit;
      midpoint = (lower + upper) / 2;

      hit = stricmp(name,users[midpoint].uid);

      if (hit > 0)
         lower = midpoint + 1;
      else if (hit < 0)
         upper = midpoint - 1;
      else
         return &users[midpoint];
   }

/*--------------------------------------------------------------------*/
/*         We didn't find the user.  Return failure to caller         */
/*--------------------------------------------------------------------*/

   return BADUSER;

}  /* checkuser */
コード例 #16
0
int initCtrl (){
    
    if(!(SDL_Init(SDL_INIT_EVERYTHING))){

        SDL_SetEventFilter(eventFilter);
        SDL_SetVideoMode(200, 200, 0, 0);
        // SDL_WM_GrabInput(SDL_GRAB_ON);
        
        // If gamepad mode specified, open gamepad
        if(ctrlmode == GAMEPAD){

            int num_pads;

            // If more than one joystick attached, let user choose which one
            if((num_pads = SDL_NumJoysticks()) > 1){

                sprintf(termbuf, "Select gamepad index (number from 0 to %d): ", (num_pads-1));
                printmsg();
                while((pad_index = fgetc(stdin)) == EOF);
            }

            if((pad = SDL_JoystickOpen(pad_index))){

                sprintf(termbuf, "%s opened successfully.\n",
                        SDL_JoystickName(pad_index));
                printmsg();
                
                // Set initial modes
                cur_move = MOV_STOP;
                cur_turn = TRN_NONE;
                cur_h_aim = AIM_H_STRGHT;
                cur_v_aim = AIM_V_STRGHT;
                cur_fire = FIRE_OFF;
                cur_l_strf = STRF_L_OFF;
                cur_r_strf = STRF_R_OFF;

                SDL_JoystickEventState(SDL_ENABLE);
            }
            else{

                sprintf(termbuf, "Gamepad %s not opened successfully.\nReverting to keyboard control\n",
                        SDL_JoystickName(pad_index));
                printmsg();
                ctrlmode = KEYBOARD;
            }
        }

        return -1;
    }

    return 0;
}
コード例 #17
0
/*----------------------------------------------------------------
* main
*
* wlanctl-ng entry point.
*
* Arguments:
*	argc	number of command line arguments
*	argv	array of argument strings
*
* Returns: 
*	0	- success 
*	~0	- failure
----------------------------------------------------------------*/
int main ( int argc, char **argv )
{
	UINT8	message[MSG_BUFF_LEN];
	UINT32	msgcode = P80211DID_INVALID;
	INT	result = 0;
	INT	i;

	if ( argc < 4 && argc >= 2 && strcmp( argv[1], "version") == 0) {
		printf("wlanctl-ng: %s\n", WLAN_RELEASE);			
	}
	else if ( argc < 4 && argc >= 2 && strcmp( argv[1], "commands") == 0) {
		print_allrequests();			
	}
	else if ( argc < 4 && argc >= 2 && strcmp( argv[1], "mibs") == 0) {
		print_allmibs();			
	}
	else if ( argc <  3 ) {
		usage();
	} else {
		/* stuff the device name in a global */
		devname = argv[1];

		/* returns P80211DID_INVALID no match */
		for ( i = 0; i < sizeof(cmdcats)/sizeof(cmdcats[0]); i++) {
			msgcode = p80211_text2did(msg_catlist, 
					cmdcats[i], argv[2], NULL);
			if ( msgcode != P80211DID_INVALID ) {
				break;
			}
		}

		if (msgcode != P80211DID_INVALID) { /* msgcode valid */
			result = cmdline2requestmsg( message, msgcode, argc, argv );

			if ( result == 0 ) {
				if ( (result = do_ioctl( message, msgcode )) == 0 ){
				printmsg( message, msgcode );
				}
			} else {
				printmsg( message, msgcode );
/*
				printf("Message \"%s\" was unable to be created\n", argv[2]);
*/
			}
		} else { /* msgcode invalid */
			printf("The cmd \'%s\' is invalid\n", argv[2]);
			result=msgcode;
		} 
	}

	return(result);
}
コード例 #18
0
ファイル: delivers.c プロジェクト: swhobbit/UUPC
static KWNetStatus
SendSMTPCmd(
  char        *cmd      /* IN The command to send */
)
{
   char buffer[KW_BUFSIZ];
   int len = (int) strlen(cmd);
   KWBoolean buffered = KWFalse;

  bufferTrace(">>>", cmd, len);

/*--------------------------------------------------------------------*/
/*       Buffer the command if possible to allow appending the        */
/*       CR/LF for transmission of the resulting logical line as      */
/*       one network write.                                           */
/*--------------------------------------------------------------------*/

  if (sizeof buffer > (len + 3))
  {
     strcpy(buffer, cmd);
     strcpy(buffer + len, CRLF);
     len += CRLF_LEN;
     cmd = buffer;
     buffered = KWTrue;
  }

/*--------------------------------------------------------------------*/
/*           Actually perform the network write of the command        */
/*--------------------------------------------------------------------*/

  if (swrite(cmd, len) < len)
  {
     printmsg(0,"Error sending command to remote host");
     return KWNSNoNet;
  }

/*--------------------------------------------------------------------*/
/*       If the command was not buffered, write the trailing CR/LF    */
/*--------------------------------------------------------------------*/

  if (!buffered && (swrite(CRLF, CRLF_LEN) < CRLF_LEN))
  {
    printmsg(0, "Error sending CR/LF to remote host");
    return KWNSNoNet;
  }

  return KWNSSuccess;

} /* SendSMTPCmd */
コード例 #19
0
ファイル: strpool.c プロジェクト: swhobbit/UUPC
void safefree( void *input , const char UUFAR *file, size_t line)
{
   STR_QUEUE *current = anchor;
   int buffers = 0;

   while( current != NULL )
   {
      buffers ++;
      if (( input > (void *) current ) &&
          (input < (void *) (current->pool + pool_size ) ))
      {
         printmsg(0,"Attempt to free string \"%s\" allocated via newstr() in pool %d",
                  input , buffers );

         bugout( file, line);
      }

      current = current->next_link;
   }

#undef free

   free(input);

} /* safefree */
コード例 #20
0
ファイル: test.c プロジェクト: erlendkg/Sanntid
int main() {
  char str[10] = "<1E2F1>";

  printmsg(str);


}
コード例 #21
0
ファイル: ndir.c プロジェクト: swhobbit/UUPC
extern DIR *opendirx( const char *dirname, char *pattern)
{
   union REGS inregs, outregs;
   struct SREGS segregs;
   char pathname[FILENAME_MAX];
   DTA far *dtasave;
   DTA far *dtaptr;
   char far *pathptr;

/*--------------------------------------------------------------------*/
/*                    Build pathname to be scanned                    */
/*--------------------------------------------------------------------*/

   strcpy(pathname, dirname);
   if ((*pattern != '/') || (dirname[ strlen(dirname) - 1] != '/'))
      strcat(pathname,"/");
   strcat(pathname, pattern);

   /* allocate control block */
   thisDirP = malloc(sizeof(DIR));
   checkref( thisDirP );

/*--------------------------------------------------------------------*/
/*                     Set disk transfer address                      */
/*--------------------------------------------------------------------*/

   dtasave = (DTA far *)getdta();
   dtaptr = (DTA far *)&(thisDirP->dirdta);
   setdta((char far *)dtaptr);

/*--------------------------------------------------------------------*/
/*                      look for the first file                       */
/*--------------------------------------------------------------------*/

   inregs.h.ah = 0x4e;
   pathptr = (char far *)pathname;
   segregs.ds = FP_SEG(pathptr);
   inregs.x.dx = FP_OFF(pathptr);
   inregs.x.cx = 0;   /* attribute */
   intdosx(&inregs, &outregs, &segregs);

   /* bad directory name? */
   if (outregs.x.cflag && (outregs.x.ax == 2 || outregs.x.ax == 3)) {
      free(thisDirP);
      return NULL;
   }

   thisDirP->dirfirst = outregs.x.cflag ? outregs.x.ax : 0;

   setdta((char far *)dtasave);
   strcpy(thisDirP->dirid, "DIR");

#ifdef UDEBUG
   printmsg(2,"opendir: Address is %p", thisDirP );
#endif

   openForBusiness = KWTrue;
   return thisDirP;

} /*opendir*/
コード例 #22
0
int cargar_archivo(sOperacion* ops)
{
   char mensaje[__TCP_MSG_LEN__];
   int totalops=0;

   /* leo las operaciones del archivo */
   FILE* f;
   
   f=stdin;
   while(!feof(f)) {
       if(fgets(mensaje,__TCP_MSG_LEN__,f)==NULL) {
          printmsg("Error reading file");
          exit(1);
       }
       int size = strlen(mensaje) - 1; /* op|data|\n */
       if(mensaje[size] == '\n') { 
           mensaje[size] = '\0';
           size--;
       }
       ops[totalops].size = size;
       ops[totalops].op = mensaje[0]-38;
       strcpy(ops[totalops].data,&mensaje[1]);   
       totalops++;
   } 
   fclose(f);
   return totalops;
}
コード例 #23
0
ファイル: ssleep.c プロジェクト: swhobbit/UUPC
static int RunningUnderDesqview(void)
{
   static int result = 2;
   union REGS inregs, outregs;

   if (result != 2)           /* First call?                          */
      return result;          /* No --> Return saved result           */

   inregs.x.ax = 0x2B01;      /* Dos Set Date function */
   inregs.x.cx = 0x4445;      /* CX DX = 'DESQ' */
   inregs.x.dx = 0x5351;

   intdos(&inregs, &outregs);

   if (outregs.h.al == 0xff) {
      result = 0;
   } else {
      printmsg(4, "RunningUnderDesqview:  Running under DesqView (AX=0x%x)",
               (int) outregs.x.ax);
      result = 1;
   }

   return result;

} /* RunningUnderDesqview */
コード例 #24
0
ファイル: imfile.c プロジェクト: swhobbit/UUPC
int imprintf(IMFILE *imf, const char *fmt, ...)
{
   va_list arg_ptr;

   va_start(arg_ptr,fmt);

   if (imf->buffer == NULL)
      return vfprintf(imf->stream, fmt, arg_ptr);
   else {
      char buffer[4096];
      int result = vsprintf(buffer, fmt, arg_ptr);

      if (result == EOF)
         return EOF;

      if (result > (sizeof buffer))
      {
         printmsg(0, "imprintf: Memory overflow processing im memory file");
         panic();                /* We corrupted the stack!          */
      }

      if (imputs(buffer, imf) == result)
         return result;
      else
         return EOF;

   }  /* else */

} /* imprintf */
コード例 #25
0
ファイル: imfile.c プロジェクト: swhobbit/UUPC
int imclose(IMFILE *imf)
{
   int result = 0;

   if (imf == NULL)
   {
      printmsg(0,"imclose: Close called with NULL pointer");
      panic();
   }

   imStatus(imf);

   if (imf->buffer != NULL)
      FREE(imf->buffer);

   if (imf->stream != NULL)
   {
      result = fclose(imf->stream);
      REMOVE(imf->filename);
   }

   if (imf->filename != NULL)
      free(imf->filename);

#ifdef UDEBUG
   memset(imf, 0, sizeof *imf);
#endif
   free(imf);

   return result;

} /* imclose */
コード例 #26
0
ファイル: testimp.c プロジェクト: swhobbit/UUPC
void bugout( const size_t lineno, const char *fname )
{
   printmsg(0,"Program aborting at line %d in file %s",
              lineno, fname );
   fcloseall();
   exit(69);
} /*bugout */
コード例 #27
0
ファイル: ulib14.c プロジェクト: swhobbit/UUPC
static void ShowModem( void )
{
   static int oldStatus = 0xDEAD;
   int status;

   if ( debuglevel < 4 )
      return;

   status = FSStatus();

   if (status == oldStatus)
      return;

   printmsg(0, "ShowModem: %#02x%s%s%s%s%s%s%s%s",
      status,
      mannounce(MDM_CD,   status, "\tCarrier Detect"),
      mannounce(MDM_RI,   status, "\tRing Indicator"),
      mannounce(MDM_DSR,  status, "\tData Set Ready"),
      mannounce(MDM_CTS,  status, "\tClear to Send"),
      mannounce(MDM_CDC,  status, "\tCD changed"),
      mannounce(MDM_TRI,  status, "\tRI went OFF"),
      mannounce(MDM_DSRC, status, "\tDSR changed"),
      mannounce(MDM_CTSC, status, "\tCTS changed"));

   oldStatus = status;

} /* ShowModem */
コード例 #28
0
ファイル: dcpfpkt.c プロジェクト: swhobbit/UUPC
short fsendpkt(char *ip, short len)
{
   char *op;
   short sum, nl;
   short ret;
   char obuf[MAXPACK * 2];
   op = obuf;
   nl = 0;
   sum = chksum;
   if (len == 0)
   {
      printmsg(0,"fsendpkt: Internal error: zero length for packet");
      return DCP_FAILED;
   }
   do {
      if (sum & 0x8000) {
         sum <<= 1;
         sum++;
      } else
         sum <<= 1;
      sum += (short) (*ip & 0377);
      sum &= 0xffff;
      if (*ip & 0200) {
         *ip &= 0177;
         if (*ip < 040) {
            *op++ = '\174';
            *op++ = (char) (*ip++ + 0100);
         } else
         if (*ip <= 0171) {
            *op++ = '\175';
            *op++ = *ip++;
         }
         else {
            *op++ = '\176';
            *op++ = (char) (*ip++ - 0100);
         }
         nl += 2;
      } else {
         if (*ip < 040) {
            *op++ = '\172';
            *op++ = (char) (*ip++ + 0100);
            nl += 2;
         } else
         if (*ip <= 0171) {
            *op++ = *ip++;
            nl++;
         } else {
            *op++ = '\173';
            *op++ = (char) (*ip++ - 0100);
            nl += 2;
         }
      }
   } while (--len > 0);
   chksum = sum;
   ret = (short) swrite(obuf, nl);
   if ( ret == nl )
      return DCP_OK;
   else
      return DCP_FAILED;
} /* fsendpkt */
コード例 #29
0
ファイル: klist.c プロジェクト: aosm/KerberosLibraries
void printfiller (char c, int count)
{
    int i;

    for (i = 0; i < count; i++)
        printmsg("%c", c);
}
コード例 #30
0
ファイル: getseq.c プロジェクト: swhobbit/UUPC
char *jobNumber( const unsigned long sequenceIn,
                 const size_t lengthIn,
                 const KWBoolean monocase )
{
   static char buf[10];
   static const char set[] =
      "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";

   unsigned long sequence = sequenceIn;
   size_t length = lengthIn;
   const int base = (sizeof set - 1) - (monocase ? 26 : 0);
   char *p = buf + sizeof buf - 2;

   if ( length >= sizeof buf )      /* User want too many digits?    */
      length = sizeof buf - 1;      /* Yes --> Limit the string      */

   while( length-- > 0 )
   {
      *p-- = set[ (size_t) (sequence % base) ];
      sequence /= base ;
   } /* while */

   p++;                             /* Step back to first character  */

   printmsg(5, "jobNumber: seq#=%ld, length = %u, job id = \"%s\"",
                sequenceIn,
                lengthIn,
                p);

   return p;

} /* jobNumber */