Пример #1
0
/*
 * render() processes a html page and returns a buffer containing the
 * rendered page
 */
Page *
render(FILE *input, int screenwidth)
{
    Page *bfr;

    if ((bfr = malloc(sizeof *bfr)) == 0)
	return 0;

    bfr->pagealloc= 10240;			/* alloc 10k for the page */
    bfr->page     = malloc(bfr->pagealloc);
    bfr->pagelen  = 0;				/* nothing written yet */
    bfr->xp       = 0;				/* set up xp and start of */
    bfr->startx   = 0;				/* line */
    bfr->hrefs    = malloc(1);			/* prepare the href array */
    bfr->nrhrefs  = 0;
    bfr->title    = 0;				/* ... the title */
    bfr->titlelen = 0;
    bfr->isbol    = 1;				/* and mark beginning of line */

    memset(&state, 0, sizeof state);		/* reset state block */
    state.align = wwLEFT;
    state.width = screenwidth;
    state.doing = D_VANILLA;
    state.page = bfr;

    addchar(DLE);
    addchar(' ');
    parse_it(input, 0, 0, ALL_TAGS);
    addchar(0);					/* null-terminate the page */
    bfr->pagelen--;

    return bfr;
} /* render */
Пример #2
0
/* -------------------------------------------------------------------- */
static BOOL alias_route(char *str, const char *srch)
{                          
    FILE *fBuf;
    char line[90];
    char *words[256];
    char path[80];

    sprintf(path, "%s\\route.cit", cfg.homepath);
    
    if ((fBuf = fopen(path, "r")) == NULL)  /* ASCII mode */
    {  
        crashout("Can't find route.cit!");
    }

    while (fgets(line, 90, fBuf) != NULL)
    {
        if (line[0] != '#') continue;
   
        if (strnicmp(line, srch, 5) != SAMESTRING) continue;
     
        parse_it( words, line);

        if (strcmpi(srch, words[0]) == SAMESTRING)
        {
            if (strcmpi(str, words[1]) == SAMESTRING)
            {
                fclose(fBuf);
                strcpy(str, words[2]);
                return TRUE;
            }
        }
    }
    fclose(fBuf);
    return FALSE;
}
Пример #3
0
/* ------------------------------------------------------------------------ */
static int directory_l(char *str)
{                          
    FILE *fBuf;
    char line[90];
    char *words[256];
    char path[80];

    sprintf(path, "%s\\external.cit", cfg.homepath);
    
    if ((fBuf = fopen(path, "r")) == NULL)  /* ASCII mode */
    {  
	crashout("Can't find route.cit!");
    }

    while (fgets(line, 90, fBuf) != NULL)
    {
	if (line[0] != '#') continue;
   
	if (strnicmp(line, "#DIRE", 5) != SAMESTRING) continue;
     
	parse_it( words, line);

	if (strcmpi(words[0], "#DIRECTORY") == SAMESTRING)
	{
	    if (u_match(str, words[1]))
	    {
		fclose(fBuf);
		return TRUE;
	    }
	}
    }
    fclose(fBuf);
    return FALSE;
}
Пример #4
0
int		add_to_mater(char *info, t_v3D **coord, t_materiau *mater)
{
  int		*col;

  if (!info)
    return (write(2, MALLOC_ERR, 21));
  if (!(col = parse_it(info, 3)))
    return (write(2, MALLOC_ERR, 21));
  if (fill_color(mater, col, 0))
    return (1);
  free(info);
  return (0);
}
Пример #5
0
int		get_coord(char *info, t_v3D **coord, t_materiau *mater)
{
  int		*coor;

  if (!info)
    return (write(2, MALLOC_ERR, 21));
  if (!(coor = parse_it(info, 3)))
    return (write(2, MALLOC_ERR, 21));
  if (!(*coord = fill_coord(coor)))
    return (write(2, MALLOC_ERR, 21));
  free(info);
  return (0);
}
Пример #6
0
int parse(char* s, inode* dest){
	int length = strlen(s);
	free (dest);
	if (length <=0)
		return -1;
	else if ( length ==1)
		if(s[0]=='/'){
			dest = (inode*)&(super.root);
			return 0;}
		else
			return -1;
	else {
		return parse_it( s + 1 , dest,super.root);}}
Пример #7
0
Bool TERMWINDOWMEMBER get_next_room(char *here, char *there)
	{
	assert(nodefile);

	char line[95];

	while (fgets(line, 90, nodefile) != NULL)
		{
		if (line[0] != '#')
			{
			continue;
			}

		char *words[256];
		const int count = parse_it(words, line);

		if (SameString(words[0], getnetmsg(37)))
			{
			fclose(nodefile);
			nodefile = NULL;
			return (FALSE);
			}

		if (SameString(words[0], getnetmsg(38)))
			{
			CopyString2Buffer(here, words[1], LABELSIZE);

			if (count > 2)
				{
				CopyString2Buffer(there, words[2], LABELSIZE);
				}
			else
				{
				strcpy(there, here);
				}

			return (TRUE);
			}
		}

	fclose(nodefile);
	nodefile = NULL;
	return (FALSE);
	}
