int main(int ac, char** av) {
  int greeted = 0;
  int i;
  for (i = 1; i < ac; i++) {
    const char* arg = av[i];
    if (arg[0] == '-') {
      if (!strcmp(arg, "-xml"))
        xml ^= 1;
      else if (!strcmp(arg, "-raw"))
        raw ^= 1;
      else if (!strncmp(arg, "-options=", 9))
        options = arg+9;
      else
        { printf("Usage: %s [-xml] [name...]\n", av[0]); exit(2); }
      continue;
    }
    greet(arg);
    greeted = 1;
  }
  if (!greeted)
    greet("world");
  printf("...And now for something completely different:\n");
  void *start = (void*) &main;
  void *end = (void*) &end_of_file;
#if defined(__ia64) || defined(__powerpc__)
  /* On IA64 and PPC function pointers are pointers to function descriptors */
  start = *((void**)start);
  end = *((void**)end);
#endif
  disassemble(start, (end > start) ? end : start + 64);
  printf("Cheers!\n");
}
int main(int ac, char** av) {
  int greeted = 0;
  int i;
  for (i = 1; i < ac; i++) {
    const char* arg = av[i];
    if (arg[0] == '-') {
      if (!strcmp(arg, "-xml"))
        xml ^= 1;
      else if (!strcmp(arg, "-raw"))
        raw ^= 1;
      else if (!strncmp(arg, "-options=", 9))
        options = arg+9;
      else
        { printf("Usage: %s [-xml] [name...]\n", av[0]); exit(2); }
      continue;
    }
    greet(arg);
    greeted = 1;
  }
  if (!greeted)
    greet("world");
  printf("...And now for something completely different:\n");
  disassemble((void*) &main, (void*) &end_of_file);
  printf("Cheers!\n");
}
Exemple #3
0
int main(void) {
	greet();
	if (setgreeting("Howdy!") != 0) {
		fprintf(stderr, "Unable to set greeting!\n");
	}
	greet();
	hello("world", getgreeting());
	return 0;
}
int main (int argc, const char * argv[])
{
    // alice
    student alice;
    alice.name = "Alice";
    alice.gender = FEMALE;
    greet(alice);
    
    // bob
    student bob;
    bob.name = "Bob";
    bob.gender = MALE;
    greet(bob);
    
    return 0;
}
Exemple #5
0
int main()
{
    char c = '!';
    int greet (char *, char);
    greet ("Hello world%c\n", c);
    return 0;
}
Exemple #6
0
// Process a command.
int pcom(char **cmd, int size)
{
  int cret = -2;
  struct passwd *pw = getpwuid(geteuid());

  if (strcmp(*cmd, "greet") == 0)
    cret = greet(pw->pw_name, pw->pw_dir);

  else if (strcmp(*cmd, "log_access") == 0)
    cret = log_access(pw->pw_name);

  else if (strcmp(*cmd, "cla") == 0)
    cret = cla();

  else if (strcmp(*cmd, "cls") == 0)
    cret = cls();

  if (cret == -2) {
    fprintf(stderr, "Unrecognized command '%s'.\n", *cmd);
    return -2;
  }

  bzero(*cmd, size);

  if (cret < 0) {
    strcpy(*cmd, "failure");
    return -1;
  }
  
  strcpy(*cmd, "success");
  return 0;
}
int main (int argc, const char * argv[])
{
    // alice
    student alice;
    alice.age = 20;
    alice.name = "Alice";
    greet(alice);
    
    // bob
    student bob;
    bob.age = 21;
    bob.name = "Bob";
    greet(bob);
    
    return 0;
}
Exemple #8
0
int main()
{
	sayhello();
	greet();

	return 0;
}
Exemple #9
0
int
main(int argc, char *argv[])
{
    // greet user with instructions
    greet();

    // ensure proper usage
    if (argc != 2)
    {
        printf("Usage: fifteen d\n");
        return 1;
    }

    // ensure valid dimensions
    d = atoi(argv[1]);
    if (d < DIM_MIN || d > DIM_MAX)
    {
        printf("Board must be between %d x %d and %d x %d, inclusive.\n",
         DIM_MIN, DIM_MIN, DIM_MAX, DIM_MAX);
        return 2;
    }

    // initialize the board
    init();

    // accept moves until game is won
    while (true)
    {
        // clear the screen
        clear();

        // draw the current state of the board
        draw();

        // check for win
        if (won())
        {
            printf("ftw!\n");
            break;
        }

        // prompt for move
        printf("Tile to move: ");
        int tile = GetInt();

        // move if possible, else report illegality
        if (!move(tile))
        {
            printf("\nIllegal move.\n");
            usleep(500000);
        }

        // sleep thread for animation's sake
        usleep(500000);
    }

    // that's all folks
    return 0;
}
Exemple #10
0
int main(int argc, char *argv[])
{
  greet();
  interact();
  /* When interact returns, session is done. */
  printf("Bye!\n");
  return 0;
}
void greet_b(int i)
{
	char c = 'c';
	scanf("%c",&c);

	greet(0);
	recursive_b(i);
}
void test2()
{
    String greet("Hello");
    char ch1 = greet.at(0); // в char ch1 = greet.at(0) будет вызвана не const версия метода at
    printf("%c\n", ch1);

    String const const_greet("Hello, Const!");
    char const &ch2 = const_greet.at(0); // в char const & ch2 = const_greet.at(0) будет вызвана const версия метода at
    printf("%c\n", ch2);
}
Exemple #13
0
int main(int argc, string argv[])
{
  // greets player
  greet();

  // ensures proper usage
  if (argc != 2) {
    printf("Usage: ./fifteen d\n");
    return 1;
  }

  // checks for valid dimensions
  d = atoi(argv[1]);
  if (d < MIN || d > MAX) {
    printf("Board must be between %i x %i and %i x %i, inclusive.\n",
	   MIN, MIN, MAX, MAX);
    return 2;
  }

  // initializes the board
  init();

  // accepts moves until game is won
  while (true) {
    // clears the screen
    clear();

    // draws the current state of the board
    draw();
    
    // saves the current state of the board (for testing)
    save();

    // checks for win
    if (won()) {
      printf("Congrats!\n");
      break;
    }

    // prompts for next move
    printf("Tile to move: ");
    int tile = GetInt();

    // moves if possible, else reports illegality
    if (!move(tile)) {
      printf("\nIllegal move.\n");
      usleep(500000);
    }

    // sleeps for animation's sake
    usleep(500000);
  }

  return 0;
}
Exemple #14
0
int main(int argc, string argv[])
{
    greet();
    
    if (argc != 2)
    {
        printf("Usage: ./fifteen d\n");
        return 1;
    }

    // ensure valid dimensions
    d = atoi(argv[1]);
    if (d < MIN || d > MAX)
    {
        printf("Board must be between %i x %i and %i x %i, inclusive.\n",
            MIN, MIN, MAX, MAX);
        return 2;
    }

    // initialize the board
    init();

    // accept moves until game is won
    while (true)
    {
        int tile;
        clear();
        draw();   
        save(); //for testing

        //if god mode on, go to god mode procedure
        if (godMode == 1)
            godSolve(d);
        
        // check for win
        if (won()) {
            printf("ftw!\n");
            break;
        }
            
        printf("Tile to move: ");
        tile = getIntOrGod();

        // move if possible, else report illegality
        if (!move(tile)){
            printf("\nIllegal move.\n");
            usleep(20000);
        }
        usleep(20000);
    }

    // that's all folks
    return 0;
}
Exemple #15
0
/*---------------------------------------------
| Print usage
---------------------------------------------*/
void usage(void) 
{
    greet();
    printf("Usage: magtisun [-u <username>] [-p <password>] [-h]\n");
    printf("options are:\n");
    printf("   -u <username>       # magtifun user name\n");
    printf("   -p <password>       # magtifun password\n");
    printf("   -i                  # get and print user information\n");
    printf("   -h                  # prints version and usage\n");
    printf("\n");
}
Exemple #16
0
int
main(int argc,char **argv)
    {
    int n;
    srand(time(0));  //reset the random number generator
    n = rand() % 100;
    greet("multiverse");
    printf("Hello, world number %d!\n",n);

    return 0;
    }
