Table of Contents
Part 1
Entries
Entry 1: August 28, 2012
Today I began reading on good old wikipedia about the different compilers I could choose from, I found the following options.
- Ch - compatible on virtually all platforms is open source. Ch also has an Integrated Development Environment for 'improved' workflow.
- GCC - What I've familiarized myself with and will most likely be using most this semester.
- Icc - A compiler thats source is open for non-commercial use. Icc has a windows only IDE, which is no help to me…
- PGCC - Part of visual studio on windows.
Entry 2: September 25, 2012
Impressions of Freeswitch
From what I've read about FreeSWITCH is that it's relatively new (as of 2006) and is a softswitch communicator that interfaces with both physical and digital phones. It's built on open source technologies like SQLight and Apache. FreeSWITCH accepts an array of protocols such as VOIP, SIP, Google Talk and many more to interface with and supports a wide array of audio codecs.
Here are some of the more important configuration file fore FreeSWITCH:
On our datacom server, FreeSWITCH is located in '/usr/local/freeswitch' and includes the following directories in its base:
[root@dhcp-171 freeswitch]# ls bin conf db grammar htdocs include lib log mod recordings run scripts sounds storage [root@dhcp-171 freeswitch]#
Bin holds the various executables that are the core of freeswitch, conf holds configuration files that some genius wrote in xml to sort in some ridiculous hierarchical model.
There are other meta items like FreeSWITCH's library and scripts.
Entry 3: August Day, 2012
This is a sample format for a dated entry. Please substitute the actual date for “Month Day, Year”, and duplicate the level 4 heading to make additional entries.
As an aid, feel free to use the following questions to help you generate content for your entries:
- What action or concept of significance, as related to the course, did you experience on this date?
- Why was this significant?
- What concepts are you dealing with that may not make perfect sense?
- What challenges are you facing with respect to the course?
Remember that 4 is just the minimum number of entries. Feel free to have more.
Entry 4: August Day, 2012
This is a sample format for a dated entry. Please substitute the actual date for “Month Day, Year”, and duplicate the level 4 heading to make additional entries.
As an aid, feel free to use the following questions to help you generate content for your entries:
- What action or concept of significance, as related to the course, did you experience on this date?
- Why was this significant?
- What concepts are you dealing with that may not make perfect sense?
- What challenges are you facing with respect to the course?
Remember that 4 is just the minimum number of entries. Feel free to have more.
Keywords
cprog Keyword 1
Identification of chosen keyword.
Functions
All programs contain at least a main() function. The main()function typically is executed when the program starts. functions contain parameters or instructions to be used during the programs computation. Here is an example of a function parameter:
long sum( int array[], int number ) // Identifiers { //body of function int i; long result = 0; for( i = 0; i < number; ++i ) result += (long)array[i]; return result; }
Functions can also have declarations before the body where you can call datatypes.
References
List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).
cprog Keyword 1 Phase 2
Identification of chosen keyword.
Definition
Structs, not your mama's sneaker shoes.
Example
#include <stdio.h> #include <stdlib.h> struct mystruct { // int test; // Declaration of initial struct. }; // typedef struct mystruct * newstruct; // newstruct function is a pointer to my struct. newstruct getnewstruct() { newstruct temp = (newstruct)malloc(sizeof(newstruct*)) ; return temp; } int main() { newstruct tester = getnewstruct() ; // tester -> test = 8; // Mathematical manipulation and printing of structure. tester -> test++; // printf ("The value is %i\n",tester -> test) ; // free(tester) ; return 0; }
Demonstration
Demonstration of the indicated keyword.
If you wish to aid your definition with a code sample, you can do so by using a wiki code block, an example follows:
Alternatively (or additionally), if you want to demonstrate something on the command-line, you can do so as follows:
andrew ~ $ gcc malloc.c -o malloc andrew ~ $ ./malloc First value: 10 Pi is: 3.140000
datacomm Keyword 1
Identification of chosen keyword.
Definition
Definition (in your own words) of the chosen keyword.
References
List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).
- Reference 1
- Reference 2
- Reference 3
datacomm Keyword 1 Phase 2
asterisk
Definition
A programming language to communicate and execute the basic functions of telephony services.
Demonstration
'extensions.conf' located in '/etc/asterisk/extensions.conf' maintains a bulk of the configurations options for the asterisk service including your dial plan and how inbound/outbound calls are routed. Example of an extension:
exten => 602,1,Dial(SIP/Andrew,20) exten => 602,n,VoiceMail(602@vm,u)
'sip.conf' located in '/etc/asterisk/sip.conf' maintains the users locations and affiliation to the asterisk server. Example of a sip.conf user entry:
[Andrew] type=friend secret=123456 host=dynamic context=users deny=0.0.0.0/0 permit=10.80.2.0/255.255.255.0 mailbox=778@vm
Experiment 1
Question
Can you include the main() of a program in a header file?
Resources
Hypothesis
I suspect that you can include any function within a header file and call it. Including main().
Then call it like so:
main();
Experiment
I'm going to take the main portion of the encipher program from project two and place it into main.h
int main(int argc, char **argv) { printf("Greetings, Agent Haas.\n"); FILE *in, *out; int cipher; int key; in = fopen("plain.txt", "r"); out = fopen("enciphered.txt", "w"); if(argv[1] == NULL) { printf("\nNo argument provided, execute with key argument.\nexample: ./encipher 1\n"); exit(1); } char *plain; plain = (char*) malloc (sizeof(char) * 127); int count = 0; if(in == NULL) { printf("\nFile empty, enter some text to encipher\n"); fgets(plain, 127, stdin); while(plain[count] != '\0') { count = count+1; } int cipher = atoi(argv[1]); count = 0; while(plain[count] != '\0') { key = 1; if(plain[count] >= 65 && plain[count] <= 90) { key = plain[count] + cipher; while(key > 90) { key = key - 26; } } if(plain[count] >= 97 && plain[count] <= 122) { key = plain[count] + cipher; while(key > 122) { key = key - 26; } } if(key == 1) { key = 32; } fprintf(out, "%c", key); count = count+1; } printf("\nEnciphered text is loated in enciphered.txt\n"); printf ("It took me %d clicks (%f seconds).\n",t,((float)t)/CLOCKS_PER_SEC); } else { fgets(plain, 127, in); printf("\nText before cipherication: "); while(plain[count] != '\0') { printf("%c", plain[count]); count = count+1; } int cipher = atoi(argv[1]); count = 0; printf("\nCiphered text output: "); while(plain[count] != '\0') { key = 1; if(plain[count] >= 65 && plain[count] <= 90) { key = plain[count] + cipher; while(key > 90) { key = key - 26; } } if(plain[count] >= 97 && plain[count] <= 122) { key = plain[count] + cipher; while(key > 122) { key = key - 26; } } if(key == 1) { key = 32; } printf("%c", key); fprintf(out, "%c", key); count = count+1; } fclose(in); fclose(out); return (0); } }
Data
Here's main.h:
#ifndef _MAIN_H #define _MAIN_H int main(int argc, char **argv) { int t; t = clock(); printf("Greetings, Agent Haas.\n"); FILE *in, *out; int cipher; int key; in = fopen("plain.txt", "r"); out = fopen("enciphered.txt", "w"); if(argv[1] == NULL) { printf("\nNo argument provided, execute with key argument.\nexample: ./encipher 1\n"); exit(1); } char *plain; plain = (char*) malloc (sizeof(char) * 127); int count = 0; if(in == NULL) { printf("\nFile empty, enter some text to encipher\n"); fgets(plain, 127, stdin); while(plain[count] != '\0') { count = count+1; } int cipher = atoi(argv[1]); count = 0; while(plain[count] != '\0') { key = 1; if(plain[count] >= 65 && plain[count] <= 90) { key = plain[count] + cipher; while(key > 90) { key = key - 26; } } if(plain[count] >= 97 && plain[count] <= 122) { key = plain[count] + cipher; while(key > 122) { key = key - 26; } } if(key == 1) { key = 32; } fprintf(out, "%c", key); count = count+1; } printf("\nEnciphered text is loated in enciphered.txt\n"); printf ("It took me %d clicks (%f seconds).\n",t,((float)t)/CLOCKS_PER_SEC); } else { fgets(plain, 127, in); printf("\nText before cipherication: "); while(plain[count] != '\0') { printf("%c", plain[count]); count = count+1; } int cipher = atoi(argv[1]); count = 0; printf("\nCiphered text output: "); while(plain[count] != '\0') { key = 1; if(plain[count] >= 65 && plain[count] <= 90) { key = plain[count] + cipher; while(key > 90) { key = key - 26; } } if(plain[count] >= 97 && plain[count] <= 122) { key = plain[count] + cipher; while(key > 122) { key = key - 26; } } if(key == 1) { key = 32; } printf("%c", key); fprintf(out, "%c", key); count = count+1; } printf("\nEnciphered text is located in enciphered.txt\n\n"); printf ("It took me %d clicks (%f seconds).\n",t,((float)t)/CLOCKS_PER_SEC); fclose(in); fclose(out); return (0); } } #endif
Here's the modified program:
#include <stdio.h> #include <math.h> #include <stdlib.h> #include "main.h" main();
And the gcc output:
lab46:~/src/cprog/cipher$ gcc encipher.c -o encipher encipher.c:20: warning: data definition has no type or storage class lab46:~/src/cprog/cipher$
Got a warning, but it worked.
Analysis
Based on the data collected:
- My hypothesis was indeed correct.
- My hypothesis halfway applicable, I have to explore the repercussions of the error.
Conclusions
Header files are a brilliant way to break up ANY function in a program to allow more readable code and FAR better organization.