Založenà projektu, funguje odesÃlánà i pÅ™ijÃmánà zpráv.
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/c++/POSIXoveFronty/Fronta/Fronta.pro Fri Apr 03 22:39:11 2009 +0200
1.3 @@ -0,0 +1,12 @@
1.4 +######################################################################
1.5 +# Automatically generated by qmake (2.01a) pá dub 3 18:45:01 2009
1.6 +######################################################################
1.7 +
1.8 +TEMPLATE = app
1.9 +TARGET =
1.10 +DEPENDPATH += .
1.11 +INCLUDEPATH += .
1.12 +
1.13 +# Input
1.14 +HEADERS += program.h
1.15 +SOURCES += program.cpp
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/c++/POSIXoveFronty/Fronta/Makefile Fri Apr 03 22:39:11 2009 +0200
2.3 @@ -0,0 +1,193 @@
2.4 +#############################################################################
2.5 +# Makefile for building: Fronta
2.6 +# Generated by qmake (2.01a) (Qt 4.4.3) on: pá dub 3 18:45:02 2009
2.7 +# Project: Fronta.pro
2.8 +# Template: app
2.9 +# Command: /usr/bin/qmake -unix -o Makefile Fronta.pro
2.10 +#############################################################################
2.11 +
2.12 +####### Compiler, tools and options
2.13 +
2.14 +CC = gcc
2.15 +CXX = g++
2.16 +DEFINES = -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
2.17 +CFLAGS = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
2.18 +CXXFLAGS = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
2.19 +INCPATH = -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I.
2.20 +LINK = g++
2.21 +LFLAGS = -Wl,--no-undefined
2.22 +LIBS = $(SUBLIBS) -L/usr/lib -lQtGui -lQtCore -lpthread
2.23 +AR = ar cqs
2.24 +RANLIB =
2.25 +QMAKE = /usr/bin/qmake
2.26 +TAR = tar -cf
2.27 +COMPRESS = gzip -9f
2.28 +COPY = cp -f
2.29 +SED = sed
2.30 +COPY_FILE = $(COPY)
2.31 +COPY_DIR = $(COPY) -r
2.32 +INSTALL_FILE = install -m 644 -p
2.33 +INSTALL_DIR = $(COPY_DIR)
2.34 +INSTALL_PROGRAM = install -m 755 -p
2.35 +DEL_FILE = rm -f
2.36 +SYMLINK = ln -sf
2.37 +DEL_DIR = rmdir
2.38 +MOVE = mv -f
2.39 +CHK_DIR_EXISTS= test -d
2.40 +MKDIR = mkdir -p
2.41 +
2.42 +####### Output directory
2.43 +
2.44 +OBJECTS_DIR = ./
2.45 +
2.46 +####### Files
2.47 +
2.48 +SOURCES = program.cpp
2.49 +OBJECTS = program.o
2.50 +DIST = /usr/share/qt4/mkspecs/common/g++.conf \
2.51 + /usr/share/qt4/mkspecs/common/unix.conf \
2.52 + /usr/share/qt4/mkspecs/common/linux.conf \
2.53 + /usr/share/qt4/mkspecs/qconfig.pri \
2.54 + /usr/share/qt4/mkspecs/features/qt_functions.prf \
2.55 + /usr/share/qt4/mkspecs/features/qt_config.prf \
2.56 + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \
2.57 + /usr/share/qt4/mkspecs/features/default_pre.prf \
2.58 + /usr/share/qt4/mkspecs/features/release.prf \
2.59 + /usr/share/qt4/mkspecs/features/default_post.prf \
2.60 + /usr/share/qt4/mkspecs/features/warn_on.prf \
2.61 + /usr/share/qt4/mkspecs/features/qt.prf \
2.62 + /usr/share/qt4/mkspecs/features/unix/thread.prf \
2.63 + /usr/share/qt4/mkspecs/features/moc.prf \
2.64 + /usr/share/qt4/mkspecs/features/resources.prf \
2.65 + /usr/share/qt4/mkspecs/features/uic.prf \
2.66 + /usr/share/qt4/mkspecs/features/yacc.prf \
2.67 + /usr/share/qt4/mkspecs/features/lex.prf \
2.68 + Fronta.pro
2.69 +QMAKE_TARGET = Fronta
2.70 +DESTDIR =
2.71 +TARGET = Fronta
2.72 +
2.73 +first: all
2.74 +####### Implicit rules
2.75 +
2.76 +.SUFFIXES: .o .c .cpp .cc .cxx .C
2.77 +
2.78 +.cpp.o:
2.79 + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
2.80 +
2.81 +.cc.o:
2.82 + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
2.83 +
2.84 +.cxx.o:
2.85 + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
2.86 +
2.87 +.C.o:
2.88 + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
2.89 +
2.90 +.c.o:
2.91 + $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
2.92 +
2.93 +####### Build rules
2.94 +
2.95 +all: Makefile $(TARGET)
2.96 +
2.97 +$(TARGET): $(OBJECTS)
2.98 + $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
2.99 +
2.100 +Makefile: Fronta.pro /usr/share/qt4/mkspecs/linux-g++/qmake.conf /usr/share/qt4/mkspecs/common/g++.conf \
2.101 + /usr/share/qt4/mkspecs/common/unix.conf \
2.102 + /usr/share/qt4/mkspecs/common/linux.conf \
2.103 + /usr/share/qt4/mkspecs/qconfig.pri \
2.104 + /usr/share/qt4/mkspecs/features/qt_functions.prf \
2.105 + /usr/share/qt4/mkspecs/features/qt_config.prf \
2.106 + /usr/share/qt4/mkspecs/features/exclusive_builds.prf \
2.107 + /usr/share/qt4/mkspecs/features/default_pre.prf \
2.108 + /usr/share/qt4/mkspecs/features/release.prf \
2.109 + /usr/share/qt4/mkspecs/features/default_post.prf \
2.110 + /usr/share/qt4/mkspecs/features/warn_on.prf \
2.111 + /usr/share/qt4/mkspecs/features/qt.prf \
2.112 + /usr/share/qt4/mkspecs/features/unix/thread.prf \
2.113 + /usr/share/qt4/mkspecs/features/moc.prf \
2.114 + /usr/share/qt4/mkspecs/features/resources.prf \
2.115 + /usr/share/qt4/mkspecs/features/uic.prf \
2.116 + /usr/share/qt4/mkspecs/features/yacc.prf \
2.117 + /usr/share/qt4/mkspecs/features/lex.prf \
2.118 + /usr/lib/libQtGui.prl \
2.119 + /usr/lib/libQtCore.prl
2.120 + $(QMAKE) -unix -o Makefile Fronta.pro
2.121 +/usr/share/qt4/mkspecs/common/g++.conf:
2.122 +/usr/share/qt4/mkspecs/common/unix.conf:
2.123 +/usr/share/qt4/mkspecs/common/linux.conf:
2.124 +/usr/share/qt4/mkspecs/qconfig.pri:
2.125 +/usr/share/qt4/mkspecs/features/qt_functions.prf:
2.126 +/usr/share/qt4/mkspecs/features/qt_config.prf:
2.127 +/usr/share/qt4/mkspecs/features/exclusive_builds.prf:
2.128 +/usr/share/qt4/mkspecs/features/default_pre.prf:
2.129 +/usr/share/qt4/mkspecs/features/release.prf:
2.130 +/usr/share/qt4/mkspecs/features/default_post.prf:
2.131 +/usr/share/qt4/mkspecs/features/warn_on.prf:
2.132 +/usr/share/qt4/mkspecs/features/qt.prf:
2.133 +/usr/share/qt4/mkspecs/features/unix/thread.prf:
2.134 +/usr/share/qt4/mkspecs/features/moc.prf:
2.135 +/usr/share/qt4/mkspecs/features/resources.prf:
2.136 +/usr/share/qt4/mkspecs/features/uic.prf:
2.137 +/usr/share/qt4/mkspecs/features/yacc.prf:
2.138 +/usr/share/qt4/mkspecs/features/lex.prf:
2.139 +/usr/lib/libQtGui.prl:
2.140 +/usr/lib/libQtCore.prl:
2.141 +qmake: FORCE
2.142 + @$(QMAKE) -unix -o Makefile Fronta.pro
2.143 +
2.144 +dist:
2.145 + @$(CHK_DIR_EXISTS) .tmp/Fronta1.0.0 || $(MKDIR) .tmp/Fronta1.0.0
2.146 + $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/Fronta1.0.0/ && $(COPY_FILE) --parents program.h .tmp/Fronta1.0.0/ && $(COPY_FILE) --parents program.cpp .tmp/Fronta1.0.0/ && (cd `dirname .tmp/Fronta1.0.0` && $(TAR) Fronta1.0.0.tar Fronta1.0.0 && $(COMPRESS) Fronta1.0.0.tar) && $(MOVE) `dirname .tmp/Fronta1.0.0`/Fronta1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/Fronta1.0.0
2.147 +
2.148 +
2.149 +clean:compiler_clean
2.150 + -$(DEL_FILE) $(OBJECTS)
2.151 + -$(DEL_FILE) *~ core *.core
2.152 +
2.153 +
2.154 +####### Sub-libraries
2.155 +
2.156 +distclean: clean
2.157 + -$(DEL_FILE) $(TARGET)
2.158 + -$(DEL_FILE) Makefile
2.159 +
2.160 +
2.161 +mocclean: compiler_moc_header_clean compiler_moc_source_clean
2.162 +
2.163 +mocables: compiler_moc_header_make_all compiler_moc_source_make_all
2.164 +
2.165 +compiler_moc_header_make_all:
2.166 +compiler_moc_header_clean:
2.167 +compiler_rcc_make_all:
2.168 +compiler_rcc_clean:
2.169 +compiler_image_collection_make_all: qmake_image_collection.cpp
2.170 +compiler_image_collection_clean:
2.171 + -$(DEL_FILE) qmake_image_collection.cpp
2.172 +compiler_moc_source_make_all:
2.173 +compiler_moc_source_clean:
2.174 +compiler_uic_make_all:
2.175 +compiler_uic_clean:
2.176 +compiler_yacc_decl_make_all:
2.177 +compiler_yacc_decl_clean:
2.178 +compiler_yacc_impl_make_all:
2.179 +compiler_yacc_impl_clean:
2.180 +compiler_lex_make_all:
2.181 +compiler_lex_clean:
2.182 +compiler_clean:
2.183 +
2.184 +####### Compile
2.185 +
2.186 +program.o: program.cpp program.h
2.187 + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o program.o program.cpp
2.188 +
2.189 +####### Install
2.190 +
2.191 +install: FORCE
2.192 +
2.193 +uninstall: FORCE
2.194 +
2.195 +FORCE:
2.196 +
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/c++/POSIXoveFronty/Fronta/program.cpp Fri Apr 03 22:39:11 2009 +0200
3.3 @@ -0,0 +1,99 @@
3.4 +/*
3.5 + * File: program.cpp
3.6 + * Author: fiki
3.7 + *
3.8 + * Created on 1. duben 2009, 23:54
3.9 + */
3.10 +
3.11 +#include <program.h>
3.12 +#include <stdlib.h>
3.13 +//#include <iostream>
3.14 +#include <c++/4.3.2/iostream>
3.15 +#include <mqueue.h>
3.16 +#include <readline/readline.h>
3.17 +
3.18 +using namespace std;
3.19 +
3.20 +struct mq_attr ma = {
3.21 + ma.mq_maxmsg = 5,
3.22 + ma.mq_msgsize = 100
3.23 +};
3.24 +
3.25 +/*
3.26 + *
3.27 + */
3.28 +int main(int argc, char** argv) {
3.29 +
3.30 + cout << "VÃtejte v programu POSIXovéFronty" << endl;
3.31 +
3.32 + ma.mq_maxmsg = 5;
3.33 + ma.mq_msgsize = 100;
3.34 +
3.35 +
3.36 +
3.37 + //cout << NAZEV_FRONTY << endl;
3.38 +
3.39 + if (isOdesilaciRezim()) {
3.40 + odesilej();
3.41 + } else {
3.42 + prijimej();
3.43 + }
3.44 +
3.45 +
3.46 +
3.47 +
3.48 +
3.49 + return (EXIT_SUCCESS);
3.50 +}
3.51 +
3.52 +bool isOdesilaciRezim() {
3.53 + //char *odpoved = readline("Zvolte režim: (p)Å™ijÃmacà / (o)desÃlacÃ");
3.54 +
3.55 + cout << "Zvolte režim: (p)Å™ijÃmacà / (o)desÃlacÃ" << endl;
3.56 +
3.57 + char odpoved = cin.get();
3.58 + cin.get();
3.59 +
3.60 + if (odpoved == 'o') {
3.61 + return true;
3.62 + } else if (odpoved == 'p') {
3.63 + return false;
3.64 + } else {
3.65 + return isOdesilaciRezim();
3.66 + }
3.67 +}
3.68 +
3.69 +void odesilej() {
3.70 + cout << "odesÃláme" << endl;
3.71 +
3.72 +
3.73 +
3.74 + mqd_t fronta = mq_open(NAZEV_FRONTY, O_RDWR | O_CREAT, S_IRWXU | S_IRWXG, &ma);
3.75 +
3.76 + char* zprava = "zpráva";
3.77 +
3.78 + mq_send(fronta, zprava, strlen(zprava) + 1, 0);
3.79 +
3.80 + cin.get();
3.81 +
3.82 + mq_close(fronta);
3.83 +}
3.84 +
3.85 +void prijimej() {
3.86 + cout << "pÅ™ijÃmáme" << endl;
3.87 +
3.88 + mqd_t fronta = mq_open(NAZEV_FRONTY, O_RDONLY);
3.89 + char s[101];
3.90 + s[100] = '\0';
3.91 + if (mq_receive(fronta, s, 100, NULL) > 0) {
3.92 + printf("Přijatá zpráva: %s\n", s);
3.93 + } else {
3.94 + cout << "Nepodařilo se přijmout zprávu" << endl;
3.95 + }
3.96 +
3.97 + //mq_unlink(NAZEV_FRONTY);
3.98 + mq_close(fronta);
3.99 +
3.100 +
3.101 +}
3.102 +
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/c++/POSIXoveFronty/Fronta/program.h Fri Apr 03 22:39:11 2009 +0200
4.3 @@ -0,0 +1,32 @@
4.4 +/*
4.5 + * File: program.h
4.6 + * Author: fiki
4.7 + *
4.8 + * Created on 2. duben 2009, 0:07
4.9 + */
4.10 +
4.11 +#ifndef _PROGRAM_H
4.12 +#define _PROGRAM_H
4.13 +
4.14 +
4.15 +#ifdef __cplusplus
4.16 +extern "C" {
4.17 +#endif
4.18 +
4.19 + const char* NAZEV_FRONTY = "/mojeFronta";
4.20 + void prijimej();
4.21 + void odesilej();
4.22 +
4.23 + /**
4.24 + * zeptá se uživatele, zda se má program spustit v odesÃlacÃm nebo pÅ™ijÃmacÃm režimu.
4.25 + * true = odesÃlacÃ
4.26 + * false = pÅ™ijÃmacÃ
4.27 + */
4.28 + bool isOdesilaciRezim();
4.29 +
4.30 +#ifdef __cplusplus
4.31 +}
4.32 +#endif
4.33 +
4.34 +#endif /* _PROGRAM_H */
4.35 +