/* * Create a bid for the command on the command line */ #include #include #include #include #include #include #include #include "dsh.h" #include "dbid.h" #define TOKENSIZE 120 /* * Get the next token */ char * nexttoken (p, token) char *p; char *token; { while (*p == ' ' || *p == '\t') p++; while (*p != ' ' && *p != '\t' && *p != 0) *token++ = *p++; *token = 0; return (p); } main (argc, argv) int argc; char *argv[]; { char token[TOKENSIZE]; char *p; bool allfound; double la[3]; int fd, rv; int pid, port; struct bidmsg b; struct passwd *pwd; struct passwd *getpwuid(); if (argc != 5) { fprintf (stderr, "dbid usage: dbid \n"); for (rv = 0; rv pw_dir, pid); } else { if (token[0] == '/' || token[0] == '~') { /* this is an absolute path */ sprintf (b.bm_dir, "%s/dsh%d", token, pid); } else { /* a relative path */ sprintf (b.bm_dir, "%s/%s/dsh%d", pwd->pw_dir, token, pid); } } /* return bid */ port = 0; /* no particular port */ fd = makedgsocket (&port); if (fd < 0) { error ("dbid: couldn't open socket to send over"); } /* fprintf (stderr, "senddg (%d, %x, %d, %s, %d)\n", fd, &b, sizeof (struct bidmsg), argv[2], atoi(argv[3])); */ rv = senddg (fd, &b, sizeof (struct bidmsg), argv[2], atoi(argv[3])); if (rv < 0) { error ("dbid: couldn't send bid"); } }