Пример #8
0
int		get_mat(char *info, t_v3D **coord, t_materiau *mater)
{
  int		j;
  int		*mat;

  j = -1;
  if (!info)
    return (write(2, MALLOC_ERR, 21));
  while (++j < 1)
    if (!my_strcmp(info, g_defmat[j].name))
    {
      mater = &(g_defmat[j].materiau);
      return (0);
    }
  if (!(mat = parse_it(info, 5)))
    return (write(2, MALLOC_ERR, 21));
  if (!(mater = fill_mat(mat)))
    return (write(2, MALLOC_ERR, 21));
  free(info);
  return (0);
}
Пример #9
0
void saveNewReality (struct messNode *nodeArray, char *room, int iTopNode)
{
    int   hInFile, hOutFile, i ;
    char  buf[256], originalBuf[256], *words[16], *curnode = NULL ;
    BOOL  shouldBePresent, present ;

    sprintf (buf, "%s\\NODES.CIT", cfg.homepath) ;
    hInFile = sopen (buf, O_TEXT | O_RDONLY, SH_DENYNO) ;

    sprintf (buf, "%s\\NODES.!!!", cfg.homepath) ;
    unlink (buf) ;

    hOutFile = sopen (buf, O_CREAT | O_TEXT | O_WRONLY,
			   SH_DENYNO,
			   S_IREAD | S_IWRITE) ;

    if (-1 == hInFile)
	crashout ("Problem opening NODES.CIT.  Snorp.") ;

    if (-1 == hOutFile)
	crashout ("Problem opening NODES.!!!.  Foom.") ;

    /* When we identify a #NODE, a BOOL tells us whether that #NODE shares */
    /* room.  If not, and the room is found, it's not passed through to    */
    /* the temporary file.  If so, and the roomname ISN'T found before the */
    /* next #NODE, it is ADDED just before the next #NODE (or EOF).        */

    originalBuf[0] = '\0' ;

    while ( !eof(hInFile) )
	{
	/* In every loop, the first thing we do is write the line from the */
	/* PREVIOUS loop around.                                           */

	write (hOutFile, originalBuf, strlen (originalBuf)) ;

	if (!sfgets (buf, 255, hInFile))
	    break ;				    /* Error reading file. */

	strcpy (originalBuf, buf) ;

	if ('#' != buf[0])			    /* It's not a keyword. */
	    continue ;

	parse_it (words, buf) ;

	/* We are only concerned about #NODE and #ROOM.  If we're reading  */
	/* #NODE line, first check whether a #ROOM line needs to be added  */
	/* for the previous node.                                          */

	if (SAMESTRING == stricmp (words[0], "#NODE"))
	    {
	    addRoomIfShould (curnode, shouldBePresent, present,
			     room, hOutFile) ;

	    /* In any event, find the node's memory bro and fill in BOOLs. */

	    for (i = 0; i <= iTopNode; i++)
		if (SAMESTRING == stricmp (nodeArray[i].nodeName, words[1]))
		    break ;

	    if (i > iTopNode)            /* Couldn't find node in memory.  */
		{
		curnode = NULL ;
		continue ;
		}

	    present = FALSE ;
	    shouldBePresent = nodeArray[i].fShared ;
	    curnode = nodeArray[i].nodeName ;
	    }


	/* If present is TRUE, we don't need to worry about parsing the    */
	/* rest of the #ROOMs, but instead will sit around until another   */
	/* #NODE comes along.  But if present is false, is this line the   */
	/* room we're looking for?  And should we remove it?               */

	if (present)
	    continue ;

	if (SAMESTRING == stricmp (words[0], "#ROOM"))
	    if (SAMESTRING == stricmp (words[1], room))
		{
		present = TRUE ;

		/* If we've found it and wished we hadn't, nuke the buffer */
		/* and end, so nothing gets written.                       */

		if (!shouldBePresent)
		    originalBuf[0] = '\0' ;
		}
	}

    /* Now that we're out of the file, we need to call addRoomIfShould     */
    /* once more to add a #ROOM line to the last node in the nodes file,   */
    /* if necessary.  And finally, write the last line of the file	   */

    addRoomIfShould (curnode, shouldBePresent, present, room, hOutFile) ;
    write (hOutFile, originalBuf, strlen (originalBuf)) ;

    close (hInFile) ;

    if (0 == close (hOutFile))     /* SUccessful close.  Rename... */
	{
	sprintf (buf, "%s\\NODES.CIT", cfg.homepath) ;
	sprintf (originalBuf, "%s\\NODES.!!!", cfg.homepath) ;

	unlink (buf) ;
	rename (originalBuf, buf) ;
	}
    else
	cPrintf ("Unable to close NODES.!!!  Spork.") ;
}
Пример #10
0
Bool ReadNodesCit(NodesCitC **newNode, const char *NameOrAddrToFind, ModemConsoleE W, Bool option)
#endif
    {
    FILE *fBuf;
    char *words[256];
    int i;
    char path[80];
    int count;
    uint lineno = 0;
    l_slot logslot;

    if (!read_node_ddata())
        {
        TWwPrintf(W, getmsg(59));
        return (FALSE);
        }

    const char **nodekeywords = (const char **) nddd->aux;
    const char **nettypes = (const char **) nddd->next->aux;
    const char **nodemsgs = (const char **) nddd->next->next->aux;

    label NameToFind;
    CopyStringToBuffer(NameToFind, NameOrAddrToFind);

    if (SameString(NameOrAddrToFind, getnodemsg(2)))
        {
        // if default, start fresh
        if (!clearNode(newNode))
            {
            dump_node_ddata();
            return (FALSE);
            }
        }
    else
        {
        // else first read in default
#ifdef WINCIT
        ReadNodesCit(TW, newNode, getnodemsg(2), W, FALSE);
#else
        ReadNodesCit(newNode, getnodemsg(2), W, FALSE);
#endif

        if (*newNode)
            {
#ifdef WINCIT
            logslot = nodexists(NameOrAddrToFind, TW ? TW->LogOrder : NULL);
#else
            logslot = nodexists(NameOrAddrToFind);
#endif

            if (logslot == CERROR)
                {
                TWwDoCR(W);
                TWwPrintf(W, getnodemsg(3), NameOrAddrToFind);

                if (strlen(NameOrAddrToFind) < 4)
                    {
                    char temp[4];

                    CopyStringToBuffer(temp, NameOrAddrToFind);
                    strlwr(temp);
                    TWwPrintf(W, getnodemsg(4), temp, cfg.locID);
                    }

                dump_node_ddata();
                return (FALSE);
                }

            label Alias, LocID;

#ifdef WINCIT
            if (!*LogTab[TW ? TW->LogOrder[logslot] : logslot].GetAlias(Alias, sizeof(Alias)) ||
                    !*LogTab[TW ? TW->LogOrder[logslot] : logslot].GetLocID(LocID, sizeof(LocID)))
#else
            if (!*LTab(logslot).GetAlias(Alias, sizeof(Alias)) || !*LTab(logslot).GetLocID(LocID, sizeof(LocID)))
#endif
                {
                TWwDoCR(W);
                TWwPrintf(W, getnodemsg(5), NameOrAddrToFind);

                dump_node_ddata();
                return (FALSE);
                }

            (*newNode)->SetAlias(Alias);
            (*newNode)->SetLocID(LocID);

            label FileName;
            sprintf(FileName, getnodemsg(6), (*newNode)->GetAlias());
            (*newNode)->SetMailFileName(FileName);

            // Make sure NameToFind is a name, not address.
#ifdef WINCIT
            LogTab[TW ? TW->LogOrder[logslot] : logslot].GetName(NameToFind, sizeof(NameToFind));
#else
            LTab(logslot).GetName(NameToFind, sizeof(NameToFind));
#endif

            // Support for optional nodes.cit entries.
            (*newNode)->SetName(NameToFind);
            }
        }

    if (!*newNode)
        {
        cOutOfMemory(44);
        dump_node_ddata();
        return (FALSE);
        }

    compactMemory();

    sprintf(path, sbs, cfg.homepath, getnodemsg(8));

    if ((fBuf = fopen(path, FO_R)) == NULL) // ASCII mode
        {
        TWdoccr();
        TWcPrintf(getmsg(15), getnodemsg(8));
        TWdoccr();

        dump_node_ddata();
        return (option);
        }

    char line[256];
    Bool FoundOurEntry = FALSE;
    long pos = ftell(fBuf);
    while (fgets(line, 254, fBuf) != NULL)
        {
        lineno++;

        if (line[0] != '#')
            {
            pos = ftell(fBuf);
            continue;
            }

        // Don't read anything until we found our entry, except possible beginnings of our entry. (#NODE...)
        if (!FoundOurEntry && strnicmp(line + 1, nodekeywords[NOK_NODE], strlen(nodekeywords[NOK_NODE])) != SAMESTRING)
            {
            pos = ftell(fBuf);
            continue;
            }

        // Save a copy of the line in case this is the #LOGIN macro: parse_it
        // changes what is passed to it.
        char ltmp[256];
        CopyStringToBuffer(ltmp, line);

        count = parse_it(words, line);

        // Look up our first word in table of keywords.
        for (i = 0; i < NOK_NUM; i++)
            {
            if (SameString(words[0] + 1, nodekeywords[i]))
                {                   //^ add one for '#'
                break;
                }
            }

        if (i < NOK_NUM && !words[1][0])    // valid keywords need a param
            {
            TWcPrintf(getnodemsg(9), getnodemsg(8), ltoac(lineno), nodekeywords[i], ns);
            TWdoccr();
            continue;
            }

        if (i == NOK_NODE)
            {
            // This is a #NODE line... if we have alread found our entry,
            // then this is the start of the next one, and we are done.
            if (FoundOurEntry)
                {
                fclose(fBuf);
                dump_node_ddata();
                return (TRUE);
                }

            // This is a #NODE line... if it is for us, then we have now
            // found our entry. If not, then we continue looking.
            if (SameString(NameToFind, words[1]))
                {
                FoundOurEntry = TRUE;
                }
            else
                {
                pos = ftell(fBuf);
                continue;
                }
            }

        switch (i)
            {
            case NOK_BAUD:
                {
                PortSpeedE PS = digitbaud(atol(words[1]));

                if (PS == PS_ERROR)
                    {
                    TWcPrintf(getnodemsg(9), getnodemsg(8), ltoac(lineno), nodekeywords[i], words[1]);
                    TWdoccr();
                    }
                else
                    {
                    (*newNode)->SetBaud(PS);
                    }

                break;
                }

            case NOK_DIALOUT:
            case NOK_PHONE:
                {
                (*newNode)->SetDialOut(words[1]);

                if (strlen(words[1]) > 49)
                    {
                    TWcPrintf(getnodemsg(1), getnodemsg(8), ltoac(lineno), nodekeywords[i], 50);
                    TWdoccr();
                    }

                break;
                }

            case NOK_PREDIAL:
                {
                (*newNode)->SetPreDial(words[1]);

                if (strlen(words[1]) > 63)
                    {
                    TWcPrintf(getnodemsg(1), getnodemsg(8), ltoac(lineno), nodekeywords[i], 64);
                    TWdoccr();
                    }

                break;
                }

            case NOK_FETCH_TIMEOUT:
                {
                (*newNode)->SetFetchTimeout(atoi(words[1]));
                break;
                }

            case NOK_ZIP:
                {
                if (!words[2][0])   // need second param
                    {
                    TWcPrintf(getnodemsg(9), getnodemsg(8), ltoac(lineno), nodekeywords[i], ns);
                    TWdoccr();
                    continue;
                    }
                else
                    {
                    (*newNode)->SetCreatePacket(words[1]);

                    if (strlen(words[1]) > 39)
                        {
                        TWcPrintf(getnodemsg(1), getnodemsg(8), ltoac(lineno), nodekeywords[i], 40);
                        TWdoccr();
                        }

                    (*newNode)->SetExtractPacket(words[2]);

                    if (strlen(words[2]) > 39)
                        {
                        TWcPrintf(getnodemsg(1), getnodemsg(8), ltoac(lineno), nodekeywords[i], 40);
                        TWdoccr();
                        }
                    }

                break;
                }

            case NOK_NETWORK:
                {
                (*newNode)->SetNetworkRevisionNumber(0);

                NETTYPES j;
                for (j = (NETTYPES) 0; j < NET_NUM; j = (NETTYPES) (j + 1))
                    {
                    if (SameString(words[1], nettypes[j]))
                        {
                        break;
                        }
                    }

                if (j == NET_DCIT11)
                    {
                    j = NET_DCIT10;
                    }

                if (j == NET_6_9a)
                    {
                    (*newNode)->SetNetworkRevisionNumber(1);
                    j = NET_6_9;
                    }

                if (j == NET_NUM)
                    {
                    TWcPrintf(getnodemsg(9), getnodemsg(8), ltoac(lineno), nodekeywords[i], words[1]);
                    TWdoccr();
                    }
                else
                    {
                    (*newNode)->SetNetworkType(j);
                    }

                break;
                }

            case NOK_PROTOCOL:
                {
                (*newNode)->SetProtocol(words[1][0]);
                break;
                }

            case NOK_AUTOHALL:
                {
                (*newNode)->SetAutoHall(hallexists(words[1]));

                if (strlen(words[1]) > LABELSIZE)
                    {
                    TWcPrintf(getnodemsg(1), getnodemsg(8), ltoac(lineno), nodekeywords[i], LABELSIZE + 1);
                    TWdoccr();
                    }

                break;
                }

            case NOK_AUTOGROUP:
                {
                (*newNode)->SetAutoGroup(FindGroupByName(words[1]));

                if (strlen(words[1]) > LABELSIZE)
                    {
                    TWcPrintf(getnodemsg(1), getnodemsg(8), ltoac(lineno), nodekeywords[i], LABELSIZE + 1);
                    TWdoccr();
                    }

                break;
                }

            case NOK_MAPUNKGROUP:
                {
                g_slot GroupSlot = FindGroupByName(words[1]);

                if (GroupSlot == CERROR)
                    {
                    GroupSlot = SPECIALSECURITY;
                    }

                (*newNode)->SetMapUnknownGroup(GroupSlot);

                if (strlen(words[1]) > LABELSIZE)
                    {
                    TWcPrintf(getnodemsg(1), getnodemsg(8), ltoac(lineno), nodekeywords[i], LABELSIZE + 1);
                    TWdoccr();
                    }

                break;
                }

            case NOK_LOGIN:
                {
                (*newNode)->SetLoginMacro(ltmp + strlen(nodekeywords[NOK_LOGIN]) + 1);
                break;
                }

            case NOK_NODE:
                {
                // A bit silly.
                (*newNode)->SetName(words[1]);

                if (strlen(words[1]) > LABELSIZE)
                    {
                    TWcPrintf(getnodemsg(1), getnodemsg(8), ltoac(lineno), nodekeywords[i], LABELSIZE + 1);
                    TWdoccr();
                    }

                if (count > 2)
                    {
                    (*newNode)->SetOldRegion(words[2]);

                    if (strlen(words[2]) > LABELSIZE)
                        {
                        TWcPrintf(getnodemsg(1), getnodemsg(8), ltoac(lineno), nodekeywords[i], LABELSIZE + 1);
                        TWdoccr();
                        }
                    }
                else
                    {
                    (*newNode)->SetOldRegion(ns);
                    }

                (*newNode)->FreeMappedGroups();
                (*newNode)->SetRoomOffset(0);

                break;
                }

            case NOK_DIAL_TIMEOUT:
                {
                (*newNode)->SetDialTimeout(atoi(words[1]));
                break;
                }

            case NOK_REQUEST:
                {
                (*newNode)->SetRequest(atoi(words[1]));
                break;
                }

            case NOK_WAIT_TIMEOUT:
                {
                (*newNode)->SetWaitTimeout(atoi(words[1]));
                break;
                }

            case NOK_AUTOROOM:
                {
                (*newNode)->SetAutoRoom(atoi(words[1]));
                break;
                }

            case NOK_VERBOSE:
                {
                (*newNode)->SetDefaultVerbose();

                const char **verbosekeywords = (const char **) nddd->next->next->next->aux;

                for (int j = 1; j < count; j++)
                    {
                    if (SameString(words[j], getnodemsg(39)))
                        {
                        (*newNode)->SetDefaultVerbose();
                        }
                    else if (SameString(words[j], getnodemsg(40)))
                        {
                        (*newNode)->SetDefaultVerbose();
                        (*newNode)->SetVerbose(NCV_FILE69INFULL, TRUE);
                        (*newNode)->SetVerbose(NCV_NOACCESS, TRUE);
                        }
                    else if (SameString(words[j], getnodemsg(41)))
                        {
                        (*newNode)->SetDefaultVerbose();
                        (*newNode)->SetVerbose(NCV_FILE69INFULL, TRUE);
                        (*newNode)->SetVerbose(NCV_NOACCESS, TRUE);
                        (*newNode)->SetVerbose(NCV_ROOMCREATED, TRUE);
                        (*newNode)->SetVerbose(NCV_ROOMNOTCREATED, TRUE);
                        (*newNode)->SetVerbose(NCV_NETIDNOTFOUND, TRUE);
                        (*newNode)->SetVerbose(NCV_NONETIDONSYSTEM, TRUE);
                        }
                    else
                        {
                        const char *Keyword;
                        Bool NewSetting;

                        if (words[j][0] == '!')
                            {
                            Keyword = words[j] + 1;
                            NewSetting = FALSE;
                            }
                        else
                            {
                            Keyword = words[j];
                            NewSetting = TRUE;
                            }

                        NCV_Type TestType;

                        for (TestType = (NCV_Type) 0; TestType < NCV_MAX; TestType = (NCV_Type) (TestType + 1))
                            {
                            if (SameString(Keyword, verbosekeywords[TestType]))
                                {
                                (*newNode)->SetVerbose(TestType, NewSetting);
                                break;
                                }
                            }

                        if (TestType == NCV_MAX)
                            {
                            if (SameString(Keyword, getnodemsg(13)))
                                {
                                // ALL
                                for (TestType = (NCV_Type) 0; TestType < NCV_MAX; TestType = (NCV_Type) (TestType + 1))
                                    {
                                    (*newNode)->SetVerbose(TestType, NewSetting);
                                    }
                                }
                            else
                                {
                                TWcPrintf(getnodemsg(12), getnodemsg(8), ltoac(lineno), words[0], Keyword);
                                TWdoccr();
                                }
                            }
                        }
                    }

                break;
                }

            case NOK_CHAT:
                {
                (*newNode)->SetDefaultChat();

                const char **chatkeywords = (const char **) nddd->next->next->next->next->aux;

                for (int j = 1; j < count; j++)
                    {
                    const char *Keyword;
                    Bool NewSetting;

                    if (words[j][0] == '!')
                        {
                        Keyword = words[j] + 1;
                        NewSetting = FALSE;
                        }
                    else
                        {
                        Keyword = words[j];
                        NewSetting = TRUE;
                        }

                    NCC_Type TestType;

                    for (TestType = (NCC_Type) 0; TestType < NCC_MAX; TestType = (NCC_Type) (TestType + 1))
                        {
                        if (SameString(Keyword, chatkeywords[TestType]))
                            {
                            (*newNode)->SetChat(TestType, NewSetting);
                            break;
                            }
                        }

                    if (TestType == NCV_MAX)
                        {
                        if (SameString(Keyword, getnodemsg(13)))
                            {
                            // ALL
                            for (TestType = (NCC_Type) 0; TestType < NCC_MAX; TestType = (NCC_Type) (TestType + 1))
                                {
                                (*newNode)->SetChat(TestType, NewSetting);
                                }
                            }
                        else
                            {
                            TWcPrintf(getnodemsg(12), getnodemsg(8), ltoac(lineno), words[0], Keyword);
                            TWdoccr();
                            }
                        }
                    }

                break;
                }

            case NOK_REDIAL:
                {
                (*newNode)->SetRedial(atoi(words[1]));
                break;
                }

            case NOK_ROOM:
                {
                (*newNode)->SetRoomOffset(pos);
                fclose(fBuf);
                dump_node_ddata();
                return (TRUE);
                }

            case NOK_GROUP:
                {
                if (!(*newNode)->AddMappedGroups(words[1], words[2]))
                    {
                    TWcPrintf(getnodemsg(10), words[1]);
                    TWdoccr();
                    }

                if (strlen(words[1]) > LABELSIZE)
                    {
                    TWcPrintf(getnodemsg(1), getnodemsg(8), ltoac(lineno), nodekeywords[i], LABELSIZE + 1);
                    TWdoccr();
                    }

                if (strlen(words[2]) > LABELSIZE)
                    {
                    TWcPrintf(getnodemsg(1), getnodemsg(8), ltoac(lineno), nodekeywords[i], LABELSIZE + 1);
                    TWdoccr();
                    }

                break;
                }

            case NOK_GATEWAY:
                {
                (*newNode)->SetGateway(atoi(words[1]));
                break;
                }

            case NOK_FETCH:
                {
                (*newNode)->SetFetch(atoi(words[1]));
                break;
                }

            case NOK_NETFAIL:
                {
                (*newNode)->SetNetFail(atoi(words[1]));
                break;
                }

            case NOK_OUTPUTPACE:
                {
                (*newNode)->SetOutputPace(atoi(words[1]));
                break;
                }

            case NOK_IPADDRESS:
                {
#ifdef WINCIT
                (*newNode)->SetIpAddress(words[1]);

                if (strlen(words[1]) > 255)
                    {
                    TWcPrintf(getnodemsg(1), getnodemsg(8), ltoac(lineno), nodekeywords[i], 256);
                    TWdoccr();
                    }
#endif
                break;
                }

            case NOK_IPPORT:
                {
#ifdef WINCIT
                (*newNode)->SetIpPort(atoi(words[1]));
#endif
                break;
                }

            default:
                {
                TWcPrintf(getnodemsg(11), getnodemsg(8), ltoac(lineno), words[0]);
                TWdoccr();

                break;
                }
            }

        pos = ftell(fBuf);
        }

    fclose(fBuf);

    if (!FoundOurEntry && !option && debug)
        {
        TWwDoCR(W);
        TWwPrintf(W, getmsg(206), NameOrAddrToFind);
        TWwDoCR(W);
        }

    dump_node_ddata();

    if (option)
        {
        return (TRUE);
        }
    else
        {
        return (FoundOurEntry);
        }
    }
