Esempio n. 1
0
File: RT1.C Progetto: g8bpq/BPQ32
static void text_tellu(USER *user, char *text, char *to, int who)
{
	CIRCUIT *circuit;
	char    *buf;

	buf = mallocw(strlen(text) + 11);
	sprintf(buf, "%-6.6s %c %s\n", user->call, (who == o_one) ? '>' : ':', text);

// Send it to all connected users in the same topic.
// Echo to originator if requested.

	for (circuit = circuit_hd; circuit; circuit = circuit->next)
	{
		if (!(circuit->flags & p_user)) continue;  // Circuit is a link.
		if ((circuit->u.user == user) && !(user->flags & u_echo)) continue;

		switch(who)
		{
			case o_topic :
				if (circuit->u.user->topic == user->topic) nputs(circuit->s, buf);
				break;
			case o_all :
				nputs(circuit->s, buf);
				break;
			case o_one :
				if (matchi(circuit->u.user->call, to)) nputs(circuit->s, buf);
				break;
		}
	}

	free(buf);
}
Esempio n. 2
0
static void read_config_file(void)
{
   int result ;

   //  search for existing file.
   //  1. look in current directory
   //  2. if not found, search location of executable
   //  3. if not found, generate default file in location of executable
   // printf("seek local ini=%s\n", local_ini_name) ;
   result = read_ini_file(local_ini_name) ;
   if (result == 0) {
      return ;
   }

   //  If search for local file failed, try location of executable,
   //  if that isn't the local directory.

   //  If global INI filename isn't present, give up on search.
   //  This will usually mean that we are running under WinNT 4.0,
   //  and the executable is already in the current directory.
   //  Just write the file in the current directory.
   // printf("ininame=%s\n", ininame) ;
   // getchar() ;
   if (ininame[0] == 0) {
      strcpy(ini_path, local_ini_name) ;
   } 
   //  If global INI filename IS present, try to load it
   else {
      result = read_ini_file(ininame) ;
      if (result == 0) {
         return ;
      }
      strcpy(ini_path, ininame) ;
   }

   //  If we couldn't open any existing INI files,
   //  generate default file in appropriate location.
   result = write_default_ini_file(ini_path) ;
   if (result != 0) {
      // perror(ini_path) ;
      sprintf (tempstr, "path [%s]\n", ini_path);
      nputs (0xA, tempstr);
      sprintf (tempstr, "FindFirst: %s\n", get_system_message ());
      nputs (0xA, tempstr);
   }
   //  try to read again, after writing defaults
   read_ini_file(ini_path) ;
}
Esempio n. 3
0
int main()
{
   uint total = sys_dir_load(0, files, n);
   uint count = n < total ? n : total;
   uint i;
   for (i = 0; i < count; i++)
   {
      nputs(files[i].Name, 11);
      if (files[i].Attr & ATTR_HIDDEN)
         puts(" <hid>");
      if (files[i].Attr & ATTR_SYSTEM)
         puts(" <sys>");
      if (files[i].Attr & ATTR_ARCHIVE)
         puts(" <arc>");
      if (files[i].Attr & ATTR_READ_ONLY)
         puts(" <ro>");
      if (files[i].Attr & ATTR_DIRECTORY)
         puts(" <dir>");
      puts("\n");
   }
   if (total > n)
      puts("...\n");

   return 0;
}
Esempio n. 4
0
/* For internal use only since it depends on the internal function nputs().
 * synchronous and doesn't require the IRQ to be enabled (actually the IRQ *must* be disabled)
 * TODO: nputs() shouldn't be used since it outputs '\n'. */
void nprintf(const char *fmt, ...) {
	char sbuf[500];
	va_list vl;
	va_start(vl, fmt);
	// TODO use vnsprintf
	vsprintf(sbuf, fmt, vl);
  va_end(vl);
	nputs(sbuf);
}
Esempio n. 5
0
int first_task(void) {
	unsigned int pid;
	pid = fork();
	if(!pid) {
		name_server_task();
	}
	if(pid != NAME_SERVER_PID) {
		bwputs("name server PID: ");
		nputs(pid);
		bwputs("\n");
		return 1;
	}
	yield_task();
	return 0;
}
Esempio n. 6
0
File: tty.c Progetto: fchai/cnix
int puts (const char * buff)
    {
    return nputs (buff, INT_MAX);
    }
Esempio n. 7
0
int Connected(Stream)
{
	int n;
	ChatCIRCUIT * conn;
	struct UserInfo * user = NULL;
	char callsign[10];
	int port, paclen, maxframe, l4window;
	char ConnectedMsg[] = "*** CONNECTED    ";
	char Msg[100];
	LINK    *link;
	KNOWNNODE *node;

	for (n = 0; n < NumberofChatStreams; n++)
	{
  		conn = &ChatConnections[n];
		
		if (Stream == conn->BPQStream)
		{
			if (conn->Active)
			{
				// Probably an outgoing connect
		
				if (conn->rtcflags == p_linkini)
				{
					conn->paclen = 236;
					nprintf(conn, "c %s\r", conn->u.link->call);
					return 0;
				}
			}
	
			memset(conn, 0, sizeof(ChatCIRCUIT));		// Clear everything
			conn->Active = TRUE;
			conn->BPQStream = Stream;

			conn->Secure_Session = GetConnectionInfo(Stream, callsign,
				&port, &conn->SessType, &paclen, &maxframe, &l4window);

			conn->paclen = paclen;

			strlop(callsign, ' ');		// Remove trailing spaces

			memcpy(conn->Callsign, callsign, 10);

			strlop(callsign, '-');		// Remove any SSID

			user = zalloc(sizeof(struct UserInfo));

			strcpy(user->Call, callsign);

			conn->UserPointer = user;

			n=sprintf_s(Msg, sizeof(Msg), "Incoming Connect from %s", user->Call);
			
			// Send SID and Prompt

			WriteLogLine(conn, '|',Msg, n, LOG_CHAT);
			conn->Flags |= CHATMODE;

			nodeprintf(conn, ChatSID, Ver[0], Ver[1], Ver[2], Ver[3]);

			// See if from a defined node
				
			for (link = link_hd; link; link = link->next)
			{
				if (matchi(conn->Callsign, link->call))
				{
					conn->rtcflags = p_linkwait;
					return 0;						// Wait for *RTL
				}
			}

			// See if from a previously known node

			node = knownnode_find(conn->Callsign);

			if (node)
			{
				// A node is trying to link, but we don't have it defined - close

				Logprintf(LOG_CHAT, conn, '!', "Node %s connected, but is not defined as a Node - closing",
					conn->Callsign);

				nodeprintf(conn, "Node %s does not have %s defined as a node to link to - closing.\r",
					OurNode, conn->Callsign);

				ChatFlush(conn);

				Sleep(500);

				Disconnect(conn->BPQStream);

				return 0;
			}

			if (user->Name[0] == 0)
			{
				char * Name = lookupuser(user->Call);

				if (Name)
				{
					if (strlen(Name) > 17)
						Name[17] = 0;

					strcpy(user->Name, Name);
					free(Name);
				}
				else
				{
					conn->Flags |= GETTINGUSER;
					nputs(conn, NewUserPrompt);
					return TRUE;
				}
			}

			SendWelcomeMsg(Stream, conn, user);
			RefreshMainWindow();
			ChatFlush(conn);
			
			return 0;
		}
	}

	return 0;
}