Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdbool.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <sys/iomsg.h>
- #include <sys/neutrino.h>
- #include "httpd_pid.h"
- //...
- //Прочие заголовки.
- //...
- int connectionId;
- int OnInit(PtWidget_t* widget, ApInfo_t* apinfo, PtCallbackInfo_t* cbinfo) {
- FILE* f = fopen(HTTPD_PID, "r");
- int nodeDescriptor, serverId, channelId;
- bool ok;
- if (!f) {
- fputs("Cannot open \"" HTTPD_PID "\"\n", stderr);
- exit(1);
- }
- ok = fscanf(f, "%d/%d/%d", &nodeDescriptor, &serverId, &channelId) == 3;
- fclose(f);
- if (!ok) {
- fputs("Invalid file format\n", stderr);
- exit(1);
- }
- connectionId = ConnectAttach(nodeDescriptor, serverId, channelId, 0, 0);
- if (connectionId == -1) {
- fputs("Server is not found\n", stderr);
- exit(1);
- }
- return Pt_CONTINUE;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement