Simple c shell I have been writing. The problem I am having is to do with my argument passing. I have written a simple state machine to parse commands given by the user into an appropriate array of character pointers for use with the function execvp().
My experience with c coding is limited, I think I'm getting confused with pointer manipulation and stack memory. I am trying to store the 'tokens' within my struct->argv[].
Add the ability to handle program names and parameters that contain white space: everything in between two double quote (") characters needs to be treated as one word! E.g. "./hello world" should be treated as the name of one program called hello world (in the current directory, with a space in the middle of the file name) rather than a program called hello with one parameter world.
I have created a Namespace Extension (I hope so) by creating a ATL Project with MFC support as dll in Visual Studio 2010.
Now I have a Implementation of IShellFolder:
Code: // ILCShellFolder.h: Deklaration von CILCShellFolder #pragma once #include "resource.h" // Hauptsymbole #include "NewNSE_i.h" #if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
[Code] ....
Not any of those IShellFolder Methods is being called... When I attach the explorer.exe process (which I know I can use to debug on other projects, just in case to exclude errors) it tells me that the DLL is not loaded by the explorer.exe process.
I want to take the standard output of a shell command (in Red Hat, using tcsh, in my case) and redirect it into my program for processing.
(Then ideally I would love to take the output of my program and redirect it to yet another command, but this is a second issue.) Simple example: I naively thought this might work:
I want to type this on the shell:
Code: $ echo Harry > hello and I was expecting this output on my terminal: Code: $ hello, Harry And this would be my simple hello program: Code: #include <iostream> #include <string> int main() { std::string usrInput; std::cin >> usrInput; std::cout << "hello, " << usrInput << std::endl; return 0; }
I will sketch the scenario I would like to get working below. I have one main application.
That application, based on user interactions, can load other applications in a secure shell. This means these child applications cannot interact with the OS anymore, nor with each other.
The parent program can at any time call functions of these child programs.
The child program can at any time call functions of these parent programs.
How to implement this in C++? Preferably both parent and child should be written in C++.
The performance of loading the child applications doesn't matter. The only thing that matters is the performance of the communication between child and parent.
Ok I'm on a Windows machine and I'm writing a simple tool to dump and touch ttf files. It's almost done except that the command line parser is giving nightmares. how do I stop the shell from automatically converting wildcards in arguments to directory listings? (I first flatten all arguments to a single string before parsing)
I'm attempting to write a little UDP socket library in c++ on linux so a user can just create a new instance of a UDPSocket class, specify destination ip and port, and just connect. Then the user should be able to call send() or receive() in any order they want.. and here I encounter a little problem..
Most of the tutorials for udp socket sending out there include a bind() call when you create your "server" that is supposed to receive data, but the code that send data does not need one. Because I also want my library to support unicast/broadcast/multicast, I have read that I need to set the socket option SO_REUSEADDR on my sockets (since multiple sockets will need to be connected to same destination IP/port for broadcast/multicast)
My question is.. do I need to create 2 socket handles per "UDPSocke in order to make this work? One for sending and one for receiving data? In my code when I try to work with only 1 socket, it is only able to receive stuff from itself on unicast.. Or should I just remove the SO_REUSEADDR when in unicast mode, then try to bind with both sockets, accept that the bind will only work on the 1st socket, and take it from there?
I want to use two separate files in 1 program, but cannot get it to work. I don't know if it's my files or the compiling thats wrong. I have never used 2 files in my programs so far. Only used #include <stdio.h>.
Here are my files: extern_static.c Code: extern int i; int main(void) {
I have a c file which can be compiled in Linux via GCC , but when I compile it in NetBeans via Cygwin or MinGW , it doesn't work and keeps throwing a segmentation fault.
I want to open an application A from another application B. By opening it, I don't want to open it within B. I found many ways to call an application from within another. However, what I want to do is open the other one(A) simultaneously. How can I achieve this? fork() and exec() seem to open A within B. I am developing a code for Linux and Mac.
I'm trying to implement this on ubuntu, to compile and run only under ubuntu.
I found 100s of other attempts at answering the general question of arrow key press in c++. Nothing solid.
Some recommend using the Readline for the functionality I am trying to implement, but I need to stay clear of GNU licences if I can for this project. And some tips only work on projects for windows machines... for example the conio library.
For linux there may be the option of using the ncurses library which I will take a look at, but I am stubborn and want to implement this myself. It should be an easy straight forward thing to do, which is why I am a bit frustrated at the moment.
So! This works... 80% of the problem is solved. If you compile this, g++ under linux, ubuntu in my case, and run. Each keystroke reveals the correct key numbers.
q=113 w=119
when I click on the up key I get,
up = 279165
I thought, I can use this number is a if(int == '279165') to detect the up key.
I was not so lucky... this int is not behaving like an int!
So I modified the code to see it I could carry out an int operation on this number.
Compiling and running this, and pressing the UP key gives the following number.
100027100091100065
Some some sort of array, something like, [27][91][65].
I tried all ways to access these individual numbers, actually the third one for comparison purposes, but no luck.
For completeness sake I list the other arrows.
UP = [27][91][65] DOWN = [27][91][66] LEFT = [27][91][68] RIGHT = [27][91][67]
A little further digging shows that these numbers are derived from the representation of a "multi-char" constant, the data type given when pressing special characters...
Now here is the main problem I have, I can find ANY decent documentation on how to handle and play with "multi-char" .
I am trying to detect keys pressed on a keyboard and mouse on both, Windows and Linux but I am unsure what would be the best practice way to do so. Will I have to detect the keys for each platform individually? Would you make use of an event listener? What's the best way to detect the input-devices?
I'm writing a server/client application in C++, one linux and one windows. The generic communication method is to use the boost::serialization package, but I'll also use a header to distinguish the type of the serialized string.
Here is the struct that the two programs communicate with
When one side wants to pass an object to another side, it uses typeid(T).name() for the field type_name. The receiving side receives SerializeString and checks its type_name against various acceptable structs as follows:
if (ss.type_name == typeid(XXX).name()) { // deserialize ss.serialized_string to XXX and do something with it } else if (ss.type_name == typeid(YYY).name()) { // deserialize ss.serialized_string to YYY and do something with it } else if (ss.type_name == typeid(ZZZ).name()) { // deserialize ss.serialized_string to ZZZ and do something with it } else { // etc... }
This worked fine when I was using Windows VS2013 on two different windows platform. However when I switch one to Linux there is a problem because their typeid(XXX).name() returns different things. So question here, is there a generic way to get some sort of unique names across platform / compiler? Or is my method reasonable at all?