999ms

Untitled

Dec 21st, 2020 (edited)
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.67 KB | None | 0 0
  1. char* GetStateOfQueue(int queue_id) {
  2.     struct msqid_ds state = GetCurrentState(queue_id);
  3.     struct ipc_perm perm = state.msg_perm;    
  4.    
  5.     char* result = (char*) malloc(sizeof(char) * MSG_SIZE);
  6.    
  7.     int pos = 0;
  8.     pos += AddToLineString(&result, pos, "ipc_perm:\n");
  9.     pos += AddToLineString(&result, pos, " key = ");
  10.     pos += AddToLineInt(&result, pos, perm.__key);
  11.     pos += AddToLineString(&result, pos, "\n");
  12.    
  13.     pos += AddToLineString(&result, pos, " uid = ");
  14.     pos += AddToLineInt(&result, pos, perm.uid);
  15.     pos += AddToLineString(&result, pos, "\n");
  16.    
  17.     pos += AddToLineString(&result, pos, " gid = ");
  18.     pos += AddToLineInt(&result, pos, perm.gid);
  19.     pos += AddToLineString(&result, pos, "\n");
  20.    
  21.     pos += AddToLineString(&result, pos, " cuid = ");
  22.     pos += AddToLineInt(&result, pos, perm.cuid);
  23.     pos += AddToLineString(&result, pos, "\n");
  24.    
  25.     pos += AddToLineString(&result, pos, " cgid = ");
  26.     pos += AddToLineInt(&result, pos, perm.cgid);
  27.     pos += AddToLineString(&result, pos, "\n");
  28.    
  29.     pos += AddToLineString(&result, pos, " mode = ");
  30.     pos += AddToLineInt(&result, pos, perm.mode);
  31.     pos += AddToLineString(&result, pos, "\n");
  32.    
  33.     pos += AddToLineString(&result, pos, " seq = ");
  34.     pos += AddToLineInt(&result, pos, perm.__seq);
  35.     pos += AddToLineString(&result, pos, "\n");
  36.  
  37.     pos += AddToLineString(&result, pos, "\n");
  38.  
  39.     pos += AddToLineString(&result, pos, "msg_qnum = ");
  40.     pos += AddToLineInt(&result, pos, state.msg_qnum);
  41.     pos += AddToLineString(&result, pos, "\n");
  42.  
  43.     pos += AddToLineString(&result, pos, "msg_qbytes = ");
  44.     pos += AddToLineInt(&result, pos, state.msg_qbytes);
  45.     pos += AddToLineString(&result, pos, "\n");
  46.  
  47.     pos += AddToLineString(&result, pos, "msg_lspid = ");
  48.     pos += AddToLineInt(&result, pos, state.msg_lspid);
  49.     pos += AddToLineString(&result, pos, "\n");
  50.  
  51.     pos += AddToLineString(&result, pos, "msg_lrpid = ");
  52.     pos += AddToLineInt(&result, pos, state.msg_lrpid);
  53.     pos += AddToLineString(&result, pos, "\n");
  54.  
  55.     pos += AddToLineString(&result, pos, "msg_msg_stime = ");
  56.     pos += AddToLineInt(&result, pos, state.msg_stime);
  57.     pos += AddToLineString(&result, pos, "\n");  
  58.  
  59.     pos += AddToLineString(&result, pos, "msg_rtime = ");
  60.     pos += AddToLineInt(&result, pos, state.msg_rtime);
  61.     pos += AddToLineString(&result, pos, "\n");
  62.  
  63.     pos += AddToLineString(&result, pos, "msg_ctime = ");
  64.     pos += AddToLineInt(&result, pos, state.msg_ctime);
  65.     pos += AddToLineString(&result, pos, "\n");
  66.  
  67.  
  68.  
  69.  
  70.  
  71.     pos += AddToLineString(&result, pos, "\0");
  72.        
  73.  
  74.     return result;
  75. }
  76.  
Add Comment
Please, Sign In to add comment