Ejemplo n.º 1
0
void free_holidays( void )
{
   HOLIDAY_DATA *day, *day_next;

   for( day = first_holiday; day; day = day_next )
   {
      day_next = day->next;
      free_holiday( day );
   }
   return;
}
Ejemplo n.º 2
0
/*---------------------------------------------------------------------------*
 *	free holidayes
 *---------------------------------------------------------------------------*/
static void
free_holiday(struct holiday *ptr)
{

	if (ptr == NULL)
		return;

	if (ptr->next != NULL)
		free_holiday(ptr->next);

	free(ptr);
}
Ejemplo n.º 3
0
/*---------------------------------------------------------------------------*
 *	free all holidays
 *---------------------------------------------------------------------------*/
void
free_holidays(void)
{
	free_holiday(firsth);
}
Ejemplo n.º 4
0
/* Calendar code (c)The Alsherok Team*/
void do_setholiday( CHAR_DATA* ch, const char* argument)
{
   HOLIDAY_DATA *day, *newday;
   int count = 0;
   int x = 0;
   char arg1[MIL], arg2[MIL], arg3[MIL];

   argument = one_argument( argument, arg1 );
   argument = one_argument( argument, arg2 );
   argument = one_argument( argument, arg3 );

   if( arg1 == '\0' || !str_cmp( arg1, " " ) )
   {
      send_to_char( "Syntax : setholiday <name> <field> <argument>\r\n", ch );
      send_to_char( "Field can be : day name create announce save delete\r\n", ch );
      return;
   }

/* Save em all.. saves the work of saving individual 
   holidays when mass-creating or editing*/
   if( !str_cmp( arg1, "save" ) )
   {
      save_holidays(  );
      send_to_char( "Holiday chart saved.\r\n", ch );
      return;
   }

/* Create a new holiday by name arg1 */
   if( !str_cmp( arg2, "create" ) )
   {
      for( day = first_holiday; day; day = day->next )
         count++;
      for( day = first_holiday; day; day = day->next )
      {
         if( !str_cmp( arg1, day->name ) )
         {
            send_to_char( "A holiday with that name exists already!\r\n", ch );
            return;
         }
      }

      if( count >= sysdata.maxholiday )
      {
         send_to_char( "There are already too many holidays!\r\n", ch );
         return;
      }

      CREATE( newday, HOLIDAY_DATA, 1 );
      newday->name = str_dup( arg1 );
      newday->day = time_info.day;
      newday->month = time_info.month;
      newday->announce = str_dup( "Today is the holiday of when some moron forgot to set the announcement for this one!" );
      LINK( newday, first_holiday, last_holiday, next, prev );
      send_to_char( "Holiday created.\r\n", ch );
      return;
   }

/* Now... let's find that holiday */

   for( day = first_holiday; day; day = day->next )
   {
      if( !str_cmp( day->name, arg1 ) )
         break;
   }

/* Anything match? */
   if( !day )
   {
      send_to_char( "Which holiday was that?\r\n", ch );
      return;
   }

/* Set the day */

   if( !str_cmp( arg2, "day" ) )
   {
      if( arg3 == '\0' || !is_number( arg3 ) || atoi( arg3 ) > sysdata.dayspermonth || atoi( arg3 ) <= 1 )
      {
         ch_printf( ch, "You must specify a numeric value : %d - %d", 1, sysdata.dayspermonth );
         return;
      }

/* What day is it?... FRIDAY!.. oh... no... it's.. arg3? */
      day->day = atoi( arg3 );
      send_to_char( "Day changed.\r\n", ch );
      return;
   }

   if( !str_cmp( arg2, "month" ) )
   {
/* Go through the months and find arg3 */

      if( arg3 == '\0' || !is_number( arg3 ) || atoi( arg3 ) > sysdata.monthsperyear || atoi( arg3 ) <= 1 )
      {
         send_to_char( "You must specify a valid month number:\r\n", ch );

/* List all the months with a counter next to them*/
         count = 1;
         while( month_name[x] != '\0' && str_cmp(month_name[x], " ") && x < sysdata.monthsperyear)

         {
            ch_printf( ch, "&R(&W%d&R)&Y%s\r\n", count, month_name[x] );
            x++;
            count++;
         }
return;
      }


/* What's the month? */
      day->month = atoi( arg3 );
      send_to_char( "Month changed.\r\n", ch );
      return;
   }

   if( !str_cmp( arg2, "announce" ) )
   {
      if( arg3 == '\0' || !str_cmp( arg3, " " ) || is_number( arg3 ) )
      {
         send_to_char( "Set the annoucement to what?\r\n", ch );
         return;
      }

/* Set the announcement */
      DISPOSE( day->announce );
      day->announce = str_dup( arg3 );
      send_to_char( "Announcement changed.\r\n", ch );
      return;
   }

/* Change the name */
   if( !str_cmp( arg2, "name" ) )
   {
      if( arg3 == '\0' || !str_cmp( arg3, " " ) || is_number( arg3 ) )
      {
         send_to_char( "Set the name to what?\r\n", ch );
         return;
      }

/* Release the good...err... name */
      DISPOSE( day->name );
      day->name = str_dup( arg3 );
      send_to_char( "Name changed.\r\n", ch );
      return;
   }

   if( !str_cmp( arg2, "delete" ) )
   {
      if( str_cmp( arg3, "yes" ) )
      {
         send_to_char( "If you are sure, use 'delete yes'.\r\n", ch );
         return;
      }

      free_holiday( day );
      send_to_char( "&RHoliday deleted.\r\n", ch );
      return;
   }

   send_to_char( "Syntax: setholiday <name> <field> <argument>\r\n", ch );
   send_to_char( "Field can be: day name create announce save delete\r\n", ch );
   return;
}