Пример #11
0
/**
	@brief Parse a JSON string, with no decoding of classname hints.
	@param s Pointer to the JSON string to parse.
	@return A pointer to the resulting JSON object, or NULL on error.

	This function is similar to jsonParse(), except that it does not give any special
	treatment to a JSON_HASH with the JSON_CLASS_KEY tag.

	The calling code is responsible for freeing the resulting jsonObject.
*/
jsonObject* jsonParseRaw( const char* s ) {
	return parse_it( s, 0 );
}
Пример #12
0
/**
	@brief Parse a JSON string, with decoding of classname hints.
	@param str Pointer to the JSON string to parse.
	@return A pointer to the resulting JSON object, or NULL on error.

	If any node in the jsonObject tree is of type JSON_HASH, with a tag of JSON_CLASS_KEY
	and another tag of JSON_DATA_KEY, the parser will collapse a level.  The subobject
	tagged with JSON_DATA_KEY will replace the JSON_HASH, and the string tagged as
	JSON_CLASS_KEY will be stored as its classname.  If there is no tag of JSON_DATA_KEY,
	the hash will be replaced by a jsonObject of type JSON_NULL.

	The calling code is responsible for freeing the resulting jsonObject.
*/
jsonObject* jsonParse( const char* str ) {
	return parse_it( str, 1 );
}
Пример #13
0
/**
	@brief Parse a JSON string received as a printf-style format string.
	@param str A printf-style format string.  Subsequent arguments, if any, are formatted
		and inserted into the JSON string before parsing.
	@return A pointer to the resulting JSON object, or NULL on error.

	Unlike jsonParse(), this function does not give any special treatment to a JSON_HASH
	with tags JSON_CLASS_KEY or JSON_DATA_KEY.

	The calling code is responsible for freeing the resulting jsonObject.
*/
jsonObject* jsonParseFmt( const char* str, ... ) {
	if( !str )
		return NULL;
	VA_LIST_TO_STRING( str );
	return parse_it( VA_BUF, 0 );
}
Пример #14
0
void TERMWINDOWMEMBER setdefaultconfig(Bool KeepTerm)
    {
    int oldATT[ATTR_NUM];

    oldATT[ATTR_NORMAL]     = CurrentUser->GetAttribute(ATTR_NORMAL);
    oldATT[ATTR_BLINK]      = CurrentUser->GetAttribute(ATTR_BLINK);
    oldATT[ATTR_REVERSE]    = CurrentUser->GetAttribute(ATTR_REVERSE);
    oldATT[ATTR_BOLD]       = CurrentUser->GetAttribute(ATTR_BOLD);
    oldATT[ATTR_UNDERLINE]  = CurrentUser->GetAttribute(ATTR_UNDERLINE);

    prevChar = ' '; // why here?

    CurrentUser->Clear();

    // set all default defaults...
    CurrentUser->SetWidth(80);
    CurrentUser->SetCredits(3600);

    CurrentUser->SetLinefeeds(TRUE);
    CurrentUser->SetOldToo(TRUE);
    CurrentUser->SetNetUser(TRUE);
    CurrentUser->SetViewRoomDesc(TRUE);
    CurrentUser->SetEnterBorders(TRUE);
    CurrentUser->SetViewTitleSurname(TRUE);
    CurrentUser->SetViewSubjects(TRUE);
    CurrentUser->SetViewSignatures(TRUE);
    CurrentUser->SetMinibin(TRUE);
    CurrentUser->SetViewRoomInfoLines(TRUE);
    CurrentUser->SetViewHallDescription(TRUE);
    CurrentUser->SetViewBorders(TRUE);
    CurrentUser->SetSeeOwnChats(TRUE);
    CurrentUser->SetHearLaughter(TRUE);

    if (!KeepTerm)
        {
        CurrentUser->SetDefaultColors(TermCap->IsColor());
        }
    else
        {
        CurrentUser->SetAttribute(ATTR_NORMAL,      oldATT[ATTR_NORMAL]);
        CurrentUser->SetAttribute(ATTR_BLINK,       oldATT[ATTR_BLINK]);
        CurrentUser->SetAttribute(ATTR_REVERSE,     oldATT[ATTR_REVERSE]);
        CurrentUser->SetAttribute(ATTR_BOLD,        oldATT[ATTR_BOLD]);
        CurrentUser->SetAttribute(ATTR_UNDERLINE,   oldATT[ATTR_UNDERLINE]);
        }

    CurrentUser->SetPromptFormat(cfg.prompt);           // "%n^A2%r%e"
    CurrentUser->SetDateStamp(cfg.datestamp);           // "%x %X %p"
    CurrentUser->SetVerboseDateStamp(cfg.vdatestamp);   // "%A %x %X %p"
    CurrentUser->SetNetPrefix(cfg.netPrefix);           // "3*0"
    CurrentUser->SetMorePrompt(cfg.moreprompt);         // "<more>"

    if (!KeepTerm)
        {
        setdefaultTerm(TT_DUMB);
        }

    if (cfg.accounting)
        {
        CurrentUserAccount->Negotiate(CurrentUser);
        }

    changedir(cfg.homepath);

    discardable *du = readData(8, 0, 0);

    if (du)
        {
        FILE *defusr;
        if ((defusr = fopen(citfiles[C_DEFUSER_CIT], FO_R)) != NULL)
            {
            const char **duk = (const char **) du->aux;
            char line[90];
            char *words[256];

            while (fgets(line, 90, defusr) != NULL)
                {
                if (line[0] != '#')
                    {
                    continue;
                    }

                const int count = parse_it(words, line);

                if (count > 1)
                    {
                    int i;
                    for (i = 0; i < DUK_NUM; i++)
                        {
                        if (SameString(words[0] + 1, duk[i]))
                            {
                            break;
                            }
                        }

                    switch (i)
                        {
                        case DUK_FORWARD:
                            {
                            CurrentUser->SetForwardAddr(words[1]);
                            break;
                            }

                        case DUK_SURNAME:
                            {
                            CurrentUser->SetSurname(words[1]);
                            break;
                            }

                        case DUK_TITLE:
                            {
                            CurrentUser->SetTitle(words[1]);
                            break;
                            }

                        case DUK_BOLD:
                            {
                            CurrentUser->SetAttribute(ATTR_BOLD, atoi(words[1]));
                            break;
                            }

                        case DUK_NULLS:
                            {
                            CurrentUser->SetNulls(atoi(words[1]));
                            break;
                            }

                        case DUK_WIDTH:
                            {
                            CurrentUser->SetWidth(atoi(words[1]));
                            break;
                            }

                        case DUK_CREDITS:
                            {
                            CurrentUser->SetCredits(60 * atol(words[1]));
                            break;
                            }

                        case DUK_INVERSE:
                            {
                            CurrentUser->SetAttribute(ATTR_REVERSE, atoi(words[1]));
                            break;
                            }

                        case DUK_BLINK:
                            {
                            CurrentUser->SetAttribute(ATTR_BLINK, atoi(words[1]));
                            break;
                            }

                        case DUK_UNDERLINE:
                            {
                            CurrentUser->SetAttribute(ATTR_UNDERLINE, atoi(words[1]));
                            break;
                            }

                        case DUK_NORMAL:
                            {
                            CurrentUser->SetAttribute(ATTR_NORMAL, atoi(words[1]));
                            break;
                            }

                        case DUK_PROTOCOL:
                            {
                            CurrentUser->SetDefaultProtocol(words[1][0]);
                            break;
                            }

                        case DUK_PROMPT:
                            {
                            CurrentUser->SetPromptFormat(words[1]);
                            break;
                            }

                        case DUK_DSTAMP:
                            {
                            CurrentUser->SetDateStamp(words[1]);
                            break;
                            }

                        case DUK_VDSTAMP:
                            {
                            CurrentUser->SetVerboseDateStamp(words[1]);
                            break;
                            }

                        case DUK_SIGNATURE:
                            {
                            CurrentUser->SetSignature(words[1]);
                            break;
                            }

                        case DUK_NETPREFIX:
                            {
                            CurrentUser->SetNetPrefix(words[1]);
                            break;
                            }

                        case DUK_ADDR1:
                            {
                            CurrentUser->SetMailAddr1(words[1]);
                            break;
                            }

                        case DUK_ADDR2:
                            {
                            CurrentUser->SetMailAddr2(words[1]);
                            break;
                            }

                        case DUK_ADDR3:
                            {
                            CurrentUser->SetMailAddr3(words[1]);
                            break;
                            }

                        case DUK_POOP:
                            {
                            CurrentUser->SetPoopcount(atol(words[1]));
                            break;
                            }

                        case DUK_UCMASK:
                            {
                            CurrentUser->SetUpperOnly(atoi(words[1]));
                            break;
                            }

                        case DUK_EXPERT:
                            {
                            CurrentUser->SetExpert(atoi(words[1]));
                            break;
                            }

                        case DUK_AIDE:
                            {
                            CurrentUser->SetAide(atoi(words[1]));
                            break;
                            }

                        case DUK_TABS:
                            {
                            CurrentUser->SetTabs(atoi(words[1]));
                            break;
                            }

                        case DUK_OLDTOO:
                            {
                            CurrentUser->SetOldToo(atoi(words[1]));
                            break;
                            }

                        case DUK_UNLISTED:
                            {
                            CurrentUser->SetUnlisted(atoi(words[1]));
                            break;
                            }

                        case DUK_PERMANENT:
                            {
                            CurrentUser->SetPermanent(atoi(words[1]));
                            break;
                            }

                        case DUK_SYSOP:
                            {
                            CurrentUser->SetSysop(atoi(words[1]));
                            break;
                            }

                        case DUK_NODE:
                            {
                            CurrentUser->SetNode(atoi(words[1]));
                            break;
                            }

                        case DUK_NOACCOUNT:
                            {
                            CurrentUser->SetAccounting(!atoi(words[1]));
                            break;
                            }

                        case DUK_NOMAIL:
                            {
                            CurrentUser->SetMail(!atoi(words[1]));
                            break;
                            }

                        case DUK_ROOMTELL:
                            {
                            CurrentUser->SetViewRoomDesc(atoi(words[1]));
                            break;
                            }

                        case DUK_BORDERS:
                            {
                            CurrentUser->SetEnterBorders(atoi(words[1]));
                            break;
                            }

                        case DUK_VERIFIED:
                            {
                            CurrentUser->SetVerified(!!atoi(words[1]));
                            break;
                            }

                        case DUK_SURNAMLOK:
                            {
                            CurrentUser->SetSurnameLocked(atoi(words[1]));
                            break;
                            }

                        case DUK_LOCKHALL:
                            {
                            CurrentUser->SetDefaultHallLocked(atoi(words[1]));
                            break;
                            }

                        case DUK_DISPLAYTS:
                            {
                            CurrentUser->SetViewTitleSurname(atoi(words[1]));
                            break;
                            }

                        case DUK_SUBJECTS:
                            {
                            CurrentUser->SetViewSubjects(atoi(words[1]));
                            break;
                            }

                        case DUK_SIGNATURES:
                            {
                            CurrentUser->SetViewSignatures(atoi(words[1]));
                            break;
                            }

                        case DUK_DEFAULTHALL:
                            {
                            CurrentUser->SetDefaultHall(words[1]);
                            break;
                            }

                        case DUK_LINESSCREEN:
                            {
                            CurrentUser->SetLinesPerScreen(atoi(words[1]));
                            break;
                            }

                        case DUK_FORWARDNODE:
                            {
                            CurrentUser->SetForwardAddrNode(words[1]);

                            if (*words[1])
                                {
                                CurrentUser->SetForwardToNode(TRUE);
                                }

                            break;
                            }

                        case DUK_LFMASK:
                            {
                            CurrentUser->SetLinefeeds(atoi(words[1]));
                            break;
                            }

                        case DUK_PROBLEM:
                            {
                            CurrentUser->SetProblem(atoi(words[1]));
                            break;
                            }

                        case DUK_NETUSER:
                            {
                            CurrentUser->SetNetUser(atoi(words[1]));
                            break;
                            }

                        case DUK_NEXTHALL:
                            {
                            CurrentUser->SetAutoNextHall(atoi(words[1]));
                            break;
                            }

                        case DUK_PSYCHO:
                            {
                            CurrentUser->SetPsycho(atoi(words[1]));
                            break;
                            }

                        case DUK_TWIRLY:
                            {
                            CurrentUser->SetTwirly(atoi(words[1]));
                            break;
                            }

                        case DUK_VERBOSE:
                            {
                            CurrentUser->SetAutoVerbose(atoi(words[1]));
                            break;
                            }

                        case DUK_MSGPAUSE:
                            {
                            CurrentUser->SetPauseBetweenMessages(atoi(words[1]));
                            break;
                            }

                        case DUK_MINIBIN:
                            {
                            CurrentUser->SetMinibin(atoi(words[1]));
                            break;
                            }

                        case DUK_MSGCLS:
                            {
                            CurrentUser->SetClearScreenBetweenMessages(atoi(words[1]));
                            break;
                            }

                        case DUK_ROOMINFO:
                            {
                            CurrentUser->SetViewRoomInfoLines(atoi(words[1]));
                            break;
                            }

                        case DUK_HALLTELL:
                            {
                            CurrentUser->SetViewHallDescription(atoi(words[1]));
                            break;
                            }

                        case DUK_VERBOSECONT:
                            {
                            CurrentUser->SetVerboseContinue(atoi(words[1]));
                            break;
                            }

                        case DUK_VIEWCENSOR:
                            {
                            CurrentUser->SetViewCensoredMessages(atoi(words[1]));
                            break;
                            }

                        case DUK_SEEBORDERS:
                            {
                            CurrentUser->SetViewBorders(atoi(words[1]));
                            break;
                            }

                        case DUK_OUT300:
                            {
                            CurrentUser->SetOut300(atoi(words[1]));
                            break;
                            }

                        case DUK_LOCKUSIG:
                            {
                            CurrentUser->SetUserSignatureLocked(atoi(words[1]));
                            break;
                            }

                        case DUK_HIDEEXCL:
                            {
                            CurrentUser->SetHideMessageExclusions(atoi(words[1]));
                            break;
                            }

                        case DUK_NODOWNLOAD:
                            {
                            CurrentUser->SetDownload(!atoi(words[1]));
                            break;
                            }

                        case DUK_NOUPLOAD:
                            {
                            CurrentUser->SetUpload(!atoi(words[1]));
                            break;
                            }

                        case DUK_NOCHAT:
                            {
                            CurrentUser->SetChat(!atoi(words[1]));
                            break;
                            }

                        case DUK_PRINTFILE:
                            {
                            CurrentUser->SetPrintFile(atoi(words[1]));
                            break;
                            }

                        case DUK_REALNAME:
                            {
                            CurrentUser->SetRealName(words[1]);
                            break;
                            }

                        case DUK_PHONENUM:
                            {
                            CurrentUser->SetPhoneNumber(words[1]);
                            break;
                            }

                        case DUK_SPELLCHECK:
                            {
                            CurrentUser->SetSpellCheckMode(atoi(words[1]));
                            break;
                            }

                        case DUK_NOMAKEROOM:
                            {
                            CurrentUser->SetMakeRoom(!atoi(words[1]));
                            break;
                            }

                        case DUK_VERBOSELO:
                            {
                            CurrentUser->SetVerboseLogOut(atoi(words[1]));
                            break;
                            }

                        case DUK_CONFSAVE:
                            {
                            CurrentUser->SetConfirmSave(atoi(words[1]));
                            break;
                            }

                        case DUK_CONFABORT:
                            {
                            CurrentUser->SetConfirmAbort(atoi(words[1]));
                            break;
                            }

                        case DUK_CONFEOABORT:
                            {
                            CurrentUser->SetConfirmNoEO(atoi(words[1]));
                            break;
                            }

                        case DUK_USEPERSONAL:
                            {
                            CurrentUser->SetUsePersonalHall(atoi(words[1]));
                            break;
                            }

                        case DUK_YOUAREHERE:
                            {
                            CurrentUser->SetYouAreHere(atoi(words[1]));
                            break;
                            }

                        case DUK_IBMROOM:
                            {
                            CurrentUser->SetIBMRoom(atoi(words[1]));
                            break;
                            }

                        case DUK_WIDEROOM:
                            {
                            CurrentUser->SetWideRoom(atoi(words[1]));
                            break;
                            }

                        case DUK_MUSIC:
                            {
                            CurrentUser->SetMusic(atoi(words[1]));
                            break;
                            }

                        case DUK_MOREPROMPT:
                            {
                            CurrentUser->SetMorePrompt(words[1]);
                            break;
                            }

                        case DUK_NUMUSERSHOW:
                            {
                            CurrentUser->SetNumUserShow(atoi(words[1]));
                            break;
                            }

                        case DUK_CALLLIMIT:
                            {
                            CurrentUser->SetCallLimit(atoi(words[1]));
                            break;
                            }

                        case DUK_CHECKAPS:
                            {
                            CurrentUser->SetCheckApostropheS(atoi(words[1]));
                            break;
                            }

                        case DUK_CHECKALLCAPS:
                            {
                            CurrentUser->SetCheckAllCaps(atoi(words[1]));
                            break;
                            }

                        case DUK_CHECKDIGITS:
                            {
                            CurrentUser->SetCheckDigits(atoi(words[1]));
                            break;
                            }

                        case DUK_EXCLUDEENCRYPTED:
                            {
                            CurrentUser->SetExcludeEncryptedMessages(atoi(words[1]));
                            break;
                            }

                        case DUK_SHOWCOMMAS:
                            {
                            CurrentUser->SetViewCommas(atoi(words[1]));
                            break;
                            }

                        case DUK_PUNPAUSES:
                            {
                            CurrentUser->SetPUnPauses(atoi(words[1]));
                            break;
                            }

                        case DUK_KUSER:
                            {
                            CurrentUser->AddKill(KF_USER, words[1]);
                            break;
                            }

                        case DUK_KTEXT:
                            {
                            CurrentUser->AddKill(KF_TEXT, words[1]);
                            break;
                            }

                        case DUK_KNODE:
                            {
                            CurrentUser->AddKill(KF_NODE, words[1]);
                            break;
                            }

                        case DUK_KREG:
                            {
                            CurrentUser->AddKill(KF_REGION, words[1]);
                            break;
                            }

                        case DUK_TUSER:
                            {
                            if (count > 2)
                                {
                                CurrentUser->AddTagUser(words[1], words[2]);
                                }

                            break;
                            }

                        case DUK_DICTWORD:
                            {
                            CurrentUser->AddWordToDictionary(words[1]);
                            break;
                            }

                        case DUK_FINGER:
                            {
                            CurrentUser->SetFinger(words[1]);
                            break;
                            }

                        case DUK_USERDEF:
                            {
                            if (count > 2)
                                {
                                CurrentUser->SetUserDefined(words[1], words[2]);
                                }

                            break;
                            }

                        case DUK_REPLACE:
                            {
                            if (count > 2)
                                {
                                CurrentUser->AddReplace(words[1], words[2]);
                                }

                            break;
                            }

                        case DUK_ROMAN:
                            {
                            CurrentUser->SetRoman(atoi(words[1]));
                            break;
                            }

                        case DUK_SUPERSYSOP:
                            {
                            CurrentUser->SetSuperSysop(atoi(words[1]));
                            break;
                            }

                        case DUK_BUNNY:
                            {
                            CurrentUser->SetBunny(atoi(words[1]));
                            break;
                            }

                        case DUK_SSE_LOGONOFF:
                            {
                            CurrentUser->SetSELogOnOff(atoi(words[1]));
                            break;
                            }

                        case DUK_SSE_NEWMSG:
                            {
                            CurrentUser->SetSENewMessage(atoi(words[1]));
                            break;
                            }

                        case DUK_SSE_EXCLMSG:
                            {
                            CurrentUser->SetSEExclusiveMessage(atoi(words[1]));
                            break;
                            }

                        case DUK_SSE_CHATALL:
                            {
                            CurrentUser->SetSEChatAll(atoi(words[1]));
                            break;
                            }

                        case DUK_SSE_CHATROOM:
                            {
                            CurrentUser->SetSEChatRoom(atoi(words[1]));
                            break;
                            }

                        case DUK_SSE_CHATGROUP:
                            {
                            CurrentUser->SetSEChatGroup(atoi(words[1]));
                            break;
                            }

                        case DUK_SSE_CHATUSER:
                            {
                            CurrentUser->SetSEChatUser(atoi(words[1]));
                            break;
                            }

                        case DUK_SSE_RMINOUT:
                            {
                            CurrentUser->SetSERoomInOut(atoi(words[1]));
                            break;
                            }

                        case DUK_TERMTYPE:
                            {
                            CurrentUser->SetTermType(words[1]);
                            TermCap->Load(words[1]);
                            break;
                            }

                        case DUK_BANNED:
                            {
                            CurrentUser->SetBanned(atoi(words[1]));
                            break;
                            }

                        case DUK_KILLOWN:
                            {
                            CurrentUser->SetKillOwn(atoi(words[1]));
                            break;
                            }

                        case DUK_SEEOWNCHATS:
                            {
                            CurrentUser->SetSeeOwnChats(atoi(words[1]));
                            break;
                            }

                        case DUK_ERASEPROMPT:
                            {
                            CurrentUser->SetErasePrompt(atoi(words[1]));
                            break;
                            }

                        case DUK_AUTOIDLESECONDS:
                            {
                            CurrentUser->SetAutoIdleSeconds(atoi(words[1]));
                            break;
                            }

                        case DUK_SSE_MSGSOMEWHERE:
                            {
                            CurrentUser->SetHearLaughter(atoi(words[1]));
                            break;
                            }

                        default:
                            {
                            doccr();
                            cPrintf(getmsg(21), citfiles[C_DEFUSER_CIT], words[0]);
                            doccr();
                            break;
                            }
                        }
                    }
                }

            fclose(defusr);
            }

        discardData(du);
        }
    }
Пример #15
0
void cyclesignature(void)
	{
	FILE *fBuf;
	char line[256];
	char *words[256];
	Bool found = FALSE;
	char path[80];

	// there is only one signature line, so get out and use it
	if (cfg.sig_current_pos == LONG_MAX)
		{
		return;
		}

	sprintf(path, sbs, cfg.homepath, citfiles[C_CONFIG_CIT]);

	if ((fBuf = fopen(path, FO_R)) == NULL) // ASCII mode
		{
		return;
		}

	fseek(fBuf, cfg.sig_current_pos, SEEK_SET);

	Bool HaveStartedOver = FALSE;

	for (; !found;)
		{
		// if end of file cycle back up
		if (fgets(line, 254, fBuf) == NULL)
			{
			if (!HaveStartedOver)
				{
				fseek(fBuf, cfg.sig_first_pos, SEEK_SET);
				HaveStartedOver = TRUE;
				}
			else 
				{
				found = TRUE;	// not found, but this breaks us out of the loop
				}

			continue;
			}

		cfg.sig_current_pos = ftell(fBuf);

		if (line[0] != '#')
			{
			continue;
			}

		if (strnicmp(line, getmsg(137), strlen(getmsg(137))) != SAMESTRING)
			{
			// okay we've gone past the last signature, cycle back up
			if (!HaveStartedOver)
				{
				fseek(fBuf, cfg.sig_first_pos, SEEK_SET);
				HaveStartedOver = TRUE;
				}
			else 
				{
				found = TRUE;	// not found, but this breaks us out of the loop
				}

			continue;
			}
		else
			{
			found = TRUE;
			}

		parse_it(words, line);

		CopyStringToBuffer(cfg.nodeSignature, words[1]);

		cfg.sig_current_pos = ftell(fBuf);
		}

	fclose(fBuf);
	}
