예제 #1
0
파일: RT1.C 프로젝트: g8bpq/BPQ32
static void rduser(USER *user)
{
	FILE *in;
	char *buf, *name, *qth;

	user->name = strdup("?_name");
	user->qth  = strdup("?_qth");

	in = nfopeni(RtUsr, "r");

	if (in)
	{
		buf = mallocw(LINE128);

	  while(fgets(buf, LINE128, in))
	  {
		  rip(buf);
	    name = strlop(buf, ' ');
			if (!matchi(buf, user->call)) continue;
			if (!name) break;
			qth = strlop(name, ' ');
			strnew(&user->name, name);
			if (!qth) break;
			strnew(&user->qth,  qth);
			break;
		}

		free(buf);
		nfclose(&in);
	}
}
예제 #2
0
char *
hostname()			/* return this Usenet machine's name */
{
	static char name[MAXHOST];

	if (name[0] == '\0') {	/* try to get the "news hostname" */
		register FILE *fp;

		fp = fopenclex(NAMEFILE, "r");
		if (fp != NULL) {
			(void) fgets(name, sizeof name, fp);
			(void) nfclose(fp);
			if (name[0] != '\0' && name[strlen(name) - 1] == '\n')
				name[strlen(name) - 1] = '\0';
		}
	}
	if (name[0] == '\0')	/* else use the ordinary hostname */
		(void) gethostname(name, sizeof name);
	return name;
}