Advertisement
SirNickolas

OS 7 Window Opening handler

Nov 28th, 2014
528
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.88 KB | None | 0 0
  1. #include <stdbool.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <unistd.h>
  5. #include <sys/iomsg.h>
  6. #include <sys/neutrino.h>
  7. #include "httpd_pid.h"
  8.  
  9. //...
  10. //Прочие заголовки.
  11. //...
  12.  
  13. int connectionId;
  14.  
  15. int OnInit(PtWidget_t* widget, ApInfo_t* apinfo, PtCallbackInfo_t* cbinfo) {
  16.     FILE* f = fopen(HTTPD_PID, "r");
  17.     int nodeDescriptor, serverId, channelId;
  18.     bool ok;
  19.     if (!f) {
  20.         fputs("Cannot open \"" HTTPD_PID "\"\n", stderr);
  21.         exit(1);
  22.     }
  23.     ok = fscanf(f, "%d/%d/%d", &nodeDescriptor, &serverId, &channelId) == 3;
  24.     fclose(f);
  25.     if (!ok) {
  26.         fputs("Invalid file format\n", stderr);
  27.         exit(1);
  28.     }
  29.     connectionId = ConnectAttach(nodeDescriptor, serverId, channelId, 0, 0);
  30.     if (connectionId == -1) {
  31.         fputs("Server is not found\n", stderr);
  32.         exit(1);
  33.     }
  34.     return Pt_CONTINUE;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement