Using Curl To Send Info - c

I have to use the Curl library to send a string to a morse code translator.(http://mattfedder.com/cgi-bin/morse.pl)
Then I have to take back the result and extract the translated code.
My prof didn't explain curl very well at all and I cannot find any clear examples.
I am not by any means asking for people to code it I just need sources to examples that may help. I apologize if these are blatantly easy to find I have put time into a search just none seemed relevant.

Curl works with webpages/webservices etc.
Its library you can use to interact with web apps without writing all the code.
read this page.
http://curl.haxx.se/libcurl/c/libcurl-tutorial.html
(could not comment as i dont have 50 rep sorry)

Related

Beginner: How do I actually use gperf? It just hangs every time I run it

I am very new to coding, currently taking Harvard's CS50x class online. The extent of my familiarity with code, languages, and environments is what they've taught me so far in C. With vague guidance from other questions on this site, I've taken about 4 days to install gperf, from discovering what Cygwin is to installing all of its libraries and error-checking the installation all the way up to finding out where it finally put the installed program. I was so happy when I actually found the application 'gperf.exe' just now. I thought I was finally just about to get the hash function I've been trying to make for almost a week.
And now, the program does nothing but hang every time I try to run it, no error messages. Offering no input file causes it to hang. Doing any amount of and selection of options specified in the manual, it just hangs. Even debugging says it's entering debugging, then just hangs. The only way I've been able to get the program to respond at all is offering it an invalid input file, which it says is invalid. Nothing else does anything; no output file, no command-line response, nothing. I am frustrated to the point of tears, and the documentation provided with gperf assumes you're a professional coder, talking endlessly about the hundreds of high-level customization options to modify the program, but not a word about how to make it just run on a basic level. I've searched Google and this site extensively, and very little pops up as soon as I search for gperf related issues specifically.
Can anyone please just walk me through how to make this program work? I'm sure it's some stupid little thing that I'm missing, but all I want it to do is take my input file of strings and give me a hash function in C. Any and all help is appreciated, I have absolutely no clue what I'm doing and even installing gperf was a multi-day process that is far beyond the scope of what I've done so far.
Thank you.
EDIT:
Executions I've tried passing:
gperf
./gperf
Arguments I've tried passing:
-a
-c
-d
--output-file 'FILE'
I have tried all of these with and without the inclusion of my input file, named 'keys' and 'keys.txt'. The only thing that has generated any response from the program has been giving it an incorrect input-file name, giving the result 'could not load input file 'keys''.
gperf can be slow if the input file you give it is large, that is, contains many keys. You can get an impression of what are "small" files vs. "large" files by looking at the documentation: Known bugs and limitations.

How to start the actual "Speech to text"?

I am a freelancing author and have gathered tons of hours of interview material which needs to be transcribed.
While browsing the Internet I came across IBM Watson "Speech to text" which should be the ideal solution to handle that huge amount of spoken word.
After registration I am struggling with even opening it. Since I am not very much equipped with programming, etc.
Can someone provide an example with steps that I can follow to achieve my task?
which platform you want to use Speech to text service on it ?
If you are not a coder, then the best starting point for you will be Node-RED. Take a look at this tutorial that creates a translator - https://developer.ibm.com/tutorials/build-universal-translator-nodered-watson-ai-services/?cm_mmc=IBMDev--Digest--ENews2019-_-email&spMailingID=39408813&spUserID=MzYzODEwODAwNzk4S0&spJobID=1500992192&spReportId=MTUwMDk5MjE5MgS2
If uses Speech to Text, Translation, and Text to Speech. You will only need the Speech to Text bit. Once you get it working with a microphone you can make use of the file inject to push your own audio files through the service.
For larger files you will need to make use of http post and multi-parts, when you get to that point, raise a new question, tag it with node-red and someone will post a sample flow for you.
You do not need to have any programming knowledge to use Watson Speech To Text. You can just send your files to the service using the curl tool. Which you can easily install in your computer, it is free.
Then you can send a file to the service running the following command:
curl -X POST -u "apikey:{apikey}" --header "Content-Type: audio/flac" --data-binary #audio-file2.flac "https://stream.watsonplatform.net/speech-to-text/api/v1/recognize"
You just need an apikey to run that command, which you can get following these steps: https://cloud.ibm.com/docs/services/watson?topic=watson-iam
Then just replace the .flac file in that command by the file you want to process. And pass the right value for the Content-Type: header. For Flac files it is audio/flac, for other audio formats you have the list here: https://cloud.ibm.com/apidocs/speech-to-text

ZMQ HTTP Server - empty Request

While reading on ZMQ, I encountered this link - A Web Server in 30 Lines of C. Highly motivated, I tried running the code and it does indeed print "Hello, World!"
Here's the problem: I never quite get the puts (request); to print anything. Essentially, I was looking for being able to send back some data based on query parrams. Example: http://localhost:8080/hello?myname=mho
response would change with sprintf of the name.
I believe I am not completely able to understand the code (:( just 30 lines!).
Any useful links on how the CZMQ is handling the frames? I am not sure, I am able to make good sense out of the inline documentation in the headers.
Any pointers? Happy to read through please.
Am I missing something obvious here?
I agree it's pretty neat, but it's not an HTTP server - it doesn't understand anything about HTTP, especially not how to parse a query string.
You can certainly use 0MQ to send messages very simply. The zguide has examples of many patterns in many languages - should be everything you need. You need to write both a client and server (really a sender and a receiver) to send anything meaningful over 0MQ. If you're hoping to use a generic http client like curl or wget, then use a real HTTP server instead of 0MQ. Many scripting languages let you launch an HTTP listener in a single line of code. Choose what best fits your needs. If you do use 0MQ, there is an IRC channel on Freenode where you can get help.

gedit plugin development in C

I'm Interested in writing gedit-plugins in C. I've checked Gedit/NewMDIPluginHowTo
...but haven't had any luck with it.
How can I get more information about writing gedit plugins in C?
If you're willing to use Python instead, here is a tutorial for writing gedit plugins in Python.
The only tutorial is the one you already found :
Gedit/NewMDIPluginHowTo
I know it can be hard to understand in a first view, but if you read it a few times and give it a try with a basic example, you should be able to achieve getting results quite fast.
Is there something specific that you don't understand?
You can also download some examples of plugins available in C:
https://gitlab.gnome.org/GNOME/gedit/-/tree/gnome-2-30/plugins
Well, you can always email some of the core Gedit developers about your question, I'm sure they have something to give. Try find them via Gedit: Help>About>Credits.
Good luck.

Connect to a website via HTTP in C

I have some C code that parses a file and generates another file of processed data. I now need to post these files to a website on a web server. I guess there is a way to do a HTTP POST but I have never done this in c (using GCC on Ubuntu). Does anyone know how to do this? I need a starting point as I have no clue of doing this in C. I also need to be able to authenticate with the website.
libcurl is probably a good place to start.
I think Hank Gay's suggestion of using a library to handle the details is the best one, but if you want to "do it yourself", you need to open a socket to the web server and then send your data in the HTTP POST format which is described here. Authentication can mean a variety of different things, so you need to be more specific.
Unfortunately, all of the above three jobs involve a fair bit of complexity, so you need to break the question down into stages and come back and ask about each bit separately.

Resources