Пример #16
0
void messWithShareList (uchar bUsage, label roomname)
{
    struct messNode  nodeArray[MAXDIRECT] ;
	   int       i, j, iNode, iTopNode, iOn ;
	   uchar     fKeyFound, fAnyPrinted, fQuit, fDisplayMenu ;
	   char      ch, oldEcho,
		     path[255], buf[255], *lpch, *lpstr,
		     aHotKeys[] = "BCDEFGHIJKLMNOPQRTUVWXYZ1234567890!#$%&*(",
		     *words[256];
	   int       hFile ;

    /* Initialize the array.  */

    for (i = 0; i < MAXDIRECT; i++)
	{
	strcpy (nodeArray[i].nodeName, '\0') ;
	nodeArray[i].fShared = FALSE ;
	nodeArray[i].bHotKey = (uchar) 0 ;
	nodeArray[i].bHotKeyPos = (uchar) 0 ;
	}

    /* In one single pass, we're going to read the NODES file and fill out */
    /* our array based on all the information we find there!               */

    sprintf (path, "%s\\NODES.CIT", cfg.homepath) ;

    hFile = sopen (path, O_TEXT | O_RDONLY, SH_DENYNO) ;

    if (-1 == hFile)
	crashout ("Problem opening NODES.CIT.") ;

    iTopNode = -1 ; 

    while ( !eof(hFile) )
	{
	if (!sfgets (buf, 255, hFile))
	    break ;                            /* Error reading file. */

	if ('#' != buf[0])            /* It's not a keyword. */
	    continue ;

	if (strnicmp (buf, "#NODE", 5) == SAMESTRING)
	    {
	    parse_it (words, buf) ;

	    if (words[1] == NULL)         /* Invalid #NODE entry. */
		continue ;

	    /* We have a new node and its name! */

	    ++iTopNode ;
	    strcpy (nodeArray[iTopNode].nodeName, words[1]) ;
	    }
	else
	    {
	    if (strnicmp (buf, "#ROOM", 5) != SAMESTRING)
		continue ;

	    if (-1 == iTopNode)       /* We don't have a node yet.  */
		continue ;

	    parse_it (words, buf) ;

	    if (stricmp (words[1], roomname) == SAMESTRING)
		nodeArray[iTopNode].fShared = TRUE ;
	    }
	}
    close (hFile) ;

    /* For the short, non-interactive output, just spew it out and quit.  */

    if (SHORT_SEE_NO_MODIFY == bUsage)
	{
	if (-1 == iTopNode)
	    mPrintf ("(No nodes in NODES.CIT.)") ;
	else
	    {
	    iOn = 0 ;
	    fAnyPrinted = FALSE ;

	    while (iOn <= iTopNode)
		{
		if (TRUE == nodeArray[iOn].fShared)
		    {
		    if (fAnyPrinted)
			mPrintf ("3, 0%s", nodeArray[iOn].nodeName) ;
		    else
			{
			mPrintf ("%s", nodeArray[iOn].nodeName) ;
			fAnyPrinted = TRUE ;
			}
		    }
		++iOn ;
		}
	    if (fAnyPrinted)
		mPrintf ("3.0") ;
	    }
	return ;
	}

    if (SEE_WITH_MODIFY == bUsage)
	{
	/* If we found more nodes than we can hotkey, say so and abort.  */

	if (iTopNode >= (int) strlen (aHotKeys))
	    {
	    mPrintf ("Uh-oh!  There are too many nodes in the userlog to use this function.") ;
	    doCR() ;
	    return ;
	    }

	/* Hotkeys are determined by a priority system. First, we try to   */
	/* get the first character of the node name.  Second, we try for   */
	/* the first character following every space in the name.  Third,  */
	/* we try every character in the name.  Last, we scan the entire   */
	/* hotkey string until we find an unused key.                      */

	for (iNode = 0; iNode <= iTopNode; iNode++)
	    {
	    fKeyFound = FALSE ;

	    /* PLAN ONE: Try for the first character.  */

	    ch = (char) toupper (*nodeArray[iNode].nodeName) ;

	    lpch = strchr (aHotKeys, ch) ;

	    if (lpch)                         /* If char = valid hotkey... */
		{
		nodeArray[iNode].bHotKey = *lpch ;
		nodeArray[iNode].bHotKeyPos = 0 ;
		*lpch = FILLED ;                      /* Ptr into aHotKeys */

		continue ;                      /* Do the next node.  */
		}

	    /* PLAN TWO: Try for the first letter of every word.  Since i  */
	    /* starts at one, it's ok to check the previous character for  */
	    /* a space.                                                    */

	    lpstr = nodeArray[iNode].nodeName ;

	    i = 1 ;

	    while (lpstr[i])      /* While we're not on the final NULL...  */
		{
		if ( ' ' == lpstr[i-1] )          /* Is the prev char a space? */
		    {
		    ch = (char) toupper (lpstr[i]) ;
		    lpch = strchr (aHotKeys, ch) ;
		    if (lpch)                                /* Valid chr? */
			{
			nodeArray[iNode].bHotKey = *lpch ;
			nodeArray[iNode].bHotKeyPos = (uchar) i ;
			*lpch = FILLED ;              /* Ptr into aHotKeys */

			fKeyFound = TRUE ; /* Signal release from for iter.*/
			break ;            /* Releases from while loop.    */
			}
		    }
		++i ;
		}

	    /* If the above loop found a key, move on to the next node.  */

	    if (fKeyFound)
		continue ;

	    /* PLAN THREE:  Check every single character in the string for */
	    /* a valid hot key.                                            */

	    i = 0 ;

	    while (lpstr[i])      /* While we're not on the final NULL...  */
		{
		ch = (char) toupper (lpstr[i]) ;
		lpch = strchr (aHotKeys, ch) ;
		if (lpch)                                    /* Valid chr? */
		    {
		    nodeArray[iNode].bHotKey = *lpch ;
		    nodeArray[iNode].bHotKeyPos = (uchar) i ;
		    *lpch = FILLED ;                  /* Ptr into aHotKeys */
		    fKeyFound = TRUE ;    /* Signal release from for iter. */
		    break ;                   /* Releases from while loop. */
		    }
		++i ;
		}

	    /* If the above loop found a key, move on to the next node. */

	    if (fKeyFound)
		continue ;

	    /* PLAN FOUR: Give the node the first available hot key.       */
	    /* Checking done previously assures that we'll get one.        */

	    i = 0 ;

	    while (FILLED == aHotKeys[i])
		++i ;

	    nodeArray[iNode].bHotKey = aHotKeys[i] ;
	    nodeArray[iNode].bHotKeyPos = NOT_IN_STRING ;
	    aHotKeys[i] = FILLED ;
	    }

	fDisplayMenu = TRUE ;
	fQuit = FALSE ;

	for (;;)
	    {
	    if (fDisplayMenu)
		{
		doCR () ;

		for (iNode = 0; iNode <= iTopNode; iNode++)
		    {
		    strcpy (buf, ".........................") ;
		    lpstr = nodeArray[iNode].nodeName ;
		    i = j = 0 ;
		    while (lpstr[i] != '\0')    /* Doesn't copy the NULL */
			{
			    if ( i == (int) nodeArray[iNode].bHotKeyPos)        /* Turn on bold */
				{
				buf[j] = '' ;
				buf[j+1] = '3' ;
				buf[j+2] = lpstr[i] ;
				buf[j+3] = '' ;
				buf[j+4] = '0' ;
				j += 5 ;
				}
			    else
				{
				buf[j] = lpstr[i] ;
				++j ;
				}
			    ++i ;
			}

		    mPrintf ("<3%c0> %s %s", nodeArray[iNode].bHotKey,
			  buf,
			  nodeArray[iNode].fShared ? "YES" : "No") ;
		    doCR() ;
		    }
		}

	    /* Take user input. */

	    doCR() ;
	    mPrintf("<3S0> to save, <3A0> to abort."); doCR();
	    
	    fDisplayMenu = (BOOL)(!expert) ;

	    outFlag = IMPERVIOUS;

	    doCR();
	    mPrintf("2Add/Drop:0 ");
	
	    oldEcho = echo;
	    echo         = NEITHER;
	    ch  = (char) iChar();
	    echo         = oldEcho;

	    if (!((whichIO == CONSOLE) || gotCarrier()))
		return;

	    switch(toupper(ch))
		{
		case 'A':
		    mPrintf("Abort");   doCR();
		    if (getYesNo("Abort", TRUE))
			return;
		    break;
    
		case 'S':
		    mPrintf("Save"); doCR();
		    if (getYesNo("Save", TRUE))
			{
			saveNewReality(nodeArray, roomname, iTopNode) ;
			return ;
			}
		    break ;

		case '\r':
		case '\n':
		case '?' :
		    mPrintf("Menu"); doCR();
		    fDisplayMenu = TRUE;
		    break;

		default:        /* Check if for hotkey and toggle right entry. */
		    for (i = 0; i <= iTopNode; i++)
			if (toupper(ch) == nodeArray[i].bHotKey)
			    {
			    nodeArray[i].fShared = (uchar) !nodeArray[i].fShared ;
			    mPrintf ("%s %s", nodeArray[i].nodeName,
			       nodeArray[i].fShared ? "added." : "dropped.") ;
			    doCR() ;
			    break ;
			    }

		    /* If it fails to break above, it's not valid input. */

		    if (i > iTopNode)
			{
			mPrintf("%c ? for help", ch); doCR();
			break ;
			}
		}
	    }  /* This is in the right place.  */
	}
}
Пример #17
0
/* -------------------------------------------------------------------- */
void ReadExternalCit(void)
	{
	FILE *fBuf;
	char line[257];
	char *words[256];
	int count;

	if ((fBuf = fopen(externalCit, "r")) == NULL)       /* ASCII mode */
		{
		printf("Cannot find %s!", externalCit);
		exit(69);
		}
	else
		{
		int i, lineNo = 0;

		while (fgets(line, 256, fBuf) != NULL)
			{
			lineNo++;

			if (line[0] != '#')
				{
				continue;
				}

			count = parse_it(words, line);

			if (SameString(words[0], "#PROTOCOL"))
				{
				protocols *theProt;

				theProt = (protocols *) addLL((void **) &protList,
							sizeof(*theProt));

				if (theProt)
					{
					CopyStringToBuffer(theProt->name, words[1], LABELSIZE);
					theProt->batch = !!atoi(words[2]);
					theProt->block = atoi(words[3]);
					CopyStringToBuffer(theProt->rcv, words[4], 127);
					CopyStringToBuffer(theProt->snd, words[5], 127);

					if (count <= 6 || words[6][0] == '\0')
						{
						theProt->autoDown[0] = '\0';
						}
					else
						{
						CopyStringToBuffer(theProt->autoDown, words[6], LABELSIZE);
						}

					if (count > 7)
						{
						CopyStringToBuffer(theProt->respDown, words[7], 127);
						}
					}
				else
					{
					printf("Not enough memory for #PROTOCOL \"%s\"",
							words[1]);
					printf("\n");
					}
				}
			}

		fclose(fBuf);
		}
	}
