::: °­ÁÂ/¼Ò½º/¹®¼­ :::

°­ÁÂ/¼Ò½º/¹®¼­ ¼º°Ý¿¡ ¸ÂÁö ¾Ê´Â ±¤°í,ºñ¹æ,Áú¹®ÀÇ ±ÛÀº Áï½Ã »èÁ¦Çϸç
³»¿ëÀ» º¹»çÇÏ¿© »ç¿ëÇÒ °æ¿ì ¹Ýµå½Ã ÀÌ°÷(http://www.howto.pe.kr)À» Ãâó·Î ¸í½ÃÇÏ¿© ÁÖ¼¼¿ä


Category

  ±è¿µ´ë(2003-03-17 02:37:24, Hit : 6464, Vote : 1490
 [System V IPC] msgctl() function - ¸Þ¼¼ÁöÅ¥

/***************************************************
*   Creat  : 2001. 02. 10  (programed by Cori-Young)
*   Site: http://www.byoneself.co.kr
*   Update :
***************************************************/

#include   <stdio.h>
#include   <sys/types.h>
#include   <sys/ipc.h>
#include   <sys/msg.h>
#include   <time.h>

static void do_msgctl();
extern void exit();
extern void perror();
static char warning_message[] = "If you remove read permissionfor  yourself, this program will fail frequently!";

main()
{
        struct msqid_ds buf;
        int    cmd;
        int    msqid;        
        
        (void) fprintf(stderr,  "t0x... is interpreted as hexadecimal,n");        
        (void) fprintf(stderr, "t0... is interpreted as octal,n");        
        (void) fprintf(stderr, "totherwise, decimal.n");
                
        /* Get the msqid and cmd arguments for the msgctl() call. */
        
        (void) fprintf(stderr,  "Please enter arguments for msgctls() as requested.");        
        (void) fprintf(stderr, "nEnter the msqid: ");
        (void) scanf("%i", &msqid);
        (void) fprintf(stderr, "tIPC_RMID = %dn", IPC_RMID);
        (void) fprintf(stderr, "tIPC_SET = %dn", IPC_SET);
        (void) fprintf(stderr, "tIPC_STAT = %dn", IPC_STAT);
        (void) fprintf(stderr, "nEnter the value for the command: ");
        (void) scanf("%i", &cmd);
                
        switch (cmd) {

                case IPC_SET:
                        /* Modify settings in the message queue control structure.*/                        
                        /* Get a copy of the current message queue control structure and show it to the user. */        
                                
                        do_msgctl(msqid, IPC_STAT, &buf);
                                
                                
                                
                        (void) fprintf(stderr,  "msg_perm.uid = %dn", buf.msg_perm.uid);                        
                        (void) fprintf(stderr,  "msg_perm.gid = %dn", buf.msg_perm.gid);                                
                        (void) fprintf(stderr,  "msg_perm.cuid = %dn", buf.msg_perm.cuid);                                
                        (void) fprintf(stderr,  "msg_perm.cgid = %dn", buf.msg_perm.cgid);                        
                        (void) fprintf(stderr, "msg_perm.mode = %#o, ",      buf.msg_perm.mode);                                
                        (void) fprintf(stderr, "access permissions = %#on", buf.msg_perm.mode & 0777);                        
                        (void) fprintf(stderr, "msg_cbytes = %dn",       buf.msg_cbytes);                                
                        (void) fprintf(stderr, "msg_qbytes = %dn",       buf.msg_qbytes);                                
                        (void) fprintf(stderr, "msg_qnum = %dn", buf.msg_qnum);                                
                        (void) fprintf(stderr, "msg_lspid = %dn",       buf.msg_lspid);                                
                        (void) fprintf(stderr, "msg_lrpid = %dn",       buf.msg_lrpid);                                
                        (void) fprintf(stderr, "msg_stime = %s", buf.msg_stime ? ctime(&buf.msg_stime) : "Not Setn");                                
                        (void) fprintf(stderr, "msg_rtime = %s", buf.msg_rtime ? ctime(&buf.msg_rtime) : "Not Setn");                                
                        (void) fprintf(stderr, "msg_ctime = %s",       ctime(&buf.msg_ctime));
                
                        if (cmd == IPC_STAT)
                                break;
                                
                        /*  Now continue with IPC_SET. */                                                                       
                        (void) fprintf(stderr, "Enter msg_perm.uid: ");
                        (void) scanf ("%hi", &buf.msg_perm.uid);
                        (void) fprintf(stderr, "Enter msg_perm.gid: ");
                        (void) scanf("%hi", &buf.msg_perm.gid);
                        (void) fprintf(stderr, "%sn", warning_message);
                        (void) fprintf(stderr, "Enter msg_perm.mode: ");
                        (void) scanf("%hi", &buf.msg_perm.mode);
                        (void) fprintf(stderr, "Enter msg_qbytes: ");
                                
                        (void) scanf("%hi", &buf.msg_qbytes);
                                
                        do_msgctl(msqid, IPC_SET, &buf);
                        break;
                        
                case IPC_RMID:
                default:
                        do_msgctl(msqid, cmd, (struct msqid_ds *)NULL);
                        break;
        }
        exit(0);
}



static void do_msgctl(msqid, cmd, buf)
struct msqid_ds    *buf;
int    cmd, msqid;
{

        register int rtrn;
        (void) fprintf(stderr, "nmsgctl: Calling msgctl(%d, %d,%s)n",  msqid, cmd, buf ? "&buf" : "(struct msqid_ds *)NULL");
        
        rtrn = msgctl(msqid, cmd, buf);

        if (rtrn == -1) {
                perror("msgctl: msgctl failed");
                exit(1);
        }
        else {
                (void) fprintf(stderr, "msgctl: msgctl returned %dn",      rtrn);
        }
}





62   [Unix/Linux] [°­ÁÂ] ÀÎÅÚ ¼¾Æ®¸®³ë ¹«¼±·£ Ä«µå: ndiswrapper  ±è¿µ´ë 2004/06/27 12517 2186
61   [Unix/Linux] [¼Ò½º] top for System V Release 4, Intel or Sparc CPU  ±è¿µ´ë 2004/02/20 11017 1288
60   [Unix/Linux] [¼Ò½º] top for SunOS 5.x (Solaris 2.x)  ±è¿µ´ë 2004/02/20 15427 1330
59   [Unix/Linux] [¼Ò½º] String Çؽ¬(hash) ÇÔ¼ö  ±è¿µ´ë 2003/07/29 7998 1586
58   [Unix/Linux] [°­ÁÂ] À¥·Î±×ºÐ¼®À» À§ÇÑ Webalizer + GDlib + PNGlib + Zlib ¼³Ä¡  ±è¿µ´ë 2003/05/04 8486 1511
57   [Unix/Linux] [°­ÁÂ] Apache + MySQL + PHP4 + Zend Optimizer ¼³Ä¡  ±è¿µ´ë 2003/04/15 8618 1597
56   [Unix/Linux] [System V IPC] shmop() function - °øÀ¯¸Þ¸ð¸®  ±è¿µ´ë 2003/03/17 6453 1580
55   [Unix/Linux] [System V IPC] shmctl() function - °øÀ¯¸Þ¸ð¸®  ±è¿µ´ë 2003/03/17 9840 1698
54   [Unix/Linux] [System V IPC] shmget() function - °øÀ¯¸Þ¸ð¸®  ±è¿µ´ë 2003/03/17 11151 1789
53   [Unix/Linux] [System V IPC] semop() function - ¼¼¸¶Æ÷¾î  ±è¿µ´ë 2003/03/17 5737 1435
52   [Unix/Linux] [System V IPC] semctl() function - ¼¼¸¶Æ÷¾î  ±è¿µ´ë 2003/03/17 6120 1408
51   [Unix/Linux] [System V IPC] semget() function - ¼¼¸¶Æ÷¾î  ±è¿µ´ë 2003/03/17 6670 1658
50   [Unix/Linux] [System V IPC] msgget() function - ¸Þ¼¼ÁöÅ¥  ±è¿µ´ë 2003/03/17 6359 1575
  [Unix/Linux] [System V IPC] msgctl() function - ¸Þ¼¼ÁöÅ¥  ±è¿µ´ë 2003/03/17 6464 1490
48   [Unix/Linux] [System V IPC] msgrcv() function - ¸Þ¼¼ÁöÅ¥  ±è¿µ´ë 2003/03/17 6999 1695
47   [Unix/Linux] [System V IPC] msgsnd() function - ¸Þ¼¼ÁöÅ¥  ±è¿µ´ë 2003/03/17 8326 1920
46   [Unix/Linux] [POSIX IPC] »ý»êÀÚ/¼ÒºñÀÚ - ¼¼¸¶Æ÷¾î  ±è¿µ´ë 2003/03/17 8074 5688
45   [Unix/Linux] [POSIX IPC] mq_receive() function - ¸Þ¼¼ÁöÅ¥  ±è¿µ´ë 2003/03/17 8238 1822
44   [Unix/Linux] [POSIX IPC] mq_send() function - ¸Þ¼¼ÁöÅ¥  ±è¿µ´ë 2003/03/17 12345 1704
43   [Unix/Linux] [Thread] pthread_cond() function  ±è¿µ´ë 2003/03/17 6610 1688

1 [2][3][4]
 

Copyright 1999-2024 Zeroboard / skin by zero