Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- else if(ntohs(sireq.requestType) == DIGEST){
- printf("Request type = digest\n");
- FILE *fp;
- char path[BUFFLEN];
- char command[70];
- int len;
- struct digest_request dreq;
- struct init_response ires;
- ires.three_b_pad[0] = '\0';
- ires.three_b_pad[1] = '\0';
- ires.three_b_pad[2] = '\0';
- ires.returnCode = 0;
- rio_t rio;
- Rio_readinitb(&rio, connfd);
- read(connfd, &dreq, sizeof(dreq));
- printf("Detail = %s\n", dreq.val);
- printf("Completion: success\n");
- //get the command
- len = snprintf(command, sizeof(command), "/bin/echo %s | /usr/bin/sha256sum",dreq.val);
- if (len <= sizeof(command))
- {
- fp = popen(command, "r");
- }
- // Open the command for reading.
- if (fp == NULL) {
- printf("Completion: failure\n");
- }
- // Read the output a line at a time to path
- fgets(path, sizeof(path)-1, fp);
- // close
- pclose(fp);
- path[SIXTYFIVE] = '\0';
- strcpy(ires.val, path);
- ires.valLength = SIXTYFIVE;
- write(connfd, &ires, sizeof(ires));
- //read(connfd, &dreq.val, ntohs(dreq.valLength));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement