-void np_attach_to_server(void) {
- char hostbuf[256], portbuf[256];
- char buf[256];
- char portname[8];
- char *args[] = { "sendcommand", NULL, NULL, NULL } ;
-
- fprintf(stderr, "Attaching to server...\n");
- sprintf(portname, "%d", config.c_port_number);
- args[2] = portname;
- attach_to_server(3, args, hostbuf, portbuf);
- serv_gets(buf);
- fprintf(stderr, "%s\n",&buf[4]);
- sprintf(buf,"IPGM %d", config.c_ipgm_secret);
- serv_puts(buf);
- serv_gets(buf);
- fprintf(stderr, "%s\n",&buf[4]);
- if (buf[0]!='2') {
- cleanup(2);
+void serv_gets(char *buf)
+{
+ int i;
+
+ /* Read one character at a time.
+ */
+ for (i = 0;; i++) {
+ serv_read(&buf[i], 1);
+ if (buf[i] == '\n' || i == (SIZ-1))
+ break;
+ }
+
+ /* If we got a long line, discard characters until the newline.
+ */
+ if (i == (SIZ-1)) {
+ while (buf[i] != '\n') {
+ serv_read(&buf[i], 1);