예제 #1
0
파일: dbf.c 프로젝트: hailynch/jnos2
void dbf_do_search(int s, char *file, int type ,char *database)
{
   FILE *f;
   char *fn, *fld = "NAME", *targ, *p, *cp;

   /* return results in regular ascii text or in CSO format */
   output_format = type;

   p = j2strdup(file);
   if (p == NULL)
   {
     tprintf("j2strdup() failed: dbf_do_search()\n");
   return;
   }

   /* if it's a CSO search then 'file' is in the form:
	"name=value" */
   strupr(p);
   if (output_format == CSOTEXT)
   {

      fn = j2strdup (database);
	if (strpbrk (p, "=") == NULL )
	{
	    targ = p;
	 }
	else
	{

	     fld = strtok(p, "=");
	     targ = strtok(NULL, "=");
      }
	cp = strrchr(targ, ' ');  /* get rid of trailing spaces */
	while (*cp == ' ')
	{
	    *cp = '\0';
	    cp--;
	}

	cp = targ;         /* get rid of leading space */
	while (*cp == ' ') cp++;
	targ = cp;
   }
   else
   {
      fn = strtok(p, "~");
      fld = strtok(NULL, "$");
      targ = strtok(NULL, "$");
   }

   gnamefix(s,fn);
   dbf_search(s, fn, fld, targ);
   if (output_format == CSOTEXT)
      free(fn);
   free(p);
}
예제 #2
0
파일: mboxcmd.c 프로젝트: hailynch/jnos2
// add aliases to the list
int
doaliases(int argc,char *argv[],void *p) {
    struct alias *a;
    int len;
  
    if(argc < 2)    // show the aliases
        return dombalias(0,NULL,NULL);
  
    if(argc == 2) {  // show a single alias, if any
        for(a=AliasList;a;a=a->next)
            if(!stricmp(a->name,argv[1])) {
                tprintf("%s\n",a->cmd);
                break;
            }
        if(!a)
            j2tputs("not set!\n");
        return 0;
    }
  
    // now either delete or add an alias !
    if((len=strlen(argv[2])) == 0) {  // delete an alias
        struct alias *p = NULL;
  
        for(a=AliasList;a;p=a,a=a->next) {
            if(!stricmp(a->name,argv[1])) {
                if(p)
                    p->next = a->next;
                else
                    AliasList = a->next;
                free(a->name);
                free(a->cmd);
                free(a);
                break;
            }
        }
    } else {    // add a new alias or change an existing one
        if(len > MBXLINE) {
            j2tputs("Alias too long!\n");
            return 1;
        }
        for(a=AliasList;a;a=a->next)
            if(!stricmp(a->name,argv[1]))
                break;
        if(!a) {    // add a new one
            a = mallocw(sizeof(struct alias));
            a->next = AliasList;
            AliasList = a;
            a->name = j2strdup(argv[1]);
            strupr(a->name);
        } else
            free(a->cmd);
        a->cmd = j2strdup(argv[2]);
    }
    return 0;
}
예제 #3
0
파일: dbf.c 프로젝트: hailynch/jnos2
int dbf_fields(int s, char *file, int OF)
{
   FILE *f;
   dbf_header dbfinfo;
   int i,port;
   char *p,Gdir[64];

   output_format = OF;        /* ASCIITEXT or CSOTEXT */

   p = j2strdup(file);
   if (p == NULL)
   {
     tprintf("j2strdup() failed: dbf_fields()\n");
     return 0;
   }

   /* open the file */
   if ((f = fopen(file, "rb")) == NULL)
   {
     tprintf("Cannot open file.\n");
     return(1);
   }

   /* get info from the file header */
   dbf_getheader(f, &dbfinfo);

   /* fill field info structure */
   dbf_getfields(f, &dbfinfo);

   gnamefix(s,p);
   for (i=1; i<=dbfinfo.nflds; i++)
   {
      if (output_format == CSOTEXT)
      {
	 usprintf(s, "-200:%d:%s:max %d Indexed Lookup Public Default",
			  i, fields[i].name, fields[i].length);

	  usputc(s, 10);
	 usprintf(s, "-200:%d:%s:%s.",
			  i, fields[i].name, fields[i].name);
	 usputc(s, 10);
      }
      else
      {
	port = findport(s,Gdir,'g');
	usprintf(s, "7%s\tq%s~%s\t%s\t%u\n",
		 fields[i].name, p, fields[i].name, Hostname,port);
      }
   }
   free(p);
   fclose(f);

   return 0;
}
예제 #4
0
파일: b2f.c 프로젝트: mlangelaar/jnos2
void j2AddnoB2F (char *callsign)
{
	int cnt;

	for (cnt = 0; cnt < MAXNOB2F; cnt++)
	{
		if (noB2Fcalls[cnt] == NULL)
		{
			noB2Fcalls[cnt] = j2strdup (callsign);
			break;
		}
	}
}
예제 #5
0
파일: fldigi.c 프로젝트: mlangelaar/jnos2
int fldigi_attach (int argc, char **argv, void *p)
{
	struct iface *ifp;

	if ((ifp = if_lookup (argv[1])) == NULLIF)
	{
		tprintf (Badinterface,argv[1]);
		return 1;
	}

	fldigiport = j2strdup (argv[1]);

	fldigi_command (ifp, "\xC0\x06KISSRAW:ON\xC0");

	// system ("/jnos/rte/send.pl");

	return 0;
}
예제 #6
0
파일: hfddrtns.c 프로젝트: mlangelaar/jnos2
static int dohfddip (int argc, char *argv[], void *p)
{
    if (argc < 2)
	{
		if (hfddip)
        	tprintf("hfdd IP address [%s]\n", hfddip);
		else
        	tprintf("not defined\n");
	}
    else
	{
		if (hfddip)
			free (hfddip);

		hfddip = j2strdup (argv[1]);
	}
	return 0;
}
예제 #7
0
파일: hfddrtns.c 프로젝트: mlangelaar/jnos2
int hfdd_connect (char *cc)
{
	char cbuf[20], *cptr, *ccptr, **pargv;

	int cnt;

	pargv = (char **)callocw(3,sizeof(char *));

	/* just to get this working, it needs better structure */
	for (ccptr = cc, cnt = 0; cnt < 3; cnt++)
	{
		cptr = cbuf;

		while (*ccptr && *ccptr != ' ')
			*cptr++ = *ccptr++;

		*cptr = 0;

		/* 20Mar2006, Maiko, Remove any EOL (end of line) chars */
		if (cnt == 2)
			rip (cbuf);

		if (hfdd_debug)
			log (-1, "cbuf [%s]", cbuf);

		pargv[cnt] = j2strdup (cbuf);

		if (*ccptr == ' ')
			ccptr++;
	}

	hfdd_conn_flag = 0; /* 03Feb2005, MAKE SURE this is set !!! */

	/*
	 * 16Apr2007, Maiko (VE4KLM), Identify which device interface is, now
	 * that I have the KAM connect working nicely, I need to add the other
	 * devices, PTC now, the DXP will be later.
	 */

	/* 17Feb2007, Maiko, New way to conn */
	if (hfdd_is_kam (pargv[1]))
		kam_make_call (pargv[2]);
	else if (hfdd_is_ptc (pargv[1]))
		ptc_make_call (pargv[2]);
	/* 23Apr2008, Maiko, Now support AEA PK232 modem */
	/* 10Sep2008, Maiko, New queue system for PK232, different function */
	else if (hfdd_is_pk232 (pargv[1]))
		pk232_connect (pargv[1], pargv[2]);
	else if (hfdd_is_dxp (pargv[1]))
		log (-1, "dxp not supported YET ...");
#ifdef WINMOR
	/* 07Apr2010, Maiko, Support the WINMOR Sound Card modem */
	else if (hfdd_is_winmor (pargv[1]))
		winmor_make_call (pargv[2]);
#endif
	/*
	 * 16Feb2007, Maiko, Need a function to request connect from hfddsrv
	 * used to be hfdd_console here - no more, since hfddsrv fulltime now
	 */

	if (hfdd_debug)
		log (-1, "trying [%s]", pargv[2]);

	/* 04Mar2006, Maiko, Fix up this wait for connection ... */

	while (!hfdd_conn_flag)
		j2pause (100);

	if (hfdd_conn_flag == -1)
	{
		if (hfdd_debug)
			log (-1, "[%s] no connection", pargv[2]);

		return -1;
	}

	if (hfdd_debug)
		log (-1, "[%s] connected - assign socket pair", pargv[2]);

	/* use socket pair like bbs side, 08Jan2005 */
	if (j2socketpair (AF_LOCAL, SOCK_STREAM, 0, fwds) == -1)
	{
		log (-1, "socketpair failed, errno %d", errno);
		return -1;
	}

	seteol (fwds[0], "\r");
	seteol (fwds[1], "\r");
/*
	seteol (fwds[0], "\r\n");
	seteol (fwds[1], "\r\n");
*/
	hfdd_fwdsock = fwds[0]; /* this is for our local access */

	sockmode (fwds[1], SOCK_ASCII);

	return (fwds[1]);	/* this one becomes m->user in forward.c */
}
예제 #8
0
파일: hfddrtns.c 프로젝트: mlangelaar/jnos2
static int dohfddsrv (int argc, char *argv[], void *p)
{
	static struct proc *hfsrvp = (struct proc*)0;

	if (argc == 3)
	{
		if (!stricmp (argv[2], "start"))
		{
			char **pargv = (char**)callocw (3, sizeof(char*));

			log (-1, "start hfdd server on port [%s]", argv[1]);

			pargv[0] = "c";
			pargv[1] = j2strdup (argv[1]);
			pargv[2] = "bbs";

			hfsrvp = newproc ("hfddsrv", 2048, hfddsrv2, 3, pargv, (void*)0, 1);
		}
		/* 09Mar2005, Maiko, Kick option incase server goes into limbo */
		else if (!stricmp (argv[2], "kick"))
		{
			log (-1, "kick hfdd server on port [%s]", argv[1]);
			alert (hfsrvp, EABORT);
		}
		/* 23Sep2006, Maiko, Unproto option for sysop to FEC at will,
		 * note this is a bit of a kludge in that we have to pass the
		 * name of the interface (will fix that later) ...
		 */
		else if (!stricmp (argv[2], "unproto"))
		{
			struct iface *ifp;

			log (-1, "sending unproto (FEC) beacon");

			/* 20Mar2007, Maiko, Added KAM hostmode */
   			if ((ifp = if_lookup (argv[1])) != NULLIF)
			{
				if (hfdd_is_dxp (ifp->name))
					dxp_FEC (ifp->dev, 1);
				else if (hfdd_is_kam (ifp->name))
					kam_FEC ();
				/* 16Apr2007, Maiko, Added FEC code for SCS modem */
				else if (hfdd_is_ptc (ifp->name))
					ptc_FEC ();
				/* 20Sepr2008, Maiko, Added FEC code for PK232 modem */
				else if (hfdd_is_pk232 (ifp->name))
					pk232_FEC (ifp->dev);
			}
		}
		/*
		 * 14Mar2007, Maiko, Utility to EXIT hostmode incase the
		 * TNC seems to get into the occasional I AM IN HOSTMODE
		 * but I AM NOT RESPONDING type of situation. Doing this
		 * kick will force the code to recognize NOT IN HOSTMODE
		 * status, and reinitialize the TNC (KAM).
		 */
		else if (!stricmp (argv[2], "exit"))
		{
			struct iface *ifp;

   			if ((ifp = if_lookup (argv[1])) != NULLIF)
			{
				/* 15May07, Now have hostmode exit for PTC-IIusb modem */
				if (hfdd_is_ptc (ifp->name))
					ptc_exit_hostmode (ifp->dev);
				/* 23Apr08, Maiko, Supporting PK232 now */
				else if (hfdd_is_pk232 (ifp->name))
					pk232_exit_hostmode (ifp->dev);
				else
					kam_exit_hostmode (ifp->dev);
			}
		}
	}
	else
		tprintf ("use: hfdd server [iface] [start|stop]\n"); 

	return 0;
}
예제 #9
0
파일: hfddrtns.c 프로젝트: mlangelaar/jnos2
int hfddsrv (int argc, char **argv, void *p)
{
	struct session spdummy, *sp = &spdummy;
	struct iface *ifp;
	struct asy *ap;
	char *ifn;

	/* 07Apr2010, Maiko, Winmor sound card tnc support */
	int notwinmor = 1;

#ifdef WINMOR
	ifp = &ifdummy;
	ifdummy.name = j2strdup ("winmor");
#endif
	/*
	 *  HFDD_PARAMS	hfddp;
	 *
	 * wonder if this getting destroyed when the client terminates is
	 * causing crashes, since a process might still be alive that expects
	 * this. Make it a static for now to see if that solves crashing !
	 */

	if (p != (void*)0)
		sp = (struct session*)p;

#ifdef WINMOR
	/* 07Apr2010, Maiko, No physical TTY for the WINMOR device */
	notwinmor = strcmp ("mor", argv[1]);
#endif

	if (notwinmor)
	{
		if (hfdd_debug)
			log (-1, "argc %d iface %s call %s", argc, argv[1], argv[2]);

    	if ((ifp = if_lookup (argv[1])) == NULLIF)
		{
        	tprintf (Badinterface, argv[1]);
        	return 1;
    	}

    	ap = &Asy[ifp->dev];
    	if (ifp->dev >= ASY_MAX || ap->iface != ifp)
		{
        	tprintf ("Interface %s not asy port\n", argv[1]);
        	return 1;
    	}

    	if (ifp->raw == bitbucket)
		{
        	tprintf ("hfdd session already active on %s\n", argv[1]);
        	return 1;
    	}

    	/* Save output handler and temporarily redirect output to null */
    	ifp->raw = bitbucket;
	}

   	/* Put tty into raw mode */
   	sp->ttystate.echo = 0;
   	sp->ttystate.edit = 0;
   	sockmode (sp->output, SOCK_BINARY);

	/*
	 * 03Jun2007, Maiko, No more keyboard mode for now. This will all be
	 * for mail forwarding only. The keyboard mode never worked very well,
	 * never got developed to it's fullest potential, and introduced some
	 * technical and logistical challenges just not worth doing (yet) !
	 */

	hfddp.keyboard = 0;	/* always from mailbox now, no keyboard user mode */

	hfddp.call = j2strdup (argv[2]);
	hfddp.iface = j2strdup (argv[1]);

	if (notwinmor)
	{
 	  /* 15Feb2005, Maiko, now using device params to configure this */
	  hfddp.pactor = (ap->flags & ASY_PACTOR);
	}
	else hfddp.pactor = 1;	/* 09Apr2010, Maiko, Automatic apparently */

	hfdd_fwdsock = -1;	/* 12Mar2005, Maiko, Make sure of this !!! */

	/*
	 * start up the keyboard handler (as of 02Feb2005, there is only
	 * only one keyboard handler now for all devices, the device specific
	 * stuff is now contained within the handler, instead of having a
	 * separate keyboard handler for each device. More standardized !
	 */
	ifn = if_name (ifp, " keybd");
	sp->proc1 = newproc (ifn, 1024, keyboard_to_hfdd, ifp->dev, sp, &hfddp, 0);
	free (ifn);

    ifn = if_name (ifp, " modem");
    chname (Curproc, ifn);
    free (ifn);

    sp->proc = Curproc;	/* important for alert */
  
    /* bring the line up (just in case) */
    if (ifp->ioctl != NULL)
        (*ifp->ioctl)(ifp, PARAM_UP, TRUE, 0L);

	if (hfdd_debug)
		log (-1, "start the modem machine");

	/*
	 * 22Jan2005, Maiko, Added 'realuser' parameter to the xxx_machine
	 * functions, so that tprintf()'s are suppressed, and the j2alarm()
	 * calls are invoked. Forwarding and having a real user at the
	 * keyboard have slightly different input/output requirements.
	 */
	if (hfdd_is_ptc (hfddp.iface))
		ptc_machine (ifp->dev, hfddp.call);
	else if (hfdd_is_dxp (hfddp.iface))
		dxp_machine (ifp->dev, &hfddp);
	/* 05Feb2007, Maiko, Switched parameters passed to function */
	else if (hfdd_is_kam (hfddp.iface))
		kam_machine (ifp->dev, &hfddp);
	/* 22Apr2008, Maiko, Now support AEA PK232 modem */
	else if (hfdd_is_pk232 (hfddp.iface))
		pk232_machine (ifp->dev, &hfddp);
#ifdef WINMOR
	/* 07Apr2010, Maiko, Support the WINMOR Sound Card modem */
	else if (hfdd_is_winmor (hfddp.iface))
		winmor_machine (ifp->dev, &hfddp);
#endif

	/* 08Feb2007, Maiko, MODEM machine will now never die !!! */

	if (hfdd_debug)
		log (-1, "left the modem machine");

	return 0;
}