Пример #18
0
Bool TERMWINDOWMEMBER parseLine(char *line)
    {
    int i, j, k;
    char *words[128];
    char newline[82];
    char done;

    const int count = parse_it(words, line);

    i = -1;

    while (++i < count)
        {
        switch (tolower(*words[i++]))
            {
            case 'd':
                {
                if (debug)
                    {
                    OC.ansiattr = cfg.wattr;
                    cPrintf(getdbmsg(6), words[i], words[i + 1], words[i + 2]);
                    OC.ansiattr = cfg.attr;
                    cPrintf(spc);
                    }
                else
                    {
                    cPrintf(getmsg(433));
                    }

                const protocols *theProt = GetProtocolByKey(words[i][0], TRUE);

                if (!theProt)
                    {
                    return (FALSE);
                    }

                wxrcv(words[i + 1], words[i + 2], theProt);

                i += 2;
                break;
                }

            case 'p':
                {
                if (debug)
                    {
                    OC.ansiattr = cfg.wattr;
                    cPrintf(getdbmsg(7), words[i]);
                    OC.ansiattr = cfg.attr;
                    cPrintf(spc);
                    }
                else
                    {
                    cPrintf(getmsg(433));
                    }

                netpause(atoi(words[i]) * 100);
                break;
                }

            case 'r':
                {
                if (debug)
                    {
                    OC.ansiattr = cfg.wattr;
                    cPrintf(getdbmsg(8), words[i], words[i+1], words[i+2]);
                    OC.ansiattr = cfg.attr;
                    cPrintf(spc);
                    }
                else
                    {
                    cPrintf(getmsg(433));
                    }

                k = atoi(words[i+2]);

                for (done = FALSE, j = 0; j < k && !done; j++)
                    {
                    if (debug)
                        {
                        OC.ansiattr = cfg.wattr;
                        cPrintf(getdbmsg(9), words[i]);
                        OC.ansiattr = cfg.attr;
                        cPrintf(spc);
                        }
                    else
                        {
                        cPrintf(getmsg(433));
                        }

                    if (!wait_for(words[i], node->GetWaitTimeout()))
                        {
                        if (debug)
                            {
                            OC.ansiattr = cfg.wattr;
                            cPrintf(getdbmsg(10), words[i+1]);
                            OC.ansiattr = cfg.attr;
                            cPrintf(spc);
                            }
                        else
                            {
                            cPrintf(getmsg(433));
                            }

                        CommPort->OutString(words[i + 1], node->GetOutputPace());
                        }
                    else
                        {
                        done = TRUE;
                        }
                    }

                i += 2;

                if (!done)
                    {
                    return (FALSE);
                    }

                break;
                }

            case 's':
                {
                if (debug)
                    {
                    OC.ansiattr = cfg.wattr;
                    cPrintf(getdbmsg(10), words[i]);
                    OC.ansiattr = cfg.attr;
                    cPrintf(spc);
                    }
                else
                    {
                    cPrintf(getmsg(433));
                    }

                CommPort->OutString(words[i], node->GetOutputPace());
                break;
                }

            case 'u':
                {
                if (debug)
                    {
                    OC.ansiattr = cfg.wattr;
                    cPrintf(getdbmsg(11), words[i], words[i + 1],
                            words[i + 2]);
                    OC.ansiattr = cfg.attr;
                    cPrintf(spc);
                    }
                else
                    {
                    cPrintf(getmsg(433));
                    }

                const protocols *theProt = GetProtocolByKey(words[i][0],
                        TRUE);

                if (!theProt)
                    {
                    return (FALSE);
                    }

                wxsnd(words[i + 1], words[i + 2], theProt, 0);

                i += 2;
                break;
                }

            case 'w':
                {
                if (debug)
                    {
                    OC.ansiattr = cfg.wattr;
                    cPrintf(getdbmsg(9), words[i]);
                    OC.ansiattr = cfg.attr;
                    cPrintf(spc);
                    }
                else
                    {
                    cPrintf(getmsg(433));
                    }

                if (!wait_for(words[i], node->GetWaitTimeout()))
                    {
                    return (FALSE);
                    }

                break;
                }

            case '!':
                {
                RunApplication(words[i], NULL, TRUE, TRUE);
                break;
                }

            case '@':
                {
                FILE *file;

                if ((file = fopen(words[i], FO_R)) != NULL)
                    {
                    while (fgets(newline, 80, file))
                        {
                        if (!parseLine(newline))
                            {
                            fclose(file);
                            return (FALSE);
                            }
                        }

                    fclose(file);
                    }
                else
                    {
                    return (FALSE);
                    }

                break;
                }

            default:
                {
                OC.ansiattr = (uchar)(cfg.cattr | 128);
                cPrintf(getnetmsg(52), words[i-1], words[i]);
                OC.ansiattr = cfg.attr;
                cPrintf(spc);
                break;
                }
            }
        }

    return (TRUE);
    }