Exemple #17
0
int main(int argc, char **argv){
    int length;
    be_nice_to_people();

    puts("How long is your name?");
    scanf("%d", &length);

    if(length < BUFSIZE) //don't allow buffer overflow
        greet(length);
    else
        puts("Length was too long!");
}
Exemple #18
0
int
main (int argc, char **argv)
{
  gcc_jit_context *ctxt;
  gcc_jit_result *result;

  /* Get a "context" object for working with the library.  */
  ctxt = gcc_jit_context_acquire ();
  if (!ctxt)
    {
      fprintf (stderr, "NULL ctxt");
      exit (1);
    }

  /* Set some options on the context.
     Let's see the code being generated, in assembler form.  */
  gcc_jit_context_set_bool_option (
    ctxt,
    GCC_JIT_BOOL_OPTION_DUMP_GENERATED_CODE,
    0);

  /* Populate the context.  */
  create_code (ctxt);

  /* Compile the code.  */
  result = gcc_jit_context_compile (ctxt);
  if (!result)
    {
      fprintf (stderr, "NULL result");
      exit (1);
    }

  /* Extract the generated code from "result".  */
  typedef void (*fn_type) (const char *);
  fn_type greet =
    (fn_type)gcc_jit_result_get_code (result, "greet");
  if (!greet)
    {
      fprintf (stderr, "NULL greet");
      exit (1);
    }

  /* Now call the generated function: */
  greet ("world");
  fflush (stdout);

  gcc_jit_context_release (ctxt);
  gcc_jit_result_release (result);
  return 0;
}
void Landlord::run()
{
	ostringstream temp;
	temp << "Landlord got to work.";
	log(name, temp.str());

	//greet and bartend until its time for last call
	while (!bLastCall)
	{
		greet();
		bartend();
	}

	//inform everyone in the bar of last call
	lastCall();

	//continue to greek and bartend until only the barmaid and assistant are left
	while (!numPeopleInBar(2))
	{
		greet();
		bartend();
	}

	//tell assistant and barmaid to close up
	for (map<int, Person*>::iterator it=people_in_bar.begin() ; it != people_in_bar.end(); it++ )
			((*it).second)->closeUp();

	//say goodbye to employees until the bar is empty
	while (!numPeopleInBar(0))
	{
		greet();
	}

	string msg = "Clocking out.";
	log(name, msg);
	pthread_exit(NULL);
}
Exemple #20
0
int main()
{
    /* Used variables */
    char char_arg[32];
    int int_arg;

    /* Init args */
    strcpy(char_arg, "test string");
    int_arg = 69;

    /* Greet users */
    greet();

    /* 
     * slog_init - Initialise slog 
     * First argument is log filename 
     * Second argument is config file
     * Third argument is max log level 
     * Fouth is thread safe flag.
     */
    slog_init("example", "slog.cfg", 3, 1);

    /* Log and print something with level 0 */
    slog(0, SLOG_LIVE, "Test message with level 0");

    /* Log and print something with level 1 */
    slog(1, SLOG_WARN, "Warn message with level 1");

    /* Log and print something with level 2 */
    slog(2, SLOG_INFO, "Info message with level 2");

    /* Log and print something with level 3 */
    slog(3, SLOG_LIVE, "Test message with level 3");

    /* Log and print something with char argument */
    slog(0, SLOG_DEBUG, "Debug message with char argument: %s", char_arg);

    /* Log and print something with int argument */
    slog(0, SLOG_ERROR, "Error message with int argument: %d", int_arg);

    /* Test log with higher level than log max value 
    * This will never be printed while log level argument is higher than max log level */
    slog(4, SLOG_NONE, "[LIVE] Test log with higher level than log max value");

    /* Print something with our own colorized line */
    slog(0, SLOG_NONE, "[%s] This is our own colorized string", strclr(CLR_GREEN, "TEST"));

    return 0;
}
Exemple #21
0
int
main (int argc, char **argv)
{
  char user_input[USER_INPUT_BUFFER_MAX];

  proper_exec_name (argv[0]);
  greet ();
  while (true)
  {
    display_prompt ();
    grab_input (user_input);
    process_input (user_input);
  }
  return EXIT_SUCCESS;
}
Exemple #22
0
int main(int argc, char *argv[])
{
  retain<Language> as(&NO_LANGUAGE); // ***
  for (int argi=1; argi<argc; ++argi) {
    if (strcmp(argv[argi],"english")==0) { english(); continue; }
    if (strcmp(argv[argi],"spanish")==0) { spanish(); continue; }
    if (strcmp(argv[argi],"greet")==0) { greet(); continue; }
    if (strcmp(argv[argi],"hello")==0) { hello(); continue; }
    if (strcmp(argv[argi],"hola")==0) { hola(); continue; }
    std::cout << 
      "unkown arg[" << argi << "]='" << argv[argi] << "'" << std::endl;
  }

  return 0;
}
int main()
{
	void (*greet)();
	int (*printit)(const char*, ...);
	
	greetings();
	printf("get: %d\n", get3());
	
	greet = dlsym(RTLD_DEFAULT, "greetings");		// search all objects for the given symbol
	greet();
	
	printit = dlsym(RTLD_DEFAULT, "printf");			// from libc
	printit("libc\n");
	
	return 0;
}
Connection *connection_make(ClientWorld *w, ClientOptions const& opt)
{
  int sock = socket(AF_INET, SOCK_STREAM, 0);

  int flag = 1;
  setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &flag, sizeof(flag));

  struct sockaddr_in sa;
  memset(&sa, 0, sizeof(sa));
  sa.sin_family = AF_INET;
  sa.sin_port = htons(opt.server_port);
  sa.sin_addr.s_addr = htonl(0x7f000001);

  if (!opt.server_host.empty()) {
    const char *hostname = opt.server_host.c_str();
    struct hostent *ent = gethostbyname(hostname);
    if (!ent) {
      perror(hostname);
      return NULL;
    }
    if (!ent->h_addr_list[0]) {
      fprintf(stderr, "%s: no addresses\n", hostname);
      return NULL;
    }
    if (ent->h_addrtype != AF_INET) {
      fprintf(stderr, "%s: not an IPv4 address\n", hostname);
      return NULL;
    }
    memcpy(&sa.sin_addr, ent->h_addr_list[0], ent->h_length);
  }

  int rc = connect(sock, (const sockaddr *)&sa, sizeof(sa));
  if (rc < 0) {
    perror("connect");
    return NULL;
  }

  Connection *cnx = new Connection();
  cnx->queue_lock = SDL_CreateMutex();
  cnx->sock = sock;
  cnx->world = w;
  greet(cnx);

  SDL_CreateThread(Connection::run, "cnxn", cnx);
  return cnx;
}
Exemple #25
0
int main(void) {

    printf("Testing lrotate: should get 0x00400000, 0x00000001\n");
    printf("lrotate(0x00040000, 4) = 0x%08lx\n", lrotate(0x40000,4));
    printf("lrotate(0x00040000, 14) = 0x%08lx\n", lrotate(0x40000,14));

    printf("This string should read `hello, world': `%s'\n", asmstr);

    printf("The integers here should be 1234, 1235 and 4321:\n");
    integer = 1234;
    commvar = 4321;
    greet();

    printf("These pointers should be equal: %p and %p\n",
	   &greet, textptr);

    printf("So should these: %p and %p\n", selfptr, &selfptr);
}
Exemple #26
0
bool smtp_client::send_envelope(const mail_message& message)
{
	if (open() == false)
		return false;
	if (get_banner() == false)
		return false;
	if (greet() == false)
		return false;

	const char* user = message.get_auth_user();
	const char* pass = message.get_auth_pass();
	if (user && pass && auth_login(user, pass) == false)
		return false;

	const rfc822_addr* from = message.get_from();
	if (from == NULL)
	{
		logger_error("from null");
		return false;
	}
	if (mail_from(from->addr) == false)
		return false;
	return to_recipients(message.get_recipients());
}
Exemple #27
0
int main(int argc, const char * const argv)
{
    greeter_retval return_value = GREETER_SUCCESS;
    greeter_t * greeter = NULL;

    /* init a greeter */
    return_value = init_greeter("Hello World !\n", &greeter);
    if (GREETER_SUCCESS != return_value)
    {
        printf("ERROR: Failed to init the greeter\r\n");
        goto cleanup;
    }

    /* invoke greet */
    return_value = greet(greeter);
    if (GREETER_SUCCESS != return_value)
    {
        printf("ERROR: Failed to greet\r\n");
        goto cleanup;
    }

cleanup:
    destroy_greeter(greeter);
}
Exemple #28
0
int main(int argc, char** argv) {
	// const literal
	greet("World");

	// non-const literal
	char thing[100];
	strcpy(thing, "Thing");
	greet(thing);

	// string class
	std::string object("Object");
	greet(object);

	greet(add(std::string("LEFT"), std::string("RIGHT")));
	greet(add(std::string("LEFT"), object));
	greet(add(std::string("LEFT"), thing));

	// auto, type deduction
	auto stringy = add(std::string("LEFT"), object);
	std::cout << real_type_name(stringy) << std::endl;

	// auto, initializers
	auto a = { 11, 23, 9 };
	std::cout << real_type_name(a) << std::endl;

	// generic conversion to vector
	std::vector<decltype(a)::value_type> va = a;
	std::cout << real_type_name(va) << std::endl;

	auto a1 = value_at(va, 1);
	std::cout << a1 << std::endl;
	std::cout << real_type_name(a1) << std::endl;

    mmm();

    rvalue();

	return 0;
}
Exemple #29
0
void QtObject::passGreet(const QString& name)
{
  emit greet(name);
}
Exemple #30
0
int main(int argc, string argv[])
{
    // greet player
    greet();

    // ensure proper usage
    if (argc != 2)
    {
        printf("Usage: ./fifteen d\n");
        return 1;
    }

    // ensure valid dimensions
    d = atoi(argv[1]);
    if (d < MIN || d > MAX)
    {
        printf("Board must be between %i x %i and %i x %i, inclusive.\n",
            MIN, MIN, MAX, MAX);
        return 2;
    }

    // initialize the board
    init(d, board);

    // accept moves until game is won
    while (true)
    {
        // clear the screen
        clear();

        // draw the current state of the board
        draw(d, board);

        // saves the current state of the board (for testing)
        save();

        // check for win
        if (won(board, d))
        {
            printf("ftw!\n");
            break;
        }

        // prompt for move
        printf("Tile to move: ");
        int tile = GetInt();

        // move if possible, else report illegality
        if (!move(tile, board, d))
        {
            printf("\nIllegal move.\n");
            usleep(500000);
        }
        else if (move(tile, board, d))
        {
            complete(tile, board, d);
        }

        // sleep for animation's sake
        usleep(500000);
    }

    // that's all folks
    return